diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/kernels_hub.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/kernels_hub.md new file mode 100644 index 0000000000000000000000000000000000000000..f3d7ee124ba58be7f9bfd503dded52d4dc90a2b5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/kernels_hub.md @@ -0,0 +1,96 @@ +# Kernels Hub Integration and Usage + +kernel-builder logo + +The [`kernels`](https://huggingface.co/blog/hello-hf-kernels#get-started-and-next-steps) library allows optimized compute kernels to be loaded directly from the Hub. +You can find `kernels` in [dedicated orgs](https://huggingface.co/kernels-community) or by searching for the [`kernel` tag](https://huggingface.co/models?other=kernel) within the Hub. + +Kernels are **optimized code pieces** that help in model development, training, and inference. Here, we’ll focus on their **integration with TRL**, but check out the above resources to learn more about them. + +## Installation + +To use kernels with TRL, you'd need to install the library in your Python environment: + +```bash +pip install kernels +``` + +## Using Kernels from the Hub in TRL + +Kernels can directly replace attention implementations, removing the need to manually compile attention backends like Flash Attention and boosting training speed just by pulling the respective attention kernel from the Hub. + +You can specify a kernel when loading a model: + + +```python +from transformers import AutoModelForCausalLM + +model = AutoModelForCausalLM.from_pretrained( + "your-model-name", + attn_implementation="kernels-community/flash-attn2" # other options: kernels-community/vllm-flash-attn3, kernels-community/paged-attention +) +``` + +Or when running a TRL training script: + +```bash +python sft.py ... --attn_implementation kernels-community/flash-attn2 +``` + +Or using the TRL CLI: + +```bash +trl sft ... --attn_implementation kernels-community/flash-attn2 +``` + +> [!TIP] +> Now you can leverage faster attention backends with a pre-optimized kernel for your hardware configuration from the Hub, speeding up both development and training. + +## Comparing Attention Implementations + +We evaluated various attention implementations available in transformers, along with different kernel backends, using **TRL** and **SFT**. +The experiments were run on a single **H100 GPU** with **CUDA 12.9**, leveraging **Qwen3-8B** with a **batch size of 8**, **gradient accumulation of 1**, and **bfloat16** precision. +Keep in mind that the results shown here are specific to this setup and may vary with different training configurations. + +The following figure illustrates both **latency** (time per training step) and **peak allocated memory** for the different attention implementations and kernel backends. +Kernel-based implementations perform on par with custom-installed attention, and increasing the model’s `max_length` further enhances performance. Memory consumption is similar across all implementations, showing no significant differences. We get the same performance but with less friction, as described in [the following section](#flash-attention-vs-hub-kernels). + +
+ Latency and Memory Usage + Latency and Memory Usage +
+ +## Flash Attention vs. Hub Kernels + +Building Flash Attention from source can be time-consuming, often taking anywhere from several minutes to hours, depending on your hardware, CUDA/PyTorch configuration, and whether precompiled wheels are available. + +In contrast, **Hugging Face Kernels** provide a much faster and more reliable workflow. Developers don’t need to worry about complex setups—everything is handled automatically. In our benchmarks, kernels were ready to use in about **2.5 seconds**, with no compilation required. This allows you to start training almost instantly, significantly accelerating development. Simply specify the desired version, and `kernels` takes care of the rest. + +## Combining FlashAttention Kernels with Liger Kernels + +You can combine **FlashAttention kernels** with **Liger kernels** for additional TRL performance improvements. + +First, install the Liger kernel dependency: + +```bash +pip install liger-kernel +``` + +Then, combine both in your code: + +```python +from transformers import AutoModelForCausalLM +from trl import SFTConfig + +model = AutoModelForCausalLM.from_pretrained( + "your-model-name", + attn_implementation="kernels-community/flash-attn2" # choose the desired FlashAttention variant +) + +training_args = SFTConfig( + use_liger_kernel=True, + # ... other TRL training args +) +``` + +Learn more about the [Liger Kernel Integration](./liger_kernel_integration). diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/kto_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/kto_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..708448620b00a4bd61ea121cdd40b4f85f228f19 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/kto_trainer.md @@ -0,0 +1,144 @@ +# KTO Trainer + +[![model badge](https://img.shields.io/badge/All_models-KTO-blue)](https://huggingface.co/models?other=kto,trl) + +> [!WARNING] +> As of TRL v1.0, `KTOTrainer` and `KTOConfig` have been moved to the `trl.experimental.kto` module. +> KTO API is experimental and may change at any time. +> Promoting KTO back into the stable API is a high-priority task: KTO is slated for refactoring to align with the standard core trainer architecture. + +## Overview + +Kahneman-Tversky Optimization (KTO) was introduced in [KTO: Model Alignment as Prospect Theoretic Optimization](https://huggingface.co/papers/2402.01306) by [Kawin Ethayarajh](https://huggingface.co/kawine), [Winnie Xu](https://huggingface.co/xwinxu), [Niklas Muennighoff](https://huggingface.co/Muennighoff), Dan Jurafsky, [Douwe Kiela](https://huggingface.co/douwekiela). + +The abstract from the paper is the following: + +> Kahneman & Tversky's prospect theory tells us that humans perceive random variables in a biased but well-defined manner; for example, humans are famously loss-averse. We show that objectives for aligning LLMs with human feedback implicitly incorporate many of these biases -- the success of these objectives (e.g., DPO) over cross-entropy minimization can partly be ascribed to them being human-aware loss functions (HALOs). However, the utility functions these methods attribute to humans still differ from those in the prospect theory literature. Using a Kahneman-Tversky model of human utility, we propose a HALO that directly maximizes the utility of generations instead of maximizing the log-likelihood of preferences, as current methods do. We call this approach Kahneman-Tversky Optimization (KTO), and it matches or exceeds the performance of preference-based methods at scales from 1B to 30B. Crucially, KTO does not need preferences -- only a binary signal of whether an output is desirable or undesirable for a given input. This makes it far easier to use in the real world, where preference data is scarce and expensive. + +The official code can be found in [ContextualAI/HALOs](https://github.com/ContextualAI/HALOs). + +This post-training method was contributed by [Kashif Rasul](https://huggingface.co/kashif), [Younes Belkada](https://huggingface.co/ybelkada), [Lewis Tunstall](https://huggingface.co/lewtun) and Pablo Vicente. + +## Quick start + +This example demonstrates how to train a model using the KTO method. We use the [Qwen 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) as the base model. We use the preference data from the [KTO Mix 14k](https://huggingface.co/datasets/trl-lib/kto-mix-14k). You can view the data in the dataset here: + + + +Below is the script to train the model: + +```python +# train_kto.py +from datasets import load_dataset +from trl.experimental.kto import KTOConfig, KTOTrainer +from transformers import AutoModelForCausalLM, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +train_dataset = load_dataset("trl-lib/kto-mix-14k", split="train") + +training_args = KTOConfig(output_dir="Qwen2-0.5B-KTO") +trainer = KTOTrainer(model=model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_kto.py +``` + +Distributed across 8 x H100 GPUs, the training takes approximately 30 minutes. You can verify the training progress by checking the reward graph. An increasing trend in the reward margin indicates that the model is improving and generating better responses over time. + +![kto qwen2 reward margin](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/kto-qwen2-reward-margin.png) + +To see how the [trained model](https://huggingface.co/trl-lib/Qwen2-0.5B-KTO) performs, you can use the [Transformers Chat CLI](https://huggingface.co/docs/transformers/quicktour#chat-with-text-generation-models). + +
$ transformers chat trl-lib/Qwen2-0.5B-KTO
+<quentin_gallouedec>:
+What is the best programming language?
+
+<trl-lib/Qwen2-0.5B-KTO>:
+The best programming language can vary depending on individual preferences, industry-specific requirements, technical skills, and familiarity with the specific use case or task. Here are some widely-used programming languages that have been noted as popular and widely used:
+
+Here are some other factors to consider when choosing a programming language for a project:
+
+ 1 JavaScript: JavaScript is at the heart of the web and can be used for building web applications, APIs, and interactive front-end applications like frameworks like React and Angular. It's similar to C, C++, and F# in syntax structure and is accessible and easy to learn, making it a popular choice for beginners and professionals alike.
+ 2 Java: Known for its object-oriented programming (OOP) and support for Java 8 and .NET, Java is used for developing enterprise-level software applications, high-performance games, as well as mobile apps, game development, and desktop applications.
+ 3 C++: Known for its flexibility and scalability, C++ offers comprehensive object-oriented programming and is a popular choice for high-performance computing and other technical fields. It's a powerful platform for building real-world applications and games at scale.
+ 4 Python: Developed by Guido van Rossum in 1991, Python is a high-level, interpreted, and dynamically typed language known for its simplicity, readability, and versatility.
+
+ +## Expected dataset format + +KTO requires an [unpaired preference dataset](dataset_formats#unpaired-preference). Alternatively, you can provide a *paired* preference dataset (also known simply as a *preference dataset*). In this case, the trainer will automatically convert it to an unpaired format by separating the chosen and rejected responses, assigning `label = True` to the chosen completions and `label = False` to the rejected ones. + +The [`experimental.kto.KTOTrainer`] supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset formats. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +In theory, the dataset should contain at least one chosen and one rejected completion. However, some users have successfully run KTO using *only* chosen or only rejected data. If using only rejected data, it is advisable to adopt a conservative learning rate. + +## Example script + +We provide an example script to train a model using the KTO method. The script is available in [`trl/scripts/kto.py`](https://github.com/huggingface/trl/blob/main/trl/scripts/kto.py) + +To test the KTO script with the [Qwen2 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) on the [UltraFeedback dataset](https://huggingface.co/datasets/trl-lib/kto-mix-14k), run the following command: + +```bash +accelerate launch trl/scripts/kto.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/kto-mix-14k \ + --num_train_epochs 1 \ + --output_dir Qwen2-0.5B-KTO +``` + +## Usage tips + +### For Mixture of Experts Models: Enabling the auxiliary loss + +MOEs are the most efficient if the load is about equally distributed between experts. +To ensure that we train MOEs similarly during preference-tuning, it is beneficial to add the auxiliary loss from the load balancer to the final loss. + +This option is enabled by setting `output_router_logits=True` in the model config (e.g. [`~transformers.MixtralConfig`]). +To scale how much the auxiliary loss contributes to the total loss, use the hyperparameter `router_aux_loss_coef=...` (default: `0.001`) in the model config. + +### Batch size recommendations + +Use a per-step batch size that is at least 4, and an effective batch size between 16 and 128. Even if your effective batch size is large, if your per-step batch size is poor, then the KL estimate in KTO will be poor. + +### Learning rate recommendations + +Each choice of `beta` has a maximum learning rate it can tolerate before learning performance degrades. For the default setting of `beta = 0.1`, the learning rate should typically not exceed `1e-6` for most models. As `beta` decreases, the learning rate should also be reduced accordingly. In general, we strongly recommend keeping the learning rate between `5e-7` and `5e-6`. Even with small datasets, we advise against using a learning rate outside this range. Instead, opt for more epochs to achieve better results. + +### Imbalanced data + +The `desirable_weight` and `undesirable_weight` of the [`experimental.kto.KTOConfig`] refer to the weights placed on the losses for desirable/positive and undesirable/negative examples. +By default, they are both 1. However, if you have more of one or the other, then you should upweight the less common type such that the ratio of (`desirable_weight` \\(\times\\) number of positives) to (`undesirable_weight` \\(\times\\) number of negatives) is in the range 1:1 to 4:3. + +## Logged metrics + +While training and evaluating, we record the following reward metrics: + +- `rewards/chosen_sum`: the sum of log probabilities of the policy model for the chosen responses scaled by beta +- `rewards/rejected_sum`: the sum of log probabilities of the policy model for the rejected responses scaled by beta +- `logps/chosen_sum`: the sum of log probabilities of the chosen completions +- `logps/rejected_sum`: the sum of log probabilities of the rejected completions +- `logits/chosen_sum`: the sum of logits of the chosen completions +- `logits/rejected_sum`: the sum of logits of the rejected completions +- `count/chosen`: the count of chosen samples in a batch +- `count/rejected`: the count of rejected samples in a batch + +## KTOTrainer + +[[autodoc]] experimental.kto.KTOTrainer + - train + - save_model + - push_to_hub + +## KTOConfig + +[[autodoc]] experimental.kto.KTOConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/liger_kernel_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/liger_kernel_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..7a387c813fd3dd16b3daeca082e08e704eddaed4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/liger_kernel_integration.md @@ -0,0 +1,78 @@ +# Liger Kernel Integration + +[Liger Kernel](https://github.com/linkedin/Liger-Kernel) is a collection of Triton kernels designed specifically for LLM training. It can effectively increase multi-GPU training throughput by 20% and reduce memory usage by 60%. That way, we can **4x** our context length, as described in the benchmark below. They have implemented Hugging Face compatible `RMSNorm`, `RoPE`, `SwiGLU`, `CrossEntropy`, `FusedLinearCrossEntropy`, with more to come. The kernel works out of the box with [FlashAttention](https://github.com/Dao-AILab/flash-attention), [PyTorch FSDP](https://pytorch.org/tutorials/intermediate/FSDP_tutorial.html), and [Microsoft DeepSpeed](https://github.com/microsoft/DeepSpeed). + +With this memory reduction, you can potentially turn off `cpu_offloading` or gradient checkpointing to further boost the performance. + +| Speed Up | Memory Reduction | +| --- | --- | +| ![Speed up](https://raw.githubusercontent.com/linkedin/Liger-Kernel/main/docs/images/e2e-tps.png) | ![Memory](https://raw.githubusercontent.com/linkedin/Liger-Kernel/main/docs/images/e2e-memory.png) | + +## Supported Trainers + +Liger Kernel is supported in the following TRL trainers: +- **SFT** (Supervised Fine-Tuning) +- **DPO** (Direct Preference Optimization) +- **GRPO** (Group Relative Policy Optimization) +- **KTO** (Kahneman-Tversky Optimization) +- **GKD** (Generalized Knowledge Distillation) + +## Usage + +1. First, install Liger Kernel: + + ```bash + pip install liger-kernel + ``` + +2. Once installed, set `use_liger_kernel=True` in your trainer config. No other changes are needed! + + + + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import DPOConfig + +training_args = DPOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import KTOConfig + +training_args = KTOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl.experimental.gkd import GKDConfig + +training_args = GKDConfig(..., use_liger_kernel=True) +``` + + + + +To learn more about Liger-Kernel, visit their [official repository](https://github.com/linkedin/Liger-Kernel/). diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/lora_without_regret.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/lora_without_regret.md new file mode 100644 index 0000000000000000000000000000000000000000..c77392e2e19c7eeef2462d4cd862f1de451ca80c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/lora_without_regret.md @@ -0,0 +1,346 @@ +# LoRA Without Regret + +Recent research from the team at [Thinking Machines Lab](https://thinkingmachines.ai/blog/lora/) (Schulman et al., 2025) shows that **LoRA can match full fine-tuning performance** when configured correctly, while using only ~67% of the compute. These findings are exciting to TRL users because they're straightforward to implement and can improve model performance on smaller budgets. + +This guide provides simple instructions to reproduce the results of the blog post in TRL. + +> [!TIP] +> It is recommended to read the blog post before following this guide, or to consult both resources in parallel for best results. + +## Benefits of LoRA over full fine-tuning + +First of all, let's remind ourselves of the benefits of [LoRA over full fine-tuning](https://huggingface.co/docs/trl/en/peft_integration). + +LoRA adds adapter layers on top of the base model, which contains significantly fewer parameters than the base model itself. This design reduces GPU memory requirements and enables more efficient training. As described in the [blog](https://thinkingmachines.ai/blog/lora/), this approach was originally thought to involve a performance trade-off, although careful configuration can overcome this trade-off and match full fine-tuning performance. + +## Examples with TRL + +Let's implement and train LoRA adapters in TRL scripts based on the core findings of the blog post. Afterwards, we'll revisit each finding in light of the TRL results. + +### Supervised Fine-Tuning (SFT) + +The blog post performs SFT on a range of models and datasets from the Hub, which we can reproduce in TRL. + +| Model | Dataset | +| --- | --- | +| [Llama-3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B) | [allenai/tulu-3-sft-mixture](https://huggingface.co/datasets/allenai/tulu-3-sft-mixture) | +| [Llama-3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B) | [open-thoughts/OpenThoughts-114k](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) | +| [Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B) | [allenai/tulu-3-sft-mixture](https://huggingface.co/datasets/allenai/tulu-3-sft-mixture) | +| [Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B) | [open-thoughts/OpenThoughts-114k](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) | + + + + +We can integrate these findings with the TRL Python API like so: + +```python + +from datasets import load_dataset +from peft import LoraConfig +from trl import SFTTrainer, SFTConfig + +dataset = load_dataset("open-thoughts/OpenThoughts-114k", split="train") + +peft_config = LoraConfig(r=256, lora_alpha=16, target_modules="all-linear") + +training_args = SFTConfig( + learning_rate=2e-4, + per_device_train_batch_size=1, + gradient_accumulation_steps=4, + num_train_epochs=1, + report_to=["trackio"], +) + +trainer = SFTTrainer( + model="Qwen/Qwen2.5-3B-Instruct", + train_dataset=dataset, + peft_config=peft_config, + args=training_args, +) + +trainer.train() + +``` + + + + +```bash + +hf jobs uv run \ + --flavor a100-large \ + --timeout 8h \ + --secrets HF_TOKEN \ + "https://raw.githubusercontent.com/huggingface/trl/main/trl/scripts/sft.py" \ + --model_name_or_path Qwen/Qwen2.5-3B-Instruct \ + --dataset_name open-thoughts/OpenThoughts-114k \ + --learning_rate 2.0e-5 \ + --num_train_epochs 1 \ + --packing \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 16 \ + --use_peft \ + --lora_r 256 \ + --lora_alpha 16 \ + --lora_target_modules all-linear \ + --output_dir Qwen2.5-3B-OpenThoughts-LoRA \ + --report_to trackio \ + --push_to_hub + +``` + +To use Hugging Face Jobs, you will need to be logged in to the Hugging Face Hub (`hf auth login`) and have a [Pro](https://hf.co/pro), [Team](https://hf.co/enterprise), or [Enterprise](https://hf.co/enterprise) plan. Check out the [Jobs documentation](https://huggingface.co/docs/huggingface_hub/en/guides/jobs) for more details. + + + + +```bash + +uv run "https://raw.githubusercontent.com/huggingface/trl/main/trl/scripts/sft.py" \ + --model_name_or_path Qwen/Qwen2.5-3B-Instruct \ + --dataset_name open-thoughts/OpenThoughts-114k \ + --learning_rate 2.0e-5 \ + --num_train_epochs 1 \ + --packing \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 16 \ + --eval_strategy no \ + --use_peft \ + --lora_r 256 \ + --lora_alpha 16 \ + --lora_target_modules all-linear \ + --output_dir Qwen2.5-3B-OpenThoughts-LoRA \ + --report_to trackio \ + --push_to_hub + +``` + +To run the script locally, you will need to have `uv` installed. Check out the [uv documentation](https://docs.astral.sh/uv/) for more details. + + + + +Once training starts, you can monitor the progress in [Trackio](https://huggingface.co/trackio), which will log the URL. + +### Reinforcement Learning (GRPO) + +The blog post performs GRPO on a range of models and datasets from the Hub, and once again we can reproduce the results in TRL. + +| Model | Dataset | +| --- | --- | +| [Llama-3.1-8B-Base](https://huggingface.co/meta-llama/Llama-3.2-1B) | [GSM8k](https://huggingface.co/datasets/openai/gsm8k) | +| [Llama-3.1-8B-Base](https://huggingface.co/meta-llama/Llama-3.2-1B) | [DeepMath-103K](https://huggingface.co/datasets/zwhe99/DeepMath-103K) | +| [Qwen3-8b-base](https://huggingface.co/Qwen/Qwen3-8b-base) | [DeepMath-103K](https://huggingface.co/datasets/zwhe99/DeepMath-103K) | + +For reinforcement learning, the blog uses a math reasoning task that we can reproduce as a Python function. + + + + +We can implement these recommendations with the TRL Python API like so: + +```python + +from datasets import load_dataset +from peft import LoraConfig +from trl import GRPOConfig, GRPOTrainer +from trl.rewards import reasoning_accuracy_reward + +dataset = load_dataset("HuggingFaceH4/OpenR1-Math-220k-default-verified", split="train") + +peft_config = LoraConfig( + r=1, + lora_alpha=32, + target_modules="all-linear" +) + +training_args = GRPOConfig( + learning_rate=5e-5, + per_device_train_batch_size=1, + gradient_accumulation_steps=4, + num_train_epochs=1, + num_generations=8, + generation_batch_size=8, + report_to=["trackio"], +) + +trainer = GRPOTrainer( + model="Qwen/Qwen3-0.6B", + reward_funcs=reasoning_accuracy_reward, + args=training_args, + train_dataset=dataset, + peft_config=peft_config, +) + +trainer.train() + +``` + +> [!WARNING] +> This snippet skips the reward function which is defined above to keep the example concise. + + + + +```bash + +hf jobs uv run \ + --flavor a100-large \ + --timeout 4h \ + --secrets HF_TOKEN \ + --env PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \ + "https://huggingface.co/datasets/burtenshaw/lora-without-regrets/resolve/main/grpo.py" \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --dataset_name HuggingFaceH4/OpenR1-Math-220k-default-verified \ + --output_dir grpo-full-qwen3-0.6b \ + --learning_rate 1.0e-6 \ + --lr_scheduler_type cosine \ + --warmup_steps 0.0 \ + --max_grad_norm 1.0 \ + --beta 0.0 \ + --max_completion_length 4096 \ + --num_generations 16 \ + --generation_batch_size 16 \ + --gradient_accumulation_steps 8 \ + --per_device_train_batch_size 1 \ + --num_train_epochs 1 \ + --lora_r 1 \ + --lora_alpha 32 \ + --lora_dropout 0.0 \ + --lora_target_modules all-linear \ + --vllm_mode colocate \ + --save_strategy steps \ + --save_steps 50 \ + --save_total_limit 1 \ + --logging_steps 1 \ + --max_steps 200 \ + --report_to trackio +``` + +To use Hugging Face Jobs, you will need to be logged in to the Hugging Face Hub (`hf auth login`) and have a [Pro](https://hf.co/pro), [Team](https://hf.co/enterprise), or [Enterprise](https://hf.co/enterprise) plan. Check out the [Jobs documentation](https://huggingface.co/docs/huggingface_hub/en/guides/jobs) for more details. + + + + +```bash +uv run "https://huggingface.co/datasets/burtenshaw/lora-without-regrets/resolve/main/grpo.py" \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --dataset_name HuggingFaceH4/OpenR1-Math-220k-default-verified \ + --output_dir grpo-full-qwen3-0.6b \ + --learning_rate 1.0e-6 \ + --lr_scheduler_type cosine \ + --warmup_steps 0.0 \ + --max_grad_norm 1.0 \ + --beta 0.0 \ + --max_completion_length 4096 \ + --num_generations 16 \ + --generation_batch_size 16 \ + --gradient_accumulation_steps 8 \ + --per_device_train_batch_size 1 \ + --num_train_epochs 1 \ + --lora_r 1 \ + --lora_alpha 32 \ + --lora_dropout 0.0 \ + --lora_target_modules all-linear \ + --vllm_mode colocate \ + --save_strategy steps \ + --save_steps 50 \ + --save_total_limit 1 \ + --logging_steps 1 \ + --max_steps 200 \ + --report_to trackio +``` + +To run the script locally, you will need to have `uv` installed. Check out the [uv documentation](https://docs.astral.sh/uv/) for more details. + + + + +The reinforcement learning script with GRPO is implemented as a custom script in TRL, which uses the reward function shown above. You can review it at [`grpo.py`](https://huggingface.co/datasets/burtenshaw/lora-without-regrets/blob/main/grpo.py) - Reinforcement learning with LoRA best practices + +## Key findings in optimizing LoRA + +The authors recommend applying LoRA to all weight matrices rather than limiting it to attention layers, as increasing the rank does not compensate for this restriction. In TRL, this can be configured using `--lora_target_modules all-linear` to apply LoRA to all weight matrices. + +We were able to reproduce the results of the blog post using TRL and the SmolLM3 model. We trained the model for 500 steps on the [Math 220k dataset](https://huggingface.co/datasets/HuggingFaceH4/OpenR1-Math-220k-default-verified) with the reward function and configuration above. As you can see in the figure below, the LoRA model's average train reward curve matches the full fine-tuning curve. + +![train reward](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lora_without_regret/5.png) + +And most importantly, the LoRA model uses significantly less memory than the full fine-tuning model, as we can see in the figure below. + +![memory usage](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lora_without_regret/6.png) + +Here are the parameters we used to train the above models + +| Parameter | LoRA | Full FT | +| --- | --- | --- | +| `--model_name_or_path` | HuggingFaceTB/SmolLM3-3B | HuggingFaceTB/SmolLM3-3B | +| `--dataset_name` | HuggingFaceH4/OpenR1-Math-220k-default-verified | HuggingFaceH4/OpenR1-Math-220k-default-verified | +| `--learning_rate` | 1.0e-5 | 1.0e-6 | +| `--max_completion_length` | 4096 | 4096 | +| `--lora_r` | 1 | - | +| `--lora_alpha` | 32 | - | +| `--lora_dropout` | 0.0 | - | +| `--lora_target_modules` | all-linear | - | + +Let's break down the key findings of the blog post and how we were able to reproduce them. + +### 1. *LoRA performs better when applied to all weight matrices* + +The authors recommend applying LoRA to all weight matrices rather than limiting it to attention layers, as increasing the rank does not compensate for this restriction. + +![all layers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lora_without_regret/1.png) + +Attention-only LoRA underperforms even when using a higher rank to match parameter count. In TRL, this can be configured using `--lora_target_modules all-linear` to apply LoRA to all weight matrices. In Python, we can do this like so: + +```python +from peft import LoraConfig + +peft_config = LoraConfig(target_modules="all-linear") +``` + +### 2. *The adapter needs sufficient capacity to learn from the dataset* + +The blog post recommends using a sufficient LoRA rank to learn from the dataset. The rank determines the number of trainable parameters in the LoRA adapter. Therefore, "For datasets that exceed LoRA capacity, LoRA underperforms FullFT". + +![learning rate](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lora_without_regret/3.png) + +In the TRL script, we could use `--lora_r` to set the rank and adapt it based on the task and dataset we're training on. The blog post recommends the following ranks based on the task and dataset size: + +Reinforcement learning tasks typically require lower capacity, so smaller LoRA ranks can be used. This is because policy gradient algorithms extract roughly ~1 bit of information per episode, demanding minimal parameter capacity. + +The blog post defines the ideal dataset size for LoRA to match full fine-tuning as "Post-training scale". Which we can use to determine the recommended rank for SFT and RL LoRAs as: + +| Task Type | Dataset Size | Recommended Rank | +| --- | --- | --- | +| **SFT** | Post-training scale | 256 | +| **RL** | Any size | 1-32 | + +### 3. *"FullFT and high-rank LoRAs have similar learning curves"* + +Counterintuitively, the blog post recommends using a higher learning rate than for full fine-tuning. In the table above, we used 1.0e-5 for LoRA and 1.0e-6 for full fine-tuning. In the TRL script, we could use `--learning_rate` to set the learning rate. The \\( \frac{1}{r} \\) scaling in LoRA makes the optimal learning rate approximately rank-independent. + +![learning rate](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lora_without_regret/2.png) + +### 4. *"In some scenarios, LoRA is less tolerant of large batch sizes than full fine-tuning."* + +The blog post recommends using an effective batch size < 32 because the authors found LoRA to be less tolerant of large batch sizes. This could not be mitigated by increasing the LoRA rank. In the TRL script, we could use `--per_device_train_batch_size` and `--gradient_accumulation_steps` to set the batch size. + +![learning rate](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lora_without_regret/4.png) + +## Takeaways + +Using TRL, you can efficiently implement LoRA adapters to match full fine-tuning performance, applying the core insights (targeting all weight matrices, choosing the right rank, and managing batch size and learning rate) without the heavy compute cost of FullFT. + +## Citation + +```bibtex +@article{schulman2025lora, + title = {{LoRA Without Regret}}, + author = {John Schulman and Thinking Machines Lab}, + year = 2025, + journal = {Thinking Machines Lab: Connectionism}, + doi = {10.64434/tml.20250929}, + note = {https://thinkingmachines.ai/blog/lora/} +} +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/merge_model_callback.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/merge_model_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..fd7241e7d15f070698410505ccdadc041726e466 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/merge_model_callback.md @@ -0,0 +1,3 @@ +# MergeModelCallback + +[[autodoc]] experimental.merge_model_callback.MergeModelCallback diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/minillm_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/minillm_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..6db88955dc38ef11e1065f237142147e0342e4e3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/minillm_trainer.md @@ -0,0 +1,67 @@ +# MiniLLM Trainer + +[![All_models-MiniLLM-blue](https://img.shields.io/badge/All_models-MiniLLM-blue)](https://huggingface.co/models?other=minillm,trl) + +## Overview + +TRL supports the MiniLLM Trainer for distilling large language models into smaller ones using reverse KLD for better precision, quality, and performance, as described in the paper [Knowledge Distillation of Large Language Models](https://huggingface.co/papers/2306.08543) by [Yuxian Gu](https://huggingface.co/t1101675), [Li Dong](https://huggingface.co/unilm), [Furu Wei](https://huggingface.co/thegenerality), and Minlie Huang. +The abstract from the paper is the following: + +> Knowledge Distillation (KD) is a promising technique for reducing the high computational demand of large language models (LLMs). However, previous KD methods are primarily applied to white-box classification models or training small models to imitate black-box model APIs like ChatGPT. How to effectively distill the knowledge from white-box generative LLMs is still under-explored, which becomes more and more important with the prosperity of LLMs. In this work, we propose MiniLLM that distills smaller language models from generative larger language models. We first replace the forward Kullback-Leibler divergence (KLD) objective in the standard KD approaches with reverse KLD, which is more suitable for KD on generative language models, to prevent the student model from overestimating the low-probability regions of the teacher distribution. Then, we derive an effective optimization approach to learn this objective. Extensive experiments in the instruction-following setting show that the MiniLLM models generate more precise responses with the higher overall quality, lower exposure bias, better calibration, and higher long-text generation performance. Our method is also scalable for different model families with 120M to 13B parameters. We will release our code and model checkpoints at https://aka.ms/MiniLLM. + +This post-training method was contributed by [Yuxian Gu](https://huggingface.co/t1101675). + +It is a generalized version of [Think Machine Lab's On-Policy Distillation](https://thinkingmachines.ai/blog/on-policy-distillation/), with the option to add distribution-level single-step distillation signals (like GKD when `beta=1`) and long-context reverse KLD signals. + +$$ +\begin{align} +L_{\text{MiniLLM}}&=\alpha_1\mathbb{E}_{x\sim \pi_{\theta}}\sum_{t'=t}^{|x|}\frac{\gamma^{t'-t}}{\sum_{t'}\gamma^{t'-t}}\left[\log \frac{\pi_{\theta}(x_{t'+1}|x_{1..t'})}{\pi_{\text{teacher}}(x_{t'+1}|x_{1..t'})}\right] \\ +&+ \alpha_2\mathbb{E}_{x\sim \pi_{\theta}} \text{KL}\left[\pi_\theta(\cdot|x_{1..t})||\pi_{\text{teacher}}(\cdot | x_{1..t})\right]. +\end{align} +$$ + +When \\( \alpha_1=1 \\), \\( \alpha_2=0 \\), \\( \gamma=0 \\), which corresponds to + +```python +from trl.experimental.minillm import MiniLLMConfig + +training_args = MiniLLMConfig( + rkl_advantage=True, + single_step_decomposition=False, + gamma=False +) +``` + +\\( L_{\text{MiniLLM}} \\) becomes the on-policy KD implemented in [Tinker](https://github.com/thinking-machines-lab/tinker-cookbook/blob/5d08be6d130596b7bedd02197861c41fa81ea436/tinker_cookbook/distillation/train_on_policy.py#L88): + +$$ +L_{\text{tinker}}=\mathbb{E}_{x\sim \pi_{\theta}}\left[\log \frac{\pi_{\theta}(x_{t'+1}|x_{1..t'})}{\pi_{\text{teacher}}(x_{t'+1}|x_{1..t'})}\right]. +$$ + +When \\( \alpha_1=0 \\), \\( \alpha_2=1 \\), which corresponds to + +```python +from trl.experimental.minillm import MiniLLMConfig + +training_args = MiniLLMConfig( + rkl_advantage=False, + single_step_decomposition=True +) +``` + +\\( L_{\text{MiniLLM}} \\) becomes the reverse KLD version of the GKD loss as in [GKD Trainer](./gkd.md): + +$$ +L_{\text{GKD-RKL}}=\mathbb{E}_{x\sim \pi_{\theta}} \text{KL}\left[\pi_\theta(\cdot|x_{1..t})||\pi_{\text{teacher}}(\cdot | x_{1..t})\right]. +$$ + +## MiniLLMTrainer + +[[autodoc]] experimental.minillm.MiniLLMTrainer + - train + - save_model + - push_to_hub + +## MiniLLMConfig + +[[autodoc]] experimental.minillm.MiniLLMConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/nash_md_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/nash_md_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..74ff77c593ff721f38a78df4ca18218c80cbc44c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/nash_md_trainer.md @@ -0,0 +1,140 @@ +# Nash-MD Trainer + +[![model badge](https://img.shields.io/badge/All_models-Nash--MD-blue)](https://huggingface.co/models?other=nash-md,trl) + +## Overview + +Nash-MD was proposed in the paper [Nash Learning from Human Feedback](https://huggingface.co/papers/2312.00886) by Rémi Munos, [Michal Valko](https://huggingface.co/misovalko), Daniele Calandriello, Mohammad Gheshlaghi Azar, Mark Rowland, Daniel Guo, Yunhao Tang, Matthieu Geist, Thomas Mésnard, and Andrea Michi. + +The abstract from the paper is the following: + +> Reinforcement learning from human feedback (RLHF) has emerged as the main paradigm for aligning large language models (LLMs) with human preferences. Typically, RLHF involves the initial step of learning a reward model from human feedback, often expressed as preferences between pairs of text generations produced by a pre-trained LLM. Subsequently, the LLM's policy is fine-tuned by optimizing it to maximize the reward model through a reinforcement learning algorithm. However, an inherent limitation of current reward models is their inability to fully represent the richness of human preferences and their dependency on the sampling distribution. In this study, we introduce an alternative pipeline for the fine-tuning of LLMs using pairwise human feedback. Our approach entails the initial learning of a preference model, which is conditioned on two inputs given a prompt, followed by the pursuit of a policy that consistently generates responses preferred over those generated by any competing policy, thus defining the Nash equilibrium of this preference model. We term this approach Nash learning from human feedback (NLHF). In the context of a tabular policy representation, we present a novel algorithmic solution, Nash-MD, founded on the principles of mirror descent. This algorithm produces a sequence of policies, with the last iteration converging to the regularized Nash equilibrium. Additionally, we explore parametric representations of policies and introduce gradient descent algorithms for deep-learning architectures. To demonstrate the effectiveness of our approach, we present experimental results involving the fine-tuning of a LLM for a text summarization task. We believe NLHF offers a compelling avenue for preference learning and policy optimization with the potential of advancing the field of aligning LLMs with human preferences. + +This post-training method was contributed by [Kashif Rasul](https://huggingface.co/kashif) and [Daniil Tiapkin](https://huggingface.co/dtiapkin), [Pierre Ménard](https://huggingface.co/menardprr), Daniele Calandriello and [Quentin Gallouédec](https://huggingface.co/qgallouedec). + +## Quick start + +This example demonstrates how to train a model using the Nash-MD method. We use the [Qwen 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) as the base model and the [trl-lib/Qwen2-0.5B-Reward](https://huggingface.co/trl-lib/Qwen2-0.5B-Reward) reward model. We use the prompts from the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback). You can view the prompts in the dataset here: + + + +Below is the script to train the model: + +```python +# train_nash_md.py +from datasets import load_dataset +from trl.experimental.nash_md import NashMDConfig, NashMDTrainer +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +reward_model = AutoModelForSequenceClassification.from_pretrained("trl-lib/Qwen2-0.5B-Reward", num_labels=1) +train_dataset = load_dataset("trl-lib/ultrafeedback-prompt", split="train") + +training_args = NashMDConfig(output_dir="Qwen2-0.5B-NashMD") +trainer = NashMDTrainer( + model=model, reward_funcs=reward_model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset +) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_nash_md.py +``` + +Distributed across 8 GPUs, the training takes approximately 3 hours. + +To see how the [trained model](https://huggingface.co/trl-lib/Qwen2-0.5B-NashMD) performs, you can use the [Transformers Chat CLI](https://huggingface.co/docs/transformers/quicktour#chat-with-text-generation-models). + +
$ transformers chat trl-lib/Qwen2-0.5B-NashMD
+<quentin_gallouedec>:
+What is the best programming language?
+
+<trl-lib/Qwen2-0.5B-NashMD>:
+The best programming language depends on personal preference, the complexity of the project, and the specific requirements of the task. Some programming languages that are often recommended include Python, Java, and JavaScript, and there are many other languages to choose from depending on individual needs.
+
+ +## Expected dataset type + +Nash-MD requires a [prompt-only dataset](dataset_formats#prompt-only). The [`experimental.nash_md.NashMDTrainer`] supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset formats. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +## Usage tips + +### Encourage EOS token generation + +We may want the model to generate completions within a given length. During training, the model will generate completions up to the maximum length specified in the `max_new_tokens` argument of [`experimental.nash_md.NashMDConfig`]. If you want to penalize the model for not generating an EOS token before reaching the maximum length, you can use the `missing_eos_penalty` argument of [`experimental.nash_md.NashMDConfig`]: + +```python +training_args = NashMDConfig(..., max_new_tokens=128, missing_eos_penalty=1.0) +``` + +> [!WARNING] +> Make sure that the SFT model and reward model use the _same_ chat template and the same tokenizer. Otherwise, you may find the model completions are scored incorrectly during training. + +### Logging Completions + +To better understand your model's behavior during training, you can log sample completions periodically using the [`LogCompletionsCallback`]. + +```python +trainer = NashMDTrainer(..., eval_dataset=eval_dataset) +completions_callback = LogCompletionsCallback(trainer, num_prompts=8) +trainer.add_callback(completions_callback) +``` + +This callback logs the model's generated completions directly to Weights & Biases. + +![Logged Completions](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/wandb_completions.png) + +## Example script + +We provide an example script to train a model using the Nash-MD method. The script is available in [`examples/scripts/nash_md.py`](https://github.com/huggingface/trl/blob/main/examples/scripts/nash_md.py) + +To test the Nash-MD script with the [Qwen2.5 0.5B model](https://huggingface.co/trl-lib/Qwen/Qwen2.5-0.5B-Instruct) on the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback), run the following command: + +```bash +python examples/scripts/nash_md.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --reward_model_path trl-lib/Qwen2-0.5B-Reward \ + --dataset_name trl-lib/ultrafeedback-prompt \ + --learning_rate 5.0e-7 \ + --output_dir Qwen2.5-0.5B-NashMD \ + --warmup_steps 0.1 \ + --push_to_hub +``` + +## Logged metrics + +While training and evaluating, we record the following reward metrics: + +* `loss/kl`: The mean KL divergence between the model and reference data. +* `objective/entropy`: The mean entropy of the model and reference data. +* `loss/score`: The mean reinforce score loss. +* `rewards/chosen`: The mean scores (according to the reward model) of the model completions. +* `rewards/rejected`: The mean scores (according to the reward model) of the mixture completions. +* `rewards/probabilities`: The mean probability (according to the reward model) of the model completions chosen vs the mixture completion. +* `rewards/accuracies`: The accuracies of the Nash-MD's implicit reward model. +* `rewards/margins`: The mean reward margin (according to reward model) between the chosen and mixture completions. +* `logps/chosen`: The mean log probabilities of the chosen completions. +* `logps/rejected`: The mean log probabilities of the reference completions. +* `val/model_contain_eos_token`: The amount of times the model's output contains the eos token. +* `val/ref_contain_eos_token`: The amount of times the mixture's output contains the eos token. +* `beta`: The parameter that controls the weight of the loss term representing the deviation from the reference model. Typically fixed, but can be made dynamic by passing a list to [`experimental.nash_md.NashMDConfig`]. +* `mixture_coef`: Logit mixture coefficient for the model and reference model. Typically fixed, but can be made dynamic by passing a list to [`experimental.nash_md.NashMDConfig`]. + +## NashMDTrainer + +[[autodoc]] experimental.nash_md.NashMDTrainer + - train + - save_model + - push_to_hub + +## NashMDConfig + +[[autodoc]] experimental.nash_md.NashMDConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/nemo_gym.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/nemo_gym.md new file mode 100644 index 0000000000000000000000000000000000000000..295c779e8e204c0365b48ee6defd079f013c3962 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/nemo_gym.md @@ -0,0 +1,293 @@ +# NeMo Gym Integration + +NVIDIA NeMo Gym is a library for building RL environments for large language models. This integration enables training models in NeMo Gym environments using TRL's GRPOTrainer with vLLM server mode. + +The integration supports multi-step and multi-turn rollouts, multi-environment training, and any NeMo Gym environment (thoroughly tested: workplace assistant, reasoning gym, MCQA, and math with judge). + +## Why NeMo Gym + +- **Production-Ready Scale**: Tested for frontier model training with diverse environments running in parallel across math, coding, tool use, reasoning, and more. +- **Multi-Verifier Training**: Supports algorithmic verification, LLM-as-a-judge, and custom verification logic in a single training run. +- **Decoupled Architecture**: Build agents and environments independently from the training loop—no RL framework expertise required. +- **OpenAI-Compatible API**: All environments use the standardized OpenAI Responses API for seamless integration with vLLM, OpenAI models, and other endpoints. + +## Available Environments + +NeMo Gym provides training-ready environments across multiple domains, including but not limited to: + +| Environment | Domain | Description | +|-------------|--------|-------------| +| Workplace Assistant | Agent | Multi-step tool calling in common office scenarios (calendar, email, and more) | +| Math with Judge | Math | Math problems with algorithmic or judge-based verification | +| Code Gen | Coding | Competitive programming problems with code execution | +| MCQA | Knowledge | Multiple-choice question answering | +| Instruction Following | Instruction Following | IFEval/IFBench style tasks | +| Reasoning Gym | Multiple | Single-step procedurally generated verifiable tasks across domains | + +For a complete list of available training environments, refer to the [NeMo Gym repository](https://github.com/NVIDIA-NeMo/Gym#-available-resource-servers). + +## Before You Start + +Complete these one-time setup steps before running training. + +### Install TRL and NeMo Gym + +1. **Install TRL with vLLM extras** + + ```bash + cd trl/ + uv venv + source .venv/bin/activate + uv sync --extra vllm + ``` + +1. **Install NeMo Gym** + + ```bash + # deactivate trl venv + deactivate + git clone https://github.com/NVIDIA-NeMo/Gym.git + cd Gym + uv venv --python 3.12 + source .venv/bin/activate + uv sync + ``` + +### Prepare a Dataset + +Many NeMo Gym datasets used to train Nemotron models are available on Hugging Face. Use `ng_prepare_data` to download and prepare datasets. This command: + +- Downloads the dataset from Hugging Face +- Validates the data format +- Adds an `agent_ref` field to each example that tells NeMo Gym which agent server should handle that example + +> **Note**: `train_multi_environment.py` adds the `agent_ref` field when loading datasets, so this step is optional if datasets are created another way. + +1. **Set Hugging Face Token** + + Create `env.yaml` in `Gym/` with your HF token: + + ```yaml + hf_token: + ``` + +1. **Prepare Dataset** + + ```bash + # Enter Gym and activate the venv + cd Gym + source .venv/bin/activate + + # Set config paths + config_paths="responses_api_models/vllm_model/configs/vllm_model.yaml,\ + resources_servers/workplace_assistant/configs/workplace_assistant.yaml" + + # Download data and prep for training + ng_prepare_data "+config_paths=[${config_paths}]" \ + +output_dirpath=data/workplace_assistant \ + +mode=train_preparation \ + +should_download=true \ + +data_source=huggingface + ``` + + This creates `train.jsonl` and `validation.jsonl` files in `data/workplace_assistant/`. + +To create a new environment, refer to the [environment creation guide](https://docs.nvidia.com/nemo/gym/latest/contribute/environments/new-environment.html). We suggest running an existing one first! + +#### Dataset Format + +NeMo Gym datasets are stored as JSONL. Each line contains a task with input messages, tool definitions, metadata such as ground truth for verification, and an agent server reference. The following example shows the workplace dataset structure. Metadata fields can differ between datasets, as long as the corresponding resources server uses the fields appropriately. + +```json +{ + "responses_create_params": { + "input": [ + {"role": "system", "content": "..."}, + {"role": "user", "content": "Move any of jinsoo's tasks that are in review to completed"} + ], + "tools": [...], + "parallel_tool_calls": false, + "temperature": 1 + }, + "ground_truth": [ + {"name": "project_management_update_task", "arguments": "{...}"}, + ... + ], + "category": "workbench_project_management", + "environment_name": "workbench", + "agent_ref": { + "type": "responses_api_agents", + "name": "workplace_assistant_simple_agent" + } +} +``` + +## Interactive Training + +For development and testing on a single node. + +### Set Up + +1. **Update Environment Config** + + Update `env.yaml` in `Gym/` to include model information: + + ```yaml + policy_base_url: http://127.0.0.1:8000/v1 + policy_api_key: EMPTY + policy_model_name: Qwen/Qwen2.5-1.5B-Instruct + hf_token: ... + ``` + +2. **Update Training Config** + + Update `examples/scripts/nemo_gym/config.yaml` to point to the dataset generated above, and any other optional modifications. + +### Run Training + +The following steps run in 3 terminals. It can also be ran with processes in the background, or using tmux. + +1. **Start NeMo Gym Servers** (Terminal 1) + + ```bash + cd Gym/ + source .venv/bin/activate + + config_paths="resources_servers/workplace_assistant/configs/workplace_assistant.yaml,\ + responses_api_models/vllm_model/configs/vllm_model_for_training.yaml" + + ng_run "+config_paths=[${config_paths}]" + ``` + + This starts: + - **Agent server**: Orchestrates rollouts using resource servers and model servers + - **Resources server**: Supports environment logic such as state-management, tool implementations, and task verification + - **Model server**: Adapts vLLM server requests to support NeMo Gym agents and on-policy RL training while ensuring OpenAI API compatibility + - **Head server**: Manages servers used in training enabling their discovery + +1. **Start TRL vLLM Server on GPU 0** (Terminal 2) + + ```bash + cd trl/ + source .venv/bin/activate + CUDA_VISIBLE_DEVICES=0 trl vllm-serve \ + --model Qwen/Qwen2.5-1.5B-Instruct \ + --max-model-len 16384 \ + --host 0.0.0.0 \ + --port 8000 + ``` + +1. **Run Training on GPU 1** (Terminal 3) + + ```bash + source trl/.venv/bin/activate + cd trl/examples/scripts/nemo_gym + export WANDB_API_KEY=... + uv add omegaconf + + CUDA_VISIBLE_DEVICES=1 python train_multi_environment.py --config config.yaml + ``` + +## Multi-Node Training with Slurm + +An example five-node training script is provided in `submit.sh`. Nodes one through four run the training algorithm, while node five runs vLLM inference for NeMo Gym agent rollouts. + +1. **Configure the Script** + + Update `submit.sh` with your Slurm account, partition, paths to your project directory, and updated training configs. + +1. **Submit the Job** + + ```bash + sbatch submit.sh + ``` + +1. **Monitor Training** + + ```bash + tail -f logs//* + ``` + +> **Tip**: Set up wandb logging for detailed training metrics. For more details on TRL's vLLM integration, refer to the vLLM integration page. + +## Multi-Environment Training + +Train on multiple NeMo Gym environments simultaneously. This allows learning diverse capabilities, such as tool calling and math reasoning, in a single training run. + +1. **Prepare Individual Datasets** + + Prepare datasets for each environment. The workplace assistant dataset was prepared above. Now lets create a dataset for the mini sudoku environment implemented by the reasoning gym resources server in NeMo Gym: + + ```bash + cd Gym + source .venv/bin/activate + uv add reasoning-gym + cd resources_servers/reasoning_gym + python scripts/create_dataset.py \ + --task mini_sudoku \ + --size 2000 \ + --seed 42 \ + --output data/reasoning_gym/train_mini_sudoku.jsonl + + python scripts/create_dataset.py \ + --task mini_sudoku \ + --size 50 \ + --seed 24 \ + --output data/reasoning_gym/val_mini_sudoku.jsonl + ``` + +1. **Create Combined Dataset** + + Combine datasets into a single file with tasks from both environments: + + ```bash + cat data/workplace_assistant/train_workplace.jsonl data/reasoning_gym/train_mini_sudoku.jsonl | shuf > train_multi_env.jsonl + ``` + + > **Tip**: Ensure datasets are the same size before shuffling for an even blend of tasks. Repeat for the validation dataset. + +1. **Update Training Config** + + Update the config to point to the combined dataset: + + ```yaml + model_name: "Qwen/Qwen3-4B-Instruct-2507" + + dataset_path: "/path/to/data/train_multi_env.jsonl" + eval_dataset_path: "/path/to/data/val_multi_env.jsonl" + + task: "workplace-sudoku" # used in wandb run name + output_dir: "outputs/nemo_gym_multi_env" + + # ... rest of config same + ``` + +1. **Update ng_run** + + Whether training interactively or via Slurm, update the `ng_run` command to include config files from each resources server: + + ```bash + cd Gym + source .venv/bin/activate + + config_paths="responses_api_models/vllm_model/configs/vllm_model.yaml,\ + resources_servers/workplace_assistant/configs/workplace_assistant.yaml,\ + resources_servers/reasoning_gym/configs/reasoning_gym.yaml" + + ng_run "+config_paths=[${config_paths}]" + ``` + + This starts servers for both environments. The training script automatically routes each example to the correct agent server based on its `agent_ref` field. + +1. **Run Training** + + Update the Slurm submission script to use the new training config and both `ng_run` resources server configs, then submit the job as before. + + The training script reads `agent_ref` from each example's metadata, routes requests to the correct NeMo Gym agent server, and handles different agents and environments in the same batch. + +## Resources + +- [NeMo Gym GitHub](https://github.com/NVIDIA-NeMo/Gym) +- [NeMo Gym Documentation](https://docs.nvidia.com/nemo/gym/latest/) +- [Training Script](https://github.com/huggingface/trl/blob/main/examples/scripts/nemo_gym/train_multi_environment.py) +- [TRL GRPO Trainer](grpo_trainer) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/online_dpo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/online_dpo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..b82029f13fc71286498429166f0a7ba3e8ab6a5c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/online_dpo_trainer.md @@ -0,0 +1,206 @@ +# Online DPO Trainer + +[![model badge](https://img.shields.io/badge/All_models-Online_DPO-blue)](https://huggingface.co/models?other=online-dpo,trl) + +## Overview + +Online DPO was proposed in [Direct Language Model Alignment from Online AI Feedback](https://huggingface.co/papers/2402.04792) by Shangmin Guo, Biao Zhang, Tianlin Liu, Tianqi Liu, Misha Khalman, Felipe Llinares, Alexandre Rame, Thomas Mesnard, Yao Zhao, Bilal Piot, Johan Ferret, and Mathieu Blondel. + +The abstract from the paper is the following: + +> Direct alignment from preferences (DAP) methods, such as DPO, have recently emerged as efficient alternatives to reinforcement learning from human feedback (RLHF), that do not require a separate reward model. However, the preference datasets used in DAP methods are usually collected ahead of training and never updated, thus the feedback is purely offline. Moreover, responses in these datasets are often sampled from a language model distinct from the one being aligned, and since the model evolves over training, the alignment phase is inevitably off-policy. In this study, we posit that online feedback is key and improves DAP methods. Our method, online AI feedback (OAIF), uses an LLM as annotator: on each training iteration, we sample two responses from the current model and prompt the LLM annotator to choose which one is preferred, thus providing online feedback. Despite its simplicity, we demonstrate via human evaluation in several tasks that OAIF outperforms both offline DAP and RLHF methods. We further show that the feedback leveraged in OAIF is easily controllable, via instruction prompts to the LLM annotator. + +This post-training method was contributed by [Michael Noukhovitch](https://huggingface.co/mnoukhov), [Shengyi Costa Huang](https://huggingface.co/vwxyzjn), [Quentin Gallouédec](https://huggingface.co/qgallouedec), and [Edward Beeching](https://huggingface.co/edbeeching). + +## Quick start + +This example demonstrates how to train a model using the online DPO method. We use the [Qwen 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) as the base model and the [trl-lib/Qwen2-0.5B-Reward](https://huggingface.co/trl-lib/Qwen2-0.5B-Reward) reward model. We use the prompts from the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback). You can view the prompts in the dataset here: + + + +Below is the script to train the model: + +```python +# train_online_dpo.py +from datasets import load_dataset +from trl.experimental.online_dpo import OnlineDPOConfig, OnlineDPOTrainer +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +reward_model = AutoModelForSequenceClassification.from_pretrained("trl-lib/Qwen2-0.5B-Reward", num_labels=1) +train_dataset = load_dataset("trl-lib/ultrafeedback-prompt", split="train") + +training_args = OnlineDPOConfig(output_dir="Qwen2-0.5B-OnlineDPO") +trainer = OnlineDPOTrainer( + model=model, reward_funcs=reward_model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset +) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_online_dpo.py +``` + +Distributed across 8 GPUs, the training takes approximately 1 hour. You can verify the training progress by checking the reward graph. An increasing trend in both the reward for rejected and chosen completions indicates that the model is improving and generating better responses over time. + +![](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/online-dpo-qwen2.png) + +To see how the [trained model](https://huggingface.co/trl-lib/Qwen2-0.5B-OnlineDPO) performs, you can use the [Transformers Chat CLI](https://huggingface.co/docs/transformers/quicktour#chat-with-text-generation-models). + +
$ transformers chat trl-lib/Qwen2-0.5B-OnlineDPO
+<quentin_gallouedec>:
+What is the best programming language?
+
+<trl-lib/Qwen2-0.5B-OnlineDPO>:
+The best programming language depends on your specific needs and priorities. Some people prefer imperative programming languages (like Haskell or Lisp), while others prefer functional programming languages (like Scala or Python). It's important to consider your work style, programming environment, and project requirements when choosing a programming language.
+
+ +## Expected dataset type + +Online DPO only requires a [prompt-only dataset](dataset_formats#prompt-only) (unlike offline DPO, that expects [preference dataset](dataset_formats#preference)). The [`experimental.online_dpo.OnlineDPOTrainer`] supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset formats. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +## Usage tips + +### Encourage EOS token generation + +When using a reward model, we may want the model to generate completions within a given length. During training, the model will generate completions up to the maximum length specified in the `max_new_tokens` argument of [`experimental.online_dpo.OnlineDPOConfig`]. If you want to penalize the model for not generating an EOS token before reaching the maximum length, you can use the `missing_eos_penalty` argument of [`experimental.online_dpo.OnlineDPOConfig`]: + +```python +training_args = OnlineDPOConfig(..., max_new_tokens=128, missing_eos_penalty=1.0) +``` + +### Logging Completions + +To better understand your model's behavior during training, you can log sample completions periodically using the [`LogCompletionsCallback`]. + +```python +trainer = OnlineDPOTrainer(..., eval_dataset=eval_dataset) +completions_callback = LogCompletionsCallback(trainer, num_prompts=8) +trainer.add_callback(completions_callback) +``` + +This callback logs the model's generated completions directly to Weights & Biases. + +![Logged Completions](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/wandb_completions.png) + +## Example script + +We provide an example script to train a model using the online DPO method. The script is available in [`examples/scripts/dpo_online.py`](https://github.com/huggingface/trl/blob/main/examples/scripts/dpo_online.py) + +To test the online DPO script with the [Qwen2.5 0.5B model](https://huggingface.co/trl-lib/Qwen/Qwen2.5-0.5B-Instruct) on the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback), run the following command: + +```bash +python examples/scripts/dpo_online.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --reward_model_path trl-lib/Qwen2-0.5B-Reward \ + --dataset_name trl-lib/ultrafeedback-prompt \ + --learning_rate 5.0e-7 \ + --output_dir Qwen2.5-0.5B-Online-DPO \ + --warmup_steps 0.1 \ + --push_to_hub +``` + +## Logged metrics + +While training and evaluating, we record the following reward metrics. Here is an example [tracked run at Weights and Biases](https://wandb.ai/huggingface/trl/runs/w4apmsi9) + +* `objective/kl`: The mean Kullback-Leibler (KL) divergence between the current model and reference model. +* `objective/entropy`: The mean entropy of the model, indicating the randomness of the actions chosen by the model. +* `objective/non_score_reward`: The mean reward from non-score-related sources, basically `beta * kl.sum(1)`, where `beta` is the KL penalty coefficient and `kl` is the per-token KL divergence. +* `objective/rlhf_reward`: The mean RLHF reward, which is `scores - non_score_reward`. The `rlhf_reward` is the ultimate objective of online DPO training. If training works as intended, this metric should keep going up. +* `objective/scores`: The mean scores returned by the reward model. +* `objective/scores_margin`: The mean score margin (according to the external reward model) between the chosen and rejected completions. +* `rewards/chosen`: The mean reward (according to online DPO's implicit reward model)of the chosen completions. +* `rewards/rejected`: The mean reward (according to online DPO's implicit reward model) of the rejected completions. +* `rewards/accuracies`: The accuracies of the online DPO's implicit reward model. +* `rewards/margins`: The mean reward margin (according to online DPO's implicit reward model) between the chosen and rejected completions. +* `logps/chosen`: The mean log probabilities of the chosen completions. +* `logps/rejected`: The mean log probabilities of the rejected completions. +* `val/contain_eos_token`: The fraction of completions which contain an EOS token. +* `beta`: The parameter that controls the weight of the loss term representing the deviation from the reference model. Typically fixed, but can be made dynamic by passing a list to [`experimental.online_dpo.OnlineDPOConfig`]. + +## Benchmark experiments + +To validate the online DPO implementation works, we ran experiments with the Pythia 1B, 2.8B, and 6.9B models on a single node of 8 x H100s. Here are the commands we used to run the experiments. We take the SFT / RM models directly from [The N+ Implementation Details of RLHF with PPO: A Case Study on TL;DR Summarization](https://huggingface.co/papers/2403.17031). + +```shell +# 1B Online DPO experiment +accelerate launch --config_file examples/accelerate_configs/multi_gpu.yaml \ + examples/scripts/dpo_online.py \ + --model_name_or_path trl-lib/pythia-1b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-1b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-1b-deduped-tldr-online-dpo \ + --beta 0.1 \ + --per_device_train_batch_size 8 \ + --gradient_accumulation_steps 2 \ + --num_train_epochs 3 \ + --max_new_tokens 53 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --save_steps 0.1 \ + --push_to_hub + +# 2.8B Online DPO experiment +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero2.yaml \ + examples/scripts/dpo_online.py \ + --model_name_or_path trl-lib/pythia-2.8b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-2.8b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-2.8b-deduped-tldr-online-dpo \ + --beta 0.1 \ + --per_device_train_batch_size 8 \ + --gradient_accumulation_steps 2 \ + --num_train_epochs 3 \ + --max_new_tokens 53 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --save_steps 0.1 \ + --push_to_hub + +# 6.9B Online DPO experiment +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero2.yaml \ + examples/scripts/dpo_online.py \ + --model_name_or_path trl-lib/pythia-6.9b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-6.9b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-6.9b-deduped-tldr-online-dpo \ + --beta 0.1 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 4 \ + --num_train_epochs 3 \ + --max_new_tokens 53 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --save_steps 0.1 \ + --push_to_hub +``` + +Checkpoints and experiment tracking are available at: + +* [🤗 Model checkpoints](https://huggingface.co/collections/trl-lib/online-dpo-66acd3fa38a331a9cd457b07) +* [🐝 Tracked experiment](https://wandb.ai/huggingface/trl/reports/Online-DPO-experiments-for-TL-DR-summarisation--Vmlldzo5MTczMDU0) + +The online DPO checkpoint gets increasingly more win rate as we scale up the model sizes. This is a good sign that the online DPO implementation is working as intended. + +## OnlineDPOTrainer + +[[autodoc]] experimental.online_dpo.OnlineDPOTrainer + - train + - save_model + - push_to_hub + +## OnlineDPOConfig + +[[autodoc]] experimental.online_dpo.OnlineDPOConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/openenv.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/openenv.md new file mode 100644 index 0000000000000000000000000000000000000000..b5e4cc37828f54513d4a280e2949ee20926f5666 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/openenv.md @@ -0,0 +1,659 @@ +# OpenEnv Integration for Training LLMs with Environments + +[OpenEnv](https://github.com/meta-pytorch/OpenEnv) is an open-source framework for defining, deploying, and interacting with environments in reinforcement learning (RL) and agentic workflows. It provides standardized APIs for environment interaction and supports running environments as backend servers (via WebSocket or containerised execution). You can find a collection of ready-to-use OpenEnv environments on the [Hugging Face Hub](https://huggingface.co/collections/openenv/openenv-environment-hub). + +This guide covers **how to integrate OpenEnv with TRL**. For more on OpenEnv itself, see the [OpenEnv docs](https://meta-pytorch.org/OpenEnv/). + +> [!NOTE] +> You can explore ready-to-use example [scripts](example_overview#openenv-scripts) and [notebooks](example_overview#openenv-notebooks) in the Examples Overview. + +## When to use environments + +[`GRPOTrainer`] can be used to train agents. For agentic tasks, it supports two modes: **tools**, where the model can call external functions but each call is stateless and independent, and **environments**, which maintain state across turns, enabling genuine multi-turn interaction where the agent's actions shape future observations. Use environments when continuity matters — for example, navigating a game, browsing a web page, or any task where what the agent sees next depends on what it did before. + +## Installation + +OpenEnv environments are hosted as Hugging Face Spaces, which are also pip-installable Git repositories: + +```bash +# Echo environment +pip install "openenv-echo-env @ git+https://huggingface.co/spaces/openenv/echo_env" + +# Wordle (TextArena) environment +pip install "openenv-textarena @ git+https://huggingface.co/spaces/openenv/wordle" + +# Catch (OpenSpiel) environment +pip install "openenv-openspiel-env @ git+https://huggingface.co/spaces/openenv/openspiel_env" +``` + +This installs the **environment client** (e.g., `EchoEnv`) that communicates with the remote environment server via WebSocket, along with the action/observation models and all required dependencies (including `openenv-core`). + +> [!TIP] +> You can find the install command for any environment on its HF Space page. Click the **⋮ (three dots)** menu and select **"Use this Space"** to see the install instructions. + +> [!TIP] +> You can also install the core package from PyPI with `pip install "openenv-core[core]>=0.2.1"`, but note that environment-specific dependencies may need to be installed separately. + +For development, you can clone the OpenEnv repo and install locally: + +```bash +git clone https://github.com/meta-pytorch/OpenEnv.git +cd OpenEnv/envs/echo_env +pip install -e . +``` + +> [!NOTE] +> Each environment script in TRL includes inline dependency metadata (PEP 723) so you can also run them directly with [uv](https://docs.astral.sh/uv/): +> +> ```bash +> uv run examples/scripts/openenv/echo.py +> ``` +> +> This automatically installs the required environment package in an isolated virtual environment. + +## Quick start + +The fastest way to understand the integration is a complete example. The [echo.py](https://github.com/huggingface/trl/blob/main/examples/scripts/openenv/echo.py) script trains a model with the [Echo environment](https://meta-pytorch.org/OpenEnv/environments/echo.html), which rewards completions based on their text length: + +```python +from datasets import Dataset +from echo_env import EchoEnv +from echo_env.models import EchoAction + +from trl import GRPOConfig, GRPOTrainer + +ENV_URL = "https://openenv-echo-env.hf.space" + +class EchoToolEnv: + def __init__(self): + self.env = EchoEnv(base_url=ENV_URL) + self.reward = 0.0 + + def reset(self, **kwargs) -> str | None: + self.reward = 0.0 + return None + + def echo(self, message: str) -> str: + """ + Echo the message back from the environment. + + Args: + message: The message to echo + + Returns: + The echoed message. + """ + observation = self.env.step(EchoAction(message=message)) + self.reward = observation.observation.reward + return observation.observation.echoed_message + +def reward_func(environments, **kwargs): + return [env.reward for env in environments] + +dataset = Dataset.from_dict( + {"prompt": [[{"role": "user", "content": "Try to echo 'Hello World!' in the environment."}]] * 64} +) + +trainer = GRPOTrainer( + model="Qwen/Qwen3-0.6B", + train_dataset=dataset, + reward_funcs=reward_func, + args=GRPOConfig( + chat_template_kwargs={"enable_thinking": False}, + log_completions=True, + ), + environment_factory=EchoToolEnv, +) +trainer.train() +``` + +That's it. Here's what happens under the hood: + +1. **`environment_factory=EchoToolEnv`**: The trainer creates one `EchoToolEnv` instance per generation (pass the class, not an instance). +2. **`reset()`** is called at the start of each episode to initialize state. Returns an observation string (or `None`). +3. **Tool discovery**: The trainer discovers all public methods on the environment instance (here, `echo()`) and exposes them as function-calling tools. Each method must have a proper docstring with typed arguments, which the trainer uses to build the tool schema. +4. **Multi-turn loop**: The trainer generates a completion, parses tool calls, executes `echo()`, appends the result, and generates again, until the model stops calling tools or `max_completion_length` is reached. +5. **Reward function**: Reads `env.reward` from each environment instance after the episode (before the environment is reset). + +```bash +# Run the example +python examples/scripts/openenv/echo.py + +# Customize model and environment URL +python examples/scripts/openenv/echo.py --model Qwen/Qwen3-0.6B --env-host https://openenv-echo-env.hf.space +``` + +Below is the reward curve from training: + + + +> [!NOTE] +> You can explore more ready-to-use example [scripts](example_overview#openenv-scripts) and [notebooks](example_overview#openenv-notebooks) in the Examples Overview. + +## How `environment_factory` works + +TRL's [`GRPOTrainer`] supports interactive environment training through the `environment_factory` argument. When provided, the trainer automatically handles the multi-turn tool-calling loop: it generates completions, parses tool calls, executes them against the environment, and feeds the results back to the model. All without custom rollout code. + +### Environment class requirements + +Your environment class must follow these rules: + +- **`__init__(self)`** *(optional)*: If provided, must take no arguments. Use it to initialize state or clients. If you need external configuration (e.g., a URL), capture it from the enclosing scope or module-level variables. +- **`reset(self, **kwargs)`**: Called at the start of each episode. Receives all dataset columns as keyword arguments. Return a string observation (or `None` for no initial observation). +- **Tool methods**: Any public method (not starting with `_`) other than `reset` is automatically exposed as a tool. Each tool method must have a docstring with `Args:` descriptions, since the trainer uses these to generate the tool schema for the model. + +### Tips for environment classes + +- **State for reward**: You can store any state you want on the environment instance (e.g., `self.reward`, `self.done`, etc.) and access it in your reward function via the `environments` parameter. Refer to the [Quick Start guide](#quick-start) for an example of this pattern. +- **Error handling**: If a tool method raises an exception (e.g., `ValueError("Game over.")`), the trainer catches it and feeds the error message back to the model as a tool response. This is the recommended way to signal that an action is invalid or that the episode has ended. + +```python +ENV_URL = "https://my-env.hf.space" + +class MyEnv: + def __init__(self): + self.client = MyClient(base_url=ENV_URL) # captured from enclosing scope + self.reward = 0.0 + + def reset(self, **kwargs) -> str | None: + self.reward = 0.0 + return "Initial observation for the model" + + def my_tool(self, arg1: str, arg2: int) -> str: + """ + Description of what this tool does. + + Args: + arg1: Description of arg1 + arg2: Description of arg2 + + Returns: + The result message. + """ + self.reward = 1.0 + return "Tool result" +``` + +> [!IMPORTANT] +> Tools must be **individual methods** with descriptive names and typed arguments (e.g., `guess(word: str)`, `move(direction: str)`). We do not recommend using generic methods like `step(action)`, since the model needs meaningful tool names and argument descriptions to learn tool calling. + +### Reward functions + +Reward functions receive the `environments` parameter (a list of environment instances), so you can access any state stored during the episode: + +```python +def reward_func(environments, **kwargs) -> list[float]: + return [env.reward for env in environments] +``` + +For more information on reward functions, see the [GRPO - Custom Reward Functions](grpo_trainer#custom-reward-functions). + +### Tips for reward functions + +A few things we've found helpful when working with OpenEnv environments and GRPO: + +- **Simple rewards work well.** In our experiments with Wordle and Sudoku, binary rewards (1.0 for success, 0.0 otherwise) gave cleaner training signals than shaped rewards with partial credit. GRPO compares completions within a group, so the relative ranking matters more than the absolute values. +- **Check the final state, not the path.** When possible, let the environment judge the outcome (e.g., "did the model solve the puzzle?") rather than checking if it followed a specific sequence of actions. This gives the model freedom to discover its own strategies. +- **Test your reward before training.** Run a few episodes manually (see the [Wordle example notebook](https://github.com/huggingface/trl/blob/main/examples/notebooks/openenv_wordle_grpo.ipynb)) to confirm the environment returns sensible rewards. If a capable model can't score higher than a random baseline, the reward signal may need adjustment. + +### `max_completion_length` in multi-turn episodes + +The `max_completion_length` parameter limits the **total number of tokens across the entire multi-turn conversation** (all model generations + tool results combined), not just a single generation. For environments with many turns (e.g., Sudoku with dozens of moves), you may need to increase it: + +```python +args = GRPOConfig( + max_completion_length=4096, # default is usually 256-1024, increase for long episodes + # ... +) +``` + +If episodes are being cut short (model stops mid-game), this is likely the cause. + +## Advanced example: Wordle + +Let's train a model to play [Wordle](https://www.nytimes.com/games/wordle/index.html) using the [`TextArena`](https://meta-pytorch.org/OpenEnv/environments/textarena.html) environment. This demonstrates multi-turn interaction, cumulative feedback handling, and episode termination via exceptions. + +> [!NOTE] +> You can explore the notebook version of this example in [the OpenEnv Wordle GRPO example](https://github.com/huggingface/trl/blob/main/examples/notebooks/openenv_wordle_grpo.ipynb). + +### The TextArena Environment + +[TextArena](https://huggingface.co/papers/2504.11442) is an open-source collection of competitive text-based games designed to evaluate reasoning skills in LLMs using textual games like Wordle, Snake, Tic-Tac-Toe, and more. + +![image of TextArena](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/text_arena_evals.png) + +### Why Wordle? + +Wordle is a good benchmark for environment-based RL because it requires reasoning about feedback, is purely text-based, and models from 1B parameters can improve at it. Each guess is only 8 tokens, making it lightweight to experiment with. + +> [!NOTE] How does Wordle work? +> Wordle is a word guessing game where the player has to guess a 5-letter word in 6 attempts. After each guess, the environment provides letter-by-letter feedback: +> +> ``` +> G U E S S +> X G Y X X +> ``` +> X = not in the word, G = correct position (green), Y = wrong position (yellow). Here, "U" is correct and in place, "E" is in the word but misplaced. + +### Environment class + +The `WordleEnv` class wraps the TextArena client and exposes `guess()` as the tool: + +```python +from textarena_env import TextArenaAction, TextArenaEnv + +class WordleEnv: + def __init__(self): + self.client = TextArenaEnv(base_url="https://openenv-wordle.hf.space") + + def reset(self, **kwargs) -> str | None: + result = self.client.reset() + self._last_full_feedback = result.observation.messages[0].content + self.reward = 0.0 + self.done = False + return self._last_full_feedback + + def guess(self, guess: str) -> str: + """ + Make a guess in the Wordle environment. + + Args: + guess: The guessed word, formatted as '[abcde]' + + Returns: + The feedback message from the environment. + """ + if self.done: + raise ValueError("Game over.") + result = self.client.step(TextArenaAction(message=guess)) + _full_feedback = result.observation.messages[0].content + feedback = _full_feedback[len(self._last_full_feedback):] + self._last_full_feedback = _full_feedback + if "You attempted an invalid move" in feedback: + self.reward = 0.0 + else: + self.reward = result.reward + self.done = result.done + return feedback +``` + +Key design choices: + +- **`reset()`** returns the initial game message as the first observation the model sees. +- **`guess()`** is the only tool. The model calls it each turn with a 5-letter word. +- **Cumulative feedback slicing**: TextArena returns the full game history each turn. We slice out only the new part to avoid repeating context. +- **Exception on done**: If the model tries to guess after the game ends, `guess()` raises a `ValueError`. The trainer catches this and feeds `"Game over."` back to the model as a tool response. The model learns to stop calling tools after this signal. + +### Reward function and training + +```python +from datasets import Dataset +from trl import GRPOConfig, GRPOTrainer + +def reward_func(environments, **kwargs) -> list[float]: + return [env.reward for env in environments] + +prompt = """You are an expert Wordle solver with deep knowledge of English vocabulary... +Use the tool `guess` to make a guess.""" + +dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": prompt}]] * 1000}) + +trainer = GRPOTrainer( + model="Qwen/Qwen3-1.7B", + reward_funcs=reward_func, + train_dataset=dataset, + args=GRPOConfig( + use_vllm=True, + vllm_mode="colocate", + chat_template_kwargs={"enable_thinking": False}, + max_completion_length=1024, + num_generations=4, + gradient_accumulation_steps=64, + ), + environment_factory=WordleEnv, +) +trainer.train() +``` + +The environment returns `1.0` if the model wins and `0.0` otherwise. + +### Running the example + + + + + +**Colocate mode (1 GPU, recommended)** + +```bash +python examples/scripts/openenv/wordle.py --vllm-mode colocate +``` + +This runs vLLM in the same process as training, requiring only a single GPU. + + + + + +**Server mode (2+ GPUs, scalable)** + +```bash +# Terminal 1: Start vLLM inference server +CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen3-1.7B --host 0.0.0.0 --port 8000 + +# Terminal 2: Run GRPO training with OpenEnv +CUDA_VISIBLE_DEVICES=1 python examples/scripts/openenv/wordle.py --vllm-mode server --vllm-server-url http://localhost:8000 +``` + + + + + +### Results + +The model improves its performance by reducing repetitions and increasing correct guesses. However, Qwen3-1.7B with `enable_thinking=False` is not able to consistently win the game. + + + +> [!NOTE] +> With `enable_thinking=False` (the default in these examples), small models like Qwen3-1.7B can learn to improve their guesses but should not be expected to consistently solve the game. For significantly better results, use larger models or enable thinking mode (`enable_thinking=True`), which allows the model to reason before making a guess at the cost of longer completions. + +We experimented with larger models like [`gpt-oss-20b`](https://huggingface.co/openai/gpt-oss-20b) and found that it was able to consistently win the game, though this requires significantly more compute. + +## Multi-environment training + +You can train a single model across multiple environments simultaneously. This is useful when you want a model to learn different skills in parallel. For example, playing Wordle (language reasoning) and Catch (spatial reasoning) in the same training run. + +The key idea is to create a **meta-environment class** that wraps multiple environments and routes each sample to the correct one using a dataset column. + +### How it works + +1. Add an `"env"` column (or similar) to your dataset that identifies which environment each sample belongs to. +2. In `reset(**kwargs)`, read `kwargs["env"]` to select the active environment for that episode. +3. Expose tools from all environments; the trainer discovers all public methods. +4. Use separate reward functions per environment, returning `None` for samples that don't belong to that environment. TRL handles `None` values with `nansum`/`nanmean`. + +### Example: Wordle + Catch + +The [multi_env.py](https://github.com/huggingface/trl/blob/main/examples/scripts/openenv/multi_env.py) script trains on Wordle and Catch simultaneously: + +```python +class MultiEnv: + def __init__(self): + self._wordle_client = None + self._catch_client = None + self.active = None + self.reward = 0.0 + self.done = False + + def reset(self, **kwargs) -> str | None: + self.active = kwargs.get("env", "wordle") + self.reward = 0.0 + self.done = False + + if self.active == "wordle": + if self._wordle_client is not None: + try: + self._wordle_client.close() + except Exception: + pass + self._wordle_client = TextArenaEnv(base_url=WORDLE_URL) + result = self._wordle_client.reset() + self._last_full_feedback = result.observation.messages[0].content + self.reward = 0.0 + return self._last_full_feedback + elif self.active == "catch": + if self._catch_client is not None: + try: + self._catch_client.close() + except Exception: + pass + self._catch_client = OpenSpielEnv(base_url=CATCH_URL) + result = self._catch_client.reset() + self.done = result.observation.done + return _format_catch_obs(result.observation.info_state) + + # Wordle tool + def guess(self, guess: str) -> str: + """Make a guess in the Wordle environment. ...""" + ... + + # Catch tools + def move(self, direction: str) -> str: + """Move the paddle left or right. ...""" + ... + + def stay(self) -> str: + """Do nothing and let the ball fall one step. ...""" + ... +``` + +Key patterns: + +- **Lazy client initialization**: Create clients in `reset()`, not `__init__()`, to avoid unnecessary WebSocket connections. +- **Close before reopen**: Close the previous client before creating a new one to avoid server capacity errors. +- **`kwargs` routing**: The `"env"` column from the dataset is passed to `reset()` as a keyword argument. +- **All tools are exposed simultaneously**: The model sees `guess`, `move`, and `stay` as available tools regardless of the active environment. If it calls the wrong tool (e.g., `move` during Wordle), the method raises a `ValueError` that the trainer catches gracefully. In practice, models learn to use the correct tools based on the system prompt. + +### Per-environment reward functions + +Each reward function returns `None` for samples from other environments: + +```python +def wordle_reward(environments, **kwargs) -> list[float | None]: + return [env.reward if env.active == "wordle" else None for env in environments] + +def catch_reward(environments, **kwargs) -> list[float | None]: + rewards = [] + for env in environments: + if env.active != "catch": + rewards.append(None) + elif env.done: + rewards.append(max(env.reward, 0.0)) + else: + rewards.append(0.0) + return rewards +``` + +TRL converts `None` to `nan` internally and uses `nansum`/`nanmean` for aggregation, so each sample is only scored by its relevant reward function. + +### Dataset with environment routing + +```python +n = 500 +dataset = Dataset.from_dict({ + "prompt": ( + [[{"role": "user", "content": wordle_prompt}]] * n + + [[{"role": "user", "content": catch_prompt}]] * n + ), + "env": ["wordle"] * n + ["catch"] * n, +}) +``` + +### Running the multi-environment example + +```bash +python examples/scripts/openenv/multi_env.py \ + --wordle-url https://openenv-wordle.hf.space \ + --catch-url https://openenv-openspiel-env.hf.space \ + --vllm-mode colocate \ + --gradient-accumulation-steps 4 \ + --num-generations 8 +``` + +> [!TIP] +> When training across multiple environments, monitor the per-reward-function metrics (`train/reward_func_0`, `train/reward_func_1`, etc.) rather than the combined `train/reward`. The combined metric alternates between environments and can appear noisy. + +## Running the environments + +When using `environment_factory`, the trainer connects to the environment server automatically. You just need the server to be running. There are three ways to run an OpenEnv environment server: + + + + + +**Connect to a remote Hugging Face Space** *(simplest)* + +Most example scripts default to a hosted Space (no setup needed): + +```python +env = EchoEnv(base_url="https://openenv-echo-env.hf.space") +``` + +> [!WARNING] +> For training, **duplicate the Space to your own account** to avoid concurrency issues. The trainer opens N simultaneous WebSocket connections (one per generation), and shared Spaces may not support this. See [Server concurrency](#server-concurrency) for details. + + + + + +**Docker container** *(recommended for production)* + +```bash +docker run -d -p 8001:8000 --platform linux/amd64 registry.hf.space/openenv-echo-env:latest +``` + +Then connect: + +```python +env = EchoEnv(base_url="http://0.0.0.0:8001") +``` + +We map port 8001 to 8000 to leave port 8000 available for a vLLM server. + +You can also start the container programmatically: + +```python +env = EchoEnv.from_docker_image("registry.hf.space/openenv-echo-env:latest") +``` + +> [!NOTE] +> You can find the Docker image for any Space on the Hub: open the Space page → **⋮ (three dots)** → **"Run locally."** +> +> ![open_env_launch_docker](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/open_env_launch_docker.png) + + + + + +**Local Python process** *(for development)* + +```bash +hf download openenv/echo_env --repo-type=space --local-dir=echo_env +python -m uvicorn echo_env.src.envs.echo_env.server.app:app --host 0.0.0.0 --port 8001 +``` + +Then connect: + +```python +env = EchoEnv(base_url="http://0.0.0.0:8001") +``` + +For more details, see the [OpenEnv catalog](https://meta-pytorch.org/OpenEnv/environments.html). + + + + + +## Environments catalog + +The best way to explore the current catalog of maintained environments is by visiting the official OpenEnv [catalog](https://huggingface.co/collections/openenv/environment-hub). + +To create your own environment, check out the guide on [Building Your Own Environment with OpenEnv](https://meta-pytorch.org/OpenEnv/auto_getting_started/plot_03_building_environments.html). Environments are tightly integrated with the Hub, so you can push new environments for the community to reuse. + +## Server concurrency + +When using `environment_factory`, the trainer creates N environment instances (one per generation), each opening a WebSocket connection to the server. By default, OpenEnv servers allow only 1 concurrent session, which will cause failures during training. + +To support parallel training, configure the server for concurrency: + +1. In your environment file, declare concurrent session support: +```python +SUPPORTS_CONCURRENT_SESSIONS: bool = True +``` + +2. In your server app, set the concurrency limit: +```python +app = create_app( + create_my_environment, + MyAction, + MyObservation, + max_concurrent_envs=64, # match or exceed generation_batch_size +) +``` + +> [!TIP] +> `max_concurrent_envs` should be ≥ `generation_batch_size` (which defaults to `per_device_train_batch_size × gradient_accumulation_steps`). For example, with `gradient_accumulation_steps=64` and batch size 1, you need at least 64 concurrent sessions. + +## `environment_factory` vs `rollout_func` + +[`GRPOTrainer`] supports two approaches for environment-based training: + +- **`environment_factory`** (recommended): You define an environment class with tool methods, and the trainer handles generation, tool-call parsing, and the multi-turn loop automatically. This is the approach used throughout this guide. +- **`rollout_func`**: You write the entire generation and environment interaction loop yourself. This gives full control over how completions are produced, how tools are executed, and how rewards are computed. + +Use `rollout_func` when `environment_factory` doesn't fit your use case. For example, **external agent servers** like [NeMo-Gym](nemo_gym), where an external server owns the generation loop and manages its own agent-environment interaction protocol. + +### Migrating from `rollout_func` to `environment_factory` + +If you have existing `rollout_func` code and want to migrate, here's the mapping: + +| `rollout_func` pattern | `environment_factory` equivalent | +|------------------------|----------------------------------| +| Manual generation loop | Handled automatically by the trainer | +| `generate_rollout_completions()` | Not needed, trainer generates internally | +| `env.step(Action(...))` in rollout | Wrap in a tool method on the environment class | +| Reward via `kwargs["env_reward"]` | Reward via `environments` parameter | +| `env_mask` construction | Automatic, trainer builds `tool_mask` | +| Token concatenation | Automatic, trainer manages token sequences | + +**Before** (`rollout_func`): + +```python +def rollout_func(prompts, trainer): + outputs = generate_rollout_completions(trainer, prompts) + env_rewards = [] + for out in outputs: + text = tokenizer.decode(out["completion_ids"], skip_special_tokens=True) + result = client.step(EchoAction(message=text)) + env_rewards.append(result.reward) + return { + "prompt_ids": [out["prompt_ids"] for out in outputs], + "completion_ids": [out["completion_ids"] for out in outputs], + "logprobs": [out["logprobs"] for out in outputs], + "env_reward": env_rewards, + } + +trainer = GRPOTrainer(..., rollout_func=rollout_func) +``` + +**After** (`environment_factory`): + +```python +class EchoToolEnv: + def __init__(self): + self.env = EchoEnv(base_url=url) + self.reward = 0.0 + + def reset(self, **kwargs) -> str | None: + self.reward = 0.0 + return None + + def echo(self, message: str) -> str: + """Echo the message back. + + Args: + message: The message to echo + + Returns: + The echoed message. + """ + result = self.env.step(EchoAction(message=message)) + self.reward = result.observation.reward + return result.observation.echoed_message + +def reward_func(environments, **kwargs): + return [env.reward for env in environments] + +trainer = GRPOTrainer(..., environment_factory=EchoToolEnv, reward_funcs=reward_func) +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/orpo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/orpo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..555f0858316a3a2ff87b111e1100f3a69993e7f4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/orpo_trainer.md @@ -0,0 +1,131 @@ +# ORPO Trainer + +[![model badge](https://img.shields.io/badge/All_models-ORPO-blue)](https://huggingface.co/models?other=orpo,trl) [![model badge](https://img.shields.io/badge/smol_course-Chapter_2-yellow)](https://github.com/huggingface/smol-course/tree/main/2_preference_alignment) + +## Overview + +Odds Ratio Preference Optimization (ORPO) was introduced in [ORPO: Monolithic Preference Optimization without Reference Model](https://huggingface.co/papers/2403.07691) by [Jiwoo Hong](https://huggingface.co/JW17), [Noah Lee](https://huggingface.co/nlee-208), and [James Thorne](https://huggingface.co/j6mes). + +The abstract from the paper is the following: + +> While recent preference alignment algorithms for language models have demonstrated promising results, supervised fine-tuning (SFT) remains imperative for achieving successful convergence. In this paper, we study the crucial role of SFT within the context of preference alignment, emphasizing that a minor penalty for the disfavored generation style is sufficient for preference-aligned SFT. Building on this foundation, we introduce a straightforward and innovative reference model-free monolithic odds ratio preference optimization algorithm, ORPO, eliminating the necessity for an additional preference alignment phase. We demonstrate, both empirically and theoretically, that the odds ratio is a sensible choice for contrasting favored and disfavored styles during SFT across the diverse sizes from 125M to 7B. Specifically, fine-tuning Phi-2 (2.7B), Llama-2 (7B), and Mistral (7B) with ORPO on the UltraFeedback alone surpasses the performance of state-of-the-art language models with more than 7B and 13B parameters: achieving up to 12.20% on AlpacaEval_{2.0} (Figure 1), 66.19% on IFEval (instruction-level loose, Table 6), and 7.32 in MT-Bench (Figure 12). We release code and model checkpoints for Mistral-ORPO-alpha (7B) and Mistral-ORPO-beta (7B). + +It studies the crucial role of SFT within the context of preference alignment. Using preference data the method posits that a minor penalty for the disfavored generation together with a strong adaption signal to the chosen response via a simple log odds ratio term appended to the NLL loss is sufficient for preference-aligned SFT. + +Thus ORPO is a reference model-free preference optimization algorithm eliminating the necessity for an additional preference alignment phase thus saving compute and memory. + +The official code can be found in [xfactlab/orpo](https://github.com/xfactlab/orpo). + +This post-training method was contributed by [Kashif Rasul](https://huggingface.co/kashif), [Lewis Tunstall](https://huggingface.co/lewtun) and [Alvaro Bartolome](https://huggingface.co/alvarobartt). + +## Quick start + +This example demonstrates how to train a model using the ORPO method. We use the [Qwen 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) as the base model. We use the preference data from the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback). You can view the data in the dataset here: + + + +Below is the script to train the model: + +```python +# train_orpo.py +from datasets import load_dataset +from trl.experimental.orpo import ORPOConfig, ORPOTrainer +from transformers import AutoModelForCausalLM, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +train_dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train") + +training_args = ORPOConfig(output_dir="Qwen2-0.5B-ORPO") +trainer = ORPOTrainer(model=model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_orpo.py +``` + +Distributed across 8 GPUs, the training takes approximately 30 minutes. You can verify the training progress by checking the reward graph. An increasing trend in the reward margin indicates that the model is improving and generating better responses over time. + +![orpo qwen2 reward margin](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/orpo-qwen2-reward-margin.png) + +To see how the [trained model](https://huggingface.co/trl-lib/Qwen2-0.5B-ORPO) performs, you can use the [Transformers Chat CLI](https://huggingface.co/docs/transformers/quicktour#chat-with-text-generation-models). + +
$ transformers chat trl-lib/Qwen2-0.5B-ORPO
+<quentin_gallouedec>:
+What is the best programming language?
+
+<trl-lib/Qwen2-0.5B-ORPO>:
+It's challenging to determine the best programming language as no one language is perfect, as the complexity of a task and the type of project are significant factors. Some popular languages include Java, Python, JavaScript, and
+C++. If you have specific needs or requirements for a specific project, it's important to choose the language that best suits those needs.
+
+Here are some other factors to consider when choosing a programming language for a project:
+
+ • Language proficiency: A good programming language is more likely to be easy to understand and use, and will allow developers to collaborate on projects more efficiently.
+ • Ease of use: There are tools and libraries available to make programming more accessible, so developers should choose a language that can help them get started easier.
+ • Code readability: A clear and concise codebase should be easy to read and understand, especially when working with large projects.
+ • Tool and framework support: There are numerous libraries available for Python, Java, and JavaScript, along with tools like IDEs and static code analysis tools.
+ • Accessibility: Some languages and tools have features that make them more accessible to developers with disabilities, such as support for screen readers.
+ • Version control: As your projects grow and complexity increases, version control tools can be beneficial for tracking changes.
+
+
+ +## Expected dataset type + +ORPO requires a [preference dataset](dataset_formats#preference). The [`experimental.orpo.ORPOTrainer`] supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset format. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +Although the [`experimental.orpo.ORPOTrainer`] supports both explicit and implicit prompts, we recommend using explicit prompts. If provided with an implicit prompt dataset, the trainer will automatically extract the prompt from the `"chosen"` and `"rejected"` columns. For more information, refer to the [preference style](dataset_formats#preference) section. + +## Example script + +We provide an example script to train a model using the ORPO method. The script is available in [`examples/scripts/orpo.py`](https://github.com/huggingface/trl/blob/main/examples/scripts/orpo.py) + +To test the ORPO script with the [Qwen2 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) on the [UltraFeedback dataset](https://huggingface.co/datasets/trl-lib/ultrafeedback_binarized), run the following command: + +```bash +accelerate launch examples/scripts/orpo.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --num_train_epochs 1 \ + --output_dir Qwen2-0.5B-ORPO +``` + +## Usage tips + +### For Mixture of Experts Models: Enabling the auxiliary loss + +MOEs are the most efficient if the load is about equally distributed between experts. +To ensure that we train MOEs similarly during preference-tuning, it is beneficial to add the auxiliary loss from the load balancer to the final loss. + +This option is enabled by setting `output_router_logits=True` in the model config (e.g. [`~transformers.MixtralConfig`]). +To scale how much the auxiliary loss contributes to the total loss, use the hyperparameter `router_aux_loss_coef=...` (default: `0.001`) in the model config. + +## Logged metrics + +While training and evaluating, we record the following reward metrics: + +- `rewards/chosen`: the mean log probabilities of the policy model for the chosen responses scaled by beta +- `rewards/rejected`: the mean log probabilities of the policy model for the rejected responses scaled by beta +- `rewards/accuracies`: mean of how often the chosen rewards are > than the corresponding rejected rewards +- `rewards/margins`: the mean difference between the chosen and corresponding rejected rewards +- `log_odds_chosen`: the mean log odds ratio of the chosen responses over the rejected responses +- `log_odds_ratio`: the mean of the `log(sigmoid(log_odds_chosen))` +- `nll_loss`: the mean negative log likelihood loss from the SFT part of the loss over chosen responses + +## ORPOTrainer + +[[autodoc]] experimental.orpo.ORPOTrainer + - train + - save_model + - push_to_hub + +## ORPOConfig + +[[autodoc]] experimental.orpo.ORPOConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/paper_index.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/paper_index.md new file mode 100644 index 0000000000000000000000000000000000000000..3fdccefff30b6ff5078d3e6c38a459a2041fcfa2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/paper_index.md @@ -0,0 +1,1825 @@ +# Paper Index + + + +## Group Relative Policy Optimization + +Papers relating to the [`GRPOTrainer`]. + +### DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models + +**📜 Paper**: https://huggingface.co/papers/2402.03300 + +Introduces Group Relative Policy Optimization (GRPO) and shows strong math-reasoning gains from math-centric pretraining plus group-relative PPO-style optimization. Used in TRL via [`GRPOTrainer`]. + +```python +from trl import GRPOConfig, GRPOTrainer + +# The paper doesn't specify its hyperparameters, so here we provide hyperparameters from "DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning" instead. +training_args = GRPOConfig( + loss_type="grpo", + beta=0.001, # "the KL coefficient to 0.001" + epsilon=10.0, # "the GRPO clip ratio ϵ to 10" + num_generations=16, # "For each question, we sample 16 outputs..." + max_completion_length=32_768, # "...with a maximum length of 32,768" + steps_per_generation=16, # "To accelerate training, each rollout generates 8,192 outputs, which are randomly split into 16 minibatches" + # "resulting in a training batch size of 512". One way to achieve this setting with 1 device is per_device_train_batch_size=4, gradient_accumulation_steps=128 + per_device_train_batch_size=4, + gradient_accumulation_steps=128, +) +trainer = GRPOTrainer( + ..., + args=training_args, +) +``` + +### DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning + +**📜 Paper**: https://huggingface.co/papers/2501.12948 + +DeepSeek-R1 achieves reasoning performance comparable to OpenAI-o1 through a multi-stage pipeline that transitions from pure reinforcement learning (RL) to a refined, human-aligned model. Unlike its predecessor, DeepSeek-R1-Zero, which used pure RL on a base model, R1 follows a structured four-stage evolution: +1. Cold Start: The base model is fine-tuned on a small set of high-quality, long Chain-of-Thought (CoT) data to provide a stable starting point. +2. Reasoning-Oriented RL: Large-scale RL is applied to enhance performance in math, coding, and logic, using rule-based rewards and a language consistency reward to reduce language mixing. +3. Rejection Sampling & SFT: The RL checkpoint generates 600k reasoning samples via rejection sampling, which are combined with 200k non-reasoning (general) samples to create a new dataset for a second round of Supervised Fine-Tuning. +4. RL for all Scenarios: A final RL stage aligns the model with human preferences (helpfulness and harmlessness) across all domains while maintaining reasoning strength. + +Distillation: Empowering Small Models + +A key contribution of the paper is demonstrating that reasoning patterns can be distilled from a large model (DeepSeek-R1) into smaller dense models (e.g., Qwen and Llama series). Distillation was found to be more effective for small models than training them with pure RL from scratch. + + +You can use the GRPOTrainer to replicate the reasoning-heavy stages of this pipeline. +```python +from trl import GRPOConfig, GRPOTrainer + +# Example configuration for a reasoning-oriented GRPO stage +# Based on the Open-R1 recipe for Qwen-7B +training_args = GRPOConfig( + learning_rate=4.0e-5, + max_prompt_length=4096, + max_completion_length=32768, # Support for long Chain-of-Thought + num_generations=16, # Sample 16 outputs per prompt for group relative advantage + beta=0.001, # KL coefficient + use_vllm=True, # Use vLLM backend for accelerated rollout generation +) + +trainer = GRPOTrainer( + model=model, + args=training_args, + train_dataset=dataset, + reward_funcs=[accuracy_reward, format_reward], # R1-Zero used rule-based rewards +) + +trainer.train() +``` + + +### Group Sequence Policy Optimization + +**📜 Paper**: https://huggingface.co/papers/2507.18071 + +GSPO is a GRPO variant that computes importance sampling weights at the sequence level instead of per-token. To reproduce the paper's setting, use this configuration: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + importance_sampling_level="sequence", + loss_type="grpo", + beta=0.0, # GSPO set KL regularization to zero: https://github.com/volcengine/verl/pull/2775#issuecomment-3131807306 + epsilon=3e-4, # GSPO paper (v2), section 5.1 + epsilon_high=4e-4, # GSPO paper (v2), section 5.1 + gradient_accumulation_steps=1, + steps_per_generation=4, # partition rollout batch into 4 mini-batches. GSPO paper (v2), section 5.1. Must be 4 times gradient_accumulation_steps +) +``` + +Note that this method only has an effect when training goes slightly off-policy—for example, when `steps_per_generation > gradient_accumulation_steps` or `num_iterations > 1`. Otherwise, it is effectively equivalent to no modification. + +TRL also provide an experimental implementation of GSPO-token, see [Experimental - GSPO-Token](experimental#gspo-token). + +#### Policy ratio: GRPO vs. GSPO + +In GSPO, the policy ratio is defined at the sequence-level. In other words, it is the ratio between the probability of the current policy generating a sequence over the old policy generating that same sequence. + +The sequence likelihood is defined as: + +$$ +\pi_\theta (o_i | q) = \prod_{t=1}^{|o_i|} \pi_\theta (o_{i,t} | q, o_{i, < t} ), +$$ + +where \\( \pi_\theta \\) is the policy \\( \pi \\) with parameters \\(\theta\\), \\( o_i \\) is the \\( i \\)-th output sequence \\( o \\) and \\(o_{i,t}\\) is the \\( t \\)-th token in this sequence, \\( q \\) is the input query. The sequence likelihood ratio \\( s_i (\theta) \\) is defined as: + +$$ +s_i (\theta) = \left(\frac{\pi_\theta (o_i | q)}{\pi_{\theta_{old}} (o_i | q)} \right)^{\frac{1}{|o_i|}} +$$ + +The exponent \\( \frac{1}{|o_i|} \\) represents a sequence-length normalization, minimizing the influence of sequence length in sequence likelihood. In other terms, it computes the geometric mean of token probabilities, ensuring a fair comparison across sequences of varying lengths. + +While GSPO defines the policy ratio at the sequence level, GRPO operates at the token level. Specifically, GRPO computes an importance ratio for each token in the sequence: + +$$ +w_{i,t}(\theta) = \frac{\pi_\theta (o_{i,t} | q, o_{i,< t})}{\pi_{\theta_{\text{old}}} (o_{i,t} | q, o_{i,< t})} +$$ + +This token-level ratio is then combined with a shared advantage \\( \hat{A}_i \\), and the GRPO objective clips and optimizes each token independently across the sequence. + +### DAPO: An Open-Source LLM Reinforcement Learning System at Scale + +**📜 Paper**: https://huggingface.co/papers/2503.14476 + +The DAPO algorithm includes 5 key components: + +- Overlong Filtering +- Clip-Higher +- Soft Overlong Punishment +- Token-level Loss +- Dynamic Sampling (⚠️ Not supported in TRL) + +To reproduce the paper's setting, use this configuration: + +```python +from trl import GRPOConfig, GRPOTrainer + +training_args = GRPOConfig( + # Overlong Filtering + mask_truncated_completions=True, + # Token-level Loss + loss_type="dapo", + # Clip-Higher + epsilon_high=0.28, # DAPO paper: section 4.1 + epsilon=0.2, # DAPO paper: section 4.1 + # Other parameters used + per_device_train_batch_size=512, # mini-batch size for training in the paper, DAPO paper: section 4.1 + num_generations=16, # number of sample responses in the paper, DAPO paper: section 4.1 + max_completion_length=20480, # maximum number of tokens for generation in the paper, DAPO paper: section 4.1 + beta=0.0, # section 2.3, DAPO paper + +) +# Soft Overlong Punishment +sop_reward = get_soft_overlong_punishment(max_completion_len=20480, soft_punish_cache=4096) # DAPO paper: section 4.1 +trainer = GRPOTrainer( + ..., + args=training_args, + reward_funcs=[..., sop_reward], +) +``` + +### INTELLECT-2: A Reasoning Model Trained Through Globally Decentralized Reinforcement Learning + +**📜 Paper**: https://huggingface.co/papers/2505.07291 + +INTELLECT-2 is the first globally distributed reinforcement learning training run of a 32 billion parameter language model using fully asynchronous RL across a dynamic, heterogeneous swarm of permissionless compute contributors. The authors propose modifications to the standard GRPO training recipe, including two-sided GRPO clipping for increased training stability. To reproduce the paper's setting, use this configuration: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + delta=4, # δ in section 4.1 of the paper + epsilon=0.2, # ε in section 4.1 of the paper + beta=0.001, # KL divergence coefficient in section 4.1 of the paper + num_generations=16, # responses per prompt in section 4.1 of the paper + learning_rate=3e-7, # section 4.1 of the paper +) +``` + +### Beyond the 80/20 Rule: High-Entropy Minority Tokens Drive Effective Reinforcement Learning for LLM Reasoning + +**📜 Paper**: https://huggingface.co/papers/2506.01939 + +A minority of tokens with high entropy act as reasoning "forks" in the CoT path, driving exploration and performance gains for RLVR, while low-entropy majority tokens contribute little or even impede learning. RLVR mainly adjusts high-entropy tokens, largely preserving the base model’s overall entropy patterns. Thus landing on the 80/20 rule, training on only 20% of the tokens with the highest entropy is comparable or supasses full-gradient updates for Qwen3 models. + +The paper's main results use vanilla DAPO (⚠️ Dynamic Sampling is not supported in TRL). To replicate the main results, use the following configuration: + +```python +from trl import GRPOConfig, GRPOTrainer +from trl.rewards import get_soft_overlong_punishment + +training_args = GRPOConfig( + # --- vanilla DAPO parameters (80/20 rule: section 5.2) --- # + # Overlong Filtering + mask_truncated_completions=True, + # Token-level Loss + loss_type="dapo", + # Clip-Higher + epsilon_high=0.28, # DAPO paper: section 4.1 + epsilon=0.2, # DAPO paper: section 4.1 + # Other parameters used + per_device_train_batch_size=512, # mini-batch size for training in the paper, DAPO paper: section 4.1 + num_generations=16, # number of sample responses in the paper, DAPO paper: section 4.1 + max_completion_length=20480, # maximum number of tokens for generation in the paper, DAPO paper: section 4.1 + beta=0.0, # section 2.3, DAPO paper + # --- Gradients on the highest entropy tokens --- # + top_entropy_quantile=0.2 +) +# Soft Overlong Punishment +sop_reward = get_soft_overlong_punishment(max_completion_len=20480, soft_punish_cache=4096) # DAPO paper: section 4.1 +trainer = GRPOTrainer( + ..., + args=training_args, + reward_funcs=[..., sop_reward], +) +``` + +### Dr. GRPO: Understanding R1-Zero-Like Training: A Critical Perspective + +**📜 Paper**: https://huggingface.co/papers/2503.20783 + +A study of R1-Zero training identifies pretraining effects on RL performance and proffers Dr. GRPO to enhance token efficiency, achieving superior accuracy on AIME 2024. To reproduce the paper's setting, use this configuration: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + loss_type="dr_grpo", + per_device_train_batch_size=1, # train_batch_size_per_device in the Training section of the repository + num_generations=8, # num_samples in the Training section of the repository + max_completion_length=3000, # generate_max_length in the Training section of the repository + beta=0.0, # β in the Training section of the repository +) +``` + +### Part I: Tricks or Traps? A Deep Dive into RL for LLM Reasoning (Lite PPO) + +**📜 Paper**: https://huggingface.co/papers/2508.08221 + +The authors of this paper find that the combination of: + +1. scaling rewards by the standard deviation computed over the entire batch and +2. aggregating loss over the total number of tokens + +can unlock the learning capability of critic-free policies using vanilla PPO loss. Their results demonstrate that this simple combination consistently improves performance, surpassing strategies like GRPO and [DAPO](https://huggingface.co/papers/2503.14476). + +TRL supports using these learnings to train a GRPO model by: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ... + scale_rewards="batch", + loss_type="dapo", + # Other parameters used + beta=0.0, # = init_kl_coef in the paper + top_p=0.99, + top_k=100, + temperature=0.99, + num_generations=8, # = num_return_sequences in the paper + num_iterations=1, # = ppo_epochs in the paper + per_device_train_batch_size=4, + gradient_accumulation_steps=32, + steps_per_generation=8, # (rollout_batch_size*num_return_sequences) / (per_device_train_batch_size*gradient_accumulation_steps) +) +``` + +Note that when using gradient accumulation, the loss is aggregated over the total number of tokens in the batch, but not over the accumulated batch. For more details, see the [GRPO Trainer - Loss types](grpo_trainer#loss_types). + +### Truncated Importance Sampling + +**📰 Blog**: https://fengyao.notion.site/off-policy-rl + +Online policy learning methods commonly use an optimized inference framework for rollout generation (e.g vLLM) that is separate from the training backend. This introduces a rollout-training mismatch, exemplified in the following PPO objective: + +$$ +\small{ +\mathbb{E}_{a\sim\textcolor{red}{\pi_{\text{inference}}}(\theta_{\mathrm{old}})} +\Bigl[ +\min\Bigl( +\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta)}{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})}\,\hat A, +\;\mathrm{clip}\bigl(\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta)}{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})},\,1-\epsilon,\,1+\epsilon\bigr)\,\hat A +\Bigr) +\Bigr] +} +$$ + +Despite \\( \textcolor{red}{\pi_{\text{inference}}} \\) and \\( \textcolor{blue}{\pi_{\text{training}}} \\) sharing the same model parameters \\( \theta \\), they can produce significantly different token probabilities. This unexpected behavior implicitly breaks the on-policy assumption, and silently turns training off-policy. + +Truncated Importance Sampling (TIS) addresses this issue by adapting the model update via importance-sampling correction. The gradient computation of the aforementioned PPO objective becomes + +$$ +\small{ +\mathbb{E}_{a\sim\textcolor{red}{\pi_{\text{inference}}}(\theta_{\mathrm{old}})} +\Bigl[ +\underbrace{\min(\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})}{\textcolor{red}{\pi_{\text{inference}}}(a, \theta_{\mathrm{old}})}, C)}_{\text{truncated importance ratio}} \cdot +\nabla_\theta +\min\Bigl( +\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta)}{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})}\,\hat A, +\;\mathrm{clip}\bigl(\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta)}{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})},\,1-\epsilon,\,1+\epsilon\bigr)\,\hat A +\Bigr) +\Bigr] +} +$$ + +where \\( C \\) is a hyper-parameter. TIS is implemented in GRPO, and is enabled by selecting a `vllm_importance_sampling_mode` variant that includes the term `truncate`, such as `"sequence_truncate"` or `"token_truncate"`. + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ... + use_vllm=True, + vllm_importance_sampling_correction=True, # default True + vllm_importance_sampling_mode="sequence_truncate", # or "token_truncate" + vllm_importance_sampling_cap=2.0, # hyper-parameter C +) +``` + +### Masked Importance Sampling + +**📰 Blog**: https://ringtech.notion.site/icepop + +**📰 Blog**: https://yingru.notion.site/When-Speed-Kills-Stability-Demystifying-RL-Collapse-from-the-Training-Inference-Mismatch-271211a558b7808d8b12d403fd15edda + +Masked Importance Sampling (MIS) addresses the same issue as [Truncated Importance Sampling](#truncated-importance-sampling) but replaces clipping with masking. MIS takes a more decisive stance by discarding updates whose discrepancy exceeds a threshold \\( C \\). We apply upper-side masking, so any ratio above \\( C \\) is removed from the update. + + +$$ +\small{ +\mathbb{E}_{a\sim\textcolor{red}{\pi_{\text{inference}}}(\theta_{\mathrm{old}})} +\Bigl[ +\underbrace{\mathbf{1}\left[ +\frac{\pi_{\text{training}}(a, \theta_{\mathrm{old}})} +{\pi_{\text{inference}}(a, \theta_{\mathrm{old}})} +\le C +\right] +\cdot +\frac{\pi_{\text{training}}(a, \theta_{\mathrm{old}})} +{\pi_{\text{inference}}(a, \theta_{\mathrm{old}})}}_{\text{masked importance ratio}} \cdot +\nabla_\theta +\min\Bigl( +\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta)}{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})}\,\hat A, +\;\mathrm{clip}\bigl(\frac{\textcolor{blue}{\pi_{\text{training}}}(a, \theta)}{\textcolor{blue}{\pi_{\text{training}}}(a, \theta_{\mathrm{old}})},\,1-\epsilon,\,1+\epsilon\bigr)\,\hat A +\Bigr) +\Bigr] +} +$$ + +MIS is implemented for GRPO, and is enabled by selecting a `vllm_importance_sampling_mode` variant that includes the term `"mask"`, such as `"sequence_mask"` or `"token_mask"`. + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ... + use_vllm=True, + vllm_importance_sampling_correction=True, # default True + vllm_importance_sampling_mode="sequence_mask", # or "token_mask" + vllm_importance_sampling_cap=2.0, # hyper-parameter C +) +``` + +### Sequence-level Importance Sampling + +**📰 Blog**: https://yingru.notion.site/When-Speed-Kills-Stability-Demystifying-RL-Collapse-from-the-Training-Inference-Mismatch-271211a558b7808d8b12d403fd15edda + +The theoretically principled way to correct for the training-inference distribution shift is importance sampling, as introduced in the two papers above [Truncated Importance Sampling](#truncated-importance-sampling) and [Masked Importance Sampling](#masked-importance-sampling). However, the choice of formulation is crucial for keeping the gradient unbiased and ensuring stable training. + +This work shows that sequence-level importance sampling is the sound approach for addressing the training–inference mismatch. Although token-level importance sampling achieves lower variance than a sequence-level ratio, it introduces bias and is therefore argued to be unsuitable for autoregressive models. The token-level gradient estimator is + +$$ +\mathbb{E}_{x\sim\mathcal{D},\, y\sim \pi^{\text{inference}}_\theta(\cdot|x)} +\Bigg[ + R(x,y)\,\cdot\, + \sum_{t=0}^{|y|-1} + \frac{\pi^{\text{training}}_\theta(y_t\,|\,x, y_{ 0`: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ..., + beta=0.001, # the paper doesn't specify the value used, so we use the value from "DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning" + use_bias_correction_kl=True, +) +``` + +- The **Off-Policy Masking**, which stabilizes training by ignoring sequences where the policy performs poorly (negative advantage) **and** has drifted significantly from the old policy (high KL divergence). + +The off-policy binary mask \\(\textcolor{red}{M_{i,t}}\\) is defined as: + +$$ +\textcolor{red}{M_{i,t}} = \begin{cases} +0 & \text{if } \hat{A}_{i,t} < 0 \quad \text{and} \quad \frac{1}{|o_i|} \sum_{t=1}^{|o_i|} \log \frac{\pi_{\theta_{\text{old}}}(o_{i,t} \mid q, o_{i, \textcolor{blue}{\delta} \\ +1 & \text{otherwise} +\end{cases} +$$ + +This mask is then applied to the GRPO loss as follows: + +$$ +\mathcal{L}_{\text{GRPO}}(\theta) = -\frac{1}{G} \sum_{i=1}^G \frac{1}{|o_i|} \sum_{t=1}^{|o_i|} \left[ \min \left( \frac{\pi_\theta(o_{i,t} \mid q, o_{i,< t})}{\pi_{\theta_{\text{old}}}(o_{i,t} \mid q, o_{i,< t})} \hat{A}_{i,t}, \, \text{clip}\left( \frac{\pi_\theta(o_{i,t} \mid q, o_{i,< t})}{\pi_{\theta_{\text{old}}}(o_{i,t} \mid q, o_{i,< t})}, 1 - \epsilon, 1 + \epsilon \right) \hat{A}_{i,t} \right) \textcolor{red}{M_{i,t}} - \beta \mathbb{D}_{\text{KL}}\left[\pi_\theta \| \pi_{\text{ref}}\right] \right] +$$ + +To enable this feature, use the `off_policy_mask_threshold` (corresponding to \\( \textcolor{blue}{\delta} \\)) in the [`GRPOConfig`]: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ..., + off_policy_mask_threshold=0.5, +) +``` + +While the paper doesn't specify a \\( \textcolor{blue}{\delta} \\) value used, a good starting point could be \\( \textcolor{blue}{\delta} = 0.5 \\). If training seems too conservative or too many sequences are masked, you can increase the value. +For reference, \\( \textcolor{blue}{\delta} = 1.0 \\) corresponds to an average log-ratio divergence of 1 nat per token, i.e. on sequences where this threshold is exceeded, the old policy was on average \\( e^1 \approx 2.7 \\) times more likely to generate these tokens than the current policy. + +### GDPO: Group reward-Decoupled Normalization Policy Optimization for Multi-reward RL Optimization + +**📜 Paper**: https://huggingface.co/papers/2601.05242 + +GDPO is a reinforcement learning optimization method designed for multi-reward training. While existing approaches commonly apply Group Relative Policy Optimization (GRPO) in multi-reward settings, the authors show that this leads to reward advantages collapse, reducing training signal resolution and causing unstable or failed convergence. GDPO resolves this issue by decoupling reward normalization across individual rewards, preserving their relative differences and enabling more faithful preference optimization. To enable GDPO for multi-reward RL training, simply set: + +For a group of \\( N \\) rewards and \\( G \\) samples per group, GDPO normalizes each reward independently: + +$$ +A_n^{(i,j)} = \frac{r_n^{(i,j)} - \text{mean}\{r_n^{(i,1)}, \ldots, r_n^{(i,G)}\}}{\text{std}\{r_n^{(i,1)}, \ldots, r_n^{(i,G)}\} + \epsilon} +$$ + +The normalized group advantage is then aggregated across rewards: + +$$ +A^{(i,j)} = \sum_{n=1}^{N} w_n A_n^{(i,j)} +$$ + +The final per-batch normalization produces: + +$$ +\hat{A}^{(i,j)} = \frac{A^{(i,j)} - \text{mean}_{i',j'}\{A^{(i',j')}\}}{\text{std}_{i',j'}\{A^{(i',j')}\} + \epsilon} +$$ + +Here, \\( \text{mean}_{i',j'}\{A^{(i',j')}\} \\) and \\( \text{std}_{i',j'}\{A^{(i',j')}\} \\) denote statistics over all groups in the batch. + +```python +from trl import GRPOConfig + + +training_args = GRPOConfig( + ..., + multi_objective_aggregation="normalize_then_sum", +) +``` + +Note that this method only has an effect when training involve more than one reward function. + +The authors provide a easy-to-use, slurm-free training example that enable the community to quickly validate GDPO’s effectiveness over GRPO, see [Experiment-"Aha" moment](https://github.com/NVlabs/GDPO/tree/main/trl-GDPO). + +### Length-Unbiased Sequence Policy Optimization: Revealing and Controlling Response Length Variation in RLVR + +**📜 Paper**: https://huggingface.co/papers/2602.05261 + +Length-Unbiased Sequence Policy Optimization (LUSPO) modifies GSPO by scaling each sequence's loss by its length. This corrects GSPO's gradient bias that penalizes longer responses. To reproduce the paper's setting, use this configuration: + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + loss_type="luspo", + importance_sampling_level="sequence", + epsilon=2e-3, # section 5.1 of the paper + epsilon_high=2.5e-3, # section 5.1 of the paper +) +``` + +### VESPO: Variational Sequence-Level Soft Policy Optimization for Stable Off-Policy LLM Training + +**📜 Paper**: https://huggingface.co/papers/2602.10693 + +VESPO addresses training instability in off-policy RL caused by policy staleness, asynchronous updates, and train-inference mismatches. Rather than relying on heuristic token-level clipping (GRPO) or sequence-length normalization (GSPO), VESPO derives a principled reshaping kernel from a variational framework. In practice, this yields a smooth, asymmetric Gamma weighting function that gracefully suppresses extreme sequence-level importance weights without introducing length bias. + +$$ +\mathcal{L}_{\text{VESPO}}(\theta) = - \mathbb{E}_{\tau \sim \mu} \left[ \underbrace{W(\tau)^{k} \cdot \exp\left(\lambda +(1 - W(\tau))\right)}_{\phi(W) \text{ detached }} \cdot \mathcal{A}(\tau) \cdot \log \pi_\theta(\tau) \right] +$$ + +with \\( W(\tau) = \frac{\pi_\theta(\tau)}{\mu(\tau)} \\) the sequence level importance ratio, and \\( \phi(W) \\) is detached from the computation graph to serve as a gradient scaling coefficient. + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + loss_type="vespo", + use_vllm=True, # or False if not using any token-level `vllm_importance_sampling_correction` methods + vllm_importance_sampling_mode="token_truncate", # default correction mode for VESPO, `token_mask` also supported + vespo_k_pos=2.0, # power exponent (c1 in paper Section 3.4) for positive advantages + vespo_lambda_pos=3.0, # decay factor (c2 in paper Section 3.4) for positive advantages + vespo_k_neg=3.0, # power exponent (c1 in paper Section 3.4) for negative advantages + vespo_lambda_neg=2.0, # decay factor (c2 in paper Section 3.4) for negative advantages +) +``` + + +### Rethinking the Trust Region in LLM Reinforcement Learning + +**📜 Paper**: https://huggingface.co/papers/2602.04879 + +DPPO replaces PPO/GRPO's heuristic ratio-clipping with a principled trust region based on direct policy divergence estimates. PPO-style clipping masks tokens based on the probability ratio π/μ, which over-penalizes low-probability tokens and under-penalizes high-probability ones. DPPO instead masks based on direct approximations of policy divergence (TV or KL), ensuring updates stay within a theoretically grounded trust region. Four divergence approximations are supported: `binary_tv`, `binary_kl`, `topk_tv`, and `topk_kl`. + +```python +from trl.experimental.dppo import DPPOConfig, DPPOTrainer + +training_args = DPPOConfig( + divergence_type="binary_tv", # divergence approximation + divergence_topk=20, # K for top-K divergence modes (Section 7 / Appendix G.2 of the paper) + epsilon=0.15, # δ_low threshold (Appendix F of the paper) + epsilon_high=0.15, # δ_high threshold (Appendix F of the paper) + clip_ratio_c=20.0, # IS ratio upper bound C (Section 5.4 of the paper) + beta=0.0, # KL regularization coefficient + use_vllm=True, +) + +trainer = DPPOTrainer( + model="your-model", + reward_funcs=[...], + args=training_args, + train_dataset=dataset, +) +trainer.train() +``` + +The official code [sail-sg/Stable-RL](https://github.com/sail-sg/Stable-RL) + +## Direct Policy Optimization + +Papers relating to the [`DPOTrainer`] + +### Direct Preference Optimization: Your Language Model is Secretly a Reward Model + +**📜 Paper**: https://huggingface.co/papers/2305.18290 + +Direct Preference Optimization (DPO) fine-tunes language models more efficiently and with better performance compared to reinforcement learning from human feedback (RLHF), by directly optimizing policy training based on human preferences. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="sigmoid", # losses in Appendix B of the paper + per_device_train_batch_size=64, # batch size in Appendix B of the paper + learning_rate=1e-6, # learning rate in Appendix B of the paper + beta=0.1, # β in Appendix B of the paper +) +``` + +### SLiC-HF: Sequence Likelihood Calibration with Human Feedback + +**📜 Paper**: https://huggingface.co/papers/2305.10425 + +Sequence Likelihood Calibration (SLiC) is shown to be an effective and simpler alternative to Reinforcement Learning from Human Feedback (RLHF) for learning from human preferences in language models. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="hinge", # Section 2 of the paper + per_device_train_batch_size=512, # batch size in Section 3.2 of the paper + learning_rate=1e-4, # learning rate in Section 3.2 of the paper +) +``` + +These parameters only appear in the [published version](https://openreview.net/pdf?id=0qSOodKmJaN) + +### Statistical Rejection Sampling Improves Preference Optimization + +**📜 Paper**: https://huggingface.co/papers/2309.06657 + +Proposes **RSO**, selecting stronger preference pairs via statistical rejection sampling to boost offline preference optimization; complements DPO/SLiC. They also introduce a new loss defined as: + +$$ +\mathcal{L}_{\text{hinge-norm}}(\pi_\theta) += \mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}} +\left[ +\max\left(0,\; 1 - \left[\gamma \log \frac{\pi_\theta(y_w \mid x)}{\pi_\text{ref}(y_w \mid x)} - \gamma \log \frac{\pi_\theta(y_l \mid x)}{\pi_\text{ref}(y_l \mid x)}\right]\right) +\right] +$$ + +To train with RSO-filtered data and the hinge-norm loss, you can use the following code: + +```python +from trl import DPOConfig, DPOTrainer + +dataset = ... + +def rso_accept(example): # replace with your actual filter/score logic + return example["rso_keep"] + +train_dataset = train_dataset.filter(rso_accept) + +training_args = DPOConfig( + loss_type="hinge", + beta=0.05, # correspond to γ in the paper +) + +trainer = DPOTrainer( + ..., + args=training_args, + train_dataset=train_dataset, +) +trainer.train() +``` + +### Beyond Reverse KL: Generalizing Direct Preference Optimization with Diverse Divergence Constraints + +**📜 Paper**: https://huggingface.co/papers/2309.16240 + +Proposes \(( f \\)-DPO, extending DPO by replacing the usual reverse-KL regularizer with a general \(( f \\)-divergence, letting you trade off mode-seeking vs mass-covering behavior (e.g. forward KL, JS, \(( \alpha \\)-divergences). The only change is replacing the DPO log-ratio margin with an **f′ score**: + +$$ +\mathcal{L}_{f\text{-DPO}}(\pi_\theta) += \mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}} +\left[ +-\log \sigma\left( +\beta \textcolor{red}{f'}\textcolor{red}{\Big(}\frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)}\textcolor{red}{\Big)} +- +\beta \textcolor{red}{f'}\textcolor{red}{\Big(}\frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)}\textcolor{red}{\Big)} +\right) +\right] +$$ + +Where \\( f' \\) is the derivative of the convex function defining the chosen \(( f \\)-divergence. + +To reproduce: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="sigmoid", + beta=0.1, + f_divergence_type="js_divergence", # or "reverse_kl" (default), "forward_kl", "js_divergence", "alpha_divergence" + f_alpha_divergence_coef=0.5, # only used if f_divergence_type="alpha_divergence" +) +``` + +### A General Theoretical Paradigm to Understand Learning from Human Preferences + +**📜 Paper**: https://huggingface.co/papers/2310.12036 + +Learning from human preferences can be written as a single KL-regularized objective over pairwise preference probabilities, + +$$ +\max_\pi ;\mathbb{E}\big[\Psi\left(p^*(y \succ y' \mid x)\right)\big] - \tau\mathrm{KL}(\pi||\pi_{\text{ref}}), +$$ + +which reveals RLHF and DPO as special cases corresponding to the logit choice of \\( \Psi \\). +The paper shows that this logit transform amplifies near-deterministic preferences and effectively weakens KL regularization, explaining overfitting. +Using the **Identity transform (IPO)** avoids this pathology by optimizing preferences directly, without assuming a Bradley–Terry reward model. +To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="ipo", # Section 5.1 of the paper + per_device_train_batch_size=90, # mini-batch size in Section C.1 of the paper + learning_rate=1e-2, # learning rate in Section C.1 of the paper +) +``` + +These parameters only appear in the [published version](https://proceedings.mlr.press/v238/gheshlaghi-azar24a/gheshlaghi-azar24a.pdf) + +### Towards Efficient and Exact Optimization of Language Model Alignment + +**📜 Paper**: https://huggingface.co/papers/2402.00856 + +The paper shows that direct preference methods like DPO optimize the wrong KL direction, leading to blurred preference capture, and proposes EXO as an efficient way to exactly optimize the human‑preference alignment objective by leveraging reverse KL probability matching rather than forward KL approximations. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="exo_pair", # Section 3.2 of the paper + # From Section B of the paper + per_device_train_batch_size=64, + learning_rate=1e-6, + beta=0.1, +) +``` + +### Noise Contrastive Alignment of Language Models with Explicit Rewards + +**📜 Paper**: https://huggingface.co/papers/2402.05369 + +The paper reframes language-model alignment as a *noise-contrastive classification* problem, proposing InfoNCA to learn a policy from explicit rewards (or preferences) by matching a reward-induced target distribution over responses, and showing DPO is a special binary case. It then introduces NCA, which adds an absolute likelihood term to prevent the likelihood collapse seen in purely relative (contrastive) objectives. + +With pairwise preferences, treat the chosen/rejected \\( K=2 \\), define scores \\( r=\beta(\log\pi_\theta-\log\pi_{\text{ref}}) \\), and apply the NCA preference loss \\( -\log\sigma(r_w)-\tfrac12\log\sigma(-r_w)-\tfrac12\log\sigma(-r_l) \\). + +To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="nca_pair", + # From Section C of the paper + per_device_train_batch_size=32, + learning_rate=5e-6, + beta=0.01, +) +``` + +### Provably Robust DPO: Aligning Language Models with Noisy Feedback + +**📜 Paper**: https://huggingface.co/papers/2403.00409 + +DPO breaks under noisy human preferences because label flips bias the objective. Robust DPO fixes this by analytically debiasing the DPO loss under a simple noise model, with provable guarantees. + +$$ +\mathcal{L}_{\text{robust}}(\pi_\theta) = \frac{(1-\varepsilon)\mathcal{L}_{\text{DPO}}(y_w, y_l) - \varepsilon\mathcal{L}_{\text{DPO}}(y_l, y_w)} +{1-2\varepsilon} +$$ + +Where \\( \mathcal{L}_{\text{DPO}} \\) is the DPO loss defined in [Direct Preference Optimization: Your Language Model is Secretly a Reward Model](#direct-preference-optimization-your-language-model-is-secretly-a-reward-model) and \\( \varepsilon \\) is the probability of a label flip. + +This single correction turns noisy preference data into an unbiased estimator of the clean DPO objective. + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="robust", + per_device_train_batch_size=16, # batch size in Section B of the paper + learning_rate=1e-3, # learning rate in Section B of the paper + beta=0.1, # β in Section B of the paper, + max_length=512, # max length in Section B of the paper + label_smoothing=0.1 # label smoothing $\varepsilon$ in Section 6 of the paper +) +``` + +### Binary Classifier Optimization for Large Language Model Alignment + +**📜 Paper**: https://huggingface.co/papers/2404.04656 + +Theoretical analysis and a new algorithm, Binary Classifier Optimization, explain and enhance the alignment of large language models using binary feedback signals. To reproduce the paper's setting, use this configuration: + +BCO reframes language-model alignment as behavioral cloning from an optimal reward-weighted distribution, yielding simple supervised objectives that avoid RL while remaining theoretically grounded. +It supports both unpaired reward data and pairwise preference data, with a reward-shift–invariant formulation that reduces to a DPO-style loss in the preference setting. + +For the pairwise preference setting, the BCO loss is defined as: + +$$ +\mathcal{L}_{\text{bco\_pair}}(\pi_\theta) = +\mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}} +\left[ +-\log \sigma\Big( +\beta[(\log\pi_\theta-\log\pi_{\text{ref}})(y_w) +- +(\log\pi_\theta-\log\pi_{\text{ref}})(y_l)] +\Big) +\right] +$$ + +To reproduce the paper in this setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="bco_pair", + # From Section C of the paper + per_device_train_batch_size=128, + learning_rate=5e-7, + beta=0.01, +) +``` + +For the unpaired version, the user should utilize [`experimental.bco.BCOConfig`] and [`experimental.bco.BCOTrainer`]. + +### Learn Your Reference Model for Real Good Alignment + +**📜 Paper**: https://huggingface.co/papers/2404.09656 + +Trust Region DPO (TR-DPO) updates the reference policy during training, demonstrating effectiveness against DPO on the Anthropic HH and TLDR datasets, outperforming DPO by up to 19% measured by automatic evaluation with GPT-4, improving coherence, correctness, level of detail, helpfulness, and harmlessness. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + sync_ref_model=True, # enable TR-DPO (Section 3 of the paper) + ref_model_mixup_alpha=0.6, # α soft update weight (Table 1 of the paper) + ref_model_sync_steps=512, # τ update frequency in steps (Table 1 of the paper) + beta=0.05, # β temperature (Table 1 of the paper) + learning_rate=1e-6, # learning rate (Table 2 of the paper) + num_train_epochs=1, # Table 2 of the paper + max_length=1024, # max tokens length (Table 2 of the paper) + max_grad_norm=2, # max gradient norm (Table 2 of the paper) + warmup_steps=100, # warm-up steps (Table 2 of the paper) +) +``` + +### Iterative Reasoning Preference Optimization + +**📜 Paper**: https://huggingface.co/papers/2404.19733 + +Iterative RPO improves reasoning by repeatedly generating chain-of-thought candidates, building preference pairs from correct vs. incorrect answers, and training with a DPO + NLL objective. The extra NLL term is key for learning to actually generate winning traces. + +TRL can express the DPO + NLL objective by mixing `"sigmoid"` (DPO) with `"sft"` (NLL): + +```python +from trl import DPOConfig, DPOTrainer + +training_args = DPOConfig( + loss_type=["sigmoid", "sft"], + loss_weights=[1.0, 1.0], # alpha in the paper, recommended value is 1.0 +) +trainer = DPOTrainer( + ..., + args=training_args, +) +``` + +Note that the paper uses an iterative loop: each iteration regenerates CoT candidates with the current model, then retrains on fresh preference pairs. TRL does not automate that loop for you. + +### Self-Play Preference Optimization for Language Model Alignment + +**📜 Paper**: https://huggingface.co/papers/2405.00675 + +A self-play method called SPPO for language model alignment achieves state-of-the-art performance by approximating Nash equilibrium policy in a constant-sum game setting, outperforming other approaches with limited data. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="sppo_hard", + # From Section 5 of the paper + beta=0.001, # β = η^−1 + per_device_train_batch_size=64, + learning_rate=5e-7, +) +``` + +### Provably Mitigating Overoptimization in RLHF: Your SFT Loss is Implicitly an Adversarial Regularizer + +**📜 Paper**: https://huggingface.co/papers/2405.16436 + +Regularized Preference Optimization (RPO) mitigates overoptimization in RLHF by fusing the DPO loss with the SFT loss, provably preventing the policy from choosing actions with spurious high proxy rewards. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type=["sigmoid", "sft"], # RPO loss = DPO + SFT (Section 5 of the paper) + loss_weights=[1.0, 0.005], # η=0.005 SFT weight in Appendix E.1 of the paper + beta=0.01, # β in Appendix E.1 of the paper + learning_rate=5e-7, # learning rate in Appendix E.1 of the paper + num_train_epochs=1, # Appendix E.1 of the paper +) +``` + +### Distributional Preference Alignment of LLMs via Optimal Transport + +**📜 Paper**: https://huggingface.co/papers/2406.05882 + +Alignment via Optimal Transport (AOT) aligns large language models distributionally by penalizing violations of stochastic dominance between positive and negative sample distributions, achieving state-of-the-art performance on alignment benchmarks. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="aot", + beta=0.01, # from the caption of Figure 2 +) +``` + +or, for the unpaired version: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="aot_unpaired", + beta=0.01, # from the caption of Figure 2 +) +``` + +There is no additional hyperparameter in the paper. + +### Discovering Preference Optimization Algorithms with and for Large Language Models + +**📜 Paper**: https://huggingface.co/papers/2406.08414 + +An LLM-driven method automatically discovers performant preference optimization algorithms, leading to a new algorithm called DiscoPOP that blends logistic and exponential losses. To reproduce the paper's setting, use this configuration: + +```python +from trl import DPOConfig + +training_args = DPOConfig( + loss_type="discopop", + per_device_train_batch_size=64, # batch size in Section B.1 of the paper + learning_rate=5e-7, # learning rate in Section B.1 of the paper + beta=0.05, # β in Section B.1 of the paper, + discopop_tau=0.05 # τ in Section E of the paper +) +``` + +### WPO: Enhancing RLHF with Weighted Preference Optimization + +**📜 Paper**: https://huggingface.co/papers/2406.11827 + +WPO reweights preference pairs by their policy probabilities to reduce the off-policy gap in DPO-style training. The loss is: + +$$ +\mathcal{L}_{\text{WPO}} = -\mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}} \left[ \textcolor{red}{w(x, y_w) w(x, y_l)} \log p(y_w \succ y_l \mid x) \right] +$$ + +where the weight \\( w(x, y) \\) is defined as: + +$$ +w(x, y) = \exp\left(\frac{1}{|y|}\sum_{t=1}^{|y|} \log \frac{\pi_\theta(y_t \mid x, y_{ 0 (optimism coefficient) and β > 0 (KL regularization) in Algorithm 1 but does not specify numerical values. The following configuration uses TRL defaults: + +```python +from trl.experimental.xpo import XPOConfig + +training_args = XPOConfig( + alpha=1e-5, # α exploration bonus weight, α ≥ 0 where α=0 reduces to online DPO (TRL default) + beta=0.1, # β KL regularization coefficient (TRL default) +) +``` + +## Distillation + +Papers relating to training a student model with the help of a teacher model. + +### On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes + +**📜 Paper**: https://huggingface.co/papers/2306.13649 + +Introduces Generalized Knowledge Distillation (GKD), which addresses distribution mismatch in KD for auto-regressive models by training the student on its own generated outputs with teacher feedback, instead of a fixed set of sequences. GKD supports flexible loss functions (e.g. beyond KL when the student cannot match the teacher) and integrates with RL fine-tuning (RLHF). The paper reports results on summarization, translation, arithmetic reasoning, and instruction-tuning. Used in TRL via [`experimental.distillation.DistillationTrainer`] and [`experimental.gkd.GKDTrainer`]. To reproduce the paper's setting, use this configuration: + +```python +from trl.experimental.distillation import DistillationConfig + +# XSum summarization task (Table A.1 of the paper) +training_args = DistillationConfig( + lmbda=0.5, # λ student data fraction (Section 3 of the paper) + beta=0.5, # β Generalized JSD interpolation, 0=KL, 1=reverse KL (Section 3 of the paper) + temperature=1.0, # student training temperature (Appendix A of the paper) + max_steps=40000, # training steps (Table A.1 of the paper) + learning_rate=3e-4, # learning rate (Table A.1 of the paper) + per_device_train_batch_size=32, # batch size (Table A.1 of the paper) + warmup_steps=2000, # warm-up steps (Table A.1 of the paper) + max_completion_length=64, # max output tokens (Table A.1 of the paper) +) +``` + +### On-Policy Distillation + +**📰 Blog**: https://thinkingmachines.ai/blog/on-policy-distillation/ + +On-Policy Distillation involves a student model generating rollouts for each batch of training data. We subsequently obtain the probability distributions for each token of the rollouts from both the student and teacher models. The student model is then optimized to minimize the negative Kullback-Leibler (KL) divergence between its own token distributions and those of the teacher model. + +| Method | Sampling | Reward signal | +|-------------------------|------------|---------------| +| Supervised finetuning | off-policy | dense | +| Reinforcement learning | on-policy | sparse | +| On-policy distillation | on-policy | dense | + +On-Policy Distillation has been shown to outperform SFT, GRPO and can be used to restore generalization capabilities lost during SFT. + +Additionally on-policy distillation is more compute efficient and is less prone to overfitting when trained with limited data. + +To train a model with on-policy distillation using TRL, you can use the following configuration, with the [`experimental.distillation.DistillationTrainer`] and [`experimental.distillation.DistillationConfig`]: + +```python +from trl.experimental.distillation import DistillationConfig + +training_args = DistillationConfig( + lmbda=1.0, # student produces rollouts for all batches + beta=1.0, # to ensure reverse-kl as the loss function + teacher_model_name_or_path="teacher-model", # specify the teacher model +) +``` + +Alternatively, you can use the [`experimental.gkd.GKDTrainer`] and [`experimental.gkd.GKDConfig`]: + +```python +from trl.experimental.gkd import GKDConfig + +training_args = GKDConfig( + lmbda=1.0, # student produces rollouts for all batches + beta=1.0, # to ensure reverse-kl as the loss function + teacher_model_name_or_path="teacher-model", # specify the teacher model +) +``` + +You can also use the [`GOLDTrainer`] and [`GOLDConfig`] to perform on-policy distillation with a similar configuration: + +```python +from trl.experimental import GOLDConfig + +config = GOLDConfig( + lmbda=1.0, # student produces rollouts for all batches + beta=1.0, # to ensure reverse-kl as the loss function + teacher_model_name_or_path="teacher-model", # specify the teacher model + +) +``` + +### Knowledge Distillation of Large Language Models + +**📜 Paper**: https://huggingface.co/papers/2306.08543 + +MiniLLM is the first on-policy knowledge distillation method, which minimizes the sequence-level reverse KLD between the teacher and the student model and is optimized by reinforcement learning. + +It is a generalized version of [Think Machine Lab's On-Policy Distillation](https://thinkingmachines.ai/blog/on-policy-distillation/), with the option to add distribution-level single-step distillation signals (like GKD when `beta=1`) and long-context reverse KLD signals. + +Alternatively, you can use the [`experimental.MiniLLMTrainer`] and [`experimental.MiniLLMConfig`] to perform MiniLLM distillation as follows: + +```python +from datasets import load_dataset +from trl.experimental.minillm import MiniLLMTrainer + +dataset = load_dataset("trl-lib/tldr", split="train") + +trainer = MiniLLMTrainer( + model="Qwen/Qwen3-0.6B", + teacher_model="Qwen/Qwen3-1.7B", + train_dataset=dataset, +) +trainer.train() +``` + +For more details, see the [MiniLLM Trainer documentation](minillm) documentation. + +### Reinforcement Learning via Self-Distillation + +**📜 Paper**: https://huggingface.co/papers/2601.20802 + +Self-Distillation Policy Optimization (SDPO) enhances reinforcement learning with verifiable rewards by converting rich textual feedback (e.g., runtime errors, judge evaluations) into a dense learning signal without any external teacher or explicit reward model. SDPO treats the current model conditioned on feedback as a self-teacher and distills its feedback-informed next-token predictions back into the policy. Notably, SDPO also outperforms baselines in standard RLVR environments that only return scalar feedback by using successful rollouts as implicit feedback for failed attempts. + +```python +from trl.experimental.sdpo import SDPOConfig, SDPOTrainer + +training_args = SDPOConfig( + distillation_alpha=0.5, # Jensen-Shannon divergence (recommended) + distillation_topk=100, # Top-K logit distillation approximation + full_logit_distillation=True, # Required for top-K logit-level SDPO + distillation_is_clip=2.0, # Importance sampling clipping + distillation_weight=1.0, # Weight for self-distillation loss + sdpo_policy_loss_mode="distillation_only", + use_successful_as_teacher=True, # Use successful rollouts as teacher + teacher_regularization="ema", # Supported: "ema", "none" + teacher_update_rate=0.05, # EMA update rate + include_environment_feedback=False, # Use dataset privileged_context when available +) + +trainer = SDPOTrainer( + model="Qwen/Qwen2.5-1.5B-Instruct", + reward_funcs=..., + args=training_args, + train_dataset=..., +) +trainer.train() +``` + +Expected dataset columns: + +- `prompt` +- `privileged_context` for optional environment feedback + +For more details, see the [SDPO Trainer documentation](sdpo_trainer). + +### Self-Training with On-Policy Self-Distillation for Language Model Alignment + +**📜 Paper**: https://huggingface.co/papers/2601.19897 + +Self-Distilled Fine-Tuning (SDFT) performs on-policy self-distillation by generating completions during training, then distilling an explicit teacher-conditioned view of those same completions back into the student. In TRL, SDFT uses a shared self-distillation core with SDPO where the teacher is the model itself (base weights with adapter disabled for PEFT, or the same model under `no_grad` for non-PEFT). +The teacher prompt is composed internally from the student `prompt` plus the dataset `privileged_context`. + +```python +from datasets import Dataset + +from trl.experimental.sdft import SDFTConfig, SDFTTrainer + +dataset = Dataset.from_dict( + { + "prompt": [[{"role": "user", "content": "Solve 2+2."}]], + "privileged_context": ["Example answer: 4."], + } +) + +training_args = SDFTConfig( + distillation_alpha=0.5, + distillation_topk=5, + max_completion_length=64, +) + +trainer = SDFTTrainer( + model="Qwen/Qwen2.5-1.5B-Instruct", + args=training_args, + train_dataset=dataset, +) +trainer.train() +``` + +Expected dataset columns: + +- `prompt` +- `privileged_context` containing only the extra teacher-only information + +For more details, see the [SDFT Trainer documentation](sdft_trainer). + +### Embarrassingly Simple Self-Distillation Improves Code Generation + +**📜 Paper**: https://huggingface.co/papers/2604.01193 + +Simple Self-Distillation (SSD) improves code generation by sampling completions from the model at a training-time temperature and truncation configuration, then fine-tuning on those raw, unverified samples with standard cross-entropy loss. No reward model, verifier, teacher model, or reinforcement learning is needed. SSD reshapes token distributions in a context-dependent way: suppressing distractor tails at "lock" positions (where syntax leaves little ambiguity) while preserving diversity at "fork" positions (where multiple valid continuations exist). + +```python +from trl.experimental.ssd import SSDConfig, SSDTrainer + +training_args = SSDConfig( + temperature=0.6, # Training-time sampling temperature (T_train) + top_k=20, # Training-time top-k truncation + top_p=0.95, # Training-time top-p truncation + max_completion_length=65536, + learning_rate=5e-6, +) + +trainer = SSDTrainer( + model="Qwen/Qwen3-4B-Instruct", + args=training_args, + train_dataset=..., +) +trainer.train() +``` + +Expected dataset columns: + +- `prompt` + +For more details, see the [SSD Trainer documentation](ssd_trainer). + +## Distributed Training + +### ZeRO: Memory Optimizations Toward Training Trillion Parameter Models + +**📜 Paper**: https://huggingface.co/papers/1910.02054 + +ZeRO (Zero Redundancy Optimizer) eliminates memory redundancies in data- and model-parallel training by partitioning optimizer states, gradients, and parameters across devices while retaining low communication volume and high computational granularity. This allows for the efficient training of large models that would otherwise not fit in GPU memory. + +TRL supports ZeRO via the [DeepSpeed integration](deepspeed_integration). To use it, provide a DeepSpeed configuration file with your desired settings, + +```yaml +# config.yaml +distributed_type: DEEPSPEED +num_processes: 2 +deepspeed_config: + zero_stage: 3 +``` + +and launch the training script using `accelerate launch --config_file config_file`. + +```sh +accelerate launch --config_file config.yaml train.py +``` + +## Proximal Policy Optimization + +Papers relating to the [`experimental.ppo.PPOTrainer`] + +### Proximal Policy Optimization Algorithms + +**📜 Paper**: https://huggingface.co/papers/1707.06347 + +Introduces Proximal Policy Optimization (PPO): policy gradient methods that alternate between collecting rollouts and optimizing a clipped surrogate objective over multiple minibatch epochs. PPO retains benefits of trust-region methods (e.g. TRPO) with simpler implementation and strong empirical sample efficiency, and was validated on robotics and Atari benchmarks. Used in TRL via [`experimental.ppo.PPOTrainer`]. To use PPO with TRL, use this configuration: + +```python +from trl.experimental.ppo import PPOConfig + +training_args = PPOConfig( + cliprange=0.2, # ε clipping range (Section 3 and Table 3 of the paper, Mujoco setting) + num_ppo_epochs=4, # K epochs of minibatch updates (TRL default; paper uses K=10 Mujoco, K=3 Atari) + gamma=1.0, # γ discount factor (TRL default for LLM tasks; paper uses γ=0.99) + lam=0.95, # λ GAE parameter (Table 3 of the paper, Mujoco setting) + kl_coef=0.05, # KL penalty coefficient (Section 4 of the paper discusses adaptive KL) + vf_coef=0.1, # c₁ value function loss weight (Equation 9 of the paper) +) +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/papo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/papo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..b9ec5aa66ed8e97de062b4e5b66a458f381c7e37 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/papo_trainer.md @@ -0,0 +1,20 @@ +# PAPO Trainer + +[![model badge](https://img.shields.io/badge/All_models-PAPO-blue)](https://huggingface.co/models?other=papo,trl) + +TRL supports the Perception-Aware Policy Optimization (PAPO) as described in the paper [Perception-Aware Policy Optimization for Multimodal Reasoning](https://huggingface.co/papers/2507.06448) by [Zhenhailong Wang](https://huggingface.co/mikewang), Xuehang Guo, Sofia Stoica, [Haiyang Xu](https://huggingface.co/xhyandwyy), Hongru Wang, Hyeonjeong Ha, Xiusi Chen, Yangyi Chen, Ming Yan, Fei Huang, Heng Ji + +The abstract from the paper is the following: + +> Reinforcement Learning with Verifiable Rewards (RLVR) has proven to be a highly effective strategy for endowing Large Language Models (LLMs) with robust multi-step reasoning abilities. However, its design and optimizations remain tailored to purely textual domains, resulting in suboptimal performance when applied to multimodal reasoning tasks. In particular, we observe that a major source of error in current multimodal reasoning lies in the perception of visual inputs. To address this bottleneck, we propose Perception-Aware Policy Optimization (PAPO), a simple yet effective extension of GRPO that encourages the model to learn to perceive while learning to reason, entirely from internal supervision signals. Notably, PAPO does not rely on additional data curation, external reward models, or proprietary models. Specifically, we introduce the Implicit Perception Loss in the form of a KL divergence term to the GRPO objective, which, despite its simplicity, yields significant overall improvements (4.4%) on diverse multimodal benchmarks. The improvements are more pronounced, approaching 8.0%, on tasks with high vision dependency. We also observe a substantial reduction (30.5%) in perception errors, indicating improved perceptual capabilities with PAPO. We conduct comprehensive analysis of PAPO and identify a unique loss hacking issue, which we rigorously analyze and mitigate through a Double Entropy Loss. Overall, our work introduces a deeper integration of perception-aware supervision into RLVR learning objectives and lays the groundwork for a new RL framework that encourages visually grounded reasoning. Project page: https://mikewangwzhl.github.io/PAPO. + +## PAPOTrainer + +[[autodoc]] experimental.papo.PAPOTrainer + - train + - save_model + - push_to_hub + +## PAPOConfig + +[[autodoc]] experimental.papo.PAPOConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/peft_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/peft_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..cfc5c180f9b89e9a5f2c5c75347e7e21e3501be8 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/peft_integration.md @@ -0,0 +1,822 @@ +# PEFT Integration + +TRL supports [PEFT](https://github.com/huggingface/peft) (Parameter-Efficient Fine-Tuning) methods for memory-efficient model training. PEFT enables fine-tuning large language models by training only a small number of additional parameters while keeping the base model frozen, significantly reducing computational costs and memory requirements. + +This guide covers how to use PEFT with different TRL trainers, including LoRA, QLoRA, and prompt tuning techniques. + +For a complete working example, see the [SFT with LoRA/QLoRA notebook](https://github.com/huggingface/trl/blob/main/examples/notebooks/sft_trl_lora_qlora.ipynb). + +## Installation + +To use PEFT with TRL, install the required dependencies: + +```bash +pip install trl[peft] +``` + +For QLoRA support (4-bit and 8-bit quantization), also install: + +```bash +pip install bitsandbytes +``` + +## Quick Start + +All TRL trainers support PEFT through the `peft_config` argument. The simplest way to enable PEFT is by using the command-line interface with the `--use_peft` flag: + +```bash +python trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --output_dir Qwen2-0.5B-SFT-LoRA +``` + +Alternatively, you can pass a PEFT config directly in your Python code: + +```python +from peft import LoraConfig +from trl import SFTTrainer + +# Configure LoRA +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", +) + +# Configure training - note the higher learning rate for LoRA (10x base rate) +training_args = SFTConfig( + learning_rate=2.0e-4, # 10x the base rate (2.0e-5) for LoRA + ... +) + +# Create trainer with PEFT +trainer = SFTTrainer( + model=model, + train_dataset=dataset, + peft_config=peft_config, +) +``` + +## Three Ways to Configure PEFT + +TRL provides three different methods to configure PEFT, each suited for different use cases: + +### 1. Using CLI Flags (Simplest) + +The easiest way to enable PEFT is to use the `--use_peft` flag with the command-line interface. This method is ideal for quick experiments and standard configurations: + +```bash +python trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --lora_dropout 0.05 \ + --output_dir Qwen2-0.5B-SFT-LoRA +``` + +**Pros**: Quick setup, no code required + +**Cons**: Limited to LoRA, fewer customization options + +### 2. Passing peft_config to Trainer (Recommended) + +For more control, pass a PEFT configuration directly to the trainer. This is the recommended approach for most use cases: + +```python +from peft import LoraConfig +from trl import SFTConfig, SFTTrainer + +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + target_modules=["q_proj", "v_proj", "k_proj", "o_proj"], +) + +trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset, + peft_config=peft_config, # Pass config here +) +``` + +**Pros**: Full control, supports all PEFT methods (LoRA, Prompt Tuning, etc.) + +**Cons**: Requires Python code + +### 3. Applying PEFT to Model Directly (Advanced) + +For maximum flexibility, you can apply PEFT to your model before passing it to the trainer: + +```python +from peft import LoraConfig, get_peft_model +from transformers import AutoModelForCausalLM +from trl import SFTConfig, SFTTrainer + +# Load base model +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B") + +# Apply PEFT configuration +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", +) +model = get_peft_model(model, peft_config) + +# Pass PEFT-wrapped model to trainer +trainer = SFTTrainer( + model=model, # Already has PEFT applied + args=training_args, + train_dataset=dataset, + # Note: no peft_config needed here +) +``` + +**Pros**: Maximum control, useful for custom model architectures or complex setups + +**Cons**: More verbose, requires understanding of PEFT internals + +## Learning Rate Considerations + +When using LoRA or other PEFT methods, you typically need to use a **higher learning rate** (approximately 10x) compared to full fine-tuning. This is because PEFT methods train only a small fraction of parameters, requiring a larger learning rate to achieve similar parameter updates. + +**Recommended learning rates:** + +| Trainer | Full Fine-Tuning | With LoRA (10x) | +|---------|------------------|-----------------| +| **SFT** | `2.0e-5` | `2.0e-4` | +| **DPO** | `5.0e-7` | `5.0e-6` | +| **GRPO** | `1.0e-6` | `1.0e-5` | +| **Prompt Tuning** | N/A | `1.0e-2` to `3.0e-2` | + +> **Why 10x?** LoRA adapters have significantly fewer trainable parameters than the full model. A higher learning rate compensates for this reduced parameter count, ensuring effective training. For detailed explanation, see [this blog post](https://thinkingmachines.ai/blog/lora/). + +For additional best practices on using LoRA effectively, refer to the [LoRA Without Regret](lora_without_regret) documentation. + +## PEFT with Different Trainers + +TRL's trainers support PEFT configurations for various training paradigms. Below are detailed examples for each major trainer. + + + + +### Supervised Fine-Tuning (SFT) + +The `SFTTrainer` is used for supervised fine-tuning on instruction datasets. + +#### With LoRA + +```bash +python trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --learning_rate 2.0e-4 \ + --num_train_epochs 1 \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 8 \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --output_dir Qwen2-0.5B-SFT-LoRA +``` + +#### Python Example + +```python +from peft import LoraConfig +from trl import SFTConfig, SFTTrainer + +# Configure LoRA +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + target_modules=["q_proj", "v_proj"], # optional: specify target modules +) + +# Configure training with higher learning rate for LoRA +training_args = SFTConfig( + learning_rate=2.0e-4, # 10x the base rate for LoRA + ... +) + +# Create trainer with PEFT config +trainer = SFTTrainer( + model="Qwen/Qwen2-0.5B", # can pass model name or loaded model + args=training_args, + train_dataset=dataset, + peft_config=peft_config, # pass PEFT config here +) +trainer.train() +``` + + + + +### Direct Preference Optimization (DPO) + +The [`DPOTrainer`] implements preference learning from human feedback. + +#### With LoRA + +```bash +python trl/scripts/dpo.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --learning_rate 5.0e-6 \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 8 \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --output_dir Qwen2-0.5B-DPO-LoRA +``` + +#### Python Example + +```python +from peft import LoraConfig +from trl import DPOConfig, DPOTrainer + +# Configure LoRA +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", +) + +# Configure training with higher learning rate for LoRA +training_args = DPOConfig( + learning_rate=5.0e-6, # 10x the base rate for DPO with LoRA + ... +) + +# Create trainer with PEFT config +trainer = DPOTrainer( + model="Qwen/Qwen2-0.5B", # can pass model name or loaded model + args=training_args, + train_dataset=dataset, + peft_config=peft_config, # pass PEFT config here +) +trainer.train() +``` + +**Note:** When using PEFT with DPO, you don't need to provide a separate reference model (`ref_model`). The trainer automatically uses the frozen base model as the reference. + + + + +### Group Relative Policy Optimization (GRPO) + +The `GRPOTrainer` optimizes policies using group-based rewards. + +#### With LoRA + +```bash +python trl/scripts/grpo.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/math-reasoning \ + --learning_rate 1.0e-5 \ + --per_device_train_batch_size 2 \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --output_dir Qwen2-0.5B-GRPO-LoRA +``` + +#### Python Example + +```python +from peft import LoraConfig +from trl import GRPOConfig, GRPOTrainer + +# Configure LoRA +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", +) + +# Configure training with higher learning rate for LoRA +training_args = GRPOConfig( + learning_rate=1.0e-5, # 10x the base rate for GRPO with LoRA + ... +) + +# Create trainer with PEFT config +trainer = GRPOTrainer( + model="Qwen/Qwen2-0.5B", # can pass model name or loaded model + args=training_args, + train_dataset=dataset, + peft_config=peft_config, # pass PEFT config here +) +trainer.train() +``` + + + + +### Proximal Policy Optimization (PPO) + +#### Multi-Adapter RL Training + +You can use a single base model with multiple PEFT adapters for the entire PPO algorithm - including retrieving reference logits, computing active logits, and calculating rewards. This approach is useful for memory-efficient RL training. + +> [!WARNING] +> This feature is experimental and convergence has not been extensively tested. We encourage the community to share feedback and report any issues. + +**Requirements** + +Install PEFT and optionally bitsandbytes for 8-bit models: + +```bash +pip install peft bitsandbytes +``` + +**Training Workflow** + +The multi-adapter approach requires three stages: + +1. **Supervised Fine-Tuning (SFT)**: Train a base model on your target domain (e.g., IMDB dataset) using `SFTTrainer` +2. **Reward Model Training**: Train a reward model adapter using PEFT and `RewardTrainer` (see [reward modeling example](https://github.com/huggingface/trl/tree/main/examples/scripts/reward_modeling.py)) +3. **PPO Training**: Fine-tune new adapters using PPO with the reward adapter + +> [!IMPORTANT] +> Use the same base model (architecture and weights) for stages 2 & 3. + +**Basic Usage** + +After training your reward adapter and pushing it to the Hub: + +```python +from peft import LoraConfig +from trl.experimental.ppo import PPOTrainer, AutoModelForCausalLMWithValueHead + +model_name = "huggyllama/llama-7b" +rm_adapter_id = "trl-lib/llama-7b-hh-rm-adapter" + +# Configure PPO adapter +lora_config = LoraConfig( + r=16, + lora_alpha=32, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", +) + +# Load model with reward adapter +model = AutoModelForCausalLMWithValueHead.from_pretrained( + model_name, + peft_config=lora_config, + reward_adapter=rm_adapter_id, +) + +trainer = PPOTrainer(model=model, ...) +``` + +In your training loop, compute rewards using: + +```python +rewards = trainer.model.compute_reward_score(**inputs) +``` + +**Advanced Features** + +**Quantized Base Models** + +For memory-efficient training, load the base model in 8-bit or 4-bit while keeping adapters in float32: + +```python +from transformers import BitsAndBytesConfig + +model = AutoModelForCausalLMWithValueHead.from_pretrained( + model_name, + peft_config=lora_config, + reward_adapter=rm_adapter_id, + quantization_config=BitsAndBytesConfig(load_in_8bit=True), +) +``` + +## QLoRA: Quantized Low-Rank Adaptation + +QLoRA combines 4-bit quantization with LoRA to enable fine-tuning of very large models on consumer hardware. This technique can reduce memory requirements by up to 4x compared to standard LoRA. + +### How QLoRA Works + +1. **4-bit Quantization**: The base model is loaded in 4-bit precision using `bitsandbytes` +2. **Frozen Weights**: The quantized model weights remain frozen during training +3. **LoRA Adapters**: Only the LoRA adapter parameters are trained in higher precision +4. **Memory Efficiency**: Enables fine-tuning of models like Llama-70B on a single consumer GPU + +### Using QLoRA with TRL + +Simply combine `load_in_4bit=True` with PEFT configuration: + +#### Command Line + +```bash +python trl/scripts/sft.py \ + --model_name_or_path meta-llama/Llama-2-7b-hf \ + --dataset_name trl-lib/Capybara \ + --load_in_4bit \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 16 \ + --output_dir Llama-2-7b-QLoRA +``` + +#### Python Example + +```python +import torch + +from peft import LoraConfig +from transformers import AutoModelForCausalLM, BitsAndBytesConfig +from trl import SFTConfig, SFTTrainer + +# Configure 4-bit quantization +bnb_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_quant_type="nf4", + bnb_4bit_compute_dtype=torch.bfloat16, + bnb_4bit_use_double_quant=True, +) + +# Load model with quantization +model = AutoModelForCausalLM.from_pretrained( + "meta-llama/Llama-2-7b-hf", + quantization_config=bnb_config, + device_map="auto", +) + +# Configure LoRA +peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", +) + +# Configure training with higher learning rate for LoRA +training_args = SFTConfig( + learning_rate=2.0e-4, # 10x the base rate for QLoRA + ... +) + +# Create trainer with PEFT config +trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset, + peft_config=peft_config, +) + +trainer.train() +``` + +### QLoRA Configuration Options + +The `BitsAndBytesConfig` provides several options to optimize memory and performance: + +```python +import torch + +from transformers import BitsAndBytesConfig + +bnb_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_quant_type="nf4", # or "fp4" + bnb_4bit_compute_dtype=torch.bfloat16, # Compute dtype for 4-bit base models + bnb_4bit_use_double_quant=True, # Nested quantization for additional memory savings +) +``` + +**Configuration Parameters:** +- `bnb_4bit_quant_type`: Quantization data type (`"nf4"` or `"fp4"`). NF4 is recommended. +- `bnb_4bit_compute_dtype`: The dtype used for computation. Use `bfloat16` for better training stability. +- `bnb_4bit_use_double_quant`: Enable nested quantization to save additional ~0.4 bits per parameter. + +### 8-bit Quantization + +For slightly higher precision with reduced memory savings, you can use 8-bit quantization: + +```python +from transformers import BitsAndBytesConfig, AutoModelForCausalLM + +bnb_config = BitsAndBytesConfig(load_in_8bit=True) + +model = AutoModelForCausalLM.from_pretrained( + "meta-llama/Llama-2-7b-hf", + quantization_config=bnb_config, + device_map="auto", +) +``` + +Or via command line: + +```bash +python trl/scripts/sft.py \ + --model_name_or_path meta-llama/Llama-2-7b-hf \ + --load_in_8bit \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 +``` + +## Prompt Tuning + +Prompt tuning is another PEFT technique that learns soft prompts (continuous embeddings) prepended to the input, while keeping the entire model frozen. This is particularly effective for large models. + +### How Prompt Tuning Works + +1. **Virtual Tokens**: Adds learnable continuous embeddings (virtual tokens) to the input +2. **Frozen Model**: The entire base model remains frozen +3. **Task-Specific Prompts**: Each task learns its own prompt embeddings +4. **Extreme Efficiency**: Only the prompt embeddings are trained (typically 8-20 tokens) + +### Using Prompt Tuning with TRL + +```python +from peft import PromptTuningConfig, PromptTuningInit, TaskType +from trl import SFTConfig, SFTTrainer + +# Configure Prompt Tuning +peft_config = PromptTuningConfig( + task_type=TaskType.CAUSAL_LM, + prompt_tuning_init=PromptTuningInit.TEXT, + num_virtual_tokens=8, + prompt_tuning_init_text="Classify if the tweet is a complaint or not:", + tokenizer_name_or_path="Qwen/Qwen2-0.5B", +) + +# Configure training with higher learning rate for Prompt Tuning +training_args = SFTConfig( + learning_rate=2.0e-2, # Prompt Tuning typically uses 1e-2 to 3e-2 + ... +) + +# Create trainer with PEFT config +trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset, + peft_config=peft_config, # pass PEFT config here +) + +trainer.train() +``` + +### Prompt Tuning Configuration + +```python +from peft import PromptTuningConfig, PromptTuningInit, TaskType + +peft_config = PromptTuningConfig( + task_type=TaskType.CAUSAL_LM, # Task type + prompt_tuning_init=PromptTuningInit.TEXT, # Initialize from text + num_virtual_tokens=8, # Number of virtual tokens + prompt_tuning_init_text="Your initialization text here", + tokenizer_name_or_path="model_name", +) +``` + +**Configuration Parameters:** +- `task_type`: The task type (`TaskType.CAUSAL_LM` for language modeling) +- `prompt_tuning_init`: Initialization method (`TEXT`, `RANDOM`) +- `num_virtual_tokens`: Number of virtual tokens to prepend (typically 8-20) +- `prompt_tuning_init_text`: Text to initialize the virtual tokens (when using `TEXT` init) +- `tokenizer_name_or_path`: Tokenizer for initializing from text + +### Prompt Tuning vs LoRA + +| Feature | Prompt Tuning | LoRA | +|---------|---------------|------| +| **Parameters Trained** | ~0.001% | ~0.1-1% | +| **Memory Usage** | Minimal | Low | +| **Training Speed** | Fastest | Fast | +| **Model Modification** | None | Adapter layers | +| **Best For** | Large models, many tasks | General fine-tuning | +| **Learning Rate** | Higher (1e-2 to 3e-2) | Standard (1e-4 to 3e-4) | + +## Advanced PEFT Configurations + +### LoRA Configuration Parameters + +```python +from peft import LoraConfig + +peft_config = LoraConfig( + r=16, # LoRA rank + lora_alpha=32, # LoRA scaling factor + lora_dropout=0.05, # Dropout probability + bias="none", # Bias training strategy + task_type="CAUSAL_LM", # Task type + target_modules=["q_proj", "v_proj"], # Modules to apply LoRA + modules_to_save=None, # Additional modules to train +) +``` + +**Key Parameters:** +- `r`: LoRA rank (typical values: 8, 16, 32, 64). Higher rank = more parameters but potentially better performance. +- `lora_alpha`: Scaling factor (typically 2x the rank). Controls the magnitude of LoRA updates. +- `lora_dropout`: Dropout probability for LoRA layers (typical: 0.05-0.1). +- `target_modules`: Which modules to apply LoRA to. Common choices: + - `["q_proj", "v_proj"]`: Attention query and value (memory efficient) + - `["q_proj", "k_proj", "v_proj", "o_proj"]`: All attention projections + - `["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]`: All linear layers +- `modules_to_save`: Additional modules to fully train (e.g., `["embed_tokens", "lm_head"]`) + +### Target Module Selection + +You can specify which modules to apply LoRA to. Common patterns: + +```python +# Minimal (most memory efficient) +target_modules=["q_proj", "v_proj"] + +# Attention only +target_modules=["q_proj", "k_proj", "v_proj", "o_proj"] + +# All linear layers (best performance, more memory) +target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"] +``` + +### Using Command-Line Arguments + +TRL scripts accept PEFT parameters via command line: + +```bash +python trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --lora_dropout 0.05 \ + --lora_target_modules q_proj v_proj \ + --output_dir output +``` + +Available flags: +- `--use_peft`: Enable PEFT +- `--lora_r`: LoRA rank (default: 16) +- `--lora_alpha`: LoRA alpha (default: 32) +- `--lora_dropout`: LoRA dropout (default: 0.05) +- `--lora_target_modules`: Target modules (space-separated) +- `--lora_modules_to_save`: Additional modules to train +- `--use_rslora`: Enable Rank-Stabilized LoRA +- `--use_dora`: Enable Weight-Decomposed LoRA (DoRA) +- `--load_in_4bit`: Enable 4-bit quantization (QLoRA) +- `--load_in_8bit`: Enable 8-bit quantization + +## Saving and Loading PEFT Models + +### Saving + +After training, save your PEFT adapters: + +```python +# Save the adapters +trainer.save_model("path/to/adapters") + +# Or manually +model.save_pretrained("path/to/adapters") +``` + +This saves only the adapter weights (~few MB) rather than the full model (~several GB). + +### Loading + +Load a PEFT model for inference: + +```python +from transformers import AutoModelForCausalLM +from peft import PeftModel + +# Load base model +base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B") + +# Load PEFT adapters +model = PeftModel.from_pretrained(base_model, "path/to/adapters") + +# Optionally merge adapters into base model for faster inference +model = model.merge_and_unload() +``` + +### Pushing to Hub + +You can easily share your PEFT adapters on the Hugging Face Hub: + +```python +# Push adapters to Hub +model.push_to_hub("username/model-name-lora") + +# Load from Hub +from peft import PeftModel +model = PeftModel.from_pretrained(base_model, "username/model-name-lora") +``` + +## Multi-GPU Training + +PEFT works seamlessly with TRL's multi-GPU support through `accelerate`: + +```bash +# Configure accelerate +accelerate config + +# Launch training +accelerate launch trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 +``` + +For QLoRA with multiple GPUs, the base model is automatically sharded: + +```bash +accelerate launch trl/scripts/sft.py \ + --model_name_or_path meta-llama/Llama-2-70b-hf \ + --load_in_4bit \ + --use_peft \ + --lora_r 32 +``` + +### Naive Pipeline Parallelism (NPP) for Large Models + +For very large models (>60B parameters), TRL supports Naive Pipeline Parallelism (NPP), which distributes the model and adapters across multiple GPUs. The activations and gradients are communicated across GPUs, supporting both `int8` and other data types. + +![NPP](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl-npp.png) + +**How to Use NPP** + +Load your model with a custom `device_map` to split it across multiple devices: + +```python +from transformers import AutoModelForCausalLM +from peft import LoraConfig + +# Create custom device map (see accelerate documentation) +device_map = { + "model.embed_tokens": 0, + "model.layers.0": 0, + # ... distribute layers across GPUs + "lm_head": 0, # Must be on GPU 0 +} + +model = AutoModelForCausalLM.from_pretrained( + "meta-llama/Llama-2-70b-hf", + device_map=device_map, + peft_config=lora_config, +) +``` + +> [!IMPORTANT] +> - Keep the `lm_head` module on the first GPU (device 0) to avoid errors +> - See this [tutorial on device maps](https://github.com/huggingface/blog/blob/main/accelerate-large-models.md) for proper configuration +> - Run training scripts directly (not with `accelerate launch`): `python script.py` +> - Data Parallelism is not yet supported with NPP + +## Resources + +### TRL Examples and Notebooks + +- **[SFT with LoRA/QLoRA Notebook](https://github.com/huggingface/trl/blob/main/examples/notebooks/sft_trl_lora_qlora.ipynb)** - Complete working example showing both LoRA and QLoRA implementations +- **[TRL Examples Directory](https://github.com/huggingface/trl/tree/main/examples)** - Collection of training scripts demonstrating PEFT with different trainers +- **[TRL Cookbook Recipes](https://github.com/huggingface/cookbook/tree/main/notebooks/transformers)** - Step-by-step guides for common PEFT training scenarios + +### Documentation + +- [PEFT Documentation](https://huggingface.co/docs/peft) - Official PEFT library documentation +- [TRL Documentation](https://huggingface.co/docs/trl) - Complete TRL documentation with trainer guides +- [LoRA Without Regret](lora_without_regret) - Best practices for using LoRA effectively + +### Research Papers + +- [LoRA Paper](https://huggingface.co/papers/2106.09685) - Original LoRA methodology and results +- [QLoRA Paper](https://huggingface.co/papers/2305.14314) - Efficient finetuning with 4-bit quantization +- [Prompt Tuning Paper](https://huggingface.co/papers/2104.08691) - The Power of Scale for Parameter-Efficient Prompt Tuning diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ppo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ppo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..1375575058bf295836cb48c39e91c7b7d6339b05 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ppo_trainer.md @@ -0,0 +1,252 @@ +# PPO Trainer + +[![model badge](https://img.shields.io/badge/All_models-PPO-blue)](https://huggingface.co/models?other=ppo,trl) + +TRL supports training LLMs with [Proximal Policy Optimization (PPO)](https://huggingface.co/papers/1707.06347). + +References: + +- [Fine-Tuning Language Models from Human Preferences](https://github.com/openai/lm-human-preferences) +- [Learning to Summarize from Human Feedback](https://github.com/openai/summarize-from-feedback) +- [The N Implementation Details of RLHF with PPO](https://huggingface.co/blog/the_n_implementation_details_of_rlhf_with_ppo) +- [The N+ Implementation Details of RLHF with PPO: A Case Study on TL;DR Summarization](https://huggingface.co/papers/2403.17031) + +## Get started + +To just run a PPO script to make sure the trainer can run, you can run the following command to train a PPO model with a dummy reward model. + +```bash +python examples/scripts/ppo/ppo.py \ + --dataset_name trl-internal-testing/descriptiveness-sentiment-trl-style \ + --dataset_train_split descriptiveness \ + --learning_rate 3e-6 \ + --num_ppo_epochs 1 \ + --num_mini_batches 1 \ + --output_dir models/minimal/ppo \ + --per_device_train_batch_size 64 \ + --gradient_accumulation_steps 1 \ + --total_episodes 10000 \ + --model_name_or_path EleutherAI/pythia-1b-deduped \ + --sft_model_path EleutherAI/pythia-1b-deduped \ + --reward_model_path EleutherAI/pythia-1b-deduped \ + --missing_eos_penalty 1.0 +``` + +## Explanation of the logged metrics + +The logged metrics are as follows. Here is an example [tracked run at Weights and Biases](https://wandb.ai/huggingface/trl/runs/dd2o3g35) + +- `eps`: Tracks the number of episodes per second. +- `objective/kl`: The mean Kullback-Leibler (KL) divergence between the current policy and reference policy. +- `objective/entropy`: The mean entropy of the policy, indicating the randomness of the actions chosen by the policy. +- `objective/non_score_reward`: The mean reward from non-score-related sources, basically `beta * kl.sum(1)`, where `beta` is the KL penalty coefficient and `kl` is the per-token KL divergence. +- `objective/rlhf_reward`: The mean RLHF reward, which is `score - non_score_reward`. +- `objective/scores`: The mean scores returned by the reward model / environment. +- `policy/approxkl_avg`: The average approximate KL divergence between consecutive PPO policies. Note that this is not the same as `objective/kl`. +- `policy/clipfrac_avg`: The average fraction of policy updates that are clipped, indicating how often the policy updates are constrained to prevent large changes. +- `loss/policy_avg`: The average policy loss, indicating how well the policy is performing. +- `loss/value_avg`: The average value loss, indicating the difference between the predicted value and the actual reward. +- `val/clipfrac_avg`: The average fraction of value function updates that are clipped, similar to policy/clipfrac_avg but for the value function. +- `policy/entropy_avg`: The average entropy of the policy during training, indicating how diverse the policy's actions are. +- `val/ratio`: The mean ratio of the current policy probability to the old policy probability, providing a measure of how much the policy has changed. +- `val/ratio_var`: The variance of the `val/ratio`, indicating the variability in policy changes. +- `val/num_eos_tokens`: The number of end-of-sequence (EOS) tokens generated, which can indicate the number of complete responses. +- `lr`: lr: The current learning rate used by the optimizer. +- `episode`: episode: The current episode count in the training process. + +## Cookbook + +- Debugging TIP: `objective/rlhf_reward`: this is the ultimate objective of the RLHF training. If training works as intended, this metric should keep going up. +- Debugging TIP: `val/ratio`: this number should float around 1.0, and it gets clipped by `--cliprange 0.2` with PPO's surrogate loss. So if this `ratio` is too high like 2.0 or 1000.0 or too small like 0.1, it means the updates between consecutive policies are too drastic. You should try understand why this is happening and try to fix it. +- Memory TIP: If you are running out of memory, you can try to reduce the `--per_device_train_batch_size` or increase the `--gradient_accumulation_steps` to reduce the memory footprint. +- Memory TIP: If you have multiple GPUs, you can also run training with DeepSpeed stage 3 to reduce the memory footprint `accelerate launch --config_file examples/accelerate_configs/deepspeed_zero3.yaml`. +- Usage TIP: We recommend to use the "EOS trick" via `--missing_eos_penalty`, which subtracts a static scalar penalty from the score of completions that do not end with an EOS token. This can help the model learn to generate more coherent completions. + +## What is my model doing exactly? + +To help you understand what your model is doing, we periodically log some sample completions from the model. Here is an example of a completion. In an example [tracked run at Weights and Biases](https://wandb.ai/huggingface/trl/runs/dd2o3g35), it looks like the following, allowing you to see the model's response at different stages of training. By default we generate `--num_sample_generations 10` during training, but you can customize the number of generations. + +![ppov2_completions](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/ppov2_completions.gif) + +In the logs the sampled generations look like + +```txt +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓ +┃ query ┃ model response ┃ score ┃ +┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩ +│ SUBREDDIT: r/AskReddit │ I'm in love with a friend, and │ 3.921875 │ +│ │ I don't know how to get rid of │ │ +│ TITLE: How do you get someone │ those feelings. I'm │ │ +│ out of your head? │ desperate.<|endoftext|>[PAD][P… │ │ +│ │ │ │ +│ POST: Hi, │ │ │ +│ I'm 22, and I have been with my │ │ │ +│ girlfriend for 5 years now. We │ │ │ +│ recently moved together. We've │ │ │ +│ always loved each other │ │ │ +│ intensely. │ │ │ +│ │ │ │ +│ Problem, I recently started to │ │ │ +│ have feelings for an other │ │ │ +│ person (a friend). This person │ │ │ +│ has had a boyfriend for now 3 │ │ │ +│ years, and has absolutely no │ │ │ +│ ideas. Those feelings were so │ │ │ +│ strong, it was hard to hide │ │ │ +│ them. After 2 months of me │ │ │ +│ being distant and really sad, │ │ │ +│ my girlfriend forced me to say │ │ │ +│ what was bothering me. I'm not │ │ │ +│ a good liar, and now she knows. │ │ │ +│ │ │ │ +│ We decided to give us a week │ │ │ +│ alone, I went to my parents. │ │ │ +│ │ │ │ +│ Now, I'm completely lost. I │ │ │ +│ keep on thinking about this │ │ │ +│ person, and I hate that. I │ │ │ +│ would like for those feelings │ │ │ +│ to go away, to leave me alone. │ │ │ +│ But I can't. │ │ │ +│ │ │ │ +│ What do I do? It's been 3 │ │ │ +│ months now, and I'm just │ │ │ +│ desperate. │ │ │ +│ │ │ │ +│ TL;DR: │ │ │ +├─────────────────────────────────┼─────────────────────────────────┼──────────┤ +│ SUBREDDIT: r/pettyrevenge │ My mom woke me up with a loud │ 6.84375 │ +│ │ TV. I blasted Gangnam Style on │ │ +│ TITLE: So, my mom woke me up │ repeat, with the bass cranked │ │ +│ with a loud TV. │ up as high as it could │ │ +│ │ go.<|endoftext|>[PAD][PAD][PAD… │ │ +│ POST: She was in her living │ │ │ +│ room, watching TV. This was at │ │ │ +│ about 8:30 in the morning, and │ │ │ +│ she was exercising. She turned │ │ │ +│ the TV up extra loud to hear it │ │ │ +│ over her excercycle, and woke │ │ │ +│ me up. I went in there asking │ │ │ +│ for her to turn it down. She │ │ │ +│ said she didn't have to; I │ │ │ +│ explained that I always used │ │ │ +│ headphones so she didn't have │ │ │ +│ to deal with my noise and that │ │ │ +│ she should give me a little │ │ │ +│ more respect, given that I paid │ │ │ +│ rent at the time. │ │ │ +│ │ │ │ +│ She disagreed. I went back to │ │ │ +│ my room, rather pissed off at │ │ │ +│ the lack of equality. I had no │ │ │ +│ lock on my door; but I had a │ │ │ +│ dresser right next to it, so I │ │ │ +│ pulled one of the drawers out │ │ │ +│ enough so that it caused the │ │ │ +│ door to not be openable. Then, │ │ │ +│ I turned my speakers up really │ │ │ +│ loud and blasted Gangnam Style │ │ │ +│ on repeat, with the bass │ │ │ +│ cranked up as high as it could │ │ │ +│ go. │ │ │ +│ │ │ │ +│ If you hate Gangnam Style for │ │ │ +│ being overplayed, you will see │ │ │ +│ why I chose that particular │ │ │ +│ song. I personally don't mind │ │ │ +│ it. But here's the thing about │ │ │ +│ my bass; it vibrates the walls, │ │ │ +│ making one hell of a lot of │ │ │ +│ noise. Needless to say, my mom │ │ │ +│ was not pleased and shut off │ │ │ +│ the internet. But it was oh so │ │ │ +│ worth it. │ │ │ +│ │ │ │ +│ TL;DR: │ │ │ +└─────────────────────────────────┴─────────────────────────────────┴──────────┘ +``` + +## Implementation details + +This PPO implementation is based on the [The N+ Implementation Details of RLHF with PPO: A Case Study on TL;DR Summarization](https://huggingface.co/papers/2403.17031). + +## Benchmark experiments + +To validate the PPO implementation works, we ran experiment on the 1B model. Here are the command we used to run the experiment. We take the SFT / RM models directly from [The N+ Implementation Details of RLHF with PPO: A Case Study on TL;DR Summarization](https://huggingface.co/papers/2403.17031). + +```shell +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero2.yaml \ + examples/scripts/ppo/ppo_tldr.py \ + --dataset_name trl-lib/tldr \ + --dataset_test_split validation \ + --output_dir models/minimal/ppo_tldr \ + --learning_rate 3e-6 \ + --per_device_train_batch_size 16 \ + --gradient_accumulation_steps 4 \ + --total_episodes 1000000 \ + --model_name_or_path EleutherAI/pythia-1b-deduped \ + --sft_model_path cleanrl/EleutherAI_pythia-1b-deduped__sft__tldr \ + --reward_model_path cleanrl/EleutherAI_pythia-1b-deduped__reward__tldr \ + --local_rollout_forward_batch_size 16 \ + --missing_eos_penalty 1.0 \ + --stop_token eos \ + --eval_strategy steps \ + --eval_steps 100 +``` + +Checkpoints and experiment tracking are available at: + +- [🤗 Model checkpoint](https://huggingface.co/trl-lib/ppo_tldr) +- [🐝 Tracked experiment](https://wandb.ai/huggingface/trl/runs/dd2o3g35) + +The PPO checkpoint gets a 64.7% preferred rate vs the 33.0% preference rate of the SFT checkpoint (evaluated with GPT-4o mini as a judge). This is a good sign that the PPO training is working as intended. + +Metrics: + +![PPO v2](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/ppov2.png) + +```bash +# pip install openrlbenchmark==0.2.1a5 +# see https://github.com/openrlbenchmark/openrlbenchmark#get-started for documentation +# to use it, change `?we=huggingface&wpn=trl` to your own project and `?tag=pr-1540` to your own tag +python -m openrlbenchmark.rlops_multi_metrics \ + --filters '?we=huggingface&wpn=trl&xaxis=train/episode&ceik=output_dir&cen=sft_model_path&metrics=train/objective/rlhf_reward&metrics=train/objective/scores&metrics=train/objective/kl&metrics=train/objective/non_score_reward&metrics=train/objective/entropy&metrics=train/policy/approxkl_avg&metrics=train/policy/clipfrac_avg&metrics=train/loss/policy_avg&metrics=train/loss/value_avg&metrics=train/val/clipfrac_avg&metrics=train/policy/entropy_avg&metrics=train/val/ratio&metrics=train/val/ratio_var&metrics=train/val/num_eos_tokens&metrics=train/lr&metrics=train/eps' \ + "cleanrl/EleutherAI_pythia-1b-deduped__sft__tldr?tag=pr-1540" \ + --env-ids models/minimal/ppo_tldr \ + --pc.ncols 4 \ + --pc.ncols-legend 1 \ + --pc.xlabel "Episode" \ + --output-filename benchmark/trl/pr-1540/ppo \ + --scan-history +``` + +## PPOTrainer + +[[autodoc]] experimental.ppo.PPOTrainer + - train + - save_model + - push_to_hub + +## PPOConfig + +[[autodoc]] experimental.ppo.PPOConfig + +## PreTrainedModelWrapper + +[[autodoc]] experimental.ppo.PreTrainedModelWrapper + +## AutoModelForCausalLMWithValueHead + +[[autodoc]] experimental.ppo.AutoModelForCausalLMWithValueHead + - __init__ + - forward + - generate + - _init_weights + +## AutoModelForSeq2SeqLMWithValueHead + +[[autodoc]] experimental.ppo.AutoModelForSeq2SeqLMWithValueHead + - __init__ + - forward + - generate + - _init_weights diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/prm_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/prm_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..29d73e819b377661191a93e495aeeb00dcf81bba --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/prm_trainer.md @@ -0,0 +1,122 @@ +# PRM Trainer + +[![model badge](https://img.shields.io/badge/All_models-PRM-blue)](https://huggingface.co/models?other=prm,trl) + +> [!WARNING] +> PRM Trainer is an experimental API which is subject to change at any time. + +## Overview + +Process-supervised Reward Models (PRM) were proposed in [Solving math word problems with process- and outcome-based feedback](https://huggingface.co/papers/2211.14275) by Jonathan Uesato, Nate Kushman, Ramana Kumar, Francis Song, Noah Siegel, Lisa Wang, Antonia Creswell, Geoffrey Irving, and Irina Higgins. + +The abstract from the paper is the following: + +> Recent work has shown that asking language models to generate reasoning steps improves performance on many reasoning tasks. When moving beyond prompting, this raises the question of how we should supervise such models: outcome-based approaches which supervise the final result, or process-based approaches which supervise the reasoning process itself? Differences between these approaches might naturally be expected not just in final-answer errors but also in reasoning errors, which can be difficult to detect and are problematic in many real-world domains such as education. We run the first comprehensive comparison between process- and outcome-based approaches trained on a natural language task, GSM8K. We find that pure outcome-based supervision produces similar final-answer error rates with less label supervision. However, for correct reasoning steps we find it necessary to use processbased supervision or supervision from learned reward models that emulate process-based feedback. In total, we improve the previous best results from 16.8% → 12.7% final-answer error and 14.0% → 3.4% reasoning error among final-answer-correct solutions. + +This post-training method was contributed by [Gaetan Lopez](https://github.com/gaetanlop), [Lewis Tunstall](https://huggingface.co/lewtun), [Quentin Gallouédec](https://huggingface.co/qgallouedec) and [Agustín Piqueres](https://huggingface.co/plaguss). + +## Quick start + +This example demonstrates how to train a model using the PRM method. We use the [Qwen 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B) as the base model. We use the stepwise supervision data from the [Math Shepherd dataset](https://huggingface.co/datasets/trl-lib/math_shepherd). You can view the data in the dataset here: + + + +Below is the script to train the model: + +```python +# train_prm.py +from datasets import load_dataset +from trl.experimental.prm import PRMConfig, PRMTrainer +from transformers import AutoModelForTokenClassification, AutoTokenizer + +model = AutoModelForTokenClassification.from_pretrained("Qwen/Qwen2-0.5B", num_labels=2) +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B") +train_dataset = load_dataset("trl-lib/math_shepherd", split="train[:10%]") + +training_args = PRMConfig(output_dir="Qwen2-0.5B-Reward-Math-Sheperd") +trainer = PRMTrainer(model=model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_prm.py +``` + +Distributed across 8 GPUs, the training takes approximately 1 hour. + +To see how the [trained model](https://huggingface.co/trl-lib/Qwen2-0.5B-Reward-Math-Sheperd) performs, you can use the following script. + +```python +from datasets import load_dataset +from transformers import pipeline + +pipe = pipeline("token-classification", model="trl-lib/Qwen2-0.5B-Reward-Math-Sheperd") +dataset = load_dataset("trl-lib/math_shepherd") +example = { + "prompt": "Musa is the class teacher of a class of 45 students. He wants to split them into three groups by age. If a third of the class is under 11 years, and two-fifths are above 11 but under 13, how many students will be in the third group (13 years and above)?", + "completions": [ + "Step 1: A third of the class is under 11 years because 11 - 1/3 = <<11-1/3=7>>7.", + "Step 2: Two-fifths of the class are above 11 but under 13 because 2/5 * 11 = <<2/5*11=8>>8.", + "Step 3: There are 45 students, so the third group will have 45 - 7 - 8 = <<45-7-8=20>>20 students. The answer is: 20", + ], + "labels": [True, False, False], +} + + +separator = "\n" # It's important to use the same separator as the one used during training + +for idx in range(1, len(example["completions"]) + 1): + steps = example["completions"][0:idx] + text = separator.join((example["prompt"], *steps)) + separator # Add a separator between the prompt and each steps + pred_entity = pipe(text)[-1]["entity"] + pred = {"LABEL_0": False, "LABEL_1": True}[pred_entity] + label = example["labels"][idx - 1] + print(f"Step {idx}\tPredicted: {pred} \tLabel: {label}") +``` + +```text +Step 1 Predicted: True Label: True +Step 2 Predicted: False Label: False +Step 3 Predicted: False Label: False +``` + +It's a win! + +## Expected dataset type + +PRM requires a [stepwise supervision](dataset_formats#stepwise-supervision). +The dataset should contain the following columns: `prompt`, `completions` and `labels`, where `completions` contains a list of reasoning steps and `labels` a list of booleans or floats indicating the correctness of each step. + +The [`experimental.prm.PRMTrainer`] only supports [standard](dataset_formats#standard) dataset format. + +## Example script + +We provide an example script to train a model using the PRM method. The script is available in [`examples/scripts/prm.py`](https://github.com/huggingface/trl/blob/main/examples/scripts/prm.py) + +To use the PRM script with the [Qwen2 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B) on the [Math Shepherd dataset](https://huggingface.co/datasets/trl-lib/math_shepherd), run the following command: + +```bash +accelerate launch examples/scripts/prm.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/math_shepherd \ + --num_train_epochs 1 \ + --output_dir Qwen2-0.5B-Reward-Math-Sheperd +``` + +## PRMTrainer + +[[autodoc]] experimental.prm.PRMTrainer + - train + - save_model + - push_to_hub + +## PRMConfig + +[[autodoc]] experimental.prm.PRMConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ptt_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ptt_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..3148215c14ec11801d63acd3e73dd175a3657b7a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ptt_integration.md @@ -0,0 +1,193 @@ +# Post-Training Toolkit Integration + +[Post-Training Toolkit](https://github.com/microsoft/post-training-toolkit) is a diagnostic and observability layer for RLHF training runs. Add one callback to any TRL trainer and get **auto-metrics**, **crash postmortems**, and **literature-backed heuristics**—without writing glue code. + +It was built to operationalize the debugging patterns we found most useful when running post-training at scale. + +## Usage + +1. First, install Post-Training Toolkit: + +```bash +pip install post-training-toolkit +``` + +2. Add one callback to your trainer. That's it! + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl import DPOTrainer + +trainer = DPOTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl.experimental.ppo import PPOTrainer + +trainer = PPOTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl import SFTTrainer + +trainer = SFTTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl.experimental.orpo import ORPOTrainer + +trainer = ORPOTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl import KTOTrainer + +trainer = KTOTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl.experimental.cpo import CPOTrainer + +trainer = CPOTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +```python +from post_training_toolkit import DiagnosticsCallback +from trl import GRPOTrainer + +trainer = GRPOTrainer( + model=model, + args=training_args, + callbacks=[DiagnosticsCallback()], # ← Just add this + ... +) +trainer.train() +``` + + + + +## What You Get + +**Example output:** +```text +[HIGH] DPO loss stuck at ~0.693 (random chance). Model may not be learning preferences. + Ref: Rafailov et al. (2023) 'DPO', Section 4.2 + +[RECOMMENDED] Increase learning rate 2-5x, check data quality, or reduce beta. +``` + +## Example Demo + +See a full working example with auto-stop in action: + +📂 **[demo/live_demo.ipynb](https://github.com/microsoft/post-training-toolkit/blob/main/demo/notebooks/demo_live_output.ipynb)** + +📂 **[demo/scripts/custom_heuristic.py](https://github.com/microsoft/post-training-toolkit/blob/main/demo/scripts/custom_heuristic_demo.py)** + + +### 1. Auto-Metrics +The callback automatically captures algorithm-specific metrics, backed by the latest research and industry push: + +| Trainer | Key Metrics Captured | +|---------|---------------------| +| **DPO** | loss, win_rate, reward_margin, logps_chosen/rejected | +| **PPO** | policy_loss, value_loss, entropy, clip_fraction, KL | +| **GRPO** | group rewards, advantages, policy loss, KL | +| **SFT** | loss, perplexity, accuracy | +| **ORPO** | sft_loss, odds_ratio_loss, log_odds_ratio | +| **KTO** | kl, logps for desirable/undesirable | + + +### 2. Crash Postmortems +If training crashes or gets interrupted, you get a `postmortem.json` with full context: + +```json +{ + "exit_reason": "exception", + "last_step": 847, + "timestamp": "2025-12-17T19:26:04Z", + "final_metrics": {"dpo_loss": 0.693, "win_rate": 0.52} +} +``` + +No more "what step did it die on?" + +### 3. Auto-Stop on Critical Issues + +Enable automatic training termination when critical issues are detected: + +```python +callback = DiagnosticsCallback(stop_on_critical=True) +``` + +## Distributed Training +Works automatically with multi-GPU setups. Zero configuration needed: + +```bash +accelerate launch --num_processes 8 train.py +``` + +Automatically detects stragglers, aggregates metrics across ranks, and tracks memory balance. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/quickstart.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/quickstart.md new file mode 100644 index 0000000000000000000000000000000000000000..bade9aa66a08d63e497a2c72e56ec86331c0ab2d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/quickstart.md @@ -0,0 +1,139 @@ +# Quickstart + +TRL is a comprehensive library for post-training foundation models using techniques like Supervised Fine-Tuning (SFT), Group Relative Policy Optimization (GRPO), Direct Preference Optimization (DPO). + +## Quick Examples + +Get started instantly with TRL's most popular trainers. Each example uses compact models for quick experimentation. + +### Supervised Fine-Tuning + +```python +from trl import SFTTrainer +from datasets import load_dataset + +trainer = SFTTrainer( + model="Qwen/Qwen2.5-0.5B", + train_dataset=load_dataset("trl-lib/Capybara", split="train"), +) +trainer.train() +``` + +### Group Relative Policy Optimization + +```python +from trl import GRPOTrainer +from datasets import load_dataset +from trl.rewards import accuracy_reward + +trainer = GRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + train_dataset=load_dataset("trl-lib/DeepMath-103K", split="train"), + reward_funcs=accuracy_reward, +) +trainer.train() +``` + +### Direct Preference Optimization + +```python +from trl import DPOTrainer +from datasets import load_dataset + +trainer = DPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + train_dataset=load_dataset("trl-lib/ultrafeedback_binarized", split="train"), +) +trainer.train() +``` + +### Reward Modeling + +```python +from trl import RewardTrainer +from datasets import load_dataset + +dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train") + +trainer = RewardTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + train_dataset=dataset, +) +trainer.train() +``` + +## Command Line Interface + +Skip the code entirely - train directly from your terminal: + +```bash +# SFT: Fine-tune on instructions +trl sft --model_name_or_path Qwen/Qwen2.5-0.5B \ + --dataset_name trl-lib/Capybara + +# DPO: Align with preferences +trl dpo --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized + +# Reward: Train a reward model +trl reward --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized +``` + +## What's Next? + +### 📚 Learn More + +- [SFT Trainer](sft_trainer) - Complete SFT guide +- [DPO Trainer](dpo_trainer) - Preference alignment +- [GRPO Trainer](grpo_trainer) - Group relative policy optimization + +### 🚀 Scale Up + +- [Distributed Training](distributing_training) - Multi-GPU setups +- [Memory Optimization](reducing_memory_usage) - Efficient training +- [PEFT Integration](peft_integration) - LoRA and QLoRA + +### 💡 Examples + +- [Example Scripts](https://github.com/huggingface/trl/tree/main/examples) - Production-ready code +- [Community Tutorials](community_tutorials) - External guides + +## Troubleshooting + +### Out of Memory? + +Reduce batch size and enable optimizations: + + + + +```python +training_args = SFTConfig( + per_device_train_batch_size=1, # Start small + gradient_accumulation_steps=8, # Maintain effective batch size +) +``` + + + + +```python +training_args = DPOConfig( + per_device_train_batch_size=1, # Start small + gradient_accumulation_steps=8, # Maintain effective batch size +) +``` + + + + +### Loss not decreasing? + +Try adjusting the learning rate: + +```python +training_args = SFTConfig(learning_rate=2e-5) # Good starting point +``` + +For more help, open an [issue on GitHub](https://github.com/huggingface/trl/issues). diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rapidfire_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rapidfire_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..cdbab5bc8e46b98c75f5760d72daab34baa89fd6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rapidfire_integration.md @@ -0,0 +1,473 @@ +# RapidFire AI Integration + +RapidFire AI is an open-source experiment execution framework that integrates with TRL to turn "train one configuration at a time" into **real-time, side-by-side comparison of many configurations on the same GPU(s)** — so you can iterate on hyperparameters, LoRA settings, prompt schemes, and ablations **16–24× faster with no extra hardware**. + +Links: [GitHub](https://github.com/RapidFireAI/rapidfireai) · [Docs](https://oss-docs.rapidfire.ai) · [Try in Colab](http://tinyurl.com/rapidfireai-colab) + +## Why use RapidFire AI with TRL? + +When fine-tuning or post-training with TRL, you typically need to: + +- Try different hyperparameter configurations +- Compare different LoRA settings +- Test different prompt schemes +- Run ablation studies + +| Scenario: comparing N training configs on the same GPU(s) | TRL alone | TRL + RapidFire AI | +| --- | --- | --- | +| Training strategy | Run N configs sequentially | Run N configs concurrently | +| When can you compare configs? | After all runs finish | Live, from the first chunk | +| Stop losers / clone winners mid-training | No | Yes (Interactive Control Operations) | + +### How It Works + +RapidFire AI employs **adaptive chunk-based scheduling**: + +``` +GPU Timeline (Single GPU): +Chunk 1: [Config A] → [Config B] → [Config C] → [Config D] +Chunk 2: [Config A] → [Config B] → [Config C] → [Config D] +Chunk 3: [Config A] → [Config B] → [Config C] → [Config D] +``` + +This enables: + +- Early comparison of configurations on same data subsets incrementally +- Efficient GPU utilization and minimizing idle times +- Real-time and automated experiment metrics tracking +- Dynamic control over runs in flight to incentivize more experimentation + +## Key Features + +- **16-24× higher experimentation throughput** compared to sequential training. +- **Almost no code changes** - simple drop-in config APIs that just wrap around existing TRL and PEFT config APIs. +- **Interactive Control Operations** - real-time control to stop, resume, and clone-modify (with or without warm starting) training runs in flight. +- **Integration with Fully Sharded Data Parallel (FSDP)** for training large models that do not fit on a single GPU by sharding parameters, gradients, and optimizer states across multiple GPUs. +- **Full compatibility** with transformers, PEFT, SFTTrainer, DPOTrainer, and GRPOTrainer. +- **Pluggable experiment tracking**: MLflow (default), TensorBoard, and Trackio, enabled individually or in combination. +- **Zero-setup Google Colab support**: one-click tutorial notebooks for SFT, DPO, and GRPO on free T4 GPUs. +- **Production-Ready**: Already used in production environments with complete working examples. + +## Installation + +### Prerequisites + +- Python 3.12.x +- NVIDIA GPU with Compute Capability 7.x or 8.x (multiple GPUs required for FSDP) +- CUDA Toolkit 11.8+ +- PyTorch 2.8+ + +### pip install + +```bash +pip install rapidfireai +``` + +Once installed, authenticate with Hugging Face and initialize RapidFire AI: + +```bash +# Authenticate with Hugging Face +hf auth login --token YOUR_TOKEN + +# Workaround for current issue: https://github.com/huggingface/xet-core/issues/527 +pip uninstall -y hf-xet + +# Initialize RapidFire AI +rapidfireai init + +# Start the RapidFire AI server +rapidfireai start +``` + +The dashboard will be available at `http://localhost:8853` where you can monitor and control experiments in real-time. + +## Quick Start: SFT Training with Multiple Configs + +Here's a complete example showing how to train multiple SFT configurations concurrently: + +```python +from rapidfireai import Experiment +from rapidfireai.automl import List, RFGridSearch, RFModelConfig, RFLoraConfig, RFSFTConfig +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer + +# Load dataset +dataset = load_dataset("bitext/Bitext-customer-support-llm-chatbot-training-dataset") +train_dataset = dataset["train"].select(range(128)).shuffle(seed=42) +eval_dataset = dataset["train"].select(range(100, 124)).shuffle(seed=42) + +# Define data formatting function +def formatting_function(row): + return { + "prompt": [ + {"role": "system", "content": "You are a helpful customer support assistant."}, + {"role": "user", "content": row["instruction"]}, + ], + "completion": [ + {"role": "assistant", "content": row["response"]} + ] + } + +# Initialize experiment +experiment = Experiment(experiment_name="sft-customer-support") + +# Define multiple LoRA configurations to compare +peft_configs = List([ + RFLoraConfig(r=8, lora_alpha=16, lora_dropout=0.1, + target_modules=["q_proj", "v_proj"], bias="none"), + RFLoraConfig(r=32, lora_alpha=64, lora_dropout=0.1, + target_modules=["q_proj", "k_proj", "v_proj", "o_proj"], bias="none") +]) + +# Define multiple training configurations +# 2 base configs × 2 PEFT configs = 4 total training runs +config_set = List([ + RFModelConfig( + model_name="TinyLlama/TinyLlama-1.1B-Chat-v1.0", + peft_config=peft_configs, + training_args=RFSFTConfig( # Wraps TRL's SFTConfig + learning_rate=1e-3, + per_device_train_batch_size=4, + max_steps=128, + fp16=True, + ), + model_type="causal_lm", + model_kwargs={"device_map": "auto", "torch_dtype": "auto", "use_cache": False}, + formatting_func=formatting_function, + ), + RFModelConfig( + model_name="TinyLlama/TinyLlama-1.1B-Chat-v1.0", + peft_config=peft_configs, + training_args=RFSFTConfig( + learning_rate=1e-4, # Different learning rate + per_device_train_batch_size=4, + max_steps=128, + fp16=True, + ), + model_type="causal_lm", + model_kwargs={"device_map": "auto", "torch_dtype": "auto", "use_cache": False}, + formatting_func=formatting_function, + ) +]) + +# Define model creation function +def create_model(model_config): + model = AutoModelForCausalLM.from_pretrained( + model_config["model_name"], + **model_config["model_kwargs"] + ) + tokenizer = AutoTokenizer.from_pretrained(model_config["model_name"]) + return (model, tokenizer) + +# Create grid search over all configurations +config_group = RFGridSearch(configs=config_set, trainer_type="SFT") + +# Run all 4 configurations concurrently with chunk-based scheduling +experiment.run_fit(config_group, create_model, train_dataset, eval_dataset, + num_chunks=4, seed=42) + +# End experiment +experiment.end() +``` + +### What Happens During Execution + +When you run this example: + +1. **Config Expansion**: 2 base configurations × 2 PEFT configs = 4 total training runs +2. **Chunk-based Scheduling**: Training data is divided into chunks, and all 4 configs train concurrently +3. **GPU Swapping**: Models are swapped in/out of GPU memory based on chunk boundaries +4. **Real-time Tracking**: All metrics visible in the dashboard at `http://localhost:8853` +5. **Interactive Control**: Stop, resume, or clone-modify any configuration from the dashboard + +This delivers **16-24× higher throughput** compared to training each configuration sequentially! + +## Supported TRL Trainers + +### SFTTrainer + +Use `RFSFTConfig` as a drop-in replacement for `SFTConfig`: + +```python +from rapidfireai.automl import RFSFTConfig + +training_args = RFSFTConfig( + learning_rate=5e-5, + per_device_train_batch_size=4, + num_train_epochs=3, + max_length = 512, + # ... all other SFTConfig parameters supported +) +``` + +**Example Notebook**: [SFT for Customer Support](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/rf-tutorial-sft-chatqa-lite.ipynb) + +### DPOTrainer + +Use `RFDPOConfig` as a drop-in replacement for `DPOConfig`: + +```python +from rapidfireai.automl import RFDPOConfig + +training_args = RFDPOConfig( + beta=0.1, + loss_type="sigmoid", + max_length=1024, + learning_rate=5e-4, + # ... all other DPOConfig parameters supported +) +``` + +**Example Notebook**: [DPO for Preference Alignment](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/post-training/rf-tutorial-dpo-alignment-lite.ipynb) + +### GRPOTrainer + +Use `RFGRPOConfig` as a drop-in replacement for `GRPOConfig`: + +```python +from rapidfireai.automl import RFGRPOConfig + +training_args = RFGRPOConfig( + learning_rate=5e-6, + num_generations=8, + max_completion_length=256, + # ... all other GRPOConfig parameters supported +) +``` + +**Example Notebook**: [GRPO for Math Reasoning](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/post-training/rf-tutorial-grpo-mathreasoning-lite.ipynb) + +## Core Concepts + +### Chunk-Based Concurrent Training + +RapidFire AI divides training data into chunks and alternates between configurations: + +``` +GPU Timeline (Single GPU): +Chunk 1: [Config A] → [Config B] → [Config C] → [Config D] +Chunk 2: [Config A] → [Config B] → [Config C] → [Config D] +Chunk 3: [Config A] → [Config B] → [Config C] → [Config D] +... +``` + +This approach maximizes GPU utilization and enables early comparison of configurations while maintaining training stability through automatic checkpointing. + +### Interactive Control Operations (IC Ops) + +Through the RapidFire AI dashboard, you can dynamically control running experiments: + +- **Stop**: Pause a configuration (checkpointed automatically) +- **Resume**: Continue from last checkpoint +- **Clone-Modify**: Duplicate a configuration with modifications (new run starts from scratch) +- **Clone-Modify with Warm Start**: Clone-modify and initialize from the parent's weights +- **Delete**: Remove failed or unwanted runs + +This enables adaptive experimentation where you can stop underperforming configs early and clone promising ones with tweaked hyperparameters. + +### Multi-Config Experimentation + +Use `RFGridSearch` or `RFRandomSearch` to automatically generate configuration combinations: + +```python +# Grid search: tests all combinations +config_group = RFGridSearch(configs=config_list, trainer_type="SFT") + +# Random search: samples N configurations +config_group = RFRandomSearch(configs=config_list, trainer_type="DPO", num_samples=10) +``` + +## Advanced Features + +### PEFT/LoRA Integration + +Full support for parameter-efficient fine-tuning: + +```python +from rapidfireai.automl import RFLoraConfig +from peft import TaskType + +lora_config = RFLoraConfig( + task_type=TaskType.CAUSAL_LM, + r=64, + lora_alpha=64, + lora_dropout=0.1, + target_modules=["q_proj", "k_proj", "v_proj", "o_proj"], + bias="none" +) +``` + +### Custom Reward Functions (GRPO) + +Define multiple reward functions for GRPO training: + +```python +def correctness_reward(prompts, completions, answer, **kwargs): + """Reward for correct answers""" + responses = [completion[0]['content'] for completion in completions] + extracted = [extract_answer(r) for r in responses] + return [2.0 if r == a else 0.0 for r, a in zip(extracted, answer)] + +def format_reward(completions, **kwargs): + """Reward for proper formatting""" + import re + pattern = r".*?\s*.*?" + responses = [completion[0]["content"] for completion in completions] + matches = [re.match(pattern, r) for r in responses] + return [0.5 if match else 0.0 for match in matches] + +# Use in model config +config = RFModelConfig( + reward_funcs=[correctness_reward, format_reward], + # ... other parameters +) +``` + +### Multi-GPU Support + +RapidFire AI automatically detects and utilizes all available GPUs. By default, the scheduler distributes independent configurations across GPUs (data-parallel across configs), so no special setup is required to run `N` configs on `N` GPUs concurrently. + +For models that do not fit on a single GPU, RapidFire AI also supports **Fully Sharded Data Parallel (FSDP)** to shard a single configuration across multiple GPUs — see the next section. + +### Multi-GPU Training with FSDP + +When a model is too large for a single GPU, enable FSDP directly through the training args of `RFSFTConfig` or `RFDPOConfig` — the same `fsdp` and `fsdp_config` fields exposed by Hugging Face `TrainingArguments`: + +```python +from rapidfireai.automl import RFModelConfig, RFSFTConfig, RFLoraConfig + +model_config = RFModelConfig( + model_name="meta-llama/Llama-3.1-8B-Instruct", + peft_config=RFLoraConfig( + r=16, lora_alpha=32, lora_dropout=0.05, + target_modules=["q_proj", "k_proj", "v_proj", "o_proj"], + bias="none", + ), + training_args=RFSFTConfig( + learning_rate=2e-4, + per_device_train_batch_size=1, + gradient_accumulation_steps=8, + fsdp="full_shard auto_wrap", + fsdp_config={ + "sharding_strategy": "FULL_SHARD", + "auto_wrap_policy": "TRANSFORMER_BASED_WRAP", + "backward_prefetch": "backward_pre", + "forward_prefetch": True, + "use_orig_params": False, + "cpu_ram_efficient_loading": True, + "offload_params": True, + "sync_module_states": True, + "limit_all_gathers": True, + }, + ), + model_type="causal_lm", + model_kwargs={"torch_dtype": "auto"}, +) +``` + +Key points: + +- FSDP works transparently with RapidFire AI's chunk-based scheduling, IC Ops (stop / resume / clone-modify with or without warm-starting), and all supported metric tracking backends. +- FSDP is fully compatible with PEFT / LoRA — LoRA adapter weights are collected efficiently across shards when saving checkpoints. +- FSDP composes with grid search and random search: each expanded config gets its own sharded training run. + +**Example Notebooks**: +- [SFT with FSDP (lite, small model)](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/rf-tutorial-sft-chatqa-fsdp-lite.ipynb) +- [SFT with FSDP (large model)](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/rf-tutorial-sft-chatqa-fsdp-large.ipynb) +- [DPO with FSDP](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/post-training/rf-tutorial-dpo-alignment-fsdp-lite.ipynb) + +### Experiment Tracking Backends + +RapidFire AI supports three metric logging backends that can be used individually or together: **MLflow** (the default for local installs), **TensorBoard** (the default in Google Colab), and **Trackio**. + +Select one or more backends at server startup with the `--tracking-backends` flag: + +```bash +# MLflow only (default on local installs) +rapidfireai start --tracking-backends mlflow + +# TensorBoard only +rapidfireai start --tracking-backends tensorboard + +# Any combination +rapidfireai start --tracking-backends mlflow tensorboard trackio +``` + +Equivalent environment variables are also available: + +- `RF_MLFLOW_ENABLED` (default `true`, or `false` in Colab) +- `RF_TENSORBOARD_ENABLED` (default `false`, or `true` in Colab) +- `RF_TRACKIO_ENABLED` (default `false`) + +All three backends receive the same metrics (loss, evaluation scores, learning rate, etc.) and respect IC Ops run lifecycle events, so you can use, for example, Trackio for lightweight sharing alongside MLflow for a full local dashboard. + +### Running in Google Colab + +RapidFire AI runs on free Google Colab T4 GPUs, with tutorial notebooks for SFT, DPO, GRPO, and RAG / context-engineering workflows. In Colab, TensorBoard is the default tracking backend (MLflow is disabled for simplicity), and the usual `rapidfireai init` / `rapidfireai start` commands run directly from notebook cells — no terminal access required. + +Get started: [RapidFire AI in Google Colab](http://tinyurl.com/rapidfireai-colab). + +## Best Practices + +### Tuning Chunk Granularity + +The `num_chunks` parameter controls swap frequency: + +```python +# Fewer chunks = less overhead, less frequent comparison +experiment.run_fit(..., num_chunks=2) + +# More chunks = more overhead, more frequent comparison +experiment.run_fit(..., num_chunks=16) +``` + +**Rule of thumb**: Start with `num_chunks=4` and adjust based on dataset size and number of configurations. + +### Memory Management + +For large models, use quantization: + +```python +from transformers import BitsAndBytesConfig +import torch + +bnb_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_compute_dtype=torch.bfloat16, + bnb_4bit_use_double_quant=True, + bnb_4bit_quant_type="nf4", +) + +model_kwargs = { + "quantization_config": bnb_config, + "device_map": "auto", +} +``` + +## Performance Benchmarks + +Based on internal benchmarks comparing sequential vs. RapidFire AI concurrent training: + +| Scenario | Sequential Time | RapidFire AI Time | Speedup | +|----------|----------------|-------------------|---------| +| 4 configs, 1 GPU | 120 min | 7.5 min | 16× | +| 8 configs, 1 GPU | 240 min | 12 min | 20× | +| 4 configs, 2 GPUs | 60 min | 4 min | 15× | +| 8 configs, 4 GPUs | 60 min | 3 min | 20× | + +*Benchmarks performed on NVIDIA A100 40GB with TinyLlama-1.1B and Llama-3.2-1B models* + +## Troubleshooting + +For troubleshooting guidance, see the [RapidFire AI Troubleshooting Guide](https://oss-docs.rapidfire.ai/en/latest/troubleshooting.html). + +## Additional Resources +- **Colab Notebook**: [RapidFire AI in Google Colab](http://tinyurl.com/rapidfireai-colab) +- **Documentation**: [oss-docs.rapidfire.ai](https://oss-docs.rapidfire.ai) +- **GitHub**: [RapidFireAI/rapidfireai](https://github.com/RapidFireAI/rapidfireai) +- **PyPI**: [pypi.org/project/rapidfireai](https://pypi.org/project/rapidfireai/) +- **Discord**: [Join our Discord](https://discord.gg/6vSTtncKNN) +- **Tutorial Notebooks**: [GitHub Repository](https://github.com/RapidFireAI/rapidfireai/tree/main/tutorial_notebooks) + +Learn more about RapidFire AI in their [official repository](https://github.com/RapidFireAI/rapidfireai) and [documentation](https://oss-docs.rapidfire.ai). + diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/reducing_memory_usage.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/reducing_memory_usage.md new file mode 100644 index 0000000000000000000000000000000000000000..c351c1d826d56d6c000be9d128f4ec1d971b31de --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/reducing_memory_usage.md @@ -0,0 +1,360 @@ +# Reducing Memory Usage + +Training workflows can often be optimized to **reduce memory consumption**, and TRL provides several built-in features to help achieve this. + +Below, we outline these techniques and recommend experimenting with different combinations to figure out which configuration works best for your specific setup. + +Each method includes examples for the supported trainers. If you're unsure whether a technique is compatible with your trainer, please take a look at the corresponding trainer documentation. + +For additional strategies, such as **gradient checkpointing**, which is supported across all trainers, see the [`transformers` performance guide](https://huggingface.co/docs/transformers/perf_train_gpu_one#gradient-checkpointing). + +## Truncation + +Sequence lengths in the dataset can vary widely. When data is batched, sequences are padded to match the longest one in the batch, which can cause high memory usage, even if most sequences are relatively short. + +![Truncation prompt-completion](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/why_you_should_truncate.png) + +To reduce memory usage, it's important to truncate sequences to a reasonable length. While TRL trainers truncate sequences by default, you may want to adjust the default truncation length to better align with your specific use case. + + + + +DPO truncation is controlled via `max_length`, which truncates the combined prompt+completion sequence. + +![DPO truncation](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/truncation_prompt_completion.png) + +To set the truncation parameter, use the following code snippet: + +```python +from trl import DPOConfig + +training_args = DPOConfig(..., max_length=...) +``` + +> [!WARNING] +> The legacy `max_prompt_length` and `max_completion_length` parameters are now removed; instead, filter or pre-truncate overlong prompts/completions in your dataset before training. + + + + +SFT truncation is applied to the input sequence via the `max_length` parameter. + +![Truncation input ids](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/truncation_input_ids.png) + +To set the truncation parameter, use the following code snippet: + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., max_length=...) +``` + + + + +### How to choose the `max_length` value? + +If `max_length` is too small, a significant portion of your tokens will be discarded and won't contribute to training. If it's too large, memory usage can spike, potentially leading to out-of-memory (OOM) errors. Without packing or padding-free, a large `max_length` may also result in inefficient training, as many tokens will be padding. + +To help you choose an appropriate value, we provide a utility to visualize the sequence length distribution in your dataset. + + + +## Packing + +> [!TIP] +> This technique is available only for **SFT** training and setups that use **FlashAttention** (or its variants). + +[Truncation](#truncation) has several drawbacks: + +1. **Loss of information**: Important tokens at the end of sequences may be discarded. +2. **Choosing truncation length**: Too short loses data; too long reduces efficiency. + +Packing mitigates these issues by grouping multiple sequences into the same training row, filling each row up to `max_length`. + +![Packing](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/packing_3.png) + +TRL implements packing using **Best-Fit Decreasing (BFD)** bin packing, which groups sequences efficiently while minimizing padding. When a sequence exceeds `max_length`, different strategies determine how the overflow tokens are handled. + +TRL supports three strategies: + +* `"bfd"` (default): Uses **Best-Fit Decreasing packing**. If a sequence exceeds `max_length`, the overflow tokens are discarded. + +* `"bfd_split"`: Uses **Best-Fit Decreasing packing**, but long sequences are split into chunks ≤ `max_length` before packing. This preserves all tokens and follows the approach proposed in [Fewer Truncations Improve Language Modeling](https://huggingface.co/papers/2404.10830). + +* `"wrapped"`: All tokens are concatenated into a stream and split into fixed-length blocks. This minimizes padding but may mix unrelated examples. This strategy corresponds to the *concatenate-then-split* preprocessing described in the literature (e.g., [Fewer Truncations Improve Language Modeling](https://huggingface.co/papers/2404.10830)). It has the downside of breaking sequence continuity for a large fraction of the dataset, which hurts performance, as discussed in the [Qwen3-Coder-Next Technical Report](https://huggingface.co/papers/2603.00729). + +> [!NOTE] +> If all sequences are shorter than `max_length`, **`bfd` and `bfd_split` behave identically**, since no truncation or splitting is required. + +```python +from trl import SFTConfig + +training_args = SFTConfig( + ..., + packing=True, + packing_strategy="bfd", + max_length=512, +) +``` + +## PEFT for parameter-efficient fine-tuning + +Parameter-Efficient Fine-Tuning (PEFT) methods like LoRA are among the most effective techniques for reducing memory usage during training. Instead of training all model parameters, PEFT methods train only a small number of adapter parameters, significantly reducing memory requirements and enabling fine-tuning of larger models on limited hardware. + +For comprehensive details on using PEFT with TRL, including various adapter methods, quantization options, and advanced configurations, see [PEFT Integration](peft_integration). + +To use PEFT for reducing memory usage: + +```python +from datasets import load_dataset +from peft import LoraConfig +from trl import SFTTrainer + +dataset = load_dataset("trl-lib/Capybara", split="train") + +peft_config = LoraConfig() + +trainer = SFTTrainer( + model="Qwen/Qwen2.5-0.5B", + train_dataset=dataset, + peft_config=peft_config, +) +``` + +PEFT can be combined with other memory reduction techniques such as quantization (4-bit or 8-bit) for even greater memory savings. See [PEFT Integration](peft_integration) for quantization examples. + +## Liger for reducing peak memory usage + +[Liger Kernel](https://github.com/linkedin/Liger-Kernel) is a collection of Triton kernels designed specifically for LLM training. It can effectively increase multi-GPU training throughput by 20% and reduce memory usage by 60%. + +For more information, see [Liger Kernel Integration](liger_kernel_integration). + +To use Liger for reducing peak memory usage, use the following code snippet: + + + + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import DPOConfig + +training_args = DPOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl.experimental.kto import KTOConfig + +training_args = KTOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl.experimental.gkd import GKDConfig + +training_args = GKDConfig(..., use_liger_kernel=True) +``` + + + + +## Chunked cross-entropy for reducing peak memory usage + +At large vocabulary sizes, the `[batch × seq_len × vocab]` logits tensor produced by the LM head is one of the dominant activations held in memory across forward and backward. `loss_type="chunked_nll"` in [`SFTTrainer`] avoids materializing it all at once: positions with `labels == -100` are dropped *before* the `lm_head` matmul, and the cross-entropy is computed in chunks of tokens using gradient checkpointing, so peak activation memory scales with `chunk_size × vocab_size` instead of `(batch × seq_len) × vocab_size`. + +Same math as the default loss — this is a memory optimization, not a new loss. + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., loss_type="chunked_nll") +``` + +Expect **typically ~30 % less peak VRAM, up to ~50 %** on large-vocab models (measured on `Qwen3-1.7B`, vocab ≈ 151k — ~30 % on single-GPU, up to ~50 % under FSDP2 × 4 GPUs) with wall time typically neutral or slightly faster. See the [PR #5575](https://github.com/huggingface/trl/pull/5575) for the full benchmark across single-GPU, DDP, FSDP2, packing, long-context, and fp32 configurations. +Under FSDP2, pass `--fsdp_reshard_after_forward false` to `accelerate launch` — the chunked path otherwise re-gathers `lm_head.weight` per chunk during backward, adding noticeable wall-time. + +Not compatible with `use_liger_kernel=True`, PEFT, or VLM. + +## Padding-free + +Padding-free batching is an alternative approach for reducing memory usage. In this method, a batch is first sampled and then flattened into a single sequence, avoiding padding. Unlike packing, which can result in incomplete sequences by combining parts of different samples, padding-free batching ensures that all sequences remain complete and intact. + +![Padding-free](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/padding-free.png) + +> [!WARNING] +> It's highly recommended to use padding-free batching with **FlashAttention 2** or **FlashAttention 3**. Otherwise, you may encounter batch contamination issues. + + + + +```python +from trl import DPOConfig + +training_args = DPOConfig(..., padding_free=True, model_init_kwargs={"attn_implementation": "kernels-community/flash-attn2"}) +``` + + + + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., padding_free=True, model_init_kwargs={"attn_implementation": "kernels-community/flash-attn2"}) +``` + + + + +## Activation offloading + +Activation offloading is a memory efficiency technique that reduces GPU VRAM usage by temporarily moving activation tensors to CPU RAM during the forward pass and bringing them back only when needed for the backward pass. This significantly reduces peak memory usage at the cost of slightly increased training time. + +To enable activation offloading in your SFT training configuration: + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., activation_offloading=True) +``` + +Under the hood, activation offloading implements PyTorch's [`saved_tensors_hooks`](https://pytorch.org/tutorials/intermediate/autograd_saved_tensors_hooks_tutorial.html#hooks-for-autograd-saved-tensors) to intercept activations during the forward pass. It intelligently manages which tensors to offload based on size and context, avoiding offloading output tensors that would be inefficient. For performance optimization, it can, via a flag (which is true by default), use CUDA streams to overlap computation with CPU-GPU transfers. + +## Padding Sequences to a Multiple + +> [!TIP] +> This technique is supported for **SFT** and **Reward** trainers currently. + +When enabled, this option ensures that all sequences are **padded to a multiple** of the specified value. +This can improve computational efficiency on some hardware by aligning sequence lengths to memory-friendly boundaries. + + + + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., pad_to_multiple_of=2048) +``` + + + + +```python +from trl import RewardConfig + +training_args = RewardConfig(..., pad_to_multiple_of=2048) +``` + + + + +## Disabling model gathering for generation in online methods + +When using DeepSpeed ZeRO-3, model weights are sharded across multiple GPUs. Online methods involve generating completions from the model as part of the training process. During this step, the model weights are temporarily gathered on a single GPU for generation. For very large models, this gathering can lead to OOM errors, as described in this issue: [#2250](https://github.com/huggingface/trl/issues/2250#issue-2598304204). + +If you encounter this issue, you can disable the gathering of model weights for generation by setting the following parameter: + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig(..., ds3_gather_for_generation=False) +``` + + + + +```python +from trl.experimental.online_dpo import OnlineDPOConfig + +training_args = OnlineDPOConfig(..., ds3_gather_for_generation=False) +``` + + + + +```python +from trl.experimental.ppo import PPOConfig + +training_args = PPOConfig(..., ds3_gather_for_generation=False) +``` + + + + +```python +from trl import RLOOConfig + +training_args = RLOOConfig(..., ds3_gather_for_generation=False) +``` + + + + +This adjustment prevents model weights from being gathered, avoiding OOM errors, but it may result in slower generation speeds. + +## vLLM sleep mode + +When using **vLLM** as the generation backend for online training methods, you can enable _sleep mode_ to offload vLLM parameters and cache to CPU RAM during the optimization step and reload them back to GPU VRAM when needed for weight synchronization and generation. + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig(..., vllm_enable_sleep_mode=True) +``` + + + + +```python +from trl import RLOOConfig + +training_args = RLOOConfig(..., vllm_enable_sleep_mode=True) +``` + + + + +Offloading the vLLM weights and cache helps keep GPU memory usage low, which can be particularly beneficial when training large models or using limited GPU resources. However, waking the vLLM engine from sleep mode introduces some host–device transfer latency, which may slightly impact training speed. + +## Gradient checkpointing + +Gradient checkpointing trades compute for memory by not storing all intermediate activations during the forward pass, recomputing them during the backward pass instead. + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., gradient_checkpointing=True) +``` + +> [!NOTE] +> Gradient checkpointing is enabled by default in all trainers to optimize memory usage. You can disable it by setting `gradient_checkpointing=False` if needed. + +For more memory optimization techniques, see the [Transformers Performance Guide](https://huggingface.co/docs/transformers/perf_train_gpu_one#gradient-checkpointing). diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/reward_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/reward_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..d757cef046c5c4419b4dd72fca6150e37286ddd0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/reward_trainer.md @@ -0,0 +1,234 @@ +# Reward Modeling + +[![model badge](https://img.shields.io/badge/All_models-Reward_Trainer-blue)](https://huggingface.co/models?other=reward-trainer,trl) + +## Overview + +TRL supports the Outcome-supervised Reward Modeling (ORM) Trainer for training reward models. + +This post-training method was contributed by [Younes Belkada](https://huggingface.co/ybelkada). + +## Quick start + +This example demonstrates how to train a reward model using the [`RewardTrainer`] from TRL. We train a [Qwen 3 0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) model on the [UltraFeedback dataset](https://huggingface.co/datasets/trl-lib/ultrafeedback_binarized), large-scale, fine-grained, diverse preference dataset. + +```python +from trl import RewardTrainer +from datasets import load_dataset + +trainer = RewardTrainer( + model="Qwen/Qwen3-0.6B", + train_dataset=load_dataset("trl-lib/ultrafeedback_binarized", split="train"), +) +trainer.train() +``` + + + +## Expected dataset type and format + +[`RewardTrainer`] supports [preference](dataset_formats#preference) datasets type (both implicit and explicit prompt). The [`RewardTrainer`] is compatible with both [standard](dataset_formats#standard) and [conversational](dataset_formats#conversational) dataset formats. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +```python +# Standard preference (implicit prompt) +{"chosen": "The sky is blue.", + "rejected": "The sky is green."} + +# Conversational preference (implicit prompt) +{"chosen": [{"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}], + "rejected": [{"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is green."}]} + +# Standard preference (explicit prompt) +{"prompt": "The sky is", + "chosen": " blue.", + "rejected": " green."} + +# Conversational preference (explicit prompt) +{"prompt": [{"role": "user", "content": "What color is the sky?"}], + "chosen": [{"role": "assistant", "content": "It is blue."}], + "rejected": [{"role": "assistant", "content": "It is green."}]} +``` + +If your dataset is not in one of these formats, you can preprocess it to convert it into the expected format. Here is an example with the [lmarena-ai/arena-human-preference-55k](https://huggingface.co/datasets/lmarena-ai/arena-human-preference-55k) dataset: + +```python +from datasets import load_dataset +import json + +dataset = load_dataset("lmarena-ai/arena-human-preference-55k") + +# Filter out ties +dataset = dataset.filter(lambda example: example["winner_tie"] == 0) + +# Create 'chosen' and 'rejected' fields based on the winner column +def response_a_b_to_chosen_rejected(example): + if example["winner_model_a"] == 1: + example["chosen"] = example["response_a"] + example["rejected"] = example["response_b"] + else: + example["chosen"] = example["response_b"] + example["rejected"] = example["response_a"] + return example + +dataset = dataset.map(response_a_b_to_chosen_rejected) + +# Convert to conversational format +def make_conversation(example): + prompt = json.loads(example["prompt"])[0] # '["What color is the sky?"]' -> "What color is the sky?" + chosen = json.loads(example["chosen"])[0] + rejected = json.loads(example["rejected"])[0] + return { + "chosen": [{"role": "user", "content": prompt}, {"role": "assistant", "content": chosen}], + "rejected": [{"role": "user", "content": prompt}, {"role": "assistant", "content": rejected}], + } + + +dataset = dataset.map(make_conversation) + +# Keep only necessary columns +dataset = dataset.select_columns(["chosen", "rejected"]) + +print(next(iter(dataset["train"]))) +``` + +```json +{ + "chosen": [ + {"role": "user", "content": "Is it morally right to try to have a certain percentage of females on managerial positions?"}, + {"role": "assistant", "content": "The question of whether it is morally right to aim for a certain percentage of females..."}, + ], + "rejected": [ + {"role": "user", "content": "Is it morally right to try to have a certain percentage of females on managerial positions?"}, + {"role": "assistant", "content": "As an AI, I don't have personal beliefs or opinions. However, ..."}, + ], +} +``` + +## Looking deeper into the training method + +Reward Models (RMs) are typically trained using supervised learning on datasets containing pairs of preferred and non-preferred responses. The goal is to learn a function that assigns higher scores to preferred responses, enabling the model to rank outputs based on preferences. + +This section breaks down how reward modeling works in practice, covering the key steps: **preprocessing** and **loss computation**. + +### Preprocessing and tokenization + +During training, each example is expected to contain a **chosen** and **rejected** field. For more details on the expected formats, see [Dataset formats - Preference](dataset_formats#preference). +The [`RewardTrainer`] tokenizes each input using the model's tokenizer. If prompts and completions (chosen and rejected) are provided separately (explicit prompt case), they are concatenated before tokenization. + +### Computing the loss + +Let \\( x \\) be the input sequence (prompt) and \\( y^+ \\) and \\( y^- \\) be the chosen and rejected sequences respectively. Under the Bradley-Terry model ([Bradley & Terry, 1952](https://www.jstor.org/stable/2334029)), the probability that \\( y^+ \\) is preferred over \\( y^- \\) given a reward function \\( r \\) is \\( p(y^+ ≻ y^- |x) = \sigma(r(x, y^+)−r(x, y^-)) \\), where \\( σ \\) is the sigmoid function. + +The reward model \\( r_\theta(x, y) \\) is trained to assign higher scores to preferred responses \\( y^+ \\) over non-preferred ones \\( y^- \\). The loss is then defined as the negative log-likelihood of the observed preferences: + +$$ +\mathcal{L}(\theta) = - \mathbb{E}_{(x,y^+,y^-) \sim \mathcal{D}} \left[ \log \sigma(r_\theta(x, y^+) - r_\theta(x, y^-)) \right]. +$$ + +> [!TIP] +> The Bradley-Terry model is underdetermined, meaning that adding a constant to all rewards does not change the preference probabilities. To address this, [Helping or Herding? Reward Model Ensembles Mitigate but do not Eliminate Reward Hacking](https://huggingface.co/papers/2312.09244) proposes adding an auxiliary loss term that encourages the rewards to be centered around zero. This is controlled by the `center_rewards_coefficient` parameter in the [`RewardConfig`]. The recommended value is `1e-2`. + +## Logged metrics + +While training and evaluating we record the following reward metrics: + +* `global_step`: The total number of optimizer steps taken so far. +* `epoch`: The current epoch number, based on dataset iteration. +* `num_tokens`: The total number of tokens processed so far. +* `loss`: The average loss over the last logging interval. +* `accuracy`: The proportion of correct predictions (i.e., the model assigned a higher score to the chosen response than to the rejected one) averaged over the last logging interval. +* `min_reward`: The minimum reward score assigned by the model. This value is averaged over the logging interval. +* `mean_reward`: The average reward score assigned by the model over the last logging interval. +* `max_reward`: The maximum reward score assigned by the model. This value is averaged over the logging interval. +* `margin`: The average margin (difference between chosen and rejected rewards) over the last logging interval. +* `learning_rate`: The current learning rate, which may change dynamically if a scheduler is used. +* `grad_norm`: The L2 norm of the gradients, computed before gradient clipping. + +## Customization + +### Model initialization + +You can directly pass the kwargs of the [`~transformers.AutoModelForSequenceClassification.from_pretrained()`] method to the [`RewardConfig`]. For example, if you want to load a model in a different precision, analogous to + +```python +model = AutoModelForSequenceClassification.from_pretrained("Qwen/Qwen3-0.6B", dtype=torch.bfloat16) +``` + +you can do so by passing the `model_init_kwargs={"dtype": torch.bfloat16}` argument to the [`RewardConfig`]. + +```python +from trl import RewardConfig + +training_args = RewardConfig( + model_init_kwargs={"dtype": torch.bfloat16}, +) +``` + +Note that all keyword arguments of [`~transformers.AutoModelForSequenceClassification.from_pretrained()`] are supported, except for `num_labels`, which is automatically set to 1. + +### Train adapters with PEFT + +We support tight integration with 🤗 PEFT library, allowing any user to conveniently train adapters and share them on the Hub, rather than training the entire model. + +```python +from datasets import load_dataset +from trl import RewardTrainer +from peft import LoraConfig + +dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train") + +trainer = RewardTrainer( + "Qwen/Qwen3-4B", + train_dataset=dataset, + peft_config=LoraConfig(modules_to_save=["score"]) # important to include the score head when base model is not a sequence classification model +) + +trainer.train() +``` + +You can also continue training your [`~peft.PeftModel`]. For that, first load a `PeftModel` outside [`RewardTrainer`] and pass it directly to the trainer without the `peft_config` argument being passed. + +```python +from datasets import load_dataset +from trl import RewardTrainer +from peft import AutoPeftModelForCausalLM + +model = AutoPeftModelForCausalLM.from_pretrained("trl-lib/Qwen3-4B-Reward-LoRA", is_trainable=True) +dataset = load_dataset("trl-lib/Capybara", split="train") + +trainer = RewardTrainer( + model=model, + train_dataset=dataset, +) + +trainer.train() +``` + +> [!TIP] +> When training adapters, you typically use a higher learning rate (≈1e‑3) since only new parameters are being learned. +> +> ```python +> RewardConfig(learning_rate=1e-3, ...) +> ``` + +## Tool Calling with Reward Modeling + +The [`RewardTrainer`] fully supports fine-tuning models with _tool calling_ capabilities. In this case, each dataset example should include: + +* The conversation messages, including any tool calls (`tool_calls`) and tool responses (`tool` role messages) +* The list of available tools in the `tools` column, typically provided as JSON schemas + +For details on the expected dataset structure, see the [Dataset Format — Tool Calling](dataset_formats#tool-calling) section. + +## RewardTrainer + +[[autodoc]] RewardTrainer + - train + - save_model + - push_to_hub + +## RewardConfig + +[[autodoc]] RewardConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rewards.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rewards.md new file mode 100644 index 0000000000000000000000000000000000000000..52752205f377ff51064ccde868762879da6720e1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rewards.md @@ -0,0 +1,19 @@ +# Reward Functions + +This module contains some useful reward functions, primarily intended for use with the [`GRPOTrainer`] and [`RLOOTrainer`]. + +## accuracy_reward + +[[autodoc]] rewards.accuracy_reward + +## reasoning_accuracy_reward + +[[autodoc]] rewards.reasoning_accuracy_reward + +## think_format_reward + +[[autodoc]] rewards.think_format_reward + +## get_soft_overlong_punishment + +[[autodoc]] rewards.get_soft_overlong_punishment diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rloo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rloo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..0f02df223f0e71ae63250386a9475e7c45b7909c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/rloo_trainer.md @@ -0,0 +1,642 @@ +# RLOO Trainer + +[![model badge](https://img.shields.io/badge/All_models-RLOO-blue)](https://huggingface.co/models?other=rloo,trl) + +## Overview + +TRL supports the RLOO Trainer for training language models, as described in the paper [Back to Basics: Revisiting REINFORCE Style +Optimization for Learning from Human Feedback in LLMs](https://huggingface.co/papers/2402.14740) by [Arash Ahmadian](https://huggingface.co/ArashAhmadian), Chris Cremer, [Matthias Gallé](https://huggingface.co/mgalle), [Marzieh Fadaee](https://huggingface.co/MarziehFadaee), [Julia Kreutzer](https://huggingface.co/JuliaKreutzerCohere), [Ahmet Üstün](https://huggingface.co/ahmetu) and [Sara Hooker](https://huggingface.co/sarahooker). + +The abstract from the paper is the following: + +> AI alignment in the shape of Reinforcement Learning from Human Feedback (RLHF) is increasingly treated as a crucial ingredient for high performance large language models. Proximal Policy Optimization (PPO) has been positioned by recent literature as the canonical method for the RL part of RLHF However, it involves both high computational cost and sensitive hyperparameter tuning. We posit that most of the motivational principles that led to the development of PPO are less of a practical concern in RLHF and advocate for a less computationally expensive method that preserves and even increases performance. We revisit the formulation of alignment from human preferences in the context of RL. Keeping simplicity as a guiding principle, we show that many components of PPO are unnecessary in an RLHF context and that far simpler REINFORCE-style optimization variants outperform both PPO and newly proposed “RL-free” methods such as DPO and RAFT. Our work suggests that careful adaptation to LLMs alignment characteristics enables benefiting from online RL optimization at low cost. + +This post-training method was contributed by [Costa Huang](https://github.com/vwxyzjn) and later refactored by [Shirin Yamani](https://huggingface.co/ShirinYamani). + +## Quick start + +This example demonstrates how to train a model using the RLOO method. We train a [Qwen 0.5B Instruct model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) with the prompts from the [DeepMath-103K dataset](https://huggingface.co/datasets/trl-lib/DeepMath-103K). You can view the data in the dataset here: + + + +Below is the script to train the model. + +```python +# train_rloo.py +from datasets import load_dataset +from trl import RLOOTrainer +from trl.rewards import accuracy_reward + +dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + +trainer = RLOOTrainer( + model="Qwen/Qwen2-0.5B-Instruct", + reward_funcs=accuracy_reward, + train_dataset=dataset, +) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_rloo.py +``` + +## Looking deeper into the RLOO method + +RLOO is an online learning algorithm, meaning it improves iteratively by using the data generated by the trained model itself during training. The intuition behind RLOO objective is to maximize the advantage of the generated completions, while ensuring that the model remains close to the reference policy. To understand how RLOO works, it can be broken down into four main steps: **Generating completions**, **computing the advantage**, **estimating the KL divergence**, and **computing the loss**. + +![RLOO](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/rloo.png) + +### Generating completions + +At each training step, we sample a batch of prompts and generate a set of \\( G \\) completions for each prompt (denoted as \\( o_i \\)). + +### Computing the reward + +In RLOO, the reward consists of two components: the reward provided by the reward model (or reward function) and a KL penalty that discourages the policy from deviating too far from a fixed reference policy + +1. For each of the \\( G \\) generated sequences \\( o_i = (o_{i,1}, \dots, o_{i,T}) \\) conditioned on a query \\( q \\), we compute a scalar reward using a reward model \\( R(o_i, q) \\). +2. Concurrently, we estimate the KL divergence between the current policy \\( \pi_\theta \\) and the fixed reference policy \\( \pi_{\text{ref}} \\) over the sequence. The KL estimate for sequence \\( o_i \\) is: + +$$ +\mathbb{D}_{\mathrm{KL}}\!\left[\pi_\theta\|\pi_{\mathrm{ref}}\right] = \sum_{t=1}^T \log \frac{\pi_\theta(o_{i,t} \mid q, o_{i, 0 \\) controls the strength of the KL penalty. + +> [!TIP] +> In a purely online setting (`num_iterations = 1`, default), the data are generated by the current policy. In this case, the KL penalty is computed directly using the current policy. +> +> In the more general setting (e.g., multiple gradient steps per batch), the data are instead generated by an earlier snapshot \\( \pi_{\text{old}} \\). To keep the penalty consistent with the sampling distribution, the KL is defined with respect to this policy: +> +> $$ +> \mathbb{D}_{\mathrm{KL}}\!\left[\pi_{\text{old}} \,\|\, \pi_{\text{ref}}\right]. +> $$ +> +> Equivalently, for a sampled sequence $o$, the Monte Carlo estimate is +> +> $$ +> \mathbb{D}_{\mathrm{KL}}\!\left[\pi_{\text{old}} \|\pi_{\mathrm{ref}}\right] = \sum_{t=1}^T \log \frac{\pi_{\text{old}}(o_{i,t} \mid q, o_{i, $$ + +### Computing the advantage + +Once the rewards for each completion have been computed, we calculate a baseline as the average reward of all other samples in the same batch, excluding the current sample. This baseline is used to reduce the variance of the policy gradient estimate. The advantage for each completion is then obtained as the difference between its own reward and this leave-one-out baseline. + +Formally, for a batch of G completions, the baseline for completion is: +$$ +b_i = \frac{1}{G-1} \sum_{j \neq i} r_j +$$ + +and then the advantage for each completion is computed as the difference between its reward and the baseline: + +$$ +A_i = r_i - b_i +$$ + +### Computing the loss + +The REINFORCE loss is simply defined as: + +$$ +\mathcal{L}_{\text{RLOO}}(\theta) = - \frac{1}{G} \sum_{i=1}^G \hat{A}_i \, \log \pi_\theta(o_i \mid q) +$$ + +In practice, performing multiple gradient steps on the same batch makes the actions effectively off-policy relative to the current parameters. To correct for this, we introduce the importance sampling ratio. To prevent excessively large updates when the policy changes between sampling and gradient steps, we clip this ratio: + +$$ +\mathcal{L}_{\text{RLOO}}(\theta) = - \frac{1}{G} \sum_{i=1}^G \min \left( \frac{\pi_\theta(o_i \mid q)}{\pi_{\theta_\text{old}}(o_i \mid q)} \hat{A}_i, \, \text{clip}\left(\frac{\pi_\theta(o_i \mid q)}{\pi_{\theta_\text{old}}(o_i \mid q)}, 1-\epsilon, 1+\epsilon\right) \hat{A}_i \right) +$$ + +In a fully online, single-step setting (default), \\( \frac{\pi_\theta(o_i \mid q)}{\pi_{\theta_\text{old}}(o_i \mid q)} = 1 \\) and this reduces to standard REINFORCE. + +## Logged metrics + +While training and evaluating, we record the following reward metrics: + +- `num_tokens`: The total number of tokens processed so far, including both prompts and completions. +- `step_time`: The average time (in seconds) taken per training step (including generation). +- `completions/mean_length`: The average length of generated completions. +- `completions/min_length`: The minimum length of generated completions. +- `completions/max_length`: The maximum length of generated completions. +- `completions/mean_terminated_length`: The average length of generated completions that terminate with EOS. +- `completions/min_terminated_length`: The minimum length of generated completions that terminate with EOS. +- `completions/max_terminated_length`: The maximum length of generated completions that terminate with EOS. +- `completions/clipped_ratio`: The ratio of truncated (clipped) completions. +- `reward/{reward_func_name}/mean`: The average reward from a specific reward function. +- `reward/{reward_func_name}/std`: The standard deviation of the reward from a specific reward function. +- `reward`: The overall average reward after summing rewards across functions (weighted by `reward_weights`). +- `reward_std`: The standard deviation of summed rewards across functions (weighted by `reward_weights`), computed over the full batch. +- `frac_reward_zero_std`: The fraction of samples in the generation batch with a reward std of zero, implying there is little diversity for that prompt (all answers are correct or incorrect). +- `entropy`: Average entropy of token predictions across generated completions. (If `mask_truncated_completions=True`, masked sequences tokens are excluded.) +- `kl`: The average KL divergence between the model and the reference model, calculated over generated completions. Logged only if `beta` is nonzero. +- `clip_ratio/region_mean`: The ratio of sequence probabilities where the RLOO objective is clipped to stay within the trust region: \\( \text{clip}\left( r_{i}(\theta), 1 - \epsilon_\mathrm{low}, 1 + \epsilon_\mathrm{high} \right)\,, \quad r_{i}(\theta) = \frac{\pi_\theta(o_{i} \mid q)}{\pi_{\theta_{\text{old}}}(o_{i} \mid q)} \\). A higher value means more samples are clipped, which constrains how much the policy $\pi_\theta$ can change. +- `clip_ratio/low_mean`: The average ratio of sequence probabilities that were clipped on the lower bound of the trust region: \\(r_{i,t}(\theta) < 1 - \epsilon_\mathrm{low}\\). +- `clip_ratio/low_min`: The minimum ratio of sequence probabilities that were clipped on the lower bound of the trust region: \\(r_{i,t}(\theta) < 1 - \epsilon_\mathrm{low}\\). +- `clip_ratio/high_mean`: The average ratio of sequence probabilities that were clipped on the upper bound of the trust region: \\(r_{i,t}(\theta) > 1 + \epsilon_\mathrm{high}\\). +- `clip_ratio/high_max`: The maximum ratio of sequence probabilities that were clipped on the upper bound of the trust region: \\(r_{i,t}(\theta) > 1 + \epsilon_\mathrm{high}\\). + +## Customization + +### Speed up training with vLLM-powered generation + +Generation is often the main bottleneck when training with online methods. To accelerate generation, you can use [vLLM](https://github.com/vllm-project/vllm), a high-throughput, low-latency inference engine for LLMs. To enable it, first install the package with + +```shell +pip install trl[vllm] +``` + +We support two ways of using vLLM during training: **server mode** and **colocate mode**. + +#### Option 1: Colocate mode + +In this mode, vLLM runs inside the trainer process and shares GPU memory with the training model. This avoids launching a separate server and can improve GPU utilization, but may lead to memory contention on the training GPUs. This is the default mode. + +```python +from trl import RLOOConfig + +training_args = RLOOConfig( + ..., + use_vllm=True, # vllm_mode="colocate" by default +) +``` + +#### Option 2: Server mode + +In this mode, vLLM runs in a separate process (and using separate GPUs) and communicates with the trainer via HTTP. This is ideal if you have dedicated GPUs for inference. + +1. **Start the vLLM server**: + + ```bash + trl vllm-serve --model + ``` + +2. **Enable server mode in your training script**: + + ```python + from trl import RLOOConfig + + training_args = RLOOConfig( + ..., + use_vllm=True, + vllm_mode="server", + ) + ``` + +> [!WARNING] +> Make sure that the server is using different GPUs than the trainer, otherwise you may run into NCCL errors. You can specify the GPUs to use with the `CUDA_VISIBLE_DEVICES` environment variable. + +> [!TIP] +> Depending on the model size and the overall GPU memory requirements for training, you may need to adjust the `vllm_gpu_memory_utilization` parameter in [`RLOOConfig`] to avoid underutilization or out-of-memory errors. +> +> We provide a [HF Space](https://huggingface.co/spaces/trl-lib/recommend-vllm-memory) to help estimate the recommended GPU memory utilization based on your model configuration and experiment settings. Simply use it as follows to get `vllm_gpu_memory_utilization` recommendation: +> +> +> +> If the recommended value does not work in your environment, we suggest adding a small buffer (e.g., +0.05 or +0.1) to the recommended value to ensure stability. +> +> If you still find you are getting out-of-memory errors set `vllm_enable_sleep_mode` to True and the vllm parameters and cache will be offloaded during the optimization step. For more information, see [Reducing Memory Usage with vLLM Sleep Mode](reducing_memory_usage#vllm-sleep-mode). + +> [!TIP] +> By default, RLOO uses `MASTER_ADDR=localhost` and `MASTER_PORT=12345` for vLLM, but you can override these values by setting the environment variables accordingly. + +For more information, see [Speeding up training with vLLM](speeding_up_training#vllm-for-fast-generation-in-online-methods). + +### RLOO at scale: train a 70B+ Model on multiple nodes + +When training large models like **Qwen2.5-72B**, you need several key optimizations to make the training efficient and scalable across multiple GPUs and nodes. These include: + +- **DeepSpeed ZeRO Stage 3**: ZeRO leverages data parallelism to distribute model states (weights, gradients, optimizer states) across multiple GPUs and CPUs, reducing memory and compute requirements on each device. Since large models cannot fit on a single GPU, using ZeRO Stage 3 is required for training such models. For more details, see [DeepSpeed Integration](deepspeed_integration). +- **Accelerate**: Accelerate is a library that simplifies distributed training across multiple GPUs and nodes. It provides a simple API to launch distributed training and handles the complexities of distributed training, such as data parallelism, gradient accumulation, and distributed data loading. For more details, see [Distributing Training](distributing_training). +- **vLLM**: See the previous section on how to use vLLM to speed up generation. + +Below is an example SLURM script to train a 70B model with RLOO on multiple nodes. This script trains a model on 4 nodes and uses the 5th node for vLLM-powered generation. + +```sh +#!/bin/bash +#SBATCH --nodes=5 +#SBATCH --gres=gpu:8 + +# Get the list of allocated nodes +NODELIST=($(scontrol show hostnames $SLURM_JOB_NODELIST)) + +# Assign the first 4 nodes for training and the 5th node for vLLM +TRAIN_NODES="${NODELIST[@]:0:4}" # Nodes 0, 1, 2, 3 for training +VLLM_NODE="${NODELIST[4]}" # Node 4 for vLLM + +# Run training on the first 4 nodes (Group 1) +srun --nodes=4 --ntasks=4 --nodelist="${NODELIST[@]:0:4}" accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + --num_processes 32 \ + --num_machines 4 \ + --main_process_ip ${NODELIST[0]} \ + --machine_rank $SLURM_PROCID \ + --rdzv_backend c10d \ + train_rloo.py \ + --server_ip $VLLM_NODE & + +# Run vLLM server on the 5th node (Group 2) +srun --nodes=1 --ntasks=1 --nodelist="${NODELIST[4]}" trl vllm-serve --model Qwen/Qwen2.5-72B --tensor_parallel_size 8 & + +wait +``` + +```python +import argparse + +from datasets import load_dataset +from trl import RLOOTrainer, RLOOConfig + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--vllm_server_host", type=str, default="", help="The server IP") + args = parser.parse_args() + + # Example dataset from TLDR + dataset = load_dataset("trl-lib/tldr", split="train") + + # Dummy reward function: count the number of unique characters in the completions + def reward_num_unique_chars(completions, **kwargs): + return [len(set(c)) for c in completions] + + training_args = RLOOConfig( + output_dir="Qwen2.5-72B-RLOO", + per_device_train_batch_size=4, + bf16=True, + use_vllm=True, + vllm_mode="server", + vllm_server_host=args.vllm_server_host.replace("ip-", "").replace("-", "."), # from ip-X-X-X-X to X.X.X.X + ) + + trainer = RLOOTrainer(model="Qwen/Qwen2.5-72B", args=training_args, reward_funcs=reward_num_unique_chars, train_dataset=dataset) + trainer.train() + +if __name__=="__main__": + main() +``` + +### Using a custom reward function + +The [`RLOOTrainer`] supports using custom reward functions instead of dense reward models. To ensure compatibility, your reward function must satisfy the following requirements: + +Reward functions can be either synchronous Python callables or asynchronous `async def` coroutines. When you provide multiple asynchronous reward functions, they are awaited concurrently (run in parallel via `asyncio.gather`) so their latency overlaps. + +1. **Input arguments**: + - The function must accept the following as keyword arguments: + - `prompts` (contains the prompts), + - `completions` (contains the generated completions), + - `completion_ids` (contains the tokenized completions), + - `trainer_state` ([`~transformers.TrainerState`]): The current state of the trainer. This can be used to implement dynamic reward functions, such as curriculum learning, where the reward is adjusted based on the training progress. + - `log_extra`: a callable `log_extra(column: str, values: list)` to add extra columns to the completions table. See Example 6. In distributed training, it's important that all processes log the same set of keys. + - `log_metric`: a callable `log_metric(name: str, value: float)` to log scalar metrics as plots alongside `kl`, `entropy`, etc. See Example 6. In distributed training, it's important that all processes log the same set of keys. + - All column names (but `prompt`) that the dataset may have. For example, if the dataset contains a column named `ground_truth`, the function will be called with `ground_truth` as a keyword argument. + + The easiest way to comply with this requirement is to use `**kwargs` in the function signature. + - Depending on the dataset format, the input will vary: + - For [standard format](dataset_formats#standard), `prompts` and `completions` will be lists of strings. + - For [conversational format](dataset_formats#conversational), `prompts` and `completions` will be lists of message dictionaries. + +2. **Return value**: The function must return a list of floats. Each float represents the reward corresponding to a single completion. + +#### Example 1: Reward longer completions + +Below is an example of a reward function for a standard format that rewards longer completions: + +```python +def reward_func(completion_ids, **kwargs): + """Reward function that assigns higher scores to longer completions (in terms of token count).""" + return [float(len(ids)) for ids in completion_ids] +``` + +You can test it as follows: + +```python +>>> prompts = ["The sky is", "The sun is"] # not used in the reward function, but the trainer will pass it +>>> completions = [" blue.", " in the sky."] # not used in the reward function, but the trainer will pass it +>>> completion_ids = [[6303, 13], [304, 279, 12884, 13]] +>>> reward_func(prompts=prompts, completions=completions, completion_ids=completion_ids) +[2.0, 4.0] +``` + +#### Example 1.1: Reward longer completions (based on the number of characters) + +Same as the previous example, but this time the reward function is based on the number of characters instead of tokens. + +```python +def reward_func(completions, **kwargs): + """Reward function that assigns higher scores to longer completions (in terms of character count).""" + return [float(len(completion)) for completion in completions] +``` + +You can test it as follows: + +```python +>>> prompts = ["The sky is", "The sun is"] +>>> completions = [" blue.", " in the sky."] +>>> completion_ids = [[6303, 13], [304, 279, 12884, 13]] # not used in the reward function, but the trainer will pass it +>>> reward_func(prompts=prompts, completions=completions, completion_ids=completion_ids) +[6.0, 12.0] +``` + +#### Example 2: Reward completions with a specific format + +Below is an example of a reward function that checks if the completion has a specific format. This example is inspired by the _format reward_ function used in the paper [DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning](https://huggingface.co/papers/2501.12948). +It is designed for a conversational format, where prompts and completions consist of structured messages. + +```python +import re + +def format_reward_func(completions, **kwargs): + """Reward function that checks if the completion has a specific format.""" + pattern = r"^.*?.*?$" + completion_contents = [completion[0]["content"] for completion in completions] + matches = [re.match(pattern, content) for content in completion_contents] + return [1.0 if match else 0.0 for match in matches] +``` + +You can test this function as follows: + +```python +>>> prompts = [ +... [{"role": "assistant", "content": "What is the result of (1 + 2) * 4?"}], +... [{"role": "assistant", "content": "What is the result of (3 + 1) * 2?"}], +... ] +>>> completions = [ +... [{"role": "assistant", "content": "The sum of 1 and 2 is 3, which we multiply by 4 to get 12.(1 + 2) * 4 = 12"}], +... [{"role": "assistant", "content": "The sum of 3 and 1 is 4, which we multiply by 2 to get 8. So (3 + 1) * 2 = 8."}], +... ] +>>> format_reward_func(prompts=prompts, completions=completions) +[1.0, 0.0] +``` + +#### Example 3: Reward completions based on a reference + +Below is an example of a reward function that checks if the completion is correct. This example is inspired by the _accuracy reward_ function used in the paper [DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning](https://huggingface.co/papers/2501.12948). +This example is designed for [standard format](dataset_formats#standard), where the dataset contains a column named `ground_truth`. + +```python +import re + +def reward_func(completions, ground_truth, **kwargs): + # Regular expression to capture content inside \boxed{} + matches = [re.search(r"\\boxed\{(.*?)\}", completion) for completion in completions] + contents = [match.group(1) if match else "" for match in matches] + # Reward 1 if the content is the same as the ground truth, 0 otherwise + return [1.0 if c == gt else 0.0 for c, gt in zip(contents, ground_truth)] +``` + +You can test this function as follows: + +```python +>>> prompts = ["Problem: Solve the equation $2x + 3 = 7$. Solution:", "Problem: Solve the equation $3x - 5 = 10$."] +>>> completions = [r" The solution is \boxed{2}.", r" The solution is \boxed{6}."] +>>> ground_truth = ["2", "5"] +>>> reward_func(prompts=prompts, completions=completions, ground_truth=ground_truth) +[1.0, 0.0] +``` + +#### Example 4: Multi-task reward functions + +Below is an example of using multiple reward functions in the [`RLOOTrainer`]. In this example, we define two task-specific reward functions: `math_reward_func` and `coding_reward_func`. The `math_reward_func` rewards math problems based on their correctness, while the `coding_reward_func` rewards coding problems based on whether the solution works. + +```python +from datasets import Dataset +from trl import RLOOTrainer + +# Define a dataset that contains both math and coding problems +dataset = Dataset.from_list( + [ + {"prompt": "What is 2+2?", "task": "math"}, + {"prompt": "Write a function that returns the sum of two numbers.", "task": "code"}, + {"prompt": "What is 3*4?", "task": "math"}, + {"prompt": "Write a function that returns the product of two numbers.", "task": "code"}, + ] +) + +# Math-specific reward function +def math_reward_func(prompts, completions, task, **kwargs): + rewards = [] + for prompt, completion, t in zip(prompts, completions, task): + if t == "math": + # Calculate math-specific reward + correct = check_math_solution(prompt, completion) + reward = 1.0 if correct else -1.0 + rewards.append(reward) + else: + # Return None for non-math tasks + rewards.append(None) + return rewards + +# Coding-specific reward function +def coding_reward_func(prompts, completions, task, **kwargs): + rewards = [] + for prompt, completion, t in zip(prompts, completions, task): + if t == "coding": + # Calculate coding-specific reward + works = test_code_solution(prompt, completion) + reward = 1.0 if works else -1.0 + rewards.append(reward) + else: + # Return None for non-coding tasks + rewards.append(None) + return rewards + +# Use both task-specific reward functions +trainer = RLOOTrainer( + model="Qwen/Qwen2-0.5B-Instruct", + reward_funcs=[math_reward_func, coding_reward_func], + train_dataset=dataset, +) + +trainer.train() +``` + +In this example, the `math_reward_func` and `coding_reward_func` are designed to work with a mixed dataset that contains both math and coding problems. The `task` column in the dataset is used to determine which reward function to apply to each problem. If there is no relevant reward function for a sample in the dataset, the reward function will return `None`, and the [`RLOOTrainer`] will continue with the valid functions and tasks. This allows the [`RLOOTrainer`] to handle multiple reward functions with different applicability. + +Note that the [`RLOOTrainer`] will ignore the `None` rewards returned by the reward functions and only consider the rewards returned by the relevant functions. This ensures that the model is trained on the relevant tasks and ignores the tasks for which there is no relevant reward function. + +#### Example 5: Asynchronous reward functions + +Custom reward functions can also be defined as `async def` coroutines. This is useful if your reward depends on slow I/O (for example, calling a remote service). When you pass multiple async reward functions, [`RLOOTrainer`] executes them concurrently so their latency overlaps. + +Below is a minimal example of an async reward function that simulates an I/O-bound operation: + +```python +import asyncio + +async def async_reward_func(prompts, completions, **kwargs): + # Simulate an I/O-bound call (e.g., HTTP request, database lookup) + await asyncio.sleep(0.01) + # Simple toy reward: 1.0 if the completion is non-empty, else 0.0 + return [1.0 if completion else 0.0 for completion in completions] +``` + +#### Example 6: Logging extra columns and metrics + +Below is an example of a reward function that logs extra columns to the completions table and scalar metrics as plots. + +```python +import re + +def reward_func(completions, ground_truth, log_extra=None, log_metric=None, **kwargs): + extracted = [re.search(r"\\boxed\{(.*?)\}", c) for c in completions] + extracted = [m.group(1) if m else None for m in extracted] + rewards = [1.0 if e == gt else 0.0 for e, gt in zip(extracted, ground_truth)] + + if log_extra: + log_extra("golden_answer", list(ground_truth)) + log_extra("extracted_answer", [e or "[none]" for e in extracted]) + + if log_metric: + log_metric("accuracy", sum(rewards) / len(rewards)) + + return rewards +``` + +#### Passing the reward function to the trainer + +To use your custom reward function, pass it to the [`RLOOTrainer`] as follows: + +```python +from trl import RLOOTrainer + +trainer = RLOOTrainer( + reward_funcs=reward_func, + ..., +) +``` + +You can pass several reward functions as a list; this list may include both synchronous and asynchronous functions: + +```python +from trl import RLOOTrainer + +trainer = RLOOTrainer( + reward_funcs=[reward_func, async_reward_func1, async_reward_func2], + ..., +) +``` + +and the reward will be computed as the sum of the rewards from each function, or the weighted sum if `reward_weights` is provided in the config. + +Note that [`RLOOTrainer`] supports multiple reward functions of different types. See the parameters documentation for more details. + +## Vision-Language Model (VLM) Training + +RLOO supports training Vision-Language Models (VLMs) on multimodal datasets containing both text and images. + +### Supported Models + +Tested with: + +- **Gemma3** — e.g., `google/gemma-3-4b-it` +- **LLaVA-NeXT** — e.g., `llava-hf/llava-v1.6-mistral-7b-hf` +- **Qwen2-VL** — e.g., `Qwen/Qwen2-VL-2B-Instruct` +- **Qwen2.5-VL** — e.g., `Qwen/Qwen2.5-VL-3B-Instruct` +- **SmolVLM2** — e.g., `HuggingFaceTB/SmolVLM2-2.2B-Instruct` + +> [!TIP] +> Compatibility with all VLMs is not guaranteed. If you believe a model should be supported, feel free to open an issue on GitHub — or better yet, submit a pull request with the required changes. + +### Quick Start + +Use [rloo\_vlm.py](https://github.com/huggingface/trl/blob/main/examples/scripts/rloo_vlm.py) to fine-tune a VLM. Example command for training on [`lmms-lab/multimodal-open-r1-8k-verified`](https://huggingface.co/datasets/lmms-lab/multimodal-open-r1-8k-verified): + +```bash +accelerate launch \ + --config_file=examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/rloo_vlm.py \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --output_dir rloo-Qwen2.5-VL-3B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_vllm \ + --vllm_mode colocate \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions +``` + +### Configuration Tips + +- Use LoRA on vision-language projection layers +- Enable 4-bit quantization to reduce memory usage +- VLMs are memory-intensive — start with smaller batch sizes +- Most models are compatible with vLLM (`server` and `colocate` modes) + +### Dataset Format + +Each training sample should include: + +- `prompt`: Text formatted via the processor's chat template +- `image`/`images`: PIL Image or list of PIL Images + +The trainer automatically handles image-to-tensor conversion via the model’s image processor. + +## RLOOTrainer + +[[autodoc]] RLOOTrainer + - train + - save_model + - push_to_hub + +## RLOOConfig + +[[autodoc]] RLOOConfig + +## References + +1. [RLOO Paper](https://openreview.net/pdf?id=r1lgTGL5DE) +2. [Paper Back to Basics: Revisiting REINFORCE Style Optimization for Learning from Human Feedback in LLMs](https://huggingface.co/papers/2402.14740) +3. [Paper - REINFORCE++: A Simple and Efficient Approach for Aligning Large Language Models](https://huggingface.co/papers/2501.03262) +4. [Blog Post - Putting RL back in RLHF](https://huggingface.co/blog/putting_rl_back_in_rlhf_with_rloo) +5. [Blog Post - Unraveling RLHF and Its Variants: Progress and Practical Engineering Insights](https://hijkzzz.notion.site/unraveling-rlhf-and-its-variants-engineering-insights#147d9a33ecc9806090f3d5c749d31f05) +6. [Youtube - RLOO: A Cost-Efficient Optimization for Learning from Human Feedback in LLMs](https://www.youtube.com/watch?v=86asXGPK6RU&ab_channel=BuzzRobot) + +## Migration Guide from the old implementation (0.21 and below) + +With the release of version 0.22.0, we have revamped the [`RLOOTrainer`] to be more aligned with other online trainers in the library, like [`GRPOTrainer`]. This new implementation introduces several changes to the configuration parameters and overall structure of the trainer. +Below is a summary of the key changes for [`RLOOConfig`]: + +| TRL ≤ 0.21.x | TRL ≥ 0.22.0 | +| --- | --- | +| `rloo_k` | renamed to `num_generations` | +| `cliprange` | renamed to `epsilon` | +| `kl_coef` | renamed to `beta` | +| `exp_name` | renamed to `run_name`. Use `run_name = f"{exp_name}__{seed}__{int(time.time())}"` to replicate old behavior | +| `normalize_reward` | renamed to `normalize_advantages`. Note: this always normalized advantages (despite the old name) | +| `num_ppo_epochs` | renamed to `num_iterations` (default: `1`) | +| `token_level_kl` | **removed** – KL is now computed only at the sequence level | +| `dataset_num_proc` | **removed** – it was unused | +| `num_mini_batches` | renamed to `steps_per_generation` | +| `total_episodes` | use `max_steps=total_episodes / gradient_accumulation_steps` instead | +| `local_rollout_forward_batch_size` | **removed** – now automatically set to `per_device_train_batch_size` (or `per_device_eval_batch_size` during evaluation) | +| `num_sample_generations` | **removed** – use `logging_steps` to control generation logging frequency | +| `response_length` | renamed to `max_completion_length` (default: `256`) | +| `stop_token` | **removed** | +| `stop_token_id` | **removed** – use `processing_class.eos_token_id` instead | +| `missing_eos_penalty` | **removed** – replicate with a custom reward function checking if `eos_token_id` is in `completion_ids` | + +Below is a summary of the key changes for [`RLOOTrainer`]: + +| TRL ≤ 0.21.x | TRL ≥ 0.22.0 | +| --- | --- | +| `config` | renamed to `args` | +| `reward_model` | renamed to `reward_funcs`, which now supports both reward models and custom reward functions | +| `policy` | renamed to `model` | +| `ref_policy` | **removed** – the reference model is now created automatically from `model` | +| `data_collator` | **removed** | diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/script_utils.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/script_utils.md new file mode 100644 index 0000000000000000000000000000000000000000..1ecb73756530d0fcdd87f668dd8385ebfbce1536 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/script_utils.md @@ -0,0 +1,24 @@ +# Scripts Utilities + +## ScriptArguments + +[[autodoc]] ScriptArguments + +## TrlParser + +[[autodoc]] TrlParser + - parse_args_and_config + - parse_args_into_dataclasses + - set_defaults_with_config + +## get_dataset + +[[autodoc]] get_dataset + +## DatasetConfig + +[[autodoc]] scripts.utils.DatasetConfig + +## DatasetMixtureConfig + +[[autodoc]] DatasetMixtureConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sdft_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sdft_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..17f6433fd7822f287f20be7e9186966232b5c956 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sdft_trainer.md @@ -0,0 +1,104 @@ +# SDFT + +Self-Distilled Fine-Tuning (SDFT) is described in [Self-Training with On-Policy Self-Distillation for Language Model Alignment](https://huggingface.co/papers/2601.19897). + +The TRL implementation adapts SDFT to the experimental trainer API while reusing the shared self-distillation infrastructure also used by SDPO. + +In the current TRL implementation: + +- the teacher is the model itself (base weights with adapter disabled for PEFT, or the same model under `no_grad` for non-PEFT); use `sync_ref_model=True` for an EMA teacher +- the dataset must provide both `prompt` and `privileged_context` +- `privileged_context` contains only the extra teacher-only information; the trainer combines it with `prompt` to build the teacher prompt +- `teacher_prompt_template` controls how `prompt` and `privileged_context` are combined into the teacher prompt +- on-policy generation can use either the student prompt or the teacher-conditioned prompt via `generate_from_teacher` +- `num_loss_tokens_to_skip` can exclude initial completion tokens from the distillation loss +- SDFT currently supports text-only training and does not support `use_vllm=True` +- the shared dataset contract is `prompt` plus `privileged_context` + +## Usage + +```python +from datasets import Dataset + +from trl.experimental.sdft import SDFTConfig, SDFTTrainer + +dataset = Dataset.from_dict( + { + "prompt": [[{"role": "user", "content": "Solve 2+2."}]], + "privileged_context": ["Example answer: 4."], + } +) + +training_args = SDFTConfig( + output_dir="sdft-model", + distillation_alpha=0.5, + distillation_topk=5, + max_completion_length=64, +) + +trainer = SDFTTrainer( + model="Qwen/Qwen2.5-1.5B-Instruct", + args=training_args, + train_dataset=dataset, +) +trainer.train() +``` + +To generate from the teacher-conditioned prompt instead of the student prompt, set `generate_from_teacher=True`. +To customize how the teacher prompt is built, set `teacher_prompt_template` on [`SDFTConfig`]. + +## Expected dataset columns + +Each example must provide: + +- `prompt`: the student-facing prompt +- `privileged_context`: only the extra teacher-only information, such as a demonstration, hint, or privileged feedback + +Both standard text prompts and conversational prompts are supported by the trainer prompt handling. + +## Callbacks + +The trainer emits a small set of callback hooks that are useful for debugging, observability, and tests. These hooks are intended as practical integration points for experimental self-distillation workflows. + +Shared self-distillation hooks: + +- `on_self_distillation_batch_prepared`: fired when a self-distillation batch is ready. The payload includes `prompt_ids`, `completion_ids`, and `old_per_token_logps` when importance-sampling clipping inputs are available. +- `on_generation_batch_built`: fired when a new buffered generation batch is created. The payload includes `generate_every` and `steps_per_generation`. + +SDFT-specific hook: + +- `on_generation_prompts_selected`: fired when SDFT chooses the prompt source for on-policy generation. The payload includes the selected `generation_prompts` and the corresponding `generation_prompt_text`. + +## Example script + +Use [`trl/experimental/sdft/sdft.py`](https://github.com/huggingface/trl/blob/main/trl/experimental/sdft/sdft.py) to launch SDFT training from the command line. The script supports any causal LM from the Hub, custom local datasets via `--dataset_path`, and PEFT/LoRA via the standard `ModelConfig` flags. + +```bash +python trl/experimental/sdft/sdft.py \ + --model_name_or_path Qwen/Qwen3.5-0.8B \ + --dataset_name your-org/your-dataset \ + --output_dir outputs/sdft-qwen3.5-0.8b \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 16 \ + --learning_rate 2e-5 \ + --max_prompt_length 1024 \ + --max_completion_length 512 \ + --generate_from_teacher \ + --sync_ref_model \ + --ref_model_sync_steps 1 \ + --ref_model_mixup_alpha 0.01 \ + --eval_strategy steps \ + --eval_steps 50 \ + --report_to wandb +``` + +## SDFTConfig + +[[autodoc]] experimental.sdft.SDFTConfig + +## SDFTTrainer + +[[autodoc]] experimental.sdft.SDFTTrainer + - train + - save_model + - push_to_hub diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sdpo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sdpo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..3910f674baf8cec6b9b84f37891165b62e476139 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sdpo_trainer.md @@ -0,0 +1,108 @@ +# SDPO + +Self-Distillation Policy Optimization (SDPO) was introduced in [Reinforcement Learning via Self-Distillation](https://huggingface.co/papers/2601.20802) by [Jonas Hübotter](https://huggingface.co/jonhue), Frederike Lübeck, Lejs Behric, [Anton Baumann](https://huggingface.co/antonbaumann), Marco Bagatella, Daniel Marta, Ido Hakimi, Idan Shenfeld, Thomas Kleine Buening, Carlos Guestrin, and Andreas Krause. + +> Large language models are increasingly post-trained with reinforcement learning in verifiable domains such as code and math. Yet, current methods for reinforcement learning with verifiable rewards (RLVR) learn only from a scalar outcome reward per attempt, creating a severe credit-assignment bottleneck. Many verifiable environments actually provide rich textual feedback, such as runtime errors or judge evaluations, that explain why an attempt failed. We formalize this setting as reinforcement learning with rich feedback and introduce Self-Distillation Policy Optimization (SDPO), which converts tokenized feedback into a dense learning signal without any external teacher or explicit reward model. SDPO treats the current model conditioned on feedback as a self-teacher and distills its feedback-informed next-token predictions back into the policy. In this way, SDPO leverages the model's ability to retrospectively identify its own mistakes in-context. Across scientific reasoning, tool use, and competitive programming on LiveCodeBench v6, SDPO improves sample efficiency and final accuracy over strong RLVR baselines. Notably, SDPO also outperforms baselines in standard RLVR environments that only return scalar feedback by using successful rollouts as implicit feedback for failed attempts. Finally, applying SDPO to individual questions at test time accelerates discovery on difficult binary-reward tasks, achieving the same discovery probability as best-of-k sampling or multi-turn conversations with 3x fewer attempts. + +The SDPO trainer is built on TRL's experimental shared self-distillation stack. It keeps the online rollout-and-reward training flow, then builds a teacher-conditioned view of the same completions from successful rollouts and optional environment feedback. + +In the current TRL implementation: + +- the default SDPO policy loss mode is `distillation_only` +- `hybrid` mode is also available to combine the base policy loss with the self-distillation loss +- supported teacher regularization modes are `ema` and `none` +- `distillation_topk` is only valid when `full_logit_distillation=True` +- when `full_logit_distillation=False`, SDPO uses token-level reverse KL and requires `distillation_alpha=1.0` +- environment feedback can be injected into teacher reprompts when the dataset exposes a `privileged_context` column + +## Expected dataset columns + +Each example must provide: + +- `prompt`: the student-facing prompt +- `privileged_context`: optional privileged text, such as environment feedback, used when `include_environment_feedback=True` + +## Usage + +```python +from datasets import Dataset + +from trl.experimental.sdpo import SDPOConfig, SDPOTrainer + +dataset = Dataset.from_dict( + { + "prompt": [[{"role": "user", "content": "Solve 2+2."}]], + "privileged_context": ["Your earlier answer used the wrong format."], + } +) + +training_args = SDPOConfig( + output_dir="sdpo-model", + distillation_topk=100, # Top-K logit distillation approximation + full_logit_distillation=True, # Required for top-K; enables non-reverse divergences + include_environment_feedback=True, # Use dataset privileged_context for teacher reprompts +) + +trainer = SDPOTrainer( + model="Qwen/Qwen2.5-1.5B-Instruct", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, +) +trainer.train() +``` + +SDPO always requires a `prompt` column. To use environment feedback, also include a `privileged_context` column and set `include_environment_feedback=True`. SDPO will use successful rollouts and, when enabled, that text to build teacher reprompts for self-distillation. + +## Callbacks + +The trainer emits a small set of callback hooks that are useful for debugging, observability, and tests. These hooks are intended as practical integration points for experimental self-distillation workflows. + +Shared self-distillation hooks: + +- `on_self_distillation_batch_prepared`: fired when a self-distillation batch is ready. The payload includes `prompt_ids`, `completion_ids`, and `old_per_token_logps` when importance-sampling clipping inputs are available. +- `on_generation_batch_built`: fired when a new buffered generation batch is created. The payload includes `generate_every` and `steps_per_generation`. + +SDPO-specific hook: + +- `on_teacher_context_built`: fired after SDPO constructs the teacher-conditioned inputs. The payload includes `teacher_input_ids`, `teacher_attention_mask`, `completion_mask`, and `self_distillation_mask`. + +## Example script + +Use [`trl/experimental/sdpo/sdpo.py`](https://github.com/huggingface/trl/blob/main/trl/experimental/sdpo/sdpo.py) to launch SDPO training from the command line. The script supports verifiable math rewards, environment feedback via `--feedback_column`, and PEFT/LoRA via the standard `ModelConfig` flags. + +```bash +python trl/experimental/sdpo/sdpo.py \ + --model_name_or_path Qwen/Qwen2.5-Math-1.5B-Instruct \ + --dataset_name openai/gsm8k \ + --dataset_config main \ + --output_dir outputs/sdpo-qwen35-2b-gsm8k \ + --learning_rate 5e-5 \ + --dtype bfloat16 \ + --bf16 true \ + --max_completion_length 128 \ + --use_peft \ + --lora_target_modules q_proj k_proj v_proj o_proj gate_proj up_proj down_proj \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 2 \ + --num_generations 8 \ + --generation_batch_size 32 \ + --distillation_alpha 1.0 \ + --full_logit_distillation false \ + --sdpo_policy_loss_mode hybrid \ + --report_to none \ + --eval_strategy steps \ + --eval_steps 1000 \ + --save_strategy no +``` + +## SDPOConfig + +[[autodoc]] experimental.sdpo.SDPOConfig + +## SDPOTrainer + +[[autodoc]] experimental.sdpo.SDPOTrainer + - train + - save_model + - push_to_hub diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sft_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sft_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..0f25a2e6f48687a328b61b5523cb16bfb69e480c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/sft_trainer.md @@ -0,0 +1,349 @@ +# SFT Trainer + +[![All_models-SFT-blue](https://img.shields.io/badge/All_models-SFT-blue)](https://huggingface.co/models?other=sft,trl) [![smol_course-Chapter_1-yellow](https://img.shields.io/badge/smol_course-Chapter_1-yellow)](https://github.com/huggingface/smol-course/tree/main/1_instruction_tuning) + +## Overview + +TRL supports the Supervised Fine-Tuning (SFT) Trainer for training language models. + +This post-training method was contributed by [Younes Belkada](https://huggingface.co/ybelkada). + +## Quick start + +This example demonstrates how to train a language model using the [`SFTTrainer`] from TRL. We train a [Qwen 3 0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) model on the [Capybara dataset](https://huggingface.co/datasets/trl-lib/Capybara), a compact, diverse multi-turn dataset to benchmark reasoning and generalization. + +```python +from trl import SFTTrainer +from datasets import load_dataset + +trainer = SFTTrainer( + model="Qwen/Qwen3-0.6B", + train_dataset=load_dataset("trl-lib/Capybara", split="train"), +) +trainer.train() +``` + + + +## Expected dataset type and format + +SFT supports both [language modeling](dataset_formats#language-modeling) and [prompt-completion](dataset_formats#prompt-completion) datasets. The [`SFTTrainer`] is compatible with both [standard](dataset_formats#standard) and [conversational](dataset_formats#conversational) dataset formats. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +```python +# Standard language modeling +{"text": "The sky is blue."} + +# Conversational language modeling +{"messages": [{"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}]} + +# Standard prompt-completion +{"prompt": "The sky is", + "completion": " blue."} + +# Conversational prompt-completion +{"prompt": [{"role": "user", "content": "What color is the sky?"}], + "completion": [{"role": "assistant", "content": "It is blue."}]} +``` + +If your dataset is not in one of these formats, you can preprocess it to convert it into the expected format. Here is an example with the [FreedomIntelligence/medical-o1-reasoning-SFT](https://huggingface.co/datasets/FreedomIntelligence/medical-o1-reasoning-SFT) dataset: + +```python +from datasets import load_dataset + +dataset = load_dataset("FreedomIntelligence/medical-o1-reasoning-SFT", "en") + +def preprocess_function(example): + return { + "prompt": [{"role": "user", "content": example["Question"]}], + "completion": [ + {"role": "assistant", "content": f"{example['Complex_CoT']}{example['Response']}"} + ], + } + +dataset = dataset.map(preprocess_function, remove_columns=["Question", "Response", "Complex_CoT"]) +print(next(iter(dataset["train"]))) +``` + +```json +{ + "prompt": [ + { + "content": "Given the symptoms of sudden weakness in the left arm and leg, recent long-distance travel, and the presence of swollen and tender right lower leg, what specific cardiac abnormality is most likely to be found upon further evaluation that could explain these findings?", + "role": "user", + } + ], + "completion": [ + { + "content": "Okay, let's see what's going on here. We've got sudden weakness [...] clicks into place!The specific cardiac abnormality most likely to be found in [...] the presence of a PFO facilitating a paradoxical embolism.", + "role": "assistant", + } + ], +} +``` + +## Looking deeper into the SFT method + +Supervised Fine-Tuning (SFT) is the simplest and most commonly used method to adapt a language model to a target dataset. The model is trained in a fully supervised fashion using pairs of input and output sequences. The goal is to minimize the negative log-likelihood (NLL) of the target sequence, conditioning on the input. + +This section breaks down how SFT works in practice, covering the key steps: **preprocessing**, **tokenization** and **loss computation**. + +### Preprocessing and tokenization + +During training, each example is expected to contain a **text field** or a **(prompt, completion)** pair, depending on the dataset format. For more details on the expected formats, see [Dataset formats](dataset_formats). +The [`SFTTrainer`] tokenizes each input using the model's tokenizer. If both prompt and completion are provided separately, they are concatenated before tokenization. + +### Computing the loss + +![sft_figure](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/sft_figure.png) + +The loss used in SFT is the **token-level cross-entropy loss**, defined as: + +$$ +\mathcal{L}_{\text{SFT}}(\theta) = - \sum_{t=1}^{T} \log p_\theta(y_t \mid y_{ [!TIP] +> The paper [On the Generalization of SFT: A Reinforcement Learning Perspective with Reward Rectification](https://huggingface.co/papers/2508.05629) proposes an alternative loss function, called **Dynamic Fine-Tuning (DFT)**, which aims to improve generalization by rectifying the reward signal. This method can be enabled by setting `loss_type="dft"` in the [`SFTConfig`]. For more details, see [Paper Index - Dynamic Fine-Tuning](paper_index#on-the-generalization-of-sft-a-reinforcement-learning-perspective-with-reward-rectification). + +> [!TIP] +> For a memory-efficient variant of the standard loss, set `loss_type="chunked_nll"` in the [`SFTConfig`]. Same math as `"nll"`, but the `lm_head` projection skips ignored-label tokens and the cross-entropy is processed in chunks, so peak activation memory does not scale with the full vocab × seq_len logits tensor. See [Chunked cross-entropy for reducing peak memory usage](reducing_memory_usage#chunked-cross-entropy-for-reducing-peak-memory-usage). + +### Label shifting and masking + +During training, the loss is computed using a **one-token shift**: the model is trained to predict each token in the sequence based on all previous tokens. Specifically, the input sequence is shifted right by one position to form the target labels. +Padding tokens (if present) are ignored in the loss computation by applying an ignore index (default: `-100`) to the corresponding positions. This ensures that the loss focuses only on meaningful, non-padding tokens. + +## Logged metrics + +While training and evaluating we record the following reward metrics: + +* `global_step`: The total number of optimizer steps taken so far. +* `epoch`: The current epoch number, based on dataset iteration. +* `num_tokens`: The total number of tokens processed so far. +* `loss`: The average cross-entropy loss computed over non-masked tokens in the current logging interval. +* `entropy`: The average entropy of the model's predicted token distribution over non-masked tokens. +* `mean_token_accuracy`: The proportion of non-masked tokens for which the model’s top-1 prediction matches the ground truth token. +* `learning_rate`: The current learning rate, which may change dynamically if a scheduler is used. +* `grad_norm`: The L2 norm of the gradients, computed before gradient clipping. + +## Customization + +### Model initialization + +You can directly pass the kwargs of the [`~transformers.AutoModelForCausalLM.from_pretrained()`] method to the [`SFTConfig`]. For example, if you want to load a model in a different precision, analogous to + +```python +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B", dtype=torch.bfloat16) +``` + +you can do so by passing the `model_init_kwargs={"dtype": torch.bfloat16}` argument to the [`SFTConfig`]. + +```python +from trl import SFTConfig + +training_args = SFTConfig( + model_init_kwargs={"dtype": torch.bfloat16}, +) +``` + +Note that all keyword arguments of [`~transformers.AutoModelForCausalLM.from_pretrained()`] are supported. + +### Packing + +[`SFTTrainer`] supports _example packing_, where multiple examples are packed in the same input sequence to increase training efficiency. To enable packing, simply pass `packing=True` to the [`SFTConfig`] constructor. + +```python +training_args = SFTConfig(packing=True) +``` + +For more details on packing, see [Packing](reducing_memory_usage#packing). + +### Train on assistant messages only + +To train on assistant messages only, use a [conversational](dataset_formats#conversational) dataset and set `assistant_only_loss=True` in the [`SFTConfig`]. This setting ensures that loss is computed **only** on the assistant responses, ignoring user or system messages. + +```python +training_args = SFTConfig(assistant_only_loss=True) +``` + +![train_on_assistant](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/train_on_assistant.png) + +> [!WARNING] +> This functionality requires the chat template to include `{% generation %}` and `{% endgeneration %}` keywords. For known model families (e.g. Qwen3), TRL automatically patches the template when `assistant_only_loss=True`. See [Chat Templates](chat_templates#training-templates) for the full list of bundled training templates. For other models, check that your chat template includes these keywords. See [HuggingFaceTB/SmolLM3-3B](https://huggingface.co/HuggingFaceTB/SmolLM3-3B/blob/main/chat_template.jinja#L76-L82) for an example. + +### Train on completion only + +To train on completion only, use a [prompt-completion](dataset_formats#prompt-completion) dataset. By default, the trainer computes the loss on the completion tokens only, ignoring the prompt tokens. If you want to train on the full sequence, set `completion_only_loss=False` in the [`SFTConfig`]. + +```python +from trl import SFTConfig, SFTTrainer +from datasets import load_dataset + +# Load a prompt-completion dataset; loss is computed on the completion only by default +dataset = load_dataset("trl-lib/kto-mix-14k", split="train") + +trainer = SFTTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + args=SFTConfig(completion_only_loss=True), # True by default for prompt-completion datasets + train_dataset=dataset, +) +trainer.train() +``` + +![train_on_completion](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/train_on_completion.png) + +> [!TIP] +> Training on completion only is compatible with training on assistant messages only. In this case, use a [conversational](dataset_formats#conversational) [prompt-completion](dataset_formats#prompt-completion) dataset and set `assistant_only_loss=True` in the [`SFTConfig`]. + +### Train adapters with PEFT + +We support tight integration with 🤗 PEFT library, allowing any user to conveniently train adapters and share them on the Hub, rather than training the entire model. + +```python +from datasets import load_dataset +from trl import SFTTrainer +from peft import LoraConfig + +dataset = load_dataset("trl-lib/Capybara", split="train") + +trainer = SFTTrainer( + "Qwen/Qwen3-0.6B", + train_dataset=dataset, + peft_config=LoraConfig(), +) + +trainer.train() +``` + +You can also continue training your [`~peft.PeftModel`]. For that, first load a `PeftModel` outside [`SFTTrainer`] and pass it directly to the trainer without the `peft_config` argument being passed. + +```python +from datasets import load_dataset +from trl import SFTTrainer +from peft import AutoPeftModelForCausalLM + +model = AutoPeftModelForCausalLM.from_pretrained("trl-lib/Qwen3-4B-LoRA", is_trainable=True) +dataset = load_dataset("trl-lib/Capybara", split="train") + +trainer = SFTTrainer( + model=model, + train_dataset=dataset, +) + +trainer.train() +``` + +> [!TIP] +> When training adapters, you typically use a higher learning rate (≈1e‑4) since only new parameters are being learned. +> +> ```python +> SFTConfig(learning_rate=1e-4, ...) +> ``` + +### Train with Liger Kernel + +Liger Kernel is a collection of Triton kernels for LLM training that boosts multi-GPU throughput by 20%, cuts memory use by 60% (enabling up to 4× longer context), and works seamlessly with tools like FlashAttention, PyTorch FSDP, and DeepSpeed. For more information, see [Liger Kernel Integration](liger_kernel_integration). + +### Rapid Experimentation for SFT + +RapidFire AI is an open-source experimentation engine that sits on top of TRL and lets you launch multiple SFT configurations at once, even on a single GPU. Instead of trying configurations sequentially, RapidFire lets you **see all their learning curves earlier, stop underperforming runs, and clone promising ones with new settings in flight** without restarting. For more information, see [RapidFire AI Integration](rapidfire_integration). + +### Train with Unsloth + +Unsloth is an open‑source framework for fine‑tuning and reinforcement learning that trains LLMs (like Llama, Mistral, Gemma, DeepSeek, and more) up to 2× faster with up to 70% less VRAM, while providing a streamlined, Hugging Face–compatible workflow for training, evaluation, and deployment. For more information, see [Unsloth Integration](unsloth_integration). + +## Instruction tuning example + +**Instruction tuning** teaches a base language model to follow user instructions and engage in conversations. This requires: + +1. **Chat template**: Defines how to structure conversations into text sequences, including role markers (user/assistant), special tokens, and turn boundaries. Read more about chat templates in [Chat templates](https://huggingface.co/docs/transformers/chat_templating#templates). +2. **Conversational dataset**: Contains instruction-response pairs + +This example shows how to transform the [Qwen 3 0.6B Base](https://huggingface.co/Qwen/Qwen3-0.6B-Base) model into an instruction-following model using the [Capybara dataset](https://huggingface.co/datasets/trl-lib/Capybara) and a chat template from [HuggingFaceTB/SmolLM3-3B](https://huggingface.co/HuggingFaceTB/SmolLM3-3B). The SFT Trainer automatically handles tokenizer updates and special token configuration. + +```python +from trl import SFTConfig, SFTTrainer +from datasets import load_dataset + +trainer = SFTTrainer( + model="Qwen/Qwen3-0.6B-Base", + args=SFTConfig( + output_dir="Qwen3-0.6B-Instruct", + chat_template_path="HuggingFaceTB/SmolLM3-3B", + ), + train_dataset=load_dataset("trl-lib/Capybara", split="train"), +) +trainer.train() +``` + +> [!WARNING] +> Some base models, like those from Qwen, have a predefined chat template in the model's tokenizer. In these cases, it is not necessary to apply [`clone_chat_template()`], as the tokenizer already handles the formatting. However, it is necessary to align the EOS token with the chat template to ensure the model's responses terminate correctly. In these cases, specify `eos_token` in [`SFTConfig`]; for example, for `Qwen/Qwen2.5-1.5B`, one should set `eos_token="<|im_end|>"`. + +Once trained, your model can now follow instructions and engage in conversations using its new chat template. + +```python +>>> from transformers import pipeline +>>> pipe = pipeline("text-generation", model="Qwen3-0.6B-Instruct/checkpoint-5000") +>>> prompt = "<|im_start|>user\nWhat is the capital of France? Answer in one word.<|im_end|>\n<|im_start|>assistant\n" +>>> response = pipe(prompt) +>>> response[0]["generated_text"] +'<|im_start|>user\nWhat is the capital of France? Answer in one word.<|im_end|>\n<|im_start|>assistant\nThe capital of France is Paris.' +``` + +Alternatively, use the structured conversation format (recommended): + +```python +>>> prompt = [{"role": "user", "content": "What is the capital of France? Answer in one word."}] +>>> response = pipe(prompt) +>>> response[0]["generated_text"] +[{'role': 'user', 'content': 'What is the capital of France? Answer in one word.'}, {'role': 'assistant', 'content': 'The capital of France is Paris.'}] +``` + +## Tool Calling with SFT + +The [`SFTTrainer`] fully supports fine-tuning models with _tool calling_ capabilities. In this case, each dataset example should include: + +* The conversation messages, including any tool calls (`tool_calls`) and tool responses (`tool` role messages) +* The list of available tools in the `tools` column, typically provided as JSON schemas + +For details on the expected dataset structure, see the [Dataset Format — Tool Calling](dataset_formats#tool-calling) section. + +## Training Vision Language Models + +[`SFTTrainer`] fully supports training Vision-Language Models (VLMs). To train a VLM, provide a dataset with either an `image` column (single image per sample) or an `images` column (list of images per sample). For more information on the expected dataset structure, see the [Dataset Format — Vision Dataset](dataset_formats#vision-dataset) section. +An example of such a dataset is the [LLaVA Instruct Mix](https://huggingface.co/datasets/trl-lib/llava-instruct-mix). + +```python +from trl import SFTConfig, SFTTrainer +from datasets import load_dataset + +trainer = SFTTrainer( + model="Qwen/Qwen2.5-VL-3B-Instruct", + args=SFTConfig(max_length=None), + train_dataset=load_dataset("trl-lib/llava-instruct-mix", split="train"), +) +trainer.train() +``` + +> [!TIP] +> For VLMs, truncating may remove image tokens, leading to errors during training. To avoid this, set `max_length=None` in the [`SFTConfig`]. This allows the model to process the full sequence length without truncating image tokens. +> +> ```python +> SFTConfig(max_length=None, ...) +> ``` +> +> Only use `max_length` when you've verified that truncation won't remove image tokens for the entire dataset. + +## SFTTrainer + +[[autodoc]] SFTTrainer + - train + - save_model + - push_to_hub + +## SFTConfig + +[[autodoc]] SFTConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/speeding_up_training.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/speeding_up_training.md new file mode 100644 index 0000000000000000000000000000000000000000..c855cc06233a198e3e6967345b2b0984c5b90d93 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/speeding_up_training.md @@ -0,0 +1,204 @@ +# Speeding Up Training + +This guide covers various methods to accelerate training in TRL. Each technique includes minimal examples with links to more comprehensive documentation. + +## vLLM for fast generation in online methods + +[Online methods](index#online-methods) such as GRPO or Online DPO require the model to generate completions, which is often a slow process and can significantly impact training time. +To speed up generation, you can use [vLLM](https://github.com/vllm-project/vllm), a library that enables fast generation through, among other things, PagedAttention. TRL's online trainers support vLLM, greatly improving training speed. For more details, see [vLLM Integration](vllm_integration). + +To use [vLLM](https://github.com/vllm-project/vllm), first install it using: + +```bash +pip install trl[vllm] +``` + + + + +First, start a vLLM server by running: + +```bash +trl vllm-serve --model +``` + +Then, run the training script and pass `use_vllm=True` in the training arguments. + +```python +from trl.experimental.online_dpo import OnlineDPOConfig + +training_args = OnlineDPOConfig(..., use_vllm=True, vllm_mode="server") +``` + + + + +First, start a vLLM server by running: + +```bash +trl vllm-serve --model +``` + +Then, run the training script and pass `use_vllm=True` in the training arguments. + +```python +from trl import GRPOConfig + +training_args = GRPOConfig(..., use_vllm=True, vllm_mode="server") +``` + +You can customize the server configuration by passing additional arguments. For more information, see [vLLM integration](vllm_integration). + +> [!WARNING] +> When using vLLM, ensure that the GPUs assigned for training and generation are separate to avoid resource conflicts. For instance, if you plan to use 4 GPUs for training and another 4 for vLLM generation, you can specify GPU allocation using `CUDA_VISIBLE_DEVICES`. +> +> Set GPUs **0-3** for vLLM generation: +> +> ```sh +> CUDA_VISIBLE_DEVICES=0,1,2,3 trl vllm-serve --model +> ``` +> +> And GPUs **4-7** for training: +> +> ```sh +> CUDA_VISIBLE_DEVICES=4,5,6,7 accelerate launch train.py +> ``` + + + + +First, start a vLLM server by running: + +```bash +trl vllm-serve --model +``` + +Then, run the training script and pass `use_vllm=True` in the training arguments. + +```python +from trl import RLOOConfig + +training_args = RLOOConfig(..., use_vllm=True, vllm_mode="server") +``` + +You can customize the server configuration by passing additional arguments. For more information, see [vLLM integration](vllm_integration). + +> [!WARNING] +> When using vLLM, ensure that the GPUs assigned for training and generation are separate to avoid resource conflicts. For instance, if you plan to use 4 GPUs for training and another 4 for vLLM generation, you can specify GPU allocation using `CUDA_VISIBLE_DEVICES`. +> +> Set GPUs **0-3** for vLLM generation: +> +> ```sh +> CUDA_VISIBLE_DEVICES=0,1,2,3 trl vllm-serve --model +> ``` +> +> And GPUs **4-7** for training: +> +> ```sh +> CUDA_VISIBLE_DEVICES=4,5,6,7 accelerate launch train.py +> ``` + + + + +## Optimized attention implementations + +TRL supports various optimized attention implementations that can significantly speed up training while reducing memory usage. You can use either a pre-optimized kernels directly from the [Kernels Hub](kernels_hub) or a manually built attention backend. + + + + +You can use pre-optimized attention kernels from the Hub without manual compilation: + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., model_init_kwargs={"attn_implementation": "kernels-community/flash-attn2"}) +``` + +Other options include `kernels-community/vllm-flash-attn3` and `kernels-community/paged-attention`. + +Optimized attention works across all TRL trainers. For more details, see [Kernels Hub Integration](kernels_hub). + + + + +> [!WARNING] +> Manually building optimized attention backends is complex and time-consuming. It's never recommended unless absolutely necessary. Consider using Kernels from the Hub instead, as described in the previous section. + +If you have manually installed an optimized attention backend like Flash Attention 2, you can specify it in the training arguments: + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., model_init_kwargs={"attn_implementation": "flash_attention_2"}) +``` + + + + +## Liger Kernel for memory optimization + +Liger Kernel is a collection of Triton kernels designed for LLM training that can increase throughput by 20% and reduce memory usage by 60%. + + + + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import DPOConfig + +training_args = DPOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl.experimental.kto import KTOConfig + +training_args = KTOConfig(..., use_liger_kernel=True) +``` + + + + +```python +from trl.experimental.gkd import GKDConfig + +training_args = GKDConfig(..., use_liger_kernel=True) +``` + + + + +For more information, see [Liger Kernel Integration](liger_kernel_integration). + +## Mixed precision training + +Mixed precision training using bf16 or fp16 can speed up training and reduce memory usage with minimal impact on model quality. + +```python +from trl import SFTConfig + +training_args = SFTConfig(..., bf16=True) # or fp16=True for older GPUs +``` + +Use `bf16=True` for Ampere GPUs (A100, RTX 30xx) or newer, and `fp16=True` for older GPUs. Mixed precision training is supported across all TRL trainers. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ssd_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ssd_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..c51f8165a2f746047f18a4bc5c163bd6f886368f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/ssd_trainer.md @@ -0,0 +1,111 @@ +# SSD + +Simple Self-Distillation (SSD) is described in [Embarrassingly Simple Self-Distillation Improves Code Generation](https://huggingface.co/papers/2604.01193). + +SSD samples completions from the model at a training-time temperature and truncation configuration, then fine-tunes on those raw, unverified samples with standard cross-entropy loss. It requires no reward model, verifier, teacher model, or reinforcement learning — only a set of problem prompts and the model itself. + +In the current TRL implementation: + +- the model generates completions at a specified training-time temperature (`temperature`) and truncation (`top_k`, `top_p`) +- the dataset only requires a `prompt` column +- training uses standard cross-entropy loss on the generated completions +- empty or single-line stub completions are filtered by default (`filter_empty=True`) +- the evaluation-time temperature and truncation are set independently at inference time +- vLLM can be used for faster generation via `use_vllm=True` (see [vLLM integration](vllm_integration)) + +## Usage + +```python +from datasets import Dataset + +from trl.experimental.ssd import SSDConfig, SSDTrainer + +dataset = Dataset.from_dict( + { + "prompt": [ + [{"role": "user", "content": "Write a function to add two numbers."}], + [{"role": "user", "content": "Write a function to check if a number is prime."}], + ], + } +) + +training_args = SSDConfig( + output_dir="ssd-model", + temperature=0.6, # T_train from the paper + top_k=20, # training-time top-k truncation + top_p=0.95, # training-time top-p truncation + max_completion_length=65536, + learning_rate=5e-6, +) + +trainer = SSDTrainer( + model="Qwen/Qwen3-4B-Instruct", + args=training_args, + train_dataset=dataset, +) +trainer.train() +``` + +## Expected dataset columns + +Each example must provide: + +- `prompt`: the problem prompt (string or conversational format) + +No `privileged_context`, reward functions, or teacher model are needed. + +## Key hyperparameters + +The paper identifies the following key hyperparameters: + +- **`temperature`**: training-time sampling temperature (T_train). Higher values create more diverse samples but may include more noise. The paper uses T_train=0.6 with truncation. +- **`top_k`** and **`top_p`**: training-time truncation parameters (rho_train). These suppress low-probability distractor tails during data synthesis. +- **T_eval**: the evaluation-time decoding temperature is set independently at inference time. The paper shows that T_train and T_eval compose through an effective temperature T_eff = T_train * T_eval, with a broad optimal band. + +## Example script + +Use [`trl/experimental/ssd/ssd.py`](https://github.com/huggingface/trl/blob/main/trl/experimental/ssd/ssd.py) to launch SSD training from the command line. The script supports any causal LM from the Hub, custom local datasets via `--dataset_path`, and PEFT/LoRA via the standard `ModelConfig` flags. + +```bash +python trl/experimental/ssd/ssd.py \ + --model_name_or_path Qwen/Qwen3-4B-Instruct-2507 \ + --dataset_name microsoft/rStar-Coder \ + --dataset_config seed_sft \ + --prompt_column question \ + --output_dir outputs/ssd-qwen3-4b \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 32 \ + --learning_rate 5e-6 \ + --lr_scheduler_type cosine \ + --max_prompt_length 1024 \ + --max_completion_length 65536 \ + --temperature 1.6 \ + --top_k 20 \ + --top_p 0.8 \ + --num_train_epochs 1 \ + --bf16 \ + --report_to trackio +``` + +## Evaluation on LiveCodeBench + +Use [`trl/experimental/ssd/ssd_eval.py`](https://github.com/huggingface/trl/blob/main/trl/experimental/ssd/ssd_eval.py) to evaluate a base model or an SSD-trained checkpoint on LiveCodeBench v6. The script uses vLLM for generation and LiveCodeBench's official `codegen_metrics` for sandboxed `pass@k` scoring; default decoding parameters match Table 3 of the paper. + +```bash +python trl/experimental/ssd/ssd_eval.py \ + --model_name_or_path \ + --temperature 1.1 --top_k 20 --top_p 0.8 \ + --n 1 \ + --output_file outputs/lcb_v6.json +``` + +## SSDConfig + +[[autodoc]] experimental.ssd.SSDConfig + +## SSDTrainer + +[[autodoc]] experimental.ssd.SSDTrainer + - train + - save_model + - push_to_hub diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/tpo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/tpo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..9b025c069b8d70c1445c32efc54e9a216071020e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/tpo_trainer.md @@ -0,0 +1,135 @@ +# TPO Trainer + +[![All_models-TPO-blue](https://img.shields.io/badge/All_models-TPO-blue)](https://huggingface.co/models?other=tpo,trl) + +## Overview + +Triple Preference Optimization (TPO) was introduced in the paper [Triple Preference Optimization: Achieving Better Alignment using a Single Step Optimization](https://huggingface.co/papers/2405.16681) by Amir Saeidi, Shivanshu Verma, Aswin RRV, and Chitta Baral. TPO enhances the instruction-following and reasoning capabilities of large language models in a single training step, starting from a pre-trained or instruction-tuned model. + +The abstract from the paper is the following: + +> Reinforcement Learning with Human Feedback (RLHF) enhances the alignment of Large Language Models (LLMs). However, its limitations have led to the development of Direct Preference Optimization (DPO), an RL-free approach designed to overcome these shortcomings. While studies have shown that DPO improves instruction-following capabilities, it negatively impacts the reasoning ability of LLMs. Additionally, DPO is highly sensitive to judgment noise in preference datasets and the size of the training set. Although several modifications to DPO have been proposed, they still fail to fully resolve these issues. To address these limitations, we propose Triple Preference Optimization (TPO), a new preference learning method designed to enhance both reasoning and instruction-following abilities through one-step optimization. We compare TPO against DPO and its recent variants using state-of-the-art training setups, including both base and instructiontuned models such as Mistral and Llama 3. Our evaluation covers a comprehensive range of chat-based and reasoning benchmarks. The results demonstrate that TPO achieves significant improvements over existing methods without substantially increasing response length across different dataset sizes. Specifically, TPO outperforms DPO and SimPO by up to 7.0% and 7.3% points on Arena-Hard, 12.2% and 13.3% points on MixEval-Hard, 10.4% and 10.1% points on MMLU-Pro, and 19.0% and 19.2% points on GSM8K, respectively. Furthermore, TPO achieves these improvements while requiring less data than DPO. + +This post-training method was contributed by [Kashif Rasul](https://huggingface.co/kashif). + +## Quick start + +This example demonstrates how to train a model using the TPO method. We use the [Qwen 3 0.6B model](https://huggingface.co/Qwen/Qwen3-0.6B) as the base model. TPO requires a *triple-preference* dataset (`prompt`, `chosen`, `rejected`, `reference`) — see [Expected dataset type](#expected-dataset-type-and-format) below. + +Below is the script to train the model: + +```python +# train_tpo.py +from datasets import load_dataset +from trl.experimental.tpo import TPOConfig, TPOTrainer +from transformers import AutoModelForCausalLM, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B") +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B") +train_dataset = load_dataset("tpo-alignment/triple-preference-ultrafeedback-40K", split="train") + +training_args = TPOConfig(output_dir="Qwen3-0.6B-TPO") +trainer = TPOTrainer(model=model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_tpo.py +``` + +## Expected dataset type and format + +TPO requires a *triple-preference* dataset: each example must contain a `prompt`, a `chosen` (preferred) completion, a `rejected` (dispreferred) completion **and** a `reference` (gold) completion. The [`experimental.tpo.TPOTrainer`] supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset formats. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +```python +# Standard format +triple_preference_example = { + "prompt": "The sky is", + "reference": " a beautiful shade of blue.", # gold response (used for the NLL term) + "chosen": " blue.", + "rejected": " green.", +} + +# Conversational format +triple_preference_example = { + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "reference": [{"role": "assistant", "content": "It is a beautiful shade of blue."}], + "chosen": [{"role": "assistant", "content": "It is blue."}], + "rejected": [{"role": "assistant", "content": "It is green."}], +} +``` + +The reference response is typically the highest-quality completion available for the prompt; in the original TPO paper it is taken from the response with the highest score in [UltraFeedback](https://huggingface.co/datasets/openbmb/UltraFeedback), with the second-highest used as the chosen completion and the lowest as the rejected completion. + +## Example script + +We provide an example script to train a model using the TPO method. The script is available at [`trl/experimental/tpo/tpo.py`](https://github.com/huggingface/trl/blob/main/trl/experimental/tpo/tpo.py). + +To test the TPO script with the [Qwen 3 0.6B model](https://huggingface.co/Qwen/Qwen3-0.6B) on a triple-preference dataset, run the following command: + +```bash +accelerate launch trl/experimental/tpo/tpo.py \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --dataset_name tpo-alignment/triple-preference-ultrafeedback-40K \ + --beta 0.01 \ + --tpo_alpha 1.0 \ + --learning_rate 5e-7 \ + --num_train_epochs 1 \ + --output_dir Qwen3-0.6B-TPO +``` + +## Looking deeper into the TPO method + +Triple Preference Optimization (TPO) extends preference-based alignment from pairs to *triples* `(y_gold, y_chosen, y_rejected)`. The model is jointly optimized with two objectives in a single step: + +1. A **contrastive loss** between the chosen and rejected completions, similar in spirit to DPO/SimPO but computed directly from the policy log-probabilities (no separate reference policy is required). +2. A **supervised negative log-likelihood (NLL) loss** on the gold (`reference`) completion, weighted by `tpo_alpha`. This term replaces the standalone SFT stage typically required before DPO. + +The total TPO loss is: + +$$ +\mathcal{L}_{\mathrm{TPO}}(\theta) = \mathcal{L}_{\mathrm{contrast}}(\theta) + \alpha \cdot \mathcal{L}_{\mathrm{NLL}}(\theta; y_{\text{gold}}) +$$ + +where \\( \alpha \\) is `tpo_alpha` and \\( \mathcal{L}_{\mathrm{contrast}} \\) is selected via `loss_type`. + +### Loss types + +| `loss_type=` | Description | +| --- | --- | +| `"sigmoid"` (default) | Sigmoid loss on the (sum) log-probability difference between the chosen and rejected completions, as in the original [TPO](https://huggingface.co/papers/2405.16681) paper. | +| `"hinge"` | Hinge loss on the normalized likelihood from the [SLiC](https://huggingface.co/papers/2305.10425) paper. In this case, `beta` is the reciprocal of the margin. | +| `"ipo"` | IPO loss from the [IPO](https://huggingface.co/papers/2310.12036) paper, computed on length-normalized log-probabilities. | +| `"tpo-l"` | Length-normalized TPO variant: uses average per-token log-probabilities and adds a target reward margin `tpo_l_gamma` to the Bradley-Terry objective, in the spirit of [SimPO](https://huggingface.co/papers/2405.14734). | + +Setting `tpo_alpha=0.0` disables the NLL term entirely (the reference response is then unused, and the corresponding cross-entropy is skipped to save compute). + +## Logged metrics + +While training and evaluating we record the following metrics: + +* `loss`: The total TPO loss (contrastive + `tpo_alpha` × NLL) averaged over the current logging interval. +* `entropy`: The average entropy of the model's predicted token distribution over completion tokens. +* `mean_token_accuracy`: The proportion of completion tokens for which the model's top-1 prediction matches the chosen completion. +* `num_tokens`: The total number of tokens processed so far. +* `logits/chosen`: The average logit values assigned by the model to the tokens in the chosen completion. +* `logits/rejected`: The average logit values assigned by the model to the tokens in the rejected completion. +* `logps/chosen`: The average log-probability assigned by the model to the chosen completion. +* `logps/rejected`: The average log-probability assigned by the model to the rejected completion. +* `rewards/chosen`: The average implicit reward computed for the chosen completion, defined as \\( \beta \log \pi_{\theta}(y^{+}\!\mid x) \\). +* `rewards/rejected`: The average implicit reward computed for the rejected completion, defined as \\( \beta \log \pi_{\theta}(y^{-}\!\mid x) \\). +* `rewards/margins`: The average implicit reward margin between the chosen and rejected completions. +* `rewards/accuracies`: The proportion of examples where the implicit reward for the chosen completion is higher than that for the rejected completion. + +## TPOTrainer + +[[autodoc]] experimental.tpo.TPOTrainer + - train + - save_model + - push_to_hub + +## TPOConfig + +[[autodoc]] experimental.tpo.TPOConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/trackio_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/trackio_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..4e93120fe19a8dfe3443e791bff8d60350908b8b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/trackio_integration.md @@ -0,0 +1,67 @@ +# Trackio Integration + +[Trackio](https://huggingface.co/docs/trackio) is a lightweight, free experiment tracking library built on top of **🤗 Datasets** and **🤗 Spaces**. It is the **recommended tracking solution for TRL** and comes natively integrated with all trainers. + +To enable logging, simply set `report_to="trackio"` in your training config: + +```python +from trl import SFTConfig # works with any trainer config (e.g. DPOConfig, GRPOConfig, etc.) + +training_args = SFTConfig( + ..., + report_to="trackio", # enable Trackio logging +) +``` + +## Organizing Your Experiments with Run Names and Projects + +By default, Trackio will generate a name to identify each run. However, we highly recommend setting a descriptive `run_name` to make it easier to organize experiments. For example: + +```python +from trl import SFTConfig + +training_args = SFTConfig( + ..., + report_to="trackio", + run_name="sft_qwen3-4b_lr2e-5_bs128", # descriptive run name +) +``` + +You can also group related experiments by project by setting the following environment variable: + +```bash +export TRACKIO_PROJECT="my_project" +``` + +## Hosting Your Logs on 🤗 Spaces + +Trackio has local-first design, meaning your logs stay on your machine. If you’d like to host them and deploy a dashboard on **🤗 Spaces**, set: + +```bash +export TRACKIO_SPACE_ID="username/space_id" +``` + +Running the following example: + +```python +import os +from trl import SFTConfig, SFTTrainer +from datasets import load_dataset + +os.environ["TRACKIO_SPACE_ID"] = "trl-lib/trackio" +os.environ["TRACKIO_PROJECT"] = "trl-documentation" + +trainer = SFTTrainer( + model="Qwen/Qwen3-0.6B", + train_dataset=load_dataset("trl-lib/Capybara", split="train"), + args=SFTConfig( + report_to="trackio", + run_name="sft_qwen3-0.6b_capybara", + ), +) +trainer.train() +``` + +will give you a hosted dashboard at https://huggingface.co/spaces/trl-lib/trackio. + + diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/unsloth_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/unsloth_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..0350bc21612580f6d333860872289e8f1b4b201c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/unsloth_integration.md @@ -0,0 +1,125 @@ +# Unsloth Integration + +Unsloth is an open‑source framework for fine‑tuning and reinforcement learning that trains LLMs (like Llama, OpenAI gpt-oss, Mistral, Gemma, DeepSeek, and more) up to 2× faster with up to 80% less VRAM. Unsloth allows [training](https://huggingface.co/docs/trl/en/unsloth_integration#Training), evaluation, running and [deployment](https://huggingface.co/docs/trl/en/unsloth_integration#Saving-the-model) with other inference engines like llama.cpp, Ollama and vLLM. + +The library provides a streamlined, Hugging Face compatible workflow for training, evaluation, inference and deployment and is fully compatible with [`SFTTrainer`]. + +## Key Features + +- Training support for all transformer compatible models: Text-to-speech (TTS), multimodal, BERT, RL and more +- Supports full fine-tuning, pretraining, LoRA, QLoRA, 8-bit training & more +- Works on Linux, Windows, Colab, Kaggle; NVIDIA GPUs, soon AMD & Intel setups +- Supports most features TRL supports, including RLHF (GSPO, GRPO, DPO etc.) +- Hand-written Triton kernels and a manual backprop engine ensure no accuracy degradation (0% approximation error) + +## Installation + +### pip install + +Local Installation (Linux recommended): + +```sh +pip install unsloth +``` + +You can also install `unsloth` according to the [official documentation](https://docs.unsloth.ai/get-started/installing-+-updating). Once installed, you can incorporate unsloth into your workflow in a very simple manner; instead of loading [`~transformers.AutoModelForCausalLM`], you just need to load a `FastLanguageModel` as follows: + +```python +import torch +from trl import SFTConfig, SFTTrainer +from unsloth import FastLanguageModel + +max_length = 2048 # Supports automatic RoPE Scaling, so choose any number + +# Load model +model, tokenizer = FastLanguageModel.from_pretrained( + model_name="unsloth/mistral-7b", + max_seq_length=max_length, + dtype="auto", # For auto-detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+ + load_in_4bit=True, # Use 4bit quantization to reduce memory usage. Can be False +) + +# Do model patching and add fast LoRA weights +model = FastLanguageModel.get_peft_model( + model, + r=16, + target_modules=[ + "q_proj", + "k_proj", + "v_proj", + "o_proj", + "gate_proj", + "up_proj", + "down_proj", + ], + lora_alpha=16, + lora_dropout=0, # Dropout = 0 is currently optimized + bias="none", # Bias = "none" is currently optimized + use_gradient_checkpointing=True, + random_state=3407, +) + +training_args = SFTConfig(output_dir="./output", max_length=max_length) + +trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset, +) +trainer.train() +``` + +The saved model is fully compatible with Hugging Face's transformers library. Learn more about unsloth in their [official repository](https://github.com/unslothai/unsloth). + +### Docker Install + +```sh +docker run -d -e JUPYTER_PASSWORD="mypassword" \ + -p 8888:8888 -p 2222:22 \ + -v $(pwd)/work:/workspace/work \ + --gpus all \ + unsloth/unsloth +``` + +Access Jupyter Lab at ```http://localhost:8888``` and start fine-tuning! + +## Training + +These are some core settings you can toggle before training: + +- ```max_seq_length = 2048``` – Controls context length. While Llama-3 supports 8192, we recommend 2048 for testing. Unsloth enables 4× longer context fine-tuning. +- ```dtype = "auto"``` – For auto-detection; use torch.float16 or torch.bfloat16 for newer GPUs. +- ```load_in_4bit = True``` – Enables 4-bit quantization, reducing memory use 4× for fine-tuning. Disabling it allows for LoRA 16-bit fine-tuning to be enabled. +- To enable full fine-tuning (FFT), set ```full_finetuning = True```. For 8-bit fine-tuning, set ```load_in_8bit = True```. Note: Only one training method can be set to True at a time. + +For more information on configuring Unsloth's hyperparameters and features, read their [documentation guide here](https://docs.unsloth.ai/get-started/fine-tuning-llms-guide). + +## Saving the model + +Unsloth allows you to directly save the finetuned model as a small file called a LoRA adapter. You can instead push to the Hugging Face hub as well if you want to upload your model! Remember to get a [Hugging Face token](https://huggingface.co/settings/tokens) and add your token! + +### Saving to GGUF + +To save to GGUF, Unsloth uses llama.cpp. To save locally: + +```python +model.save_pretrained_gguf("directory", tokenizer, quantization_method = "q4_k_m") +model.save_pretrained_gguf("directory", tokenizer, quantization_method = "q8_0") +model.save_pretrained_gguf("directory", tokenizer, quantization_method = "f16") +``` + +To push to the hub: + +```python +model.push_to_hub_gguf("hf_username/directory", tokenizer, quantization_method = "q4_k_m") +model.push_to_hub_gguf("hf_username/directory", tokenizer, quantization_method = "q8_0") +``` + +### Saving to vLLM + +To save to 16-bit for vLLM, use: + +```python +model.save_pretrained_merged("model", tokenizer, save_method = "merged_16bit",) +model.push_to_hub_merged("hf/model", tokenizer, save_method = "merged_16bit", token = "") +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/use_model.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/use_model.md new file mode 100644 index 0000000000000000000000000000000000000000..fb12e4df92a637326b04a409edd0930c4d57df38 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/use_model.md @@ -0,0 +1,58 @@ +# Use model after training + +Once you have trained a model using either the SFTTrainer, PPOTrainer, or DPOTrainer, you will have a fine-tuned model that can be used for text generation. In this section, we'll walk through the process of loading the fine-tuned model and generating text. If you need to run an inference server with the trained model, you can explore libraries such as [`text-generation-inference`](https://github.com/huggingface/text-generation-inference). + +## Load and Generate + +If you have fine-tuned a model fully, meaning without the use of PEFT you can simply load it like any other language model in transformers. E.g. the value head that was trained during the PPO training is no longer needed and if you load the model with the original transformer class it will be ignored: + +```python +from transformers import AutoTokenizer, AutoModelForCausalLM + +model_name_or_path = "Qwen/Qwen3-0.6B" #path/to/your/model/or/name/on/hub +device = "cpu" # or "cuda" if you have a GPU + +model = AutoModelForCausalLM.from_pretrained(model_name_or_path).to(device) +tokenizer = AutoTokenizer.from_pretrained(model_name_or_path) + +inputs = tokenizer.encode("This movie was really", return_tensors="pt").to(device) +outputs = model.generate(inputs) +print(tokenizer.decode(outputs[0])) +``` + +Alternatively you can also use the pipeline: + +```python +from transformers import pipeline + +model_name_or_path = "Qwen/Qwen3-0.6B" #path/to/your/model/or/name/on/hub +pipe = pipeline("text-generation", model=model_name_or_path) +print(pipe("This movie was really")[0]["generated_text"]) +``` + +## Use Adapters PEFT + +```python +from peft import PeftConfig, PeftModel +from transformers import AutoModelForCausalLM, AutoTokenizer + +base_model_name = "Qwen/Qwen3-0.6B" #path/to/your/model/or/name/on/hub +adapter_model_name = "path/to/my/adapter" + +model = AutoModelForCausalLM.from_pretrained(base_model_name) +model = PeftModel.from_pretrained(model, adapter_model_name) + +tokenizer = AutoTokenizer.from_pretrained(base_model_name) +``` + +You can also merge the adapters into the base model so you can use the model like a normal transformers model, however the checkpoint will be significantly bigger: + +```python +model = AutoModelForCausalLM.from_pretrained(base_model_name) +model = PeftModel.from_pretrained(model, adapter_model_name) + +model = model.merge_and_unload() +model.save_pretrained("merged_adapters") +``` + +Once you have the model loaded and either merged the adapters or keep them separately on top you can run generation as with a normal model outlined above. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/vllm_integration.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/vllm_integration.md new file mode 100644 index 0000000000000000000000000000000000000000..78ba3f1890f052ae0b5da1041563ad8e5dff0b31 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/vllm_integration.md @@ -0,0 +1,430 @@ +# vLLM Integration + +This document will guide you through the process of using vLLM with TRL for faster generation in online methods like GRPO and Online DPO. We first summarize a tl;dr on how to use vLLM with TRL, and then we will go into the details of how it works under the hood. + +> [!WARNING] +> TRL currently only supports vLLM versions from `0.12.0` to `0.18.0`. Please ensure you have a version in this range installed to avoid compatibility issues. + +> [!TIP] +> The following trainers currently support generation with vLLM: +> +> - [`GRPOTrainer`] +> - [`RLOOTrainer`] +> - [`experimental.nash_md.NashMDTrainer`] +> - [`experimental.online_dpo.OnlineDPOTrainer`] +> - [`experimental.xpo.XPOTrainer`] + +## 🚀 How can I use vLLM with TRL to speed up training? + +💡 **Note**: Resources required for this specific example: a single node with 8 GPUs. + +> [!WARNING] +> When using vLLM with TRL, the **vLLM server** and the **trainer** must run on **separate CUDA devices** to prevent conflicts. +> For guidance on configuring this properly, see [Modes of using vLLM during training](#modes-of-using-vllm-during-training). + +First, install vLLM using the following command: + +```bash +pip install "trl[vllm]" +``` + +Then run the server on specific GPUs (e.g., GPUs 0-3): + +```sh +CUDA_VISIBLE_DEVICES=0,1,2,3 trl vllm-serve --model Qwen/Qwen2.5-7B --tensor-parallel-size 4 +``` + +Once the server is running, you can use it to generate completions for training. In the example below, we are using the different supported trainers using the vLLM server for generation. The `--tensor-parallel-size` and `--data-parallel-size` arguments control how the model and data are sharded across GPUs. + +In this example, we shard one model across 4 GPUs with tensor parallelism. Then, run the training script on different GPUs (e.g., GPUs 4-7) by passing `use_vllm=True` in the training arguments as follows: + +Sample of a simple `train.py` script: + + + + +```python +from datasets import load_dataset +from trl import GRPOTrainer, GRPOConfig +from trl.rewards import accuracy_reward + +dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + +trainer = GRPOTrainer( + model="Qwen/Qwen2.5-7B", + args=GRPOConfig(use_vllm=True, vllm_mode="server"), + reward_funcs=accuracy_reward, + train_dataset=dataset, +) + +trainer.train() +``` + + + + +```python +from datasets import load_dataset +from trl.experimental.online_dpo import OnlineDPOConfig, OnlineDPOTrainer +from trl.rewards import accuracy_reward + +dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + +trainer = OnlineDPOTrainer( + model="Qwen/Qwen2.5-7B", + args=OnlineDPOConfig(use_vllm=True, vllm_mode="server"), + reward_funcs=accuracy_reward, + train_dataset=dataset, +) + +trainer.train() +``` + + + + +```python +from datasets import load_dataset +from trl.experimental.nash_md import NashMDConfig, NashMDTrainer +from trl.rewards import accuracy_reward + +dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + +trainer = NashMDTrainer( + model="Qwen/Qwen2.5-7B", + args=NashMDConfig(use_vllm=True, vllm_mode="server"), + reward_funcs=accuracy_reward, + train_dataset=dataset, +) + +trainer.train() +``` + + + + +```python +from datasets import load_dataset +from trl.experimental.xpo import XPOTrainer, XPOConfig +from trl.rewards import accuracy_reward + +dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + +trainer = XPOTrainer( + model="Qwen/Qwen2.5-7B", + args=XPOConfig(use_vllm=True, vllm_mode="server"), + reward_funcs=accuracy_reward, + train_dataset=dataset, +) + +trainer.train() +``` + + + + +```python +from datasets import load_dataset +from trl import RLOOTrainer, RLOOConfig +from trl.rewards import accuracy_reward + +dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + +trainer = RLOOTrainer( + model="Qwen/Qwen2.5-7B", + args=RLOOConfig(use_vllm=True, vllm_mode="server"), + reward_funcs=accuracy_reward, + train_dataset=dataset, +) + +trainer.train() +``` + + + + +And the train command on separate GPUs from the server: + +```sh +CUDA_VISIBLE_DEVICES=4,5,6,7 accelerate launch train.py +``` + +## Why using vLLM? + +### 🎬 Flashback: Why do we need to use vLLM in online methods? + +Online methods like GRPO or Online DPO require the model to generate completions during training, which are then used to compute reward signals. However, generation can be extremely time-consuming, especially with large or reasoning models. In the default setup (without vLLM), completions are generated using the [(unwrapped) model's `generate` method](https://github.com/huggingface/trl/blob/f3e8c2304428ef16e9ae5de9e5741ed84d533b7b/trl/trainer/grpo_trainer.py#L965C39-L965C66). This approach quickly becomes a major bottleneck — generation is slow and inefficient, particularly for large batches or models. As a result, training times increase significantly, and overall efficiency drops. To address this, we turn to vLLM, which enables much faster and more scalable generation, helping eliminate this bottleneck in online methods. + +### 🤔 How does vLLM solve the slow generation issue? + +If you've ever done autoregressive decoder training, you know all the input tokens to the LLM produce their attention key and value tensors, and these tensors are kept in GPU memory to later generate subsequent tokens based on them. These cached key and value tensors are often referred to as the KV cache. However, storing the KV cache occupies a lot of memory, so vLLM uses a technique called **PagedAttention** to solve this problem. PagedAttention, which is inspired by the OS’s virtual memory concept, stores continuous keys and values in **non-contiguous memory space**, which is much more efficient. The details of this are beyond the scope of this document, but in short, it allows the model to store the keys and values in a more efficient way, reducing the memory footprint and speeding up the generation process. If you are interested, make sure to check out the [vLLM PagedAttention](https://blog.vllm.ai/2023/06/20/vllm.html) for more details. + +## How vLLM Works (Under the Hood) 🔍 + +### 🤔 What exactly happens when you run `trl vllm-serve --model `? + +When you run for example + +```sh +CUDA_VISIBLE_DEVICES=0,1,2,3 trl vllm-serve --model Qwen/Qwen2.5-7B --tensor-parallel-size 4 +``` + +1. vLLM first spawns multiple workers to handle incoming requests in parallel. The number of workers is determined by multiplying the `--tensor-parallel-size` and `--data-parallel-size` values. In this example, it spawns 4 workers (4 × 1). +Each worker operates independently and processes a chunk of the incoming requests — which are basically the prompts sent to the server for generation. + +2. Once the incoming requests (prompts) are distributed across the workers, the model starts generating completions. Internally, the model’s weights are split across multiple GPUs based on the `--tensor-parallel-size` argument — this is how tensor parallelism is handled. + +3. Although the GPUs process requests independently and in parallel, they still need to communicate with each other. Remember that each GPU handles only a slice of the incoming prompts (for example, with 4 GPUs and 8 prompts using `--tensor-parallel-size=4`, each GPU participates in serving the full model). +This GPU-to-GPU communication is managed efficiently by NVIDIA’s NCCL library. The communication mainly ensures that each GPU gets its correct portion of the incoming requests — it’s lightweight and doesn’t interfere with generation itself. +Separately, the number of completions to generate per prompt is controlled by the `num_generations` setting in the GRPO config. For instance, if you set `num_generations=2` (like in the picture above), each prompt will have 2 completions. So, with 8 prompts and `num_generations=2`, you would end up with 16 completions total — regardless of the number of GPUs or parallelism settings. + +### 🥸 More detail on what happens under the hood when running the server + +- The vLLM server starts by running the command: `trl vllm-serve --model Qwen/Qwen2.5-7B`. +- Once the server is running, it generates completions based on requests from the client (trainer) using `vllm_client.generate` [these lines](https://github.com/huggingface/trl/blob/cc044e35b285be7dc062764b3364e1e684db4c7c/trl/trainer/grpo_trainer.py#L1025-L1035). +- The client (trainer) then requests these completions from the server. +- These completions are used to compute the reward signal. +- Based on the reward signal and the model’s output, the loss is computed, and the backward pass is performed to update the model’s weights. +- **Note**: The server only handles completion generation — it doesn’t train the model. Therefore, the model’s weights aren’t updated on the server. Once the backward pass is complete, the client sends the updated weights to the server using `vllm_client.update_named_param(name, param.data)`. + +When using vLLM, ensure the GPUs assigned for training and generation are separate to avoid NCCL communication conflicts. If you do not set the `CUDA_VISIBLE_DEVICES` environment variable, the training script will use all available GPUs by default, which may lead to device conflicts. Starting from TRL next release after v0.19.1, the code automatically detects and prevents same-device usage, raising a error at the vllm server process: + +```log +RuntimeError: Attempting to use the same CUDA device for multiple distinct roles/ranks within the same communicator. +Ensure that trainer is using different devices than vLLM server. +``` + +For example, if you want to use GPUs 4–7 for training while the server runs on GPUs 0-3, set: + +```sh +CUDA_VISIBLE_DEVICES=4,5,6,7 accelerate launch train.py +``` + +## Advanced usage + +### 🍷 More customization options with vLLM? + +You can customize the server configuration by passing additional arguments. + +```txt +$ trl vllm-serve --help +usage: trl vllm-serve [-h] --model MODEL [--revision REVISION] [--tensor_parallel_size TENSOR_PARALLEL_SIZE] [--data_parallel_size DATA_PARALLEL_SIZE] [--host HOST] + [--port PORT] [--gpu_memory_utilization GPU_MEMORY_UTILIZATION] [--dtype DTYPE] [--max_model_len MAX_MODEL_LEN] + [--enable_prefix_caching ENABLE_PREFIX_CACHING] [--enforce_eager [ENFORCE_EAGER]] [--kv_cache_dtype KV_CACHE_DTYPE] + [--trust_remote_code [TRUST_REMOTE_CODE]] [--log_level LOG_LEVEL] [--vllm_model_impl VLLM_MODEL_IMPL] + +options: + -h, --help show this help message and exit + --model MODEL Model name or path to load the model from. (default: None) + --revision REVISION Revision to use for the model. If not specified, the default branch will be used. (default: None) + --tensor_parallel_size TENSOR_PARALLEL_SIZE, --tensor-parallel-size TENSOR_PARALLEL_SIZE + Number of tensor parallel workers to use. (default: 1) + --data_parallel_size DATA_PARALLEL_SIZE, --data-parallel-size DATA_PARALLEL_SIZE + Number of data parallel workers to use. For dense models, keep this at 1. Starting from vLLM `0.14.0`, setting + this above `1` for dense models is no longer supported/useful and will error out (see vLLM PR #30739). + (default: 1) + --host HOST Host address to run the server on. (default: 0.0.0.0) + --port PORT Port to run the server on. (default: 8000) + --gpu_memory_utilization GPU_MEMORY_UTILIZATION, --gpu-memory-utilization GPU_MEMORY_UTILIZATION + Ratio (between 0 and 1) of GPU memory to reserve for the model weights, activations, and KV cache on the device dedicated to generation + powered by vLLM. Higher values will increase the KV cache size and thus improve the model's throughput. However, if the value is too high, + it may cause out-of-memory (OOM) errors during initialization. (default: 0.9) + --dtype DTYPE Data type to use for vLLM generation. If set to 'auto', the data type will be automatically determined based on the model configuration. + Find the supported values in the vLLM documentation. (default: auto) + --max_model_len MAX_MODEL_LEN, --max-model-len MAX_MODEL_LEN + If set, the `max_model_len` to use for vLLM. This can be useful when running with reduced `vllm_gpu_memory_utilization`, leading to a + reduced KV cache size. If not set, vLLM will use the model context size, which might be much larger than the KV cache, leading to + inefficiencies. (default: None) + --enable_prefix_caching ENABLE_PREFIX_CACHING, --enable-prefix-caching ENABLE_PREFIX_CACHING + Whether to enable prefix caching in vLLM. If set to `True`, ensure that the model and the hardware support this feature. (default: None) + --enforce_eager [ENFORCE_EAGER], --enforce-eager [ENFORCE_EAGER] + Whether to enforce eager execution. If set to `True`, we will disable CUDA graph and always execute the model in eager mode. If `False` + (default behavior), we will use CUDA graph and eager execution in hybrid. (default: False) + --kv_cache_dtype KV_CACHE_DTYPE, --kv-cache-dtype KV_CACHE_DTYPE + Data type to use for KV cache. If set to 'auto', the dtype will default to the model data type. (default: auto) + --trust_remote_code [TRUST_REMOTE_CODE], --trust-remote-code [TRUST_REMOTE_CODE] + Whether to trust remote code when loading models. Set to True to allow executing code from model repositories. This is required for some + custom models but introduces security risks. (default: False) + --log_level LOG_LEVEL, --log-level LOG_LEVEL + Log level for uvicorn. Possible choices: 'critical', 'error', 'warning', 'info', 'debug', 'trace'. (default: info) + --vllm_model_impl VLLM_MODEL_IMPL, --vllm-model-impl VLLM_MODEL_IMPL + Model implementation to use for vLLM. Must be one of `transformers` or `vllm`. `transformers`: Use the `transformers` backend for model + implementation. `vllm`: Use the `vllm` library for model implementation. (default: vllm) +``` + +### 💆🏻‍♀️ What's the best distributed setup? + +![tp dp throughput 8 gpus](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/tp_dp_throughput_8_gpus.png) +![tp dp throughput 4 gpus](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/tp_dp_throughput_4_gpus.png) + +> [!WARNING] +> The benchmark plots above were collected with older vLLM versions. Starting with [vLLM PR #30739](https://github.com/vllm-project/vllm/pull/30739) (released in `0.14.0`), offline data parallel scaling for non-MoE (dense) models is no longer supported. To follow the latest recommendations, do not scale DP for non-MoE models. + +### vLLM with Transformers Backend + +vLLM can use the **Transformers backend** for model implementations, which works for both LLMs and VLMs. +To enable this, set `vllm_model_impl="transformers"` in your configuration or pass it via the command-line argument. + +For more details, check out [vLLM Transformers Backend](https://blog.vllm.ai/2025/04/11/transformers-backend.html). + +Example: + +```sh +CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen +2.5-VL-3B-Instruct --tensor-parallel-size 1 --port 8000 --enforce_eager --vllm_model_impl transformers +``` + +### Modes of Using vLLM During Training + +TRL supports **two modes** for integrating vLLM during training: **colocate mode** (default) and **server mode**. + +#### Colocate Mode + +In **colocate mode**, vLLM runs inside the trainer process and shares GPU memory with the training model. +This avoids launching a separate server and can improve GPU utilization, but may lead to memory contention on the training GPUs. This is the default mode. + +Example configuration: + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ..., + use_vllm=True, # vllm_mode="colocate" by default +) +``` + + + + +```python +from trl.experimental.online_dpo import OnlineDPOConfig + +training_args = OnlineDPOConfig( + ..., + use_vllm=True, # vllm_mode="colocate" by default +) +``` + + + + +```python +from trl.experimental.nash_md import NashMDConfig + +training_args = NashMDConfig( + ..., + use_vllm=True, # vllm_mode="colocate" by default +) +``` + + + + +```python +from trl.experimental.xpo import XPOConfig + +training_args = XPOConfig( + ..., + use_vllm=True, # vllm_mode="colocate" by default +) +``` + + + + +```python +from trl import RLOOConfig + +training_args = RLOOConfig( + ..., + use_vllm=True, # vllm_mode="colocate" by default +) +``` + + + + +#### Server Mode + +In **server mode**, vLLM runs as a separate process on dedicated GPUs and communicates with the trainer via HTTP. +This setup is ideal if you have GPUs dedicated to inference. + +Example configuration: + + + + +```python +from trl import GRPOConfig + +training_args = GRPOConfig( + ..., + use_vllm=True, + vllm_mode="server", +) +``` + + + + +```python +from trl.experimental.online_dpo import OnlineDPOConfig + +training_args = OnlineDPOConfig( + ..., + use_vllm=True, + vllm_mode="server", +) +``` + + + + +```python +from trl.experimental.nash_md import NashMDConfig + +training_args = NashMDConfig( + ..., + use_vllm=True, + vllm_mode="server", +) +``` + + + + +```python +from trl.experimental.xpo import XPOConfig + +training_args = XPOConfig( + ..., + use_vllm=True, + vllm_mode="server", +) +``` + + + + +```python +from trl import RLOOConfig + +training_args = RLOOConfig( + ..., + use_vllm=True, + vllm_mode="server", +) +``` + + + + +> [!WARNING] +> Check the documentation of the trainer you are using for specific details on vLLM usage and parameters. + +> [!WARNING] +> To reduce GPU memory usage when running vLLM, consider [enabling vLLM sleep mode](reducing_memory_usage#vllm-sleep-mode). diff --git a/tasks/tasksmith-1c108f674e97/tests/source/docs/source/xpo_trainer.md b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/xpo_trainer.md new file mode 100644 index 0000000000000000000000000000000000000000..428c4432ea0642150e9a399fc444cd0b55129298 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/docs/source/xpo_trainer.md @@ -0,0 +1,145 @@ +# XPO Trainer + +[![model badge](https://img.shields.io/badge/All_models-XPO-blue)](https://huggingface.co/models?other=xpo,trl) + +## Overview + +Exploratory Preference Optimization (XPO) was proposed in the paper [Exploratory Preference Optimization: Harnessing Implicit Q*-Approximation for Sample-Efficient RLHF](https://huggingface.co/papers/2405.21046) by Tengyang Xie, Dylan J. Foster, Akshay Krishnamurthy, [Corby Rosset](https://huggingface.co/corbyrosset), [Ahmed Awadallah](https://huggingface.co/AhmedAwadallah), and Alexander Rakhlin. It is a simple online preference tuning method based on the DPO loss together with a reward model (RM). XPO augments the DPO objective with an exploration bonus allowing the method to explore outside the support of the initial model and human feedback data. + +The abstract from the paper is the following: + +> Reinforcement learning from human feedback (RLHF) has emerged as a central tool for language model alignment. We consider online exploration in RLHF, which exploits interactive access to human or AI feedback by deliberately encouraging the model to produce diverse, maximally informative responses. By allowing RLHF to confidently stray from the pre-trained model, online exploration offers the possibility of novel, potentially super-human capabilities, but its full potential as a paradigm for language model training has yet to be realized, owing to computational and statistical bottlenecks in directly adapting existing reinforcement learning techniques. We propose a new algorithm for online exploration in RLHF, Exploratory Preference Optimization (XPO), which is simple and practical -- a one-line change to (online) Direct Preference Optimization (DPO; Rafailov et al., 2023) -- yet enjoys the strongest known provable guarantees and promising empirical performance. XPO augments the DPO objective with a novel and principled exploration bonus, empowering the algorithm to explore outside the support of the initial model and human feedback data. In theory, we show that XPO is provably sample-efficient and converges to a near-optimal language model policy under natural exploration conditions, irrespective of whether the initial model has good coverage. Our analysis, which builds on the observation that DPO implicitly performs a form of Q*-approximation (or, Bellman error minimization), combines previously disparate techniques from language modeling and theoretical reinforcement learning in a serendipitous fashion through the perspective of KL-regularized Markov decision processes. Empirically, we find that XPO is more sample-efficient than non-exploratory DPO variants in a preliminary evaluation. + +This post-training method was contributed by [Kashif Rasul](https://huggingface.co/kashif), [Quentin Gallouédec](https://huggingface.co/qgallouedec) and [Lewis Tunstall](https://huggingface.co/lewtun). + +> [!NOTE] +> XPO is currently experimental. The API may change without notice while the feature is iterated on. + +## Quick start + +This example demonstrates how to train a model using the XPO method. We use the [Qwen 0.5B model](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) as the base model and the [trl-lib/Qwen2-0.5B-Reward](https://huggingface.co/trl-lib/Qwen2-0.5B-Reward) reward model. We use the prompts from the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback). You can view the prompts in the dataset here: + + +Below is the script to train the model: + +```python +# train_xpo.py +from datasets import load_dataset +from trl.experimental.xpo import XPOConfig, XPOTrainer +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct") +reward_model = AutoModelForSequenceClassification.from_pretrained("trl-lib/Qwen2-0.5B-Reward", num_labels=1) +train_dataset = load_dataset("trl-lib/ultrafeedback-prompt", split="train") + +training_args = XPOConfig(output_dir="Qwen2-0.5B-XPO") +trainer = XPOTrainer( + model=model, reward_funcs=reward_model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset +) +trainer.train() +``` + +Execute the script using the following command: + +```bash +accelerate launch train_xpo.py +``` + +Distributed across 8 GPUs, the training takes approximately 1 hour. + +To see how the [trained model](https://huggingface.co/trl-lib/Qwen2-0.5B-XPO) performs, you can use the [Transformers Chat CLI](https://huggingface.co/docs/transformers/quicktour#chat-with-text-generation-models). + +
$ transformers chat trl-lib/Qwen2-0.5B-XPO
+<quentin_gallouedec>:
+What is the best programming language?
+
+<trl-lib/Qwen2-0.5B-XPO>:
+The best programming language depends on individual preferences and familiarity with coding concepts. Some popular languages include Python, Java, C++, and JavaScript.
+
+ +## Expected dataset type + +XPO requires a [prompt-only dataset](dataset_formats#prompt-only). The [`experimental.xpo.XPOTrainer`] supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset format. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset. + +## Usage tips + +### Encourage EOS token generation + +When using a reward model, we may want the model to generate completions within a given length. During training, the model will generate completions up to the maximum length specified in the `max_new_tokens` argument of [`experimental.xpo.XPOConfig`]. If you want to penalize the model for not generating an EOS token before reaching the maximum length, you can use the `missing_eos_penalty` argument of [`experimental.xpo.XPOConfig`]: + +```python +training_args = XPOConfig(..., max_new_tokens=128, missing_eos_penalty=1.0) +``` + +> [!WARNING] +> Make sure that the SFT model and reward model use the _same_ chat template and the same tokenizer. Otherwise, you may find the model completions are scored incorrectly during training. + +### Logging Completions + +To better understand your model's behavior during training, you can log sample completions periodically using the [`LogCompletionsCallback`]. + +```python +trainer = XPOTrainer(..., eval_dataset=eval_dataset) +completions_callback = LogCompletionsCallback(trainer, num_prompts=8) +trainer.add_callback(completions_callback) +``` + +This callback logs the model's generated completions directly to Weights & Biases. + +![Logged Completions](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/wandb_completions.png) + +## Example script + +We provide an example script to train a model using the XPO method. The script is available in [`examples/scripts/xpo.py`](https://github.com/huggingface/trl/blob/main/examples/scripts/xpo.py) + +To test the XPO script with the [Qwen2.5 0.5B model](https://huggingface.co/trl-lib/Qwen/Qwen2.5-0.5B-Instruct) on the [UltraFeedback dataset](https://huggingface.co/datasets/openbmb/UltraFeedback), run the following command: + +```bash +python examples/scripts/xpo.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --reward_model_path trl-lib/Qwen2-0.5B-Reward \ + --dataset_name trl-lib/ultrafeedback-prompt \ + --learning_rate 5.0e-7 \ + --output_dir Qwen2.5-0.5B-XPO \ + --warmup_steps 0.1 \ + --push_to_hub +``` + +## Logged metrics + +While training and evaluating we record the following reward metrics: + +* `loss/xpo`: The mean xpo part of the full loss. +* `loss/dpo`: The mean dpo part of the full loss. +* `objective/kl`: The mean KL divergence between the model and reference data. +* `objective/entropy`: The mean entropy of the model and reference data. +* `objective/model_scores`: The mean scores (according to the reward model) of the model completions. +* `objective/ref_scores`: The mean scores (according to the reward model) of the reference completions. +* `objective/scores_margin`: The mean score margin (according to the external reward model) between the chosen and rejected completions. +* `rewards/chosen`: The mean reward (according to XPO's DPO implicit reward model) of the chosen completions. +* `rewards/rejected`: The mean reward (according to XPO's DPO implicit reward model) of the rejected completions. +* `rewards/accuracies`: The accuracies of the XPO's implicit reward model. +* `rewards/margins`: The mean reward margin (according to online DPO's implicit reward model) between the chosen and rejected completions. +* `logps/chosen`: The mean log probabilities of the chosen completions. +* `logps/rejected`: The mean log probabilities of the rejected completions. +* `val/model_contain_eos_token`: The amount of times the model's output contains the eos token. +* `val/ref_contain_eos_token`: The amount of times the reference's output contains the eos token. +* `alpha`: The weight of the XPO loss term. Typically fixed, but can be made dynamic by passing a list to [`experimental.xpo.XPOConfig`]. +* `beta`: The parameter that controls the weight of the loss term representing the deviation from the reference model. Typically fixed, but can be made dynamic by passing a list to [`experimental.xpo.XPOConfig`]. + +## XPOTrainer + +[[autodoc]] experimental.xpo.XPOTrainer + - train + - save_model + - push_to_hub + +## XPOConfig + +[[autodoc]] experimental.xpo.XPOConfig diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/README.md b/tasks/tasksmith-1c108f674e97/tests/source/examples/README.md new file mode 100644 index 0000000000000000000000000000000000000000..785826dfd3741f30857f85109e95995679a2b581 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/README.md @@ -0,0 +1,3 @@ +# Examples + +Please check out https://huggingface.co/docs/trl/example_overview for documentation on our examples. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/alst_ulysses_4gpu.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/alst_ulysses_4gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e6c7cfa8125e78cfdbb45c6a260be7a03b4bd057 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/alst_ulysses_4gpu.yaml @@ -0,0 +1,45 @@ +# ALST/Ulysses Sequence Parallelism with 2D Parallelism (DP + SP) for 4 GPUs +# +# This configuration enables 2D parallelism: +# - Sequence Parallelism (sp_size=2): Sequences split across 2 GPUs using ALST/Ulysses +# - Data Parallelism (dp_shard_size=2): Model/optimizer sharded across 2 GPUs +# - Total: 4 GPUs (2 × 2) +# +# Set parallelism_config in your training script: +# parallelism_config = ParallelismConfig( +# sp_backend="deepspeed", +# sp_size=2, +# dp_shard_size=2, # Calculated as: num_gpus // sp_size +# sp_handler=DeepSpeedSequenceParallelConfig(...) +# ) + +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + zero_stage: 3 + seq_parallel_communication_data_type: bf16 + offload_optimizer_device: none + offload_param_device: none + zero3_init_flag: true + zero3_save_16bit_model: true +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 4 # Total number of GPUs +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false +parallelism_config: + parallelism_config_dp_replicate_size: 1 + parallelism_config_dp_shard_size: 2 # Enables 2D parallelism with SP + parallelism_config_tp_size: 1 + parallelism_config_sp_size: 2 # Sequence parallel size + parallelism_config_sp_backend: deepspeed + parallelism_config_sp_seq_length_is_variable: true + parallelism_config_sp_attn_implementation: flash_attention_2 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/context_parallel_2gpu.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/context_parallel_2gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e45a62ba2edde9633350260b01ff71cca2a89d3e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/context_parallel_2gpu.yaml @@ -0,0 +1,30 @@ +# Context Parallelism with FSDP for 2 GPUs +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: FSDP +downcast_bf16: 'no' +enable_cpu_affinity: false +fsdp_config: + fsdp_activation_checkpointing: true # Enable activation checkpointing for memory efficiency + fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP + fsdp_cpu_ram_efficient_loading: true + fsdp_offload_params: false + fsdp_reshard_after_forward: true + fsdp_state_dict_type: FULL_STATE_DICT + fsdp_version: 2 +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 2 # Number of GPUs +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false +parallelism_config: + parallelism_config_dp_replicate_size: 1 + parallelism_config_dp_shard_size: 1 + parallelism_config_tp_size: 1 + parallelism_config_cp_size: 2 # Context parallel size diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero1.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d5b5f782fb30f9fcbcc8fc58262f09eaf2e10368 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero1.yaml @@ -0,0 +1,20 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + gradient_accumulation_steps: 1 + zero3_init_flag: false + zero_stage: 1 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero2.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..239b14ac3a9ae8de73122d1154bf0d71903dc15f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero2.yaml @@ -0,0 +1,21 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + offload_optimizer_device: none + offload_param_device: none + zero3_init_flag: false + zero_stage: 2 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero3.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero3.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b5a1201f8a2ee8706b63f0f80c664a1fc61a7d9d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/deepspeed_zero3.yaml @@ -0,0 +1,22 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + offload_optimizer_device: none + offload_param_device: none + zero3_init_flag: true + zero3_save_16bit_model: true + zero_stage: 3 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/fsdp1.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/fsdp1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c01b0b567bc93bf87ec136ea975b3793d273a45c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/fsdp1.yaml @@ -0,0 +1,28 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: FSDP +downcast_bf16: 'no' +enable_cpu_affinity: false +fsdp_config: + fsdp_activation_checkpointing: false + fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP + fsdp_backward_prefetch: BACKWARD_PRE + fsdp_cpu_ram_efficient_loading: true + fsdp_forward_prefetch: true + fsdp_offload_params: false + fsdp_reshard_after_forward: FULL_SHARD + fsdp_state_dict_type: FULL_STATE_DICT + fsdp_sync_module_states: true + fsdp_use_orig_params: true + fsdp_version: 1 +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/fsdp2.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/fsdp2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af498f3eced9c2434b80113f2f22d40395e0ab8a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/fsdp2.yaml @@ -0,0 +1,25 @@ +# Requires accelerate 1.7.0 or higher +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: FSDP +downcast_bf16: 'no' +enable_cpu_affinity: false +fsdp_config: + fsdp_activation_checkpointing: false + fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP + fsdp_cpu_ram_efficient_loading: true + fsdp_offload_params: false + fsdp_reshard_after_forward: true + fsdp_state_dict_type: FULL_STATE_DICT + fsdp_version: 2 +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/multi_gpu.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/multi_gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..15dad9be3ba44f7c934e1ecab98a93cb83cbc79a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/multi_gpu.yaml @@ -0,0 +1,16 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: MULTI_GPU +downcast_bf16: 'no' +gpu_ids: all +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/single_gpu.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/single_gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..200fcc18dde040e6c35708d18927ce9bc522079d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/accelerate_configs/single_gpu.yaml @@ -0,0 +1,16 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: "NO" +downcast_bf16: 'no' +gpu_ids: all +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 1 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/cli_configs/example_config.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/cli_configs/example_config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bb44cec69e219e3435057b8437a1bb6198a339b0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/cli_configs/example_config.yaml @@ -0,0 +1,18 @@ +# This is an example configuration file of TRL CLI, you can use it for +# SFT like that: `trl sft --config config.yaml --output_dir test-sft` +# The YAML file supports environment variables by adding an `env` field +# as below + +# env: +# CUDA_VISIBLE_DEVICES: 0 + +model_name_or_path: + Qwen/Qwen2.5-0.5B +dataset_name: + stanfordnlp/imdb +report_to: + none +learning_rate: + 0.0001 +lr_scheduler_type: + cosine diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/deepmath_103k.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/deepmath_103k.py new file mode 100644 index 0000000000000000000000000000000000000000..d9d79c293ad82a0fe85b4bb8b0b32ea0b0bea646 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/deepmath_103k.py @@ -0,0 +1,98 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/DeepMath-103K"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/DeepMath-103K", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def process_example(example): + solution = example["final_answer"] + if solution not in ["True", "False", "Yes", "No"]: + solution = f"${solution}$" + prompt = [{"role": "user", "content": example["question"]}] + return {"prompt": prompt, "solution": solution} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# DeepMath-103K Dataset + +## Summary + +[DeepMath-103K](https://huggingface.co/datasets/zwhe99/DeepMath-103K) is meticulously curated to push the boundaries of mathematical reasoning in language models. + +## Data Structure + +- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational) +- **Type**: [Prompt-only](https://huggingface.co/docs/trl/main/dataset_formats#prompt-only) + +Column: +- `"prompt"`: The input question. +- `"solution"`: The solution to the math problem. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/deepmath_103k.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("zwhe99/DeepMath-103K", split="train") + + dataset = dataset.map( + process_example, + remove_columns=dataset.column_names, + num_proc=script_args.dataset_num_proc, + ) + dataset = dataset.train_test_split(test_size=0.05, seed=42) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/hh-rlhf-helpful-base.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/hh-rlhf-helpful-base.py new file mode 100644 index 0000000000000000000000000000000000000000..410847b02b8263530c513cb4a86144b8791b953c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/hh-rlhf-helpful-base.py @@ -0,0 +1,132 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/hh-rlhf-helpful-base"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/hh-rlhf-helpful-base", metadata={"help": "Hugging Face repository ID to push the dataset to."} + ) + dataset_num_proc: int | None = field( + default=None, metadata={"help": "Number of workers to use for dataset processing."} + ) + + +def common_start(str1: str, str2: str) -> str: + # Zip the two strings and iterate over them together + common_chars = [] + for c1, c2 in zip(str1, str2, strict=True): + if c1 == c2: + common_chars.append(c1) + else: + break + # Join the common characters and return as a string + return "".join(common_chars) + + +def extract_dialogue(example: str) -> list[dict[str, str]]: + # Extract the prompt, which corresponds to the common start of the chosen and rejected dialogues + prompt_text = common_start(example["chosen"], example["rejected"]) + + # The chosen and rejected may share a common start, so we need to remove the common part + if not prompt_text.endswith("\n\nAssistant: "): + prompt_text = prompt_text[: prompt_text.rfind("\n\nAssistant: ")] + "\n\nAssistant: " + + # Extract the chosen and rejected lines + chosen_line = example["chosen"][len(prompt_text) :] + rejected_line = example["rejected"][len(prompt_text) :] + + # Remove the generation prompt ("\n\nAssistant: ") from the prompt + prompt_text = prompt_text[: -len("\n\nAssistant: ")] + + # Split the string at every occurrence of "Human: " or "Assistant: " + prompt_lines = re.split(r"(\n\nAssistant: |\n\nHuman: )", prompt_text) + + # Remove the first element as it's empty + prompt_lines = prompt_lines[1:] + + prompt = [] + for idx in range(0, len(prompt_lines), 2): + role = "user" if prompt_lines[idx] == "\n\nHuman: " else "assistant" + content = prompt_lines[idx + 1] + prompt.append({"role": role, "content": content}) + + # Remove the prompt from the chosen and rejected dialogues + chosen = [{"role": "assistant", "content": chosen_line}] + rejected = [{"role": "assistant", "content": rejected_line}] + + return {"prompt": prompt, "chosen": chosen, "rejected": rejected} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# HH-RLHF-Helpful-Base Dataset + +## Summary + +The HH-RLHF-Helpful-Base dataset is a processed version of [Anthropic's HH-RLHF](https://huggingface.co/datasets/Anthropic/hh-rlhf) dataset, specifically curated to train models using the [TRL library](https://github.com/huggingface/trl) for preference learning and alignment tasks. It contains pairs of text samples, each labeled as either "chosen" or "rejected," based on human preferences regarding the helpfulness of the responses. This dataset enables models to learn human preferences in generating helpful responses, enhancing their ability to assist users effectively. + +## Data Structure + +- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational) +- **Type**: [Preference](https://huggingface.co/docs/trl/main/dataset_formats#preference) + +Columns: +- `"prompt"`: The user query. +- `"chosen"`: A response deemed helpful by human evaluators. +- `"rejected"`: A response considered less helpful or unhelpful. + +This structure allows models to learn to prefer the _chosen_ response over the _rejected_ one, thereby aligning with human preferences in helpfulness. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/hh-rlhf-helpful-base.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("Anthropic/hh-rlhf", data_dir="helpful-base") + dataset = dataset.map(extract_dialogue, num_proc=script_args.dataset_num_proc) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/llava_instruct_mix.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/llava_instruct_mix.py new file mode 100644 index 0000000000000000000000000000000000000000..c932c06a0313997004c3efcc75e553f844503de0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/llava_instruct_mix.py @@ -0,0 +1,118 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import ast +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/llava-instruct-mix"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/llava-instruct-mix", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def process_example(example): + messages = [] + for message in ast.literal_eval(example["conversations"]): + content = message["value"] + content = content.replace("", "").strip() + role = "user" if message["from"] == "human" else "assistant" + messages.append({"role": role, "content": content}) + return {"messages": messages, "images": [example["image"]]} + + +def filter_long_examples(example): + total_length = sum(len(msg["content"]) for msg in example["messages"]) + return total_length <= 1000 + + +def split_prompt_completion(example): + """ + Splits the messages into a prompt and a completion. The last message is considered the completion. + """ + assert len(example["messages"]) > 1 + example["prompt"] = example["messages"][:-1] + example["completion"] = example["messages"][-1:] + return example + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# LLaVA Instruct Mix + +## Summary + +The LLaVA Instruct Mix dataset is a processed version of [LLaVA Instruct Mix](https://huggingface.co/datasets/theblackcat102/llava-instruct-mix). + +## Data Structure + +- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational) +- **Type**: [Language-modeling](https://huggingface.co/docs/trl/main/dataset_formats#language-modeling) + +Columns: +- `"images"`: The image associated with the text. +- `"prompt"`: A list of messages that form the context for the conversation. +- `"completion"`: The last message in the conversation, which is the model's response. + +This structure allows models to learn from the context of the conversation, enhancing their understanding of how to generate descriptive text based on visual inputs. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/llava_instruct_mix.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("theblackcat102/llava-instruct-mix", split="train", num_proc=script_args.dataset_num_proc) + + dataset = dataset.map( + process_example, remove_columns=["conversations", "image"], num_proc=script_args.dataset_num_proc + ) + dataset = dataset.filter(filter_long_examples, num_proc=script_args.dataset_num_proc) + dataset = dataset.map(split_prompt_completion, remove_columns=["messages"], num_proc=script_args.dataset_num_proc) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id, num_proc=script_args.dataset_num_proc) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/lm-human-preferences-descriptiveness.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/lm-human-preferences-descriptiveness.py new file mode 100644 index 0000000000000000000000000000000000000000..a0b70947e0204620e915b3eaa6ce5cf65be00eaf --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/lm-human-preferences-descriptiveness.py @@ -0,0 +1,119 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import AutoTokenizer, HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/lm-human-preferences-descriptiveness"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/lm-human-preferences-descriptiveness", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +# Edge cases handling: remove the cases where all samples are the same +def samples_not_all_same(example): + return not all(example["sample0"] == example[f"sample{j}"] for j in range(1, 4)) + + +def to_prompt_completion(example, tokenizer): + prompt = tokenizer.decode(example["query"]).strip() + best_idx = example["best"] + chosen = tokenizer.decode(example[f"sample{best_idx}"]) + for rejected_idx in range(4): # take the first rejected sample that is different from the chosen one + rejected = tokenizer.decode(example[f"sample{rejected_idx}"]) + if chosen != rejected: + break + assert chosen != rejected + return {"prompt": prompt, "chosen": chosen, "rejected": rejected} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# LM-Human-Preferences-Descriptiveness Dataset + +## Summary + +The LM-Human-Preferences-Descriptiveness dataset is a processed subset of [OpenAI's LM-Human-Preferences](https://github.com/openai/lm-human-preferences), focusing specifically on enhancing the descriptiveness of generated text. It contains pairs of text samples, each labeled as either "chosen" or "rejected," based on human preferences regarding the level of detail and vividness in the descriptions. This dataset enables models to learn human preferences in descriptive language, improving their ability to generate rich and engaging narratives. + +## Data Structure + +- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard) +- **Type**: [Preference](https://huggingface.co/docs/trl/main/dataset_formats#preference) + +Columns: +- `"prompt"`: The text sample. +- `"chosen"`: A version of the text with enhanced descriptiveness. +- `"rejected"`: A version of the text with less descriptiveness. + +This structure allows models to learn to prefer the _chosen_ response over the _rejected_ one, thereby aligning with human preferences in descriptive language. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/lm-human-preferences-descriptiveness.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset( + "json", + data_files="https://openaipublic.blob.core.windows.net/lm-human-preferences/labels/descriptiveness/offline_5k.json", + split="train", + ) + + dataset = dataset.filter(samples_not_all_same, num_proc=script_args.dataset_num_proc) + + dataset = dataset.map( + to_prompt_completion, + num_proc=script_args.dataset_num_proc, + remove_columns=["query", "sample0", "sample1", "sample2", "sample3", "best"], + fn_kwargs={"tokenizer": AutoTokenizer.from_pretrained("gpt2")}, + ) + + # train_size taken from https://github.com/openai/lm-human-preferences/blob/cbfd210bb8b08f6bc5c26878c10984b90f516c66/launch.py#L79) + dataset = dataset.train_test_split(train_size=4992) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/lm-human-preferences-sentiment.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/lm-human-preferences-sentiment.py new file mode 100644 index 0000000000000000000000000000000000000000..0981940902f6045920ae51f5c0fdbbead4abebb7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/lm-human-preferences-sentiment.py @@ -0,0 +1,112 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import AutoTokenizer, HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/lm-human-preferences-sentiment"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/lm-human-preferences-sentiment", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def to_prompt_completion(example, tokenizer): + prompt = tokenizer.decode(example["query"]).strip() + best_idx = example["best"] + chosen = tokenizer.decode(example[f"sample{best_idx}"]) + for rejected_idx in range(4): # take the first rejected sample that is different from the chosen one + rejected = tokenizer.decode(example[f"sample{rejected_idx}"]) + if chosen != rejected: + break + assert chosen != rejected + return {"prompt": prompt, "chosen": chosen, "rejected": rejected} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# LM-Human-Preferences-Sentiment Dataset + +## Summary + +The LM-Human-Preferences-Sentiment dataset is a processed subset of [OpenAI's LM-Human-Preferences](https://github.com/openai/lm-human-preferences), focusing specifically on sentiment analysis tasks. It contains pairs of text samples, each labeled as either "chosen" or "rejected," based on human preferences regarding the sentiment conveyed in the text. This dataset enables models to learn human preferences in sentiment expression, enhancing their ability to generate and evaluate text with desired emotional tones. + +## Data Structure + +- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard) +- **Type**: [Preference](https://huggingface.co/docs/trl/main/dataset_formats#preference) + +Columns: +- `"prompt"`: The text sample. +- `"chosen"`: A version of the text that conveys the desired sentiment. +- `"rejected"`: A version of the text that does not convey the desired sentiment. + +This structure allows models to learn to prefer the _chosen_ response over the _rejected_ one, thereby aligning with human preferences in sentiment expression. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/lm-human-preferences-sentiment.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset( + "json", + data_files="https://openaipublic.blob.core.windows.net/lm-human-preferences/labels/sentiment/offline_5k.json", + split="train", + ) + + dataset = dataset.map( + to_prompt_completion, + num_proc=script_args.dataset_num_proc, + remove_columns=["query", "sample0", "sample1", "sample2", "sample3", "best"], + fn_kwargs={"tokenizer": AutoTokenizer.from_pretrained("gpt2")}, + ) + + # train_size taken from https://github.com/openai/lm-human-preferences/blob/cbfd210bb8b08f6bc5c26878c10984b90f516c66/launch.py#L70) + dataset = dataset.train_test_split(train_size=4992) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/math_shepherd.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/math_shepherd.py new file mode 100644 index 0000000000000000000000000000000000000000..6cf34435d51fe72c15fe874be2f4ab302dba6c0a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/math_shepherd.py @@ -0,0 +1,169 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re +from dataclasses import dataclass, field +from itertools import chain + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/math_shepherd"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/math_shepherd", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def process_example(example): + # Replace "ки" with "ⶻ" so that the size of the "input" matches the size of the "label" + inputs = example["input"].replace("ки", "ⶻ") + + # Find the indices of the "ⶻ" characters (that should match with the indexes of the "+" or "-" in the label) + indexes = [m.start() for m in re.finditer("ⶻ", inputs)] + + # Sanity that all indexes are either "+" or "-" + assert all(example["label"][idx] in ["+", "-"] for idx in indexes) + + # Get the labels + labels = [example["label"][idx] == "+" for idx in indexes] + + # Split the inputs into steps (caution, the first step is missing here, it is the prompt) + steps = [inputs[i:j] for i, j in zip(chain([0], indexes), chain(indexes, [None]), strict=True)] + + # Remove the last step (single ⶻ) + steps = steps[:-1] + + # Get the prompt (first part) and completions (rest) + prompt = steps[0] + completions = steps[1:] + + # Remove the heading "ⶻ" and the final whitespace from the completions + assert all(completion.startswith("ⶻ") for completion in completions) + completions = [completion[1:].strip() for completion in completions] + + # At this point, we need to retrieve the first step from the prompt. + # First, we handle particular cases (annotation error) where we have a first label before the end of the prompt. + if prompt.startswith( + ( + "Mr. Rocky", + "Parker", + "What is the smallest positive", + " The Myth", + "Let $\\mathbf{a}$", + "Find the arithmetic", + "Determine an ordered pair", + "Determine the ordered pair", + "At the Quill and Scroll stationery", + "Round to the nearest", + r"Calculate $\sqrt{10p}", + r"Simplify $\sqrt{28x}", + ) + ): + # Some spotted datasets errors where there is an annotation in the prompt: we remove it + labels = labels[1:] + + # Then we handle the general case: we get the first step from the prompt by looking for "Step 1:" or "step 1:" or + # (less common) "?". + elif "Step 1:" in prompt: + prompt, first_step = prompt.split("Step 1:") + first_step = "Step 1:" + first_step + completions = [first_step.strip()] + completions + elif "step 1:" in prompt: + prompt, first_step = prompt.split("step 1:") + first_step = "step 1:" + first_step + completions = [first_step.strip()] + completions + elif "?" in prompt: + prompt, first_step = prompt.split("?") + prompt = prompt + "?" + completions = [first_step.strip()] + completions + else: + raise ValueError(f"Prompt can't be processed: {prompt}") + + # Strip the prompt + prompt = prompt.strip() + + # Sanity check that the length of the completions is the same as the length of the labels + assert len(completions) == len(labels) + + return {"prompt": prompt, "completions": completions, "labels": labels} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# Math-Shepherd Dataset + +## Summary + +The Math-Shepherd dataset is a processed version of [Math-Shepherd dataset](peiyi9979/Math-Shepherd), designed to train models using the [TRL library](https://github.com/huggingface/trl) for stepwise supervision tasks. It provides step-by-step solutions to mathematical problems, enabling models to learn and verify each step of a solution, thereby enhancing their reasoning capabilities. + +## Data Structure + +- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard) +- **Type**: [Stepwise supervision](https://huggingface.co/docs/trl/main/dataset_formats#stepwise-supervision) + +Columns: +- `"prompt"`: The problem statement. +- `"completions"`: A list of reasoning steps generated to solve the problem. +- `"labels"`: A list of booleans or floats indicating the correctness of each corresponding reasoning step. + +This structure allows models to learn the correctness of each step in a solution, facilitating improved reasoning and problem-solving abilities. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/math_shepherd.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("peiyi9979/Math-Shepherd", split="train") + + dataset = dataset.map( + process_example, + remove_columns=["input", "label", "task"], + num_proc=script_args.dataset_num_proc, + ) + dataset = dataset.train_test_split(test_size=0.05, seed=42) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/prm800k.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/prm800k.py new file mode 100644 index 0000000000000000000000000000000000000000..b85efdb25daf7ecc5127668edbe64676849f1b39 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/prm800k.py @@ -0,0 +1,156 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/prm800k"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/prm800k", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def process_example(example): + outputs = [] + prompt = example["question"]["problem"] + + # Iterate through each step + previous_completions = [] + previous_labels = [] + for step in example["label"]["steps"]: + if step["completions"] is None and step["human_completion"] is None and step["chosen_completion"] is None: + # happens sometimes + break + # Loop through completions + for completion_idx, completion in enumerate(step["completions"]): + # For every completion that are not chosen, we are in a terminal state, so we can add it to the list of outputs. + if completion_idx != step["chosen_completion"]: + content = completion["text"] + completions = previous_completions[:] + [content] + label = completion["rating"] == 1 + labels = previous_labels[:] + [label] + outputs.append({"prompt": prompt, "completions": completions, "labels": labels}) + + # Now, expand the previous completions and labels + if step["chosen_completion"] is not None: + chosen_completion = step["completions"][step["chosen_completion"]] + label = chosen_completion["rating"] == 1 + elif step["human_completion"] is not None: + chosen_completion = step["human_completion"] + label = True + else: + break + content = chosen_completion["text"] + previous_completions.append(content) + previous_labels.append(label) + + # Last step: we are in a terminal state, so we can add it to the list of outputs + outputs.append({"prompt": prompt, "completions": previous_completions, "labels": previous_labels}) + return outputs + + +def process_batch(examples): + outputs = [] + batch_size = len(examples["label"]) + for idx in range(batch_size): + example = {k: v[idx] for k, v in examples.items()} + outputs.extend(process_example(example)) + # list of dict to dict of list + outputs = {k: [v[k] for v in outputs] for k in outputs[0]} + return outputs + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# PRM800K Dataset + +## Summary + +The PRM800K dataset is a processed version of [OpenAI's PRM800K](https://github.com/openai/prm800k), designed to train models using the [TRL library](https://github.com/huggingface/trl) for stepwise supervision tasks. It contains 800,000 step-level correctness labels for model-generated solutions to problems from the MATH dataset. This dataset enables models to learn and verify each step of a solution, enhancing their reasoning capabilities. + +## Data Structure + +- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard) +- **Type**: [Stepwise supervision](https://huggingface.co/docs/trl/main/dataset_formats#stepwise-supervision) + +Columns: +- `"prompt"`: The problem statement. +- `"completions"`: A list of reasoning steps generated to solve the problem. +- `"labels"`: A list of booleans or floats indicating the correctness of each corresponding reasoning step. + +This structure allows models to learn the correctness of each step in a solution, facilitating improved reasoning and problem-solving abilities. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/prm800k.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + data_files = { + "train": "https://github.com/openai/prm800k/raw/refs/heads/main/prm800k/data/phase1_train.jsonl", + "test": "https://github.com/openai/prm800k/raw/refs/heads/main/prm800k/data/phase1_test.jsonl", + } + dataset = load_dataset("json", data_files=data_files) + + dataset = dataset.map( + process_batch, + batched=True, + batch_size=10, + remove_columns=[ + "labeler", + "timestamp", + "generation", + "is_quality_control_question", + "is_initial_screening_question", + "question", + "label", + ], + num_proc=script_args.dataset_num_proc, + ) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/rlaif-v.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/rlaif-v.py new file mode 100644 index 0000000000000000000000000000000000000000..f65c65f832bcebbf02c49f23cadf8f68c79eed9d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/rlaif-v.py @@ -0,0 +1,112 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import features, load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/rlaif-v"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/rlaif-v", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def to_conversational(example): + """ + Convert prompt from "xxx" to [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "xxx"}]}] + and chosen and rejected from "xxx" to [{"role": "assistant", "content": [{"type": "text", "text": "xxx"}]}]. + Images are wrapped into a list. + """ + prompt = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": example["question"]}]}] + chosen = [{"role": "assistant", "content": [{"type": "text", "text": example["chosen"]}]}] + rejected = [{"role": "assistant", "content": [{"type": "text", "text": example["rejected"]}]}] + return {"prompt": prompt, "images": [example["image"]], "chosen": chosen, "rejected": rejected} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# RLAIF-V Dataset + +## Summary + +The RLAIF-V dataset is a processed version of the [openbmb/RLAIF-V-Dataset](https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset#dataset-card-for-rlaif-v-dataset), specifically curated to train vision-language models using the [TRL library](https://github.com/huggingface/trl) for preference learning tasks. It contains 83,132 high-quality comparison pairs, each comprising an image and two textual descriptions: one preferred and one rejected. This dataset enables models to learn human preferences in visual contexts, enhancing their ability to generate and evaluate image captions. + +## Data Structure + +- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational) +- **Type**: [Preference](https://huggingface.co/docs/trl/main/dataset_formats#preference) + +Columns: +- `"prompt"`: The task related to the image. +- `"images"`: The image. +- `"chosen"`: The preferred answer. +- `"rejected"`: An alternative answer that was not preferred. + +This structure allows models to learn to prefer the _chosen_ response over the _rejected_ one, thereby aligning with human preferences in visual tasks. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/rlaif-v.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("openbmb/RLAIF-V-Dataset", split="train") + dataset = dataset.map( + to_conversational, + num_proc=script_args.dataset_num_proc, + remove_columns=dataset.column_names, + writer_batch_size=128, + ) + + # Cast the images to Sequence[Image] to avoid bytes format + f = dataset.features + f["images"] = features.Sequence(features.Image(decode=True)) + dataset = dataset.cast(f) + + dataset = dataset.train_test_split(test_size=0.01, writer_batch_size=128) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/tldr.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/tldr.py new file mode 100644 index 0000000000000000000000000000000000000000..ec62cdd98cab8f57736c99f7ee341385ffb1cb51 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/tldr.py @@ -0,0 +1,104 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/tldr"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/tldr", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def to_prompt_completion(example): + tldr_format_str = "SUBREDDIT: r/{subreddit}\n\nTITLE: {title}\n\nPOST: {post}\n\nTL;DR:" + prompt = tldr_format_str.format(subreddit=example["subreddit"], title=example["title"], post=example["post"]) + completion = " " + example["summary"] # Add a space to separate the prompt from the completion + return {"prompt": prompt, "completion": completion} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# TL;DR Dataset + +## Summary + +The TL;DR dataset is a processed version of Reddit posts, specifically curated to train models using the [TRL library](https://github.com/huggingface/trl) for summarization tasks. It leverages the common practice on Reddit where users append "TL;DR" (Too Long; Didn't Read) summaries to lengthy posts, providing a rich source of paired text data for training summarization models. + +## Data Structure + +- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard) +- **Type**: [Prompt-completion](https://huggingface.co/docs/trl/main/dataset_formats#prompt-completion) + +Columns: +- `"prompt"`: The unabridged Reddit post. +- `"completion"`: The concise "TL;DR" summary appended by the author. + +This structure enables models to learn the relationship between detailed content and its abbreviated form, enhancing their summarization capabilities. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/tldr.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + # Filtered reddit TL;DR dataset from https://github.com/openai/summarize-from-feedback?tab=readme-ov-file#reddit-tldr-dataset + data_files = { + "train": "https://openaipublic.blob.core.windows.net/summarize-from-feedback/datasets/tldr_3_filtered/train.jsonl", + "validation": "https://openaipublic.blob.core.windows.net/summarize-from-feedback/datasets/tldr_3_filtered/valid.jsonl", + "test": "https://openaipublic.blob.core.windows.net/summarize-from-feedback/datasets/tldr_3_filtered/test.jsonl", + } + dataset = load_dataset("json", data_files=data_files) + + dataset = dataset.map( + to_prompt_completion, + num_proc=script_args.dataset_num_proc, + remove_columns=["id", "subreddit", "title", "post", "summary"], + ) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/tldr_preference.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/tldr_preference.py new file mode 100644 index 0000000000000000000000000000000000000000..39a0957c4e220ff0dab7c9cc0dd4ff546da8a98d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/tldr_preference.py @@ -0,0 +1,110 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/tldr-preference"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/tldr-preference", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def to_preference(example): + info = example["info"] + if example["batch"] in ["batch0_cnndm", "cnndm0", "cnndm2"]: # CNN Daily Mail batches + article = info["article"].replace("\n\n", "\n") + prompt = f"TITLE: {info['title']}\n\n{article}\n\nTL;DR:" + elif example["batch"] in [f"batch{i}" for i in range(3, 23)] + ["edit_b2_eval_test"]: # Reddit batches + post = info["post"].replace("\n\n", "\n") + prompt = f"SUBREDDIT: r/{info['subreddit']}\n\nTITLE: {info['title']}\n\nPOST: {post}\n\nTL;DR:" + else: + raise ValueError(f"Unknown batch: {example['batch']}") + + chosen_idx = example["choice"] + rejected_idx = 1 - chosen_idx + chosen = example["summaries"][chosen_idx]["text"] + rejected = example["summaries"][rejected_idx]["text"] + return {"prompt": prompt, "chosen": chosen, "rejected": rejected} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# TL;DR Dataset for Preference Learning + +## Summary + +The TL;DR dataset is a processed version of Reddit posts, specifically curated to train models using the [TRL library](https://github.com/huggingface/trl) for preference learning and Reinforcement Learning from Human Feedback (RLHF) tasks. It leverages the common practice on Reddit where users append "TL;DR" (Too Long; Didn't Read) summaries to lengthy posts, providing a rich source of paired text data for training models to understand and generate concise summaries. + +## Data Structure + +- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard) +- **Type**: [Preference](https://huggingface.co/docs/trl/main/dataset_formats#preference) + +Columns: +- `"prompt"`: The unabridged Reddit post. +- `"chosen"`: The concise "TL;DR" summary appended by the author. +- `"rejected"`: An alternative summary or response that was not selected. + +This structure enables models to learn the relationship between detailed content and its abbreviated form, enhancing their summarization capabilities. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/tldr_preference.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("openai/summarize_from_feedback", "comparisons") + + dataset = dataset.map( + to_preference, + num_proc=script_args.dataset_num_proc, + remove_columns=["info", "summaries", "choice", "worker", "batch", "split", "extra"], + ) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/ultrafeedback-prompt.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/ultrafeedback-prompt.py new file mode 100644 index 0000000000000000000000000000000000000000..8fa63d6183e91cc2c1fe8737a5b2de9ad52b73c1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/ultrafeedback-prompt.py @@ -0,0 +1,102 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/ultrafeedback-prompt"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/ultrafeedback-prompt", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def to_unpaired_preference(example): + prompt = [{"role": "user", "content": example["instruction"]}] + return {"prompt": prompt} + + +def drop_long_prompt(example): + if len(example["prompt"][0]["content"]) > 512: + return False + else: + return True + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# UltraFeedback - Prompts Dataset + +## Summary + +The UltraFeedback - Prompts dataset is a processed version of the [UltraFeedback](https://huggingface.co/datasets/openbmb/UltraFeedback) dataset for model evaluation on specific aspects like helpfulness, honesty, and instruction-following. + +## Data Structure + +- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational) +- **Type**: [Prompt-only](https://huggingface.co/docs/trl/main/dataset_formats#prompt-only) + +Column: +- `"prompt"`: The input question or instruction provided to the model. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/ultrafeedback-prompt.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("openbmb/UltraFeedback", split="train") + + dataset = dataset.map( + to_unpaired_preference, + remove_columns=["source", "instruction", "models", "completions", "correct_answers", "incorrect_answers"], + num_proc=script_args.dataset_num_proc, + ) + dataset = dataset.filter(drop_long_prompt) + dataset = dataset.train_test_split(test_size=0.05, seed=42) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/ultrafeedback.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/ultrafeedback.py new file mode 100644 index 0000000000000000000000000000000000000000..2f9a91a553837be5d73174a265a9d687644b3fa0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/datasets/ultrafeedback.py @@ -0,0 +1,144 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import load_dataset +from huggingface_hub import ModelCard +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + model_name (`str`, *optional*, defaults to `"gpt-3.5-turbo"`): + Language model to target. Possible values are: + aspect (`str`, *optional*, defaults to `"helpfulness"`): + Aspect to target. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-lib/ultrafeedback-gpt-3.5-turbo-helpfulness"`): + Hugging Face repository ID to push the dataset to. + dataset_num_proc (`int`, *optional*): + Number of workers to use for dataset processing. + """ + + model_name: str = field( + default="gpt-3.5-turbo", + metadata={ + "help": "Language model to target.", + "choices": [ + "alpaca-7b", + "bard", + "falcon-40b-instruct", + "gpt-3.5-turbo", + "gpt-4", + "llama-2-13b-chat", + "llama-2-70b-chat", + "llama-2-7b-chat", + "mpt-30b-chat", + "pythia-12b", + "starchat", + "ultralm-13b", + "ultralm-65b", + "vicuna-33b", + "wizardlm-13b", + "wizardlm-70b", + "wizardlm-7b", + ], + }, + ) + aspect: str = field( + default="helpfulness", + metadata={ + "help": "Aspect to target. Possible values are: 'helpfulness' (default), 'honesty', " + "'instruction-following', 'truthfulness'.", + "choices": ["helpfulness", "honesty", "instruction-following", "truthfulness"], + }, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-lib/ultrafeedback-gpt-3.5-turbo-helpfulness", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of workers to use for dataset processing."}, + ) + + +def to_unpaired_preference(example, model_name, aspect): + prompt = [{"role": "user", "content": example["instruction"]}] + model_index = example["models"].index(model_name) + response_content = example["completions"][model_index]["response"] + completion = [{"role": "assistant", "content": response_content}] + score = int(example["completions"][model_index]["annotations"][aspect]["Rating"]) + label = score >= 5 + return {"prompt": prompt, "completion": completion, "label": label} + + +model_card = ModelCard(""" +--- +tags: [trl] +--- + +# UltraFeedback GPT-3.5-Turbo Helpfulness Dataset + +## Summary + +The UltraFeedback GPT-3.5-Turbo Helpfulness dataset contains processed user-assistant interactions filtered for helpfulness, derived from the [openbmb/UltraFeedback](https://huggingface.co/datasets/openbmb/UltraFeedback) dataset. It is designed for fine-tuning and evaluating models in alignment tasks. + +## Data Structure + +- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational) +- **Type**: [Unpaired preference](https://huggingface.co/docs/trl/main/dataset_formats#unpaired-preference) + +Column: +- `"prompt"`: The input question or instruction provided to the model. +- `"completion"`: The model's response to the prompt. +- `"label"`: A binary value indicating whether the response is sufficiently helpful. + +## Generation script + +The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/ultrafeedback.py). +""") + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + + dataset = load_dataset("openbmb/UltraFeedback", split="train") + + dataset = dataset.filter( + lambda example: script_args.model_name in example["models"], + batched=False, + num_proc=script_args.dataset_num_proc, + ) + dataset = dataset.map( + to_unpaired_preference, + remove_columns=["source", "instruction", "models", "completions", "correct_answers", "incorrect_answers"], + fn_kwargs={"model_name": script_args.model_name, "aspect": script_args.aspect}, + num_proc=script_args.dataset_num_proc, + ) + dataset = dataset.train_test_split(test_size=0.05, seed=42) + + if script_args.push_to_hub: + dataset.push_to_hub(script_args.repo_id) + model_card.push_to_hub(script_args.repo_id, repo_type="dataset") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/README.md b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f744d417ec4c81c5e3795ee4a85f6ba7d58130bd --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/README.md @@ -0,0 +1,26 @@ +# Notebooks + +This directory contains a collection of Jupyter notebooks that demonstrate how to use the TRL library in different applications. + +| Notebook | Description | Open in Colab | +| --- | --- | --- | +| [`grpo_trl_lora_qlora.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/grpo_trl_lora_qlora.ipynb) | GRPO using QLoRA on free Colab | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_trl_lora_qlora.ipynb) | +| [`grpo_agent.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/grpo_agent.ipynb) | GRPO for agent training | Not available due to OOM with Colab GPUs | +| [`grpo_rnj_1_instruct.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/grpo_rnj_1_instruct.ipynb) | GRPO rnj-1-instruct with QLoRA using TRL on Colab to add reasoning capabilities | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_rnj_1_instruct.ipynb) | +| [`sft_ministral3_vl.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/sft_ministral3_vl.ipynb) | Supervised Fine-Tuning (SFT) Ministral 3 with QLoRA using TRL on free Colab | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_ministral3_vl.ipynb) | +| [`grpo_ministral3_vl.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/grpo_ministral3_vl.ipynb) | GRPO Ministral 3 with QLoRA using TRL on free Colab | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_ministral3_vl.ipynb) | +| [`sft_nemotron_3.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/sft_nemotron_3.ipynb) | SFT with LoRA on NVIDIA Nemotron 3 models | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_nemotron_3.ipynb) | +| [`sft_trl_lora_qlora.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/sft_trl_lora_qlora.ipynb) | Supervised Fine-Tuning (SFT) using QLoRA on free Colab | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_trl_lora_qlora.ipynb) | +| [`sft_qwen_vl.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/sft_qwen_vl.ipynb) | Supervised Fine-Tuning (SFT) Qwen3-VL with QLoRA using TRL on free Colab | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_qwen_vl.ipynb) | +| [`sft_tool_calling.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/sft_tool_calling.ipynb) | Teaching tool calling to a model without native tool-calling support using SFT with QLoRA | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_tool_calling.ipynb) | +| [`grpo_qwen3_vl.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/grpo_qwen3_vl.ipynb) | GRPO Qwen3-VL with QLoRA using TRL on free Colab | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_qwen3_vl.ipynb) | + +## OpenEnv Notebooks + +These notebooks demonstrate GRPO training with [OpenEnv](https://github.com/meta-pytorch/OpenEnv) environments using `environment_factory`. The BrowserGym notebook uses the lower-level `rollout_func` API instead. + +| Notebook | Description | Open in Colab | +| --- | --- | --- | +| [`openenv_wordle_grpo.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/openenv_wordle_grpo.ipynb) | GRPO to play Wordle on an OpenEnv environment | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/openenv_wordle_grpo.ipynb) | +| [`openenv_sudoku_grpo.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/openenv_sudoku_grpo.ipynb) | GRPO to play Sudoku on an OpenEnv environment | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/openenv_sudoku_grpo.ipynb) | +| [`grpo_functiongemma_browsergym_openenv.ipynb`](https://github.com/huggingface/trl/tree/main/examples/notebooks/grpo_functiongemma_browsergym_openenv.ipynb) | GRPO on FunctionGemma in the BrowserGym environment | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_functiongemma_browsergym_openenv.ipynb) | diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_agent.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_agent.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..9fec579c2935efcf1c6efa1391f971a7e423231b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_agent.ipynb @@ -0,0 +1,703 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "63ceecbc-87ad-4ad3-a317-f49267ffc93b", + "metadata": {}, + "source": [ + "# Agent Training with GRPO using TRL\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "\n", + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can train a language model to act as an **agent**. One that learns to reason, interact with external tools, and improve through reinforcement.\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)\n", + "- [OpenEnv](https://github.com/meta-pytorch/OpenEnv)\n", + "\n", + "\n", + "TRL supports training agents that can use external tools as part of their decision process. \n", + "In this notebook, the agent has access to the **BioGRID database**, which it can query using **read-only SQL commands** to retrieve biological interaction data. The model learns when and how to use tools based on rewards.\n", + "\n", + "We'll fine-tune a model using GRPO (Group Relative Policy Optimization) via TRL. The agent will:\n", + "\n", + "1. Generate tool call to query the database if needed.\n", + "2. Receive the tool response and add it it to the context.\n", + "3. Learn to improve its tool usage and general capabilities over time through reward signals.\n", + "\n", + "## Install dependencies\n", + "\n", + "We'll start by installing **TRL**, which automatically includes the main dependencies like **Transformers**. \n", + "We'll also install **trackio** (for logging and monitoring training runs), **vLLM** (for efficient generation), and **jmespath** (needed for the tools capabilities)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b4812fbf-3f61-481e-9a64-95277eada9c9", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[vllm]\" git+https://github.com/huggingface/transformers.git trackio jmespath " + ] + }, + { + "cell_type": "markdown", + "id": "ede8e566-a1b5-460f-9fe8-a6010bc56148", + "metadata": {}, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "21756ac0-78b2-495d-8137-28dfa9faae6a", + "metadata": {}, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "id": "KVGklspLYlmz", + "metadata": {}, + "source": [ + "## Create the database for the tool\n", + "\n", + "For this example, we will use the [BioGRID database](https://thebiogrid.org/), a curated resource containing **protein, genetic, and chemical interaction data**. We've already compiled and uploaded it to the Hub at [qgallouedec/biogrid](https://huggingface.co/datasets/qgallouedec/biogrid). The dataset is loaded and converted into an sqlite database.\n", + "\n", + "> 💡 We remove spaces in the column names to easen the model work. In real-world deployments, you may keep your original column names and rely on the agent to reason about them. Here, we simplify the schema to make training smoother." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "rRzPMhfXBLkF", + "metadata": {}, + "outputs": [], + "source": [ + "import sqlite3\n", + "from datasets import load_dataset\n", + "\n", + "# Load dataset\n", + "biogrid_dataset = load_dataset(\"qgallouedec/biogrid\", split=\"train\")\n", + "df = biogrid_dataset.to_pandas()\n", + "\n", + "# Normalize column names: remove spaces, replace with underscores\n", + "df.columns = [c.replace(\" \", \"_\") for c in df.columns]\n", + "\n", + "# Save to SQLite\n", + "conn = sqlite3.connect(\"biogrid.db\")\n", + "try:\n", + " df.to_sql(\"interactions\", conn, if_exists=\"replace\", index=False)\n", + " print(f\"biogrid.db created. Rows stored: {len(df)}\")\n", + "finally:\n", + " conn.close()" + ] + }, + { + "cell_type": "markdown", + "id": "pSSGvLbmZyC2", + "metadata": {}, + "source": [ + "## Load the QA dataset\n", + "\n", + "The training objective is to fine-tune a model to answer gene-related questions. The model should learn to use the database query tool to retrieve factual information when needed.\n", + "\n", + "We'll define a formatting function for each sample, adding instructions about the database and how to call it. The model must answer with **yes** or **no**. Let's implement the `format_example` function.\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "asrv7LbaD71C", + "metadata": {}, + "outputs": [], + "source": [ + "import textwrap\n", + "\n", + "def format_example(example):\n", + " question = example[\"question\"]\n", + " preamble = textwrap.dedent(\"\"\"\\\n", + " You have access to the BioGRID SQLite database.\n", + " Use SQL queries to retrieve only the information needed to answer the question.\n", + "\n", + " Genes may appear in the database in columns `Alt_IDs_Interactor_A` `Alt_IDs_Interactor_B`, `Aliases_Interactor_A` and `Aliases_Interactor_B`,\n", + " and each entry can contain multiple gene names or synonyms separated by '|', for example:\n", + " 'entrez gene/locuslink:JNKK(gene name synonym)|entrez gene/locuslink:MAPKK4(gene name synonym)|...'\n", + " So a gene like 'JNKK' or 'MAPKK4' may appear inside one of these strings.\n", + "\n", + " If the database schema is unclear or you are unsure about column names:\n", + " - First inspect the schema with `PRAGMA table_info(interactions);`\n", + " - Or preview a few rows with `SELECT * FROM interactions LIMIT 1;`\n", + "\n", + " Otherwise, directly query the required data.\n", + "\n", + " Final answer must be enclosed in stars, e.g. *Yes* or *No*.\n", + " Facts:\n", + " - The NCBI Taxonomy identifier for humans is taxid:9606.\n", + " \"\"\")\n", + " content = f\"{preamble}\\nQuestion: {question}\"\n", + " prompt = [{\"role\": \"user\", \"content\": content}]\n", + " return {\"prompt\": prompt}" + ] + }, + { + "cell_type": "markdown", + "id": "UMnHXYZla_EO", + "metadata": {}, + "source": [ + "Now, let's load the database and call the previous function. \n", + "For simplicity, we will only use questions that start with **“Does the gene…”**. \n", + "In a real use case, the full dataset can be used.\n", + "\n", + "The QA dataset is available on the [Hub](https://huggingface.co/datasets/qgallouedec/biogrid_qa)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "jEs12KqwDnVl", + "metadata": {}, + "outputs": [], + "source": [ + "dataset = load_dataset(\"qgallouedec/biogrid_qa\", split=\"train\")\n", + "dataset = dataset.filter(\n", + " lambda example: example[\"question\"].startswith(\"Does the gene \")\n", + ") # keep only simple questions for example\n", + "dataset = dataset.map(format_example, remove_columns=[\"question\"])\n", + "\n", + "train_dataset = dataset\n", + "eval_dataset = None # No eval by default, can be added if needed" + ] + }, + { + "cell_type": "markdown", + "id": "m4GRjbHycM5L", + "metadata": {}, + "source": [ + "## Create tool for the agent\n", + "\n", + "The `query_biogrid` function is the tool the model will use to query the database and retrieve factual information. \n", + "Each tool must be a standard Python function with **type-hinted arguments and return types**, and a **Google-style docstring** describing its purpose, parameters, and return value." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "nLMH7hahGTyO", + "metadata": {}, + "outputs": [], + "source": [ + "from contextlib import contextmanager\n", + "import signal\n", + "\n", + "@contextmanager\n", + "def timeout(seconds):\n", + " \"\"\"Context manager that raises TimeoutError if execution exceeds time limit.\"\"\"\n", + "\n", + " def timeout_handler(signum, frame):\n", + " raise TimeoutError(f\"Operation timed out after {seconds} seconds\")\n", + "\n", + " signal.signal(signal.SIGALRM, timeout_handler)\n", + " signal.alarm(seconds)\n", + " try:\n", + " yield\n", + " finally:\n", + " signal.alarm(0)\n", + "\n", + "def query_biogrid(sql_command: str) -> list[tuple]:\n", + " \"\"\"\n", + " Execute a read-only SQL command on the BioGRID database.\n", + "\n", + " BioGRID is a curated biological database that compiles protein, genetic, and chemical interactions from multiple organisms. It provides researchers with experimentally verified interaction data to support studies in systems biology and functional genomics.\n", + "\n", + " Args:\n", + " sql_command: The SQL command to execute.\n", + "\n", + " Returns:\n", + " A list of tuples containing the query results.\n", + " \"\"\"\n", + " with timeout(5):\n", + " conn = sqlite3.connect(\"file:biogrid.db?mode=ro\", uri=True)\n", + " cursor = conn.cursor()\n", + " try:\n", + " cursor.execute(sql_command)\n", + " results = cursor.fetchall()\n", + " finally:\n", + " conn.close()\n", + " return results" + ] + }, + { + "cell_type": "markdown", + "id": "GiHtooTwci3B", + "metadata": {}, + "source": [ + "## Define reward functions\n", + "\n", + "To guide the agent during training, we define a few simple reward functions:\n", + "\n", + "- **`query_reward`**: evaluates the model’s query strategy — penalizes more than two queries, penalizes generic database scans, and rewards use of `WHERE` and evidence supporting the final answer.\n", + "- **`correctness_reward`**: rewards Yes/No predictions that match the expected answer.\n", + "- **`structure_reward`**: rewards a proper assistant structure (tool call → response → optional explanation).\n", + "\n", + "Each function returns a list of floats used by the **GRPOTrainer** during optimization. \n", + "Combined, they encourage effective tool use and factual answers." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "sXyqC6cJGe3L", + "metadata": {}, + "outputs": [], + "source": [ + "import re\n", + "\n", + "def query_reward(completions, answer, **kwargs):\n", + " \"\"\"\n", + " Reward query strategy:\n", + " - Penalize more than 2 queries\n", + " - Penalize generic queries (LIMIT 1 / PRAGMA)\n", + " - Reward usage of WHERE\n", + " - Reward evidence supporting the final answer\n", + " \"\"\"\n", + " rewards = []\n", + "\n", + " for completion, ans in zip(completions, answer, strict=False):\n", + " reward = 0.0\n", + " sql_queries = []\n", + " tool_results = []\n", + "\n", + " # collect all SQL queries and tool results\n", + " for turn in completion:\n", + " if turn.get(\"tool_calls\"):\n", + " for call in turn[\"tool_calls\"]:\n", + " sql = call[\"function\"][\"arguments\"].get(\"sql_command\", \"\").lower()\n", + " sql_queries.append(sql)\n", + " if turn.get(\"role\") == \"tool\" and turn.get(\"content\"):\n", + " tool_results.append(turn[\"content\"])\n", + "\n", + " # --- penalize too many queries ---\n", + " if len(sql_queries) > 3:\n", + " reward -= 1.5\n", + "\n", + " # --- check query quality ---\n", + " where_count = 0\n", + " for q in sql_queries:\n", + " if \"limit 1\" in q:\n", + " reward -= 1.0\n", + " if \" where \" not in q:\n", + " reward -= 0.5\n", + " else:\n", + " where_count += 1\n", + " reward += min(where_count, 3) * 0.4 # small bonus for WHERE usage\n", + "\n", + " # --- evidence check: do queries support the answer? ---\n", + " combined_results = []\n", + " error_detected = False\n", + "\n", + " for res in tool_results:\n", + " if isinstance(res, dict) and \"error\" in res:\n", + " error_detected = True\n", + " elif isinstance(res, list):\n", + " combined_results.extend(res)\n", + "\n", + " # if error detected, penalize heavily\n", + " if error_detected:\n", + " reward -= 2.0\n", + " elif len(sql_queries) == 0:\n", + " reward -= 1.5\n", + " else:\n", + " has_hits = len(combined_results) > 0\n", + " correct_answer = ans.lower()\n", + " if (has_hits and correct_answer == \"yes\") or (not has_hits and correct_answer == \"no\"):\n", + " reward += 2.0\n", + " else:\n", + " reward -= 1.5\n", + "\n", + " rewards.append(reward)\n", + "\n", + " return rewards\n", + "\n", + "\n", + "def correctness_reward(completions, answer, **kwargs):\n", + " \"\"\"\n", + " Reward Yes/No correctness.\n", + " Model must provide final answer enclosed in stars — *yes* or *no*.\n", + " Does not reward informal yes/no buried in text.\n", + " \"\"\"\n", + " rewards = []\n", + " for completion, ans in zip(completions, answer, strict=False):\n", + " raw = completion[-1][\"content\"].lower()\n", + "\n", + " # detect form *yes* or *no*\n", + " match = re.search(r\"\\*(yes|no)\\*\", raw)\n", + " guess = match.group(1) if match else None\n", + "\n", + " reward = 0.0\n", + "\n", + " if guess is None:\n", + " reward -= 0.5 # invalid format\n", + " elif guess == ans.lower():\n", + " reward += 0.6 # correct under required format\n", + " else:\n", + " reward -= 1.0 # wrong answer\n", + "\n", + " rewards.append(reward)\n", + "\n", + " return rewards\n", + "\n", + "\n", + "def structure_reward(completions, **kwargs):\n", + " \"\"\"\n", + " Reward proper assistant structure.\n", + " Encourages a logical sequence: tool call + response + optional extra content.\n", + " \"\"\"\n", + " rewards = []\n", + "\n", + " for completion in completions:\n", + " has_call = False\n", + " has_response = False\n", + " has_other = False\n", + "\n", + " for turn in completion:\n", + " role = turn.get(\"role\")\n", + " if role == \"assistant\" and turn.get(\"tool_calls\"):\n", + " has_call = True\n", + " elif role == \"tool\":\n", + " has_response = True\n", + " else:\n", + " content = turn.get(\"content\")\n", + " if content and content.strip() not in [\"\", \"\"]:\n", + " has_other = True\n", + "\n", + " # Reward sequences\n", + " if has_call and has_response:\n", + " if has_other:\n", + " reward = 0.1\n", + " else:\n", + " reward = 0.05 # still positive even without extra text\n", + " elif has_call and not has_response:\n", + " reward = -0.15\n", + " else:\n", + " reward = 0.0 # neutral if no call\n", + "\n", + " rewards.append(reward)\n", + "\n", + " return rewards\n" + ] + }, + { + "cell_type": "markdown", + "id": "zcgkrKtTb4T9", + "metadata": {}, + "source": [ + "## Set GRPO Config\n", + "\n", + "Next, we define the **GRPOConfig**, which controls the main training parameters. \n", + "This configuration specifies how the model interacts with **vLLM**, manages memory, and logs results." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "t4ifJsNLElIN", + "metadata": {}, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "output_dir = \"grpo_biogrid_qwen_3g-1.7b\"\n", + "\n", + "grpo_config = GRPOConfig(\n", + " # Training schedule / optimization\n", + " max_steps=400, # Max number of training steps\n", + " chat_template_kwargs = {\"enable_thinking\": False}, # Disable thinking to reduce token generation\n", + "\n", + " # GRPO configuration\n", + " max_completion_length = 1024, # Maximum tokens generated per model response\n", + "\n", + " # vLLM configuration\n", + " use_vllm = True, # Enable vLLM for faster inference during rollouts\n", + " vllm_mode = \"colocate\", # Run vLLM in colocate mode (same process as training)\n", + " vllm_enable_sleep_mode=False,\n", + "\n", + " # Logging / reporting\n", + " output_dir = output_dir, # Directory for checkpoints and logs\n", + " report_to=\"trackio\", # Experiment tracking tool (integrates with HF Spaces)\n", + " trackio_space_id = output_dir, # HF Space where experiment tracking will be saved\n", + " save_steps = 10, # Interval for saving checkpoints\n", + " log_completions = True,\n", + "\n", + " # Hub integration\n", + " push_to_hub = True, # Set True to automatically push model to Hugging Face Hub\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "34I-Q2MJuf42", + "metadata": {}, + "source": [ + "## Create `GRPOTrainer` and Start Training\n", + "\n", + "Next, we initialize the **`GRPOTrainer`**, which handles the full reinforcement learning loop.\n", + "\n", + "It receives the model name, reward functions, tool(s), and dataset defined earlier. \n", + "\n", + "Finally, we call `trainer.train()` to begin fine-tuning, allowing the model to learn how to query the database effectively through iterative feedback." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "IysntAUOFvRn", + "metadata": {}, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "model_name=\"Qwen/Qwen3-1.7B\"\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model_name,\n", + " train_dataset=train_dataset,\n", + " eval_dataset=eval_dataset,\n", + " tools=[query_biogrid],\n", + " reward_funcs=[correctness_reward, structure_reward, query_reward],\n", + " args=grpo_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "r_qJ5UwLuzCG", + "metadata": {}, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "DusT8JUaGmA6", + "metadata": {}, + "outputs": [], + "source": [ + "import torch\n", + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "id": "OTPkiz3fu0lp", + "metadata": {}, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "NwI3buPOFMFk", + "metadata": {}, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "id": "ITnLBLcTu2-p", + "metadata": {}, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ftek6m4-GncK", + "metadata": {}, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "id": "O6LAwznKu7mc", + "metadata": {}, + "source": [ + "Let's save the trained model." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "idVgnNS1MWPr", + "metadata": {}, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub()" + ] + }, + { + "cell_type": "markdown", + "id": "707318cb", + "metadata": {}, + "source": [ + "## Load the fine-tuned model and run inference using `smolagents`\n", + "\n", + "After fine-tuning the model with **GRPO (TRL)** for tool calling, we can test it at inference time using **`smolagents`**, a lightweight library for running multi-step agents.\n", + "\n", + "`smolagents` handles the agent loop for us:\n", + "- Detecting tool calls generated by the model\n", + "- Executing the corresponding tools (e.g. database queries)\n", + "- Feeding the results back to the model until a final answer is produced\n", + "\n", + "> **Note** \n", + "> Using an agent framework is optional. The fine-tuned model can also be used directly with `transformers` by manually controlling the inference loop and executing the tools outside the model.\n", + "> Agent frameworks are especially useful when the number of steps or tool calls is not fixed.\n", + "\n", + "We start by installing the required package:\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aab7fd5c", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install git+https://github.com/huggingface/smolagents.git" + ] + }, + { + "cell_type": "markdown", + "id": "24453572", + "metadata": {}, + "source": [ + "We will use the `CodeAgent` class from `smolagents` to instantiate our agent. \n", + "First, we need to define the tool the agent can use. This is done using the `@tool` decorator.\n", + "\n", + "As shown below, the tool definition is **exactly the same** as the one used during GRPO training with TRL. This consistency is important: the model was trained to emit calls following this schema, and at inference time the agent simply executes the corresponding Python function." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "adcbbafa", + "metadata": {}, + "outputs": [], + "source": [ + "from smolagents import tool\n", + "\n", + "@tool\n", + "def query_biogrid(sql_command: str) -> list[tuple]:\n", + " \"\"\"\n", + " Execute a read-only SQL query on the BioGRID database.\n", + "\n", + " BioGRID is a curated biological database that compiles protein, genetic,\n", + " and chemical interactions from multiple organisms.\n", + "\n", + " Args:\n", + " sql_command: A read-only SQL query to execute.\n", + "\n", + " Returns:\n", + " A list of tuples containing the query results.\n", + " \"\"\"\n", + " with timeout(5):\n", + " conn = sqlite3.connect(\n", + " \"file:biogrid.db?mode=ro\",\n", + " uri=True,\n", + " )\n", + " cursor = conn.cursor()\n", + " try:\n", + " cursor.execute(sql_command)\n", + " results = cursor.fetchall()\n", + " finally:\n", + " conn.close()\n", + "\n", + " return results" + ] + }, + { + "cell_type": "markdown", + "id": "59721ad2", + "metadata": {}, + "source": [ + "Now we can instantiate the agent using our fine-tuned model and the database tool defined above.\n", + "We wrap the model with `TransformersModel` and pass both the model and the tool when creating the `CodeAgent`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e9ed8d00", + "metadata": {}, + "outputs": [], + "source": [ + "from smolagents import TransformersModel, CodeAgent\n", + "\n", + "model = TransformersModel(model_id=\"sergiopaniego/grpo_biogrid_qwen_3g-1.7b\", apply_chat_template_kwargs={\"enable_thinking\": False})\n", + "\n", + "# Create an agent with query_biogrid as tool\n", + "agent = CodeAgent(tools=[query_biogrid], model=model)" + ] + }, + { + "cell_type": "markdown", + "id": "57ba9462", + "metadata": {}, + "source": [ + "Finally, we run the agent by passing the full prompt (including the instruction preamble and the question), exactly as it was used during training. This ensures the agent operates under the same context and assumptions learned with GRPO, allowing it to correctly decide when to query the database and how to format the final answer." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "23a3cdf4", + "metadata": {}, + "outputs": [], + "source": [ + "result = agent.run(train_dataset[0]['prompt'][0]['content'])\n", + "print(result)" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_functiongemma_browsergym_openenv.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_functiongemma_browsergym_openenv.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..e19df898d54c18891b2ca3a99cdd5216ba3015ff --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_functiongemma_browsergym_openenv.ipynb @@ -0,0 +1,1914 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "lSR2nwdJg962" + }, + "source": [ + "# Fine-Tune FunctionGemma using Hugging Face TRL and OpenEnv\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_functiongemma_browsergym_openenv.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "This guide describes the process of fine-tuning [FunctionGemma](https://huggingface.co/google/functiongemma-270m-it) by Google DeepMind in the [BrowserGym](https://meta-pytorch.org/OpenEnv/environments/browsergym/) environment provided by OpenEnv, using Hugging Face TRL. The steps covered include:\n", + "\n", + "* What is GRPO and OpenEnv\n", + "* Setup dependencies for training\n", + "* Initialize the OpenEnv's BrowserGym environment\n", + "* Create rollout function with helpers\n", + "* Define the reward functions\n", + "* Load the custom dataset\n", + "* Fine tune using TRL and the GRPOTrainer\n", + "* Load the fine-tuned model and run inference\n", + "\n", + "> Note: The guide is designed to run on Google Colaboratory with access to an NVIDIA A100 GPU (40GB) using FunctionGemma. The workflow can be adapted to other GPU configurations, models, or environments." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "duXYuR6Cu_na" + }, + "source": [ + "## What is GRPO and OpenEnv\n", + "\n", + "Group Relative Policy Optimization ([GRPO](https://huggingface.co/papers/2402.03300)) is a post-training method widely used for efficiently fine-tuning large language models. GRPO leverages reward functions to guide learning, enabling models to optimize task-specific behaviors without retraining the entire network.\n", + "\n", + "[OpenEnv](https://meta-pytorch.org/OpenEnv) provides a standard interface for interacting with agentic execution environments using simple Gymnasium-style APIs, such as `step()`, `reset()`, and `state()`. These APIs facilitate reinforcement learning training loops by allowing models to interact with environments in a structured manner. OpenEnv also offers tools for environment creators to build isolated, secure, and deployable environments that can be shared via common protocols like HTTP or packaged in Docker.\n", + "\n", + "The combination of GRPO and OpenEnv enables efficient fine-tuning of models in controlled, interactive tasks while minimizing resource requirements." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cpSAQkzKmv50" + }, + "source": [ + "## Setup dependencies for training\n", + "\n", + "Install the required libraries, including Hugging Face TRL for fine-tuning and OpenEnv for reinforcement learning environments." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "c-2drnj5BP56" + }, + "outputs": [], + "source": [ + "!pip install -Uq trl[vllm] git+https://huggingface.co/spaces/openenv/browsergym_env liger-kernel trackio" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Inxeq6ZGpRno" + }, + "source": [ + "A valid Hugging Face token is required to save the fine-tuned model. In Google Colab, the token can be securely accessed through Colab secrets. Otherwise, it can be provided directly in the login method. Ensure the token has write permissions to allow uploading the model to the Hugging Face Hub during training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "C4q5UVu3BP57" + }, + "outputs": [], + "source": [ + "from google.colab import userdata\n", + "from huggingface_hub import login\n", + "\n", + "# Login into Hugging Face Hub\n", + "hf_token = userdata.get('HF_TOKEN') # If you are running inside a Google Colab\n", + "login(hf_token)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "O3kr38TGm_hb" + }, + "source": [ + "## Initialize the OpenEnv's BrowserGym environment\n", + "\n", + "External environments can guide the fine-tuning of LLMs for function calling by providing interactive feedback that enhances performance on task-specific behaviors.\n", + "\n", + "[BrowserGym](https://meta-pytorch.org/OpenEnv/environments/browsergym/) is a unified framework for web-based agent tasks, offering multiple benchmarks through a Gymnasium-compatible API. It enables training on simple synthetic tasks with [MiniWoB++](https://github.com/Farama-Foundation/miniwob-plusplus) and evaluation on more complex, realistic tasks with [WebArena](https://github.com/web-arena-x/webarena), [VisualWebArena](https://github.com/web-arena-x/visualwebarena), or [WorkArena](https://github.com/ServiceNow/WorkArena). This setup supports iterative training and assessment of web agents without requiring extensive infrastructure.\n", + "\n", + "BrowserGym supports both LLM and VLM training by providing visual information, including screenshots and DOM data, which can be utilized depending on the model type. This guide focuses on a simple web-based task called *\"click-test\"*, which is part of the MiniWoB++ benchmark of synthetic web tasks. Environments can be run locally, in Docker containers, or accessed remotely via the Hugging Face Hub. For this example, the remote environment [openenv/browsergym_env](https://huggingface.co/spaces/openenv/browsergym_env) will be used.\n", + "\n", + "> Note: Hosted environments on the Hub currently have limited concurrency. For higher reliability or parallel runs, duplicating the Space to your own account is strongly recommended." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "clDs-WQlBP57" + }, + "outputs": [], + "source": [ + "from browsergym_env import BrowserGymEnv\n", + "space_url = \"https://openenv-browsergym-env.hf.space\"\n", + "\n", + "client = BrowserGymEnv(base_url=space_url)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "EqfDavDQnD_5" + }, + "source": [ + "## Create rollout function with helpers\n", + "\n", + "The rollout function defines how the agent interacts with the environment during GRPO training. It generates model outputs, collects feedback in the form of rewards, and returns the information required for optimization.\n", + "\n", + "In this setup:\n", + "- The function is invoked automatically by the GRPOTrainer (introduced later), which orchestrates the training loop and handles policy updates.\n", + "- It uses the trainer's `generate_rollout_completions()` method for efficient output generation. This leverages vLLM, a high-performance inference engine for large language models, and is integrated within TRL to streamline rollout generation and reward collection during fine-tuning.\n", + "- Each rollout represents a complete interaction loop, where the model acts, receives feedback from the environment, and updates based on reward signals.\n", + "\n", + "Rewards capture various aspects of the agent's performance. Helper functions, such as `rollout_once`, manage individual episodes, keeping the main `rollout_func` clean, modular, and reusable.\n", + "\n", + "This modular structure allows GRPO to efficiently sample, evaluate, and refine the model's behavior through reinforcement learning.\n", + "\n", + "Before executing rollouts, a `system prompt` is defined to instruct the model on how to interact with the environment. This prompt specifies the available BrowserGym actions (such as `click`, `fill`, `send_keys`, and `scroll`), describes the page structure, and enforces that the model responds with exactly one action per step. It ensures consistent and structured interactions, guiding the model to complete tasks effectively without providing extra explanations or multiple actions." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ItCXS6H0BP58" + }, + "outputs": [], + "source": [ + "# @title System prompt (click to expand)\n", + "SYSTEM_PROMPT = \"\"\"You control a web browser through BrowserGym actions.\n", + "You must complete the given web task by interacting with the page.\n", + "\n", + "Available actions:\n", + "- noop() - Do nothing\n", + "- click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "- fill(bid, text) - Fill input field with text\n", + "- send_keys(text) - Send keyboard input\n", + "- scroll(direction) - Scroll up/down\n", + "\n", + "The page structure shows elements as: [bid] element_type 'element_text'\n", + "For example: [13] button 'Click Me!' means bid='13'\n", + "\n", + "Reply with exactly ONE action on a single line, e.g.:\n", + "click('13')\n", + "fill('42', 'hello world')\n", + "noop()\n", + "\n", + "Do not include explanations or multiple actions.\"\"\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Vi1rFey39GUl" + }, + "source": [ + "The `rollout_func` orchestrates the interaction between the model and the remote BrowserGym environment. For each prompt in the batch, it executes a complete episode using the `rollout_once` function, collecting model outputs and rewards for GRPO optimization.\n", + "\n", + "The parameter `max_steps` defines the maximum number of steps the model can take within a single episode. This limits the length of the interaction loop, ensuring that episodes terminate even if the task is not completed, and helps maintain efficient training.\n", + "\n", + "During each episode, the function tracks prompt and completion IDs, log probabilities, and both step-wise and final rewards, returning them in a structured format for the trainer to perform policy updates." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "CgHd5CFBBP58" + }, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "max_steps=10\n", + "\n", + "def rollout_func(prompts: list[str], trainer: GRPOTrainer) -> dict[str, list]:\n", + " episode_prompt_ids: list[list[int]] = []\n", + " episode_completion_ids: list[list[int]] = []\n", + " episode_logprobs: list[list[float]] = []\n", + " completion_rewards: list[float] = []\n", + "\n", + " print(f\"\\n[DEBUG] rollout_func called with {len(prompts)} prompts (LLM mode, text-only)\")\n", + "\n", + " for i, prompt_text in enumerate(prompts):\n", + " print(f\"[DEBUG] Processing prompt {i + 1}/{len(prompts)}\")\n", + " episode = rollout_once(\n", + " trainer=trainer,\n", + " env=client,\n", + " tokenizer=trainer.processing_class,\n", + " dataset_prompt=prompt_text,\n", + " max_steps=max_steps,\n", + " )\n", + " episode_prompt_ids.append(episode[\"prompt_ids\"])\n", + " episode_completion_ids.append(episode[\"completion_ids\"])\n", + " episode_logprobs.append(episode[\"logprobs\"])\n", + " completion_rewards.append(episode[\"completion_reward\"])\n", + "\n", + " return {\n", + " \"prompt_ids\": episode_prompt_ids,\n", + " \"completion_ids\": episode_completion_ids,\n", + " \"logprobs\": episode_logprobs,\n", + " \"completion_reward\": completion_rewards,\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ioUHdIxr9ZQO" + }, + "source": [ + "### Define `rollout_once`\n", + "\n", + "The `rollout_once` function runs one complete interaction loop between the model and the BrowserGym environment using the trainer's generation method. \n", + "It executes a single episode, from generating an action to receiving feedback and computing rewards.\n", + "\n", + "Here's the step-by-step breakdown:\n", + "\n", + "1. Environment reset: Start a new BrowserGym session and initialize the observation.\n", + "2. Prompt construction: Combine the system prompt, environment observation (text-only via the accessibility tree), and any relevant errors or state information to form the model input.\n", + "3. Generation: Use `trl.experimental.openenv.generate_rollout_completions()` to produce the model's action efficiently with vLLM.\n", + "4. Action parsing and execution: Interpret the model's output and execute the corresponding BrowserGym action (e.g., `click`, `fill`, `scroll`).\n", + "5. Reward calculation: Track step-wise rewards provided by the environment and compute completion rewards based on task success or failure.\n", + "6. Return structured rollout data: Includes prompt/completion IDs, log probabilities, step rewards, and the final reward for the episode.\n", + "\n", + "This modular design allows each episode to be processed independently while providing rich feedback for the GRPO training loop, supporting both task completion and intermediate reward shaping." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "y8Ml47SYBP58" + }, + "outputs": [], + "source": [ + "from trl.experimental.openenv import generate_rollout_completions\n", + "from browsergym_env import BrowserGymAction\n", + "from transformers import AutoTokenizer\n", + "\n", + "def rollout_once(\n", + " trainer: GRPOTrainer,\n", + " env: BrowserGymEnv,\n", + " tokenizer: AutoTokenizer,\n", + " dataset_prompt: str,\n", + " max_steps: int,\n", + ") -> dict[str, list]:\n", + " \"\"\"Run one episode and collect training data (text-only, no screenshots).\"\"\"\n", + " result = env.reset()\n", + " observation = result.observation\n", + "\n", + " prompt_ids: list[int] = []\n", + " completion_ids: list[int] = []\n", + " logprobs: list[float] = []\n", + " step_rewards: list[float] = []\n", + " completion_rewards: list[float] = []\n", + "\n", + " for step_num in range(max_steps):\n", + " if result.done:\n", + " break\n", + "\n", + " # Create prompt from observation (text-only using accessibility tree)\n", + " goal = observation.goal or dataset_prompt\n", + " axtree = observation.axtree_txt or \"\"\n", + " error = observation.error if observation.last_action_error else \"\"\n", + "\n", + " user_prompt = make_user_prompt(goal, step_num, axtree, error)\n", + " messages = [\n", + " {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n", + " {\"role\": \"user\", \"content\": user_prompt},\n", + " ]\n", + " prompt_text = tokenizer.apply_chat_template(\n", + " messages,\n", + " add_generation_prompt=True,\n", + " tokenize=False,\n", + " )\n", + "\n", + " # Generate action with vLLM\n", + " rollout_outputs = generate_rollout_completions(trainer, [prompt_text])[0]\n", + " prompt_ids.extend(rollout_outputs[\"prompt_ids\"])\n", + " completion_ids.extend(rollout_outputs[\"completion_ids\"])\n", + " logprobs.extend(rollout_outputs[\"logprobs\"])\n", + "\n", + " completion_text = rollout_outputs.get(\"text\") or tokenizer.decode(\n", + " rollout_outputs[\"completion_ids\"], skip_special_tokens=True\n", + " )\n", + "\n", + " # Parse and execute action\n", + " action_str = parse_action(completion_text)\n", + "\n", + " print(f\"Step {step_num + 1}: {action_str}\")\n", + "\n", + " # Take action in environment\n", + " result = env.step(BrowserGymAction(action_str=action_str))\n", + " observation = result.observation\n", + "\n", + " # Track rewards\n", + " step_reward = float(result.reward or 0.0)\n", + " step_rewards.append(step_reward)\n", + "\n", + " # Reward shaping: success is most important\n", + " if result.done and step_reward > 0:\n", + " completion_rewards.append(1.0) # Task completed successfully\n", + " elif result.done and step_reward == 0:\n", + " completion_rewards.append(0.0) # Task failed\n", + " else:\n", + " completion_rewards.append(step_reward) # Intermediate reward\n", + "\n", + " # Final reward is based on task completion\n", + " final_reward = completion_rewards[-1] if completion_rewards else 0.0\n", + "\n", + " return {\n", + " \"prompt_ids\": prompt_ids,\n", + " \"completion_ids\": completion_ids,\n", + " \"logprobs\": logprobs,\n", + " \"step_rewards\": step_rewards,\n", + " \"completion_reward\": final_reward,\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "MDJKMQ__8qzj" + }, + "source": [ + "### Helper functions\n", + "\n", + "Supporting utilities used in `rollout_once`:\n", + "\n", + "- `make_user_prompt`: builds the user prompt combining the base text and previous game messages.\n", + "- `parse_action`: parses BrowserGym action from model response" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "GG4ba41PBP58" + }, + "outputs": [], + "source": [ + "# @title Helpers (click to expand)\n", + "def make_user_prompt(goal: str, step_num: int, axtree: str, error: str = \"\") -> str:\n", + " \"\"\"Create user prompt from observation.\"\"\"\n", + " prompt_parts = [f\"Step {step_num + 1}\"]\n", + "\n", + " if goal:\n", + " prompt_parts.append(f\"Goal: {goal}\")\n", + "\n", + " if error:\n", + " prompt_parts.append(f\"Previous action error: {error}\")\n", + "\n", + " # Include accessibility tree (truncated for context)\n", + " if axtree:\n", + " max_len = 2000\n", + " axtree_truncated = axtree[:max_len] + \"...\" if len(axtree) > max_len else axtree\n", + " prompt_parts.append(f\"Page structure:\\n{axtree_truncated}\")\n", + "\n", + " prompt_parts.append(\"What action do you take?\")\n", + "\n", + " return \"\\n\\n\".join(prompt_parts)\n", + "\n", + "\n", + "def parse_action(response_text: str) -> str:\n", + " \"\"\"Parse BrowserGym action from model response.\"\"\"\n", + " # Extract first line that looks like an action\n", + " for line in response_text.strip().split(\"\\n\"):\n", + " line = line.strip()\n", + " if \"(\" in line and \")\" in line:\n", + " return line\n", + "\n", + " # Fallback to noop if no valid action found\n", + " return \"noop()\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Oek3JhcWnKhw" + }, + "source": [ + "## Define the reward functions\n", + "\n", + "Reward functions quantify the model's performance in the environment and guide the GRPO optimization process.\n", + "\n", + "In this setup, the `reward_completion` function assigns rewards based on task completion. It extracts the final reward for each episode, which indicates whether the agent successfully completed the task. If no reward information is available, it defaults to zero.\n", + "\n", + "This modular approach allows additional reward functions to be added easily, enabling more granular feedback such as intermediate progress, efficiency, or correctness of actions, depending on the task requirements." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "WxkXaz5aBP59" + }, + "outputs": [], + "source": [ + "def reward_completion(completions: list[str], **kwargs) -> list[float]:\n", + " \"\"\"Reward for task completion.\"\"\"\n", + " rewards = kwargs.get(\"completion_reward\") if kwargs else None\n", + " if rewards is None:\n", + " return [0.0 for _ in completions]\n", + " return [float(r) for r in rewards]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "66ZsrLplm07U" + }, + "source": [ + "## Load the custom dataset\n", + "\n", + "The dataset is constructed with repeated prompts to control the total number of training episodes.\n", + "\n", + "Each entry in the dataset triggers a single rollout episode during training. The `dataset_prompt` provides the initial instruction to the model at the start of each episode, ensuring consistent guidance for task execution." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "UX6jUjxaBP59" + }, + "outputs": [], + "source": [ + "from datasets import Dataset\n", + "\n", + "dataset_prompt = \"Complete the web task successfully.\"\n", + "dataset_size = 1000\n", + "\n", + "dataset = Dataset.from_dict({\"prompt\": [dataset_prompt] * dataset_size})" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-mvka-96m3I7" + }, + "source": [ + "## Fine-tune using TRL and the GRPOTrainer\n", + "\n", + "The next step is to define the GRPOConfig, which sets all key training parameters.\n", + "\n", + "This configuration determines how the model interacts with vLLM, handles memory and computation, and records training metrics and logs for monitoring the fine-tuning process." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "TZ34a1h-BP59" + }, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "output_dir = \"browsergym-grpo-functiongemma-270m-it\"\n", + "\n", + "grpo_config = GRPOConfig(\n", + " # num_train_epochs=1, # Number of times to iterate over the full dataset (use for full training runs)\n", + " max_steps=100, # Number of dataset passes (for shorter runs/testing). For full trainings, use `num_train_epochs` instead\n", + " learning_rate=5e-6, # Learning rate for the optimizer\n", + " warmup_steps=10, # Number of steps to linearly increase learning rate at the start of training\n", + "\n", + " per_device_train_batch_size=1, # Number of samples per device per step\n", + " num_generations=4, # Number of completions to generate per prompt\n", + " generation_batch_size=4, # Batch size used during generation (must be divisible by num_generations)\n", + " max_completion_length=32, # Maximum length of generated completions\n", + "\n", + " use_vllm=True, # Use vLLM engine for fast inference\n", + " vllm_mode=\"colocate\", # vLLM mode: \"colocate\" runs generation on the same GPU as training\n", + " vllm_gpu_memory_utilization=0.1, # Fraction of GPU memory allocated to vLLM\n", + "\n", + " output_dir=str(output_dir), # Directory where checkpoints, logs, and outputs will be saved\n", + " logging_steps=1, # Log metrics every N steps\n", + " report_to=\"trackio\", # Logging/reporting platform (e.g., \"trackio\")\n", + " trackio_space_id=output_dir, # HF Space where the experiment tracking will be saved\n", + " push_to_hub=True, # Optionally push trained model to Hugging Face Hub\n", + "\n", + " use_liger_kernel=True, # Enable Liger kernel optimizations for faster training\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "a1taGmD--0Y4" + }, + "source": [ + "The next step is to initialize the GRPOTrainer, which manages the complete reinforcement learning loop.\n", + "\n", + "It receives the model name, reward functions, rollout function, and dataset defined earlier. From the model name, the trainer automatically initializes the model and tokenizer. It then coordinates interactions between the model and the environment, applies the defined reward signals, and updates the policy during training.\n", + "\n", + "Finally, calling `trainer.train()` starts the fine-tuning process, enabling the model to progressively improve its performance through iterative interaction and reinforcement learning.\n", + "\n", + "> Note: The training pipeline uses approximately 10.6 GB of GPU VRAM and can be adapted to different hardware configurations." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "En43o4NZBP59" + }, + "outputs": [], + "source": [ + "model_name = \"google/functiongemma-270m-it\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "047d386e54704add95edd4beace781d7" + ] + }, + "id": "k8-SvqJcBP59", + "outputId": "6a4d9276-fc91-4217-d3a2-51a18d222338" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipython-input-3830121904.py:1: UserWarning: You are importing from 'rollout_func', which is an experimental feature. This API may change or be removed at any time without prior notice. Silence this warning by setting environment variable TRL_EXPERIMENTAL_SILENCE=1.\n", + " trainer = GRPOTrainer(\n", + "The model is already on multiple devices. Skipping the move to device specified in `args`.\n", + "`torch_dtype` is deprecated! Use `dtype` instead!\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "047d386e54704add95edd4beace781d7", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Loading safetensors checkpoint shards: 0% Completed | 0/1 [00:00" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Created new run: sergiopaniego-1765969078\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: noop()\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: Click 'click(bid) - Click element with BrowserGym ID (the number in brackets\n", + "Step 8: I will use the action `click()` to click the button.\n", + "Step 9: noop()\n", + "Step 10: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: noop()\n", + "Step 2: noop()\n", + "Step 3: Clicks ('13')\n", + "Step 4: I will click 'Click Me!' using action 'click(bid)' on page 'Click Test Task' using a bid of '13'.\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: I will use the 'click(bid)' action.\n", + "Step 2: mouse_click(bid)\n", + "Step 3: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 4: Add action 'click(bid)' to Step 4.\n", + "Step 5: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 9: noop()\n", + "Step 10: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: noop()\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: Click('13')\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:liger_kernel.transformers.model.gemma3:It is strongly recommended to train Gemma3 models with the `eager` attention implementation instead of `sdpa`. Use `eager` with `AutoModelForCausalLM.from_pretrained('', attn_implementation='eager')`.\n", + "/usr/local/lib/python3.12/dist-packages/torch/_inductor/compile_fx.py:282: UserWarning: TensorFloat32 tensor cores for float32 matrix multiplication available but not enabled. Consider setting `torch.set_float32_matmul_precision('high')` for better performance.\n", + " warnings.warn(\n", + "/usr/local/lib/python3.12/dist-packages/torch/_inductor/lowering.py:7095: UserWarning: \n", + "Online softmax is disabled on the fly since Inductor decides to\n", + "split the reduction. Cut an issue to PyTorch if this is an\n", + "important use case and you want to speed it up with online\n", + "softmax.\n", + "\n", + " warnings.warn(\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " [100/100 35:02, Epoch 0/1]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining Loss
10.000000
20.000000
30.000000
40.000000
50.000000
60.000000
70.000000
80.000000
9-0.877900
101965.894400
11-0.830900
1210.616100
130.000000
140.000000
150.000000
160.000000
172.320100
181.887500
19-0.691600
20-0.764400
210.000000
220.000000
230.000000
240.000000
250.000000
260.000000
270.000000
280.000000
290.000000
300.000000
310.000000
320.000000
330.000000
340.000000
350.000000
360.000000
370.000000
380.000000
390.000000
400.000000
410.000000
420.000000
430.000000
440.000000
450.000000
460.000000
470.000000
480.000000
490.000000
500.000000
510.000000
520.000000
530.000000
540.000000
550.000000
560.000000
570.000000
580.000000
590.000000
600.000000
610.000000
620.000000
630.000000
640.000000
650.000000
660.000000
670.000000
680.000000
690.000000
700.000000
710.000000
720.000000
730.000000
740.000000
750.000000
760.000000
770.000000
780.000000
790.000000
800.000000
810.000000
820.000000
830.000000
840.000000
850.000000
860.000000
870.000000
880.000000
890.000000
900.000000
910.000000
920.000000
930.000000
940.000000
950.000000
960.000000
970.000000
980.000000
990.000000
1000.000000

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: Clicks ('13')\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 10: noop()\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: noop()\n", + "Step 2: I will use action: click(bid) to click the button.\n", + "Step 3: Yes, I can handle this. I will use the `click()` action to click the button.\n", + "Step 4: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 9: noop()\n", + "Step 10: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 8: noop()\n", + "Step 9: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 10: Pass the button ID ('Click Me!') to the action \"click('bid')\".\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: noop()\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: I will click the button by emitting `click(bid)` and `fill(bid, text)` simultaneously.\n", + "Step 6: noop()\n", + "Step 7: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: - Noop()\n", + "Step 2: noop()\n", + "Step 3: -noop()\n", + "Step 4: noop()\n", + "Step 5: Click('13')\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: noop()\n", + "Step 2: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: Complete action: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: I will use the action 'click('bid') to click the button.\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: I call action Click (bid) on the page.\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: Oops()\n", + "Step 2: noop()\n", + "Step 3: fill(bid, text)\n", + "Step 4: noop()\n", + "Step 5: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: def click_button_on_page():\n", + "Step 2: noop()\n", + "Step 3: click(bid)\n", + "Step 4: Click('13')\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: noop()\n", + "Step 2: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 3: noop()\n", + "Step 4: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 5: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 6: I will click the button 'Click Me!' by using the action `click(bid)` and emitting a bid of 13.\n", + "Step 7: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: noop()\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: `click(bid)` - No action\n", + "Step 2: - Noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: noop()\n", + "Step 10: I will click the button 'Click Me!' using the action 'click(bid)'.\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: noop()\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: Complete action: click(bid)\n", + "Step 10: noop()\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: noop()\n", + "Step 2: I will perform action 1: click('13') to complete the action.\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: noop()\n", + "Step 2: noop()\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: Click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 8: noop()\n", + "Step 9: Click ('13')\n", + "Step 10: Add action 'fill(bid, text) - Send keyboard input' to perform the click.\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: noop()\n", + "Step 2: Click('click(bid) - Bid')\n", + "Step 3: noop()\n", + "Step 4: noop()\n", + "Step 5: noop()\n", + "Step 6: noop()\n", + "Step 7: noop()\n", + "Step 8: noop()\n", + "Step 9: click(bid) - Click element with BrowserGym ID (the number in brackets)\n", + "Step 10: noop()\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "\n", + "[DEBUG] rollout_func called with 4 prompts (LLM mode, text-only)\n", + "[DEBUG] Processing prompt 1/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 2/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 3/4\n", + "Step 1: click('13')\n", + "[DEBUG] Processing prompt 4/4\n", + "Step 1: click('13')\n", + "* Run finished. Uploading logs to Trackio (please wait...)\n" + ] + } + ], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "BZj4IG9ZBAix" + }, + "source": [ + "In this step, the fine-tuned model is saved locally and uploaded to the Hugging Face Hub using the configured account credentials." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "244ced1920694dbaae9bf98065b4f01d", + "e3769ae107554c9ba38c1e491b15bf4e", + "6d5b8bff73474faeb1d1b438fb4e8cec", + "9f952f8eb63b42e4b38711737da5461e", + "bd12780895064467b5be14e2ec3df114", + "d1261c1083a74dca877e6eece6395d73", + "999744cacd6a4fb08a1d4977ce2f06fd", + "faa5e0fb4ee244689c0f9eef9902acf7", + "6403bed2cd984ba18f74f416748c64e4", + "38be017369524e2eb22050e7a0a18ec5", + "b0720a4a2df948308011d4d87a288426", + "889ca2520f4d446daf2e6ed16ce11d2e" + ] + }, + "id": "9oOBgEWeBP59", + "outputId": "76bef375-fc6b-4fdd-a296-549a9b109b11" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "244ced1920694dbaae9bf98065b4f01d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e3769ae107554c9ba38c1e491b15bf4e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6d5b8bff73474faeb1d1b438fb4e8cec", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...270m-it/training_args.bin: 100%|##########| 7.57kB / 7.57kB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9f952f8eb63b42e4b38711737da5461e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...a-270m-it/tokenizer.model: 100%|##########| 4.69MB / 4.69MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "bd12780895064467b5be14e2ec3df114", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...ma-270m-it/tokenizer.json: 100%|##########| 33.4MB / 33.4MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d1261c1083a74dca877e6eece6395d73", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...270m-it/model.safetensors: 4%|3 | 41.9MB / 1.07GB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "No files have been modified since last commit. Skipping to prevent empty commit.\n", + "WARNING:huggingface_hub.hf_api:No files have been modified since last commit. Skipping to prevent empty commit.\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "999744cacd6a4fb08a1d4977ce2f06fd", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "faa5e0fb4ee244689c0f9eef9902acf7", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6403bed2cd984ba18f74f416748c64e4", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...270m-it/training_args.bin: 100%|##########| 7.57kB / 7.57kB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "38be017369524e2eb22050e7a0a18ec5", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...a-270m-it/tokenizer.model: 100%|##########| 4.69MB / 4.69MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b0720a4a2df948308011d4d87a288426", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...270m-it/model.safetensors: 3%|3 | 33.5MB / 1.07GB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "889ca2520f4d446daf2e6ed16ce11d2e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...ma-270m-it/tokenizer.json: 100%|##########| 33.4MB / 33.4MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "No files have been modified since last commit. Skipping to prevent empty commit.\n", + "WARNING:huggingface_hub.hf_api:No files have been modified since last commit. Skipping to prevent empty commit.\n" + ] + }, + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "CommitInfo(commit_url='https://huggingface.co/sergiopaniego/browsergym-grpo-functiongemma-270m-it/commit/a17de133c28ca7fddfcb2694c32f2791de5ddbe6', commit_message='End of training', commit_description='', oid='a17de133c28ca7fddfcb2694c32f2791de5ddbe6', pr_url=None, repo_url=RepoUrl('https://huggingface.co/sergiopaniego/browsergym-grpo-functiongemma-270m-it', endpoint='https://huggingface.co', repo_type='model', repo_id='sergiopaniego/browsergym-grpo-functiongemma-270m-it'), pr_revision=None, pr_num=None)" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "talmc8b7nPXJ" + }, + "source": [ + "## Load the Fine-Tuned Model and Run Inference\n", + "\n", + "The fine-tuned model is loaded to perform inference and evaluate its behavior on the target task. \n", + "In this case, the model is tested within the BrowserGym environment using OpenEnv, focusing on the *click* task from the MiniWoB++ benchmark, which is included among the available BrowserGym tasks." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "c3879b716f37442a87d51b8414fe8c48" + ] + }, + "id": "iIDiaGVlBP5-", + "outputId": "4dc0e365-e89f-40ba-b391-74c7efdc932d" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c3879b716f37442a87d51b8414fe8c48", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "model.safetensors: 0%| | 0.00/1.07G [00:00 **Note:**\n", + "> In older GPUs (including those available on Colab), **FP8 support** is limited, so we use the BF16 version of the model.\n", + "> In that case, you can select the official checkpoint or the one from Unsloth.\n", + "> If you have access to GPUs with **FP8 support**, you can switch to that version instead." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "83dfeaab2bd04b06899d09b6b35bacd1", + "8588996c1d2d444193e9cf53c1a73b8e", + "138a997da09f40ada32171e51b51b708", + "06ef4d5f41de4436ad4731cbf2f8471f" + ] + }, + "id": "WlK7KYKT99p-", + "outputId": "db72808f-21cf-4022-ed1a-b78ebb3ee47e" + }, + "outputs": [], + "source": [ + "from transformers import AutoProcessor\n", + "\n", + "#model_name = \"mistralai/Ministral-3-3B-Instruct-2512\"\n", + "model_name = \"mistralai/Ministral-3-3B-Instruct-2512-BF16\" # \"unsloth/Ministral-3-3B-Instruct-2512\"\n", + "\n", + "processor = AutoProcessor.from_pretrained(model_name, padding_side=\"left\")\n", + "\n", + "SYSTEM_PROMPT = (\n", + " \"You are a helpful AI Assistant that provides well-reasoned and detailed responses. \"\n", + " \"You first think about the reasoning process as an internal monologue and then provide the user with the answer. \"\n", + " \"Respond in the following format: \\n...\\n\\n\\n...\\n\"\n", + ")\n", + "\n", + "\n", + "def make_conversation(example):\n", + " conversation = [\n", + " {\n", + " \"role\": \"system\",\n", + " \"content\": [{\"type\": \"text\", \"text\": SYSTEM_PROMPT}],\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\"type\": \"image\", \"image\": example[\"image\"]},\n", + " {\"type\": \"text\", \"text\": example[\"problem\"]},\n", + " ],\n", + " },\n", + " ]\n", + " return {\n", + " \"prompt\": conversation,\n", + " \"image\": example[\"image\"],\n", + " }\n", + "\n", + "train_dataset = train_dataset.map(make_conversation)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5txAuMAa8ock" + }, + "source": [ + "Let's review one example to understand the internal structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "sjxG7duU99p_" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ZooycTF099p_" + }, + "outputs": [], + "source": [ + "train_dataset = train_dataset.remove_columns(['problem', 'original_question', 'original_answer'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "2LcjFKgD99p_" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YY3uMp909Eqy" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "RcQn7mGs99p_" + }, + "outputs": [], + "source": [ + "from transformers import Mistral3ForConditionalGeneration, FineGrainedFP8Config, BitsAndBytesConfig\n", + "import torch\n", + "\n", + "FP8 = False\n", + "\n", + "if FP8:\n", + " model_name = \"mistralai/Ministral-3-3B-Instruct-2512\"\n", + " quantization_config = FineGrainedFP8Config(dequantize=False)\n", + "else:\n", + " model_name = \"mistralai/Ministral-3-3B-Instruct-2512-BF16\" # \"unsloth/Ministral-3-3B-Instruct-2512\"\n", + " quantization_config = BitsAndBytesConfig(\n", + " load_in_4bit=True, # Load the model in 4-bit precision to save memory\n", + " bnb_4bit_compute_dtype=torch.float16, # Data type used for internal computations in quantization\n", + " bnb_4bit_use_double_quant=True, # Use double quantization to improve accuracy\n", + " bnb_4bit_quant_type=\"nf4\", # Type of quantization. \"nf4\" is recommended for recent LLMs\n", + " )\n", + "\n", + "model = Mistral3ForConditionalGeneration.from_pretrained(\n", + " model_name,\n", + " dtype=\"float32\",\n", + " device_map=\"auto\",\n", + " quantization_config=quantization_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WZGf-GF09Gsc" + }, + "source": [ + "The following cell defines LoRA (or QLoRA if needed). When training with LoRA/QLoRA, we use a **base model** (the one selected above) and, instead of modifying its original weights, we fine-tune a **LoRA adapter** — a lightweight layer that enables efficient and memory-friendly training. The **`target_modules`** specify which parts of the model (e.g., attention or projection layers) will be adapted by LoRA during fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "LqCEI4hf99p_" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "# You may need to update `target_modules` depending on the architecture of your chosen model.\n", + "# For example, different VLMs might have different attention/projection layer names.\n", + "peft_config = LoraConfig(\n", + " r=8,\n", + " lora_alpha=32,\n", + " lora_dropout=0.1,\n", + " target_modules=[\"q_proj\", \"v_proj\"],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mDq4V6dN9MGk" + }, + "source": [ + "## Train model\n", + "\n", + "We'll configure **GRPO** using `GRPOConfig`, keeping the parameters minimal so the training fits on a free Colab instance. You can adjust these settings if more resources are available. For full details on all available parameters, check the [TRL GRPOConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.GRPOConfig).\n", + "\n", + "First, we need to define the rewards functions that the training algorithm will use to improve the model. In this case, we'll include two reward functions.\n", + "We'll use a format reward that will reward the model when the output includes `` and `` tags and additionally a length-based reward to discourage overthinking. Both functions have been extracted from [here](https://github.com/huggingface/open-r1/blob/main/src/open_r1/rewards.py)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "jhgqx8kO99p_" + }, + "outputs": [], + "source": [ + "import re\n", + "\n", + "def format_reward(completions, **kwargs):\n", + " \"\"\"Reward function that checks if the reasoning process is enclosed within and tags, while the final answer is enclosed within and tags.\"\"\"\n", + " pattern = r\".*?.*?.*?\"\n", + "\n", + " matches = []\n", + " for item in completions:\n", + " if isinstance(item, list):\n", + " text = item[0]['content']\n", + " else:\n", + " text = item\n", + " match = re.match(pattern, text, re.DOTALL | re.MULTILINE)\n", + " matches.append(match)\n", + "\n", + " return [1.0 if match else 0.0 for match in matches]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "sVmzQ_wL99p_" + }, + "outputs": [], + "source": [ + "from math_verify import LatexExtractionConfig, parse, verify\n", + "from latex2sympy2_extended import NormalizationConfig\n", + "\n", + "\n", + "def len_reward(completions, solution, **kwargs) -> float:\n", + " \"\"\"Compute length-based rewards to discourage overthinking and promote token efficiency.\n", + "\n", + " Taken from the Kimi 1.5 tech report: https://huggingface.co/papers/2501.12599\n", + "\n", + " Args:\n", + " completions: List of model completions\n", + " solution: List of ground truth solutions\n", + "\n", + " Returns:\n", + " List of rewards where:\n", + " - For correct answers: reward = 0.5 - (len - min_len)/(max_len - min_len)\n", + " - For incorrect answers: reward = min(0, 0.5 - (len - min_len)/(max_len - min_len))\n", + " \"\"\"\n", + " contents = []\n", + " for item in completions:\n", + " if isinstance(item, list):\n", + " text = item[0]['content']\n", + " else:\n", + " text = item\n", + " contents.append(text)\n", + "\n", + " # First check correctness of answers\n", + " correctness = []\n", + " for content, sol in zip(contents, solution):\n", + " gold_parsed = parse(\n", + " sol,\n", + " extraction_mode=\"first_match\",\n", + " extraction_config=[LatexExtractionConfig()],\n", + " )\n", + " if len(gold_parsed) == 0:\n", + " # Skip unparsable examples\n", + " correctness.append(True) # Treat as correct to avoid penalizing\n", + " print(\"Failed to parse gold solution: \", sol)\n", + " continue\n", + "\n", + " answer_parsed = parse(\n", + " content,\n", + " extraction_config=[\n", + " LatexExtractionConfig(\n", + " normalization_config=NormalizationConfig(\n", + " nits=False,\n", + " malformed_operators=False,\n", + " basic_latex=True,\n", + " equations=True,\n", + " boxed=True,\n", + " units=True,\n", + " ),\n", + " boxed_match_priority=0,\n", + " try_extract_without_anchor=False,\n", + " )\n", + " ],\n", + " extraction_mode=\"first_match\",\n", + " )\n", + " correctness.append(verify(answer_parsed, gold_parsed))\n", + "\n", + " # Calculate lengths\n", + " lengths = [len(content) for content in contents]\n", + " min_len = min(lengths)\n", + " max_len = max(lengths)\n", + "\n", + " # If all responses have the same length, return zero rewards\n", + " if max_len == min_len:\n", + " return [0.0] * len(completions)\n", + "\n", + " rewards = []\n", + " for length, is_correct in zip(lengths, correctness):\n", + " lambda_val = 0.5 - (length - min_len) / (max_len - min_len)\n", + "\n", + " if is_correct:\n", + " reward = lambda_val\n", + " else:\n", + " reward = min(0, lambda_val)\n", + "\n", + " rewards.append(float(reward))\n", + "\n", + " return rewards" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9xBL7Rni9LZb" + }, + "source": [ + "After defining the reward function(s), we can define the `GRPOConfig`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "pcv6KXUD99qA" + }, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "output_dir = \"Ministral-3-3B-Instruct-trl-grpo\"\n", + "\n", + "# Configure training arguments using GRPOConfig\n", + "training_args = GRPOConfig(\n", + " learning_rate=2e-5,\n", + " #num_train_epochs=1,\n", + " max_steps=100, # Number of dataset passes. For full trainings, use `num_train_epochs` instead\n", + "\n", + " # Parameters that control the data preprocessing\n", + " per_device_train_batch_size=2,\n", + " max_completion_length=1024, # default: 256 # Max completion length produced during training\n", + " num_generations=2, # 2, # default: 8 # Number of generations produced during training for comparison\n", + "\n", + " fp16=False,\n", + " bf16=False,\n", + "\n", + " # Parameters related to reporting and saving\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + " logging_steps=1, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + " trackio_space_id = output_dir,\n", + "\n", + " # Hub integration\n", + " push_to_hub=True,\n", + " log_completions=True,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "O0q3myQg927v" + }, + "source": [ + "Configure the GRPO Trainer. We pass the previously configured `training_args`. We don't use eval dataset to maintain memory usage low but you can configure it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "-zd7s5Cs99qA" + }, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model,\n", + " reward_funcs=[format_reward, len_reward],\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "kQC7Q5kg95xq" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "iF7cnD0T99qA" + }, + "outputs": [], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YazYtLAe97Dc" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Ynhxdv3a99qA" + }, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "SmcYN5yW99IP" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "mi-exH7699qA" + }, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "saarW87Y9_-R" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "m3mlwQl699qA" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_id)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nfqvO0qw-OvS" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "B7usNBq699qA" + }, + "outputs": [], + "source": [ + "from transformers import Mistral3ForConditionalGeneration, MistralCommonBackend\n", + "from peft import PeftModel\n", + "\n", + "base_model = model_name\n", + "adapter_model = f\"{output_dir}\" # Replace with your HF username or organization\n", + "\n", + "model = Mistral3ForConditionalGeneration.from_pretrained(base_model, dtype=\"float32\", device_map=\"auto\")\n", + "model = PeftModel.from_pretrained(model, adapter_model)\n", + "\n", + "tokenizer = MistralCommonBackend.from_pretrained(base_model)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "XnIOkXfy99qA" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "0le5gBl_99qA" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "import base64\n", + "from io import BytesIO\n", + "\n", + "dataset_id = 'lmms-lab/multimodal-open-r1-8k-verified'\n", + "train_dataset = load_dataset(dataset_id, split='train[:5%]')\n", + "\n", + "problem = train_dataset[0]['problem']\n", + "image = train_dataset[0]['image']\n", + "\n", + "buffer = BytesIO()\n", + "image.save(buffer, format=\"JPEG\")\n", + "image_bytes = buffer.getvalue()\n", + "image_b64 = base64.b64encode(image_bytes).decode(\"utf-8\")\n", + "\n", + "messages = [\n", + " {\n", + " \"role\": \"system\", \"content\": [\n", + " {\"type\": \"text\", \"text\": SYSTEM_PROMPT}\n", + " ]\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\n", + " \"type\": \"image_url\",\n", + " \"image_url\": {\n", + " \"url\": f\"data:image/jpeg;base64,{image_b64}\"\n", + " },\n", + " },\n", + " {\"type\": \"text\", \"text\": problem},\n", + " ],\n", + " },\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "f9PgBCD499qA" + }, + "outputs": [], + "source": [ + "messages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ENOGILKk99qA" + }, + "outputs": [], + "source": [ + "import torch\n", + "\n", + "tokenized = tokenizer.apply_chat_template(messages, return_tensors=\"pt\", return_dict=True)\n", + "tokenized[\"input_ids\"] = tokenized[\"input_ids\"].to(device=\"cuda\")\n", + "tokenized[\"pixel_values\"] = tokenized[\"pixel_values\"].to(dtype=torch.bfloat16, device=\"cuda\")\n", + "image_sizes = [tokenized[\"pixel_values\"].shape[-2:]]\n", + "\n", + "output = model.generate(\n", + " **tokenized,\n", + " image_sizes=image_sizes,\n", + " max_new_tokens=512,\n", + ")[0]\n", + "\n", + "decoded_output = tokenizer.decode(output[len(tokenized[\"input_ids\"][0]):])\n", + "print(decoded_output)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "provenance": [] + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_qwen3_vl.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_qwen3_vl.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..f9c0f3d60667602acf1abde25356a4ff2b2ee62e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_qwen3_vl.ipynb @@ -0,0 +1,689 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "-J8iGzLf4rUJ" + }, + "source": [ + "# GRPO Qwen3-VL with QLoRA using TRL\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_qwen3_vl.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "\n", + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can fine-tune cutting edge vision language models. It comes with support for quantized parameter efficient fine-tuning technique **QLoRA**, so we can use free Colab (T4 GPU) to fine-tune models like [Qwen3-VL](https://huggingface.co/collections/Qwen/qwen3-vl-68d2a7c1b8a8afce4ebd2dbe).\n", + "\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)\n", + "- [More Qwen3-VL Fine-tuning Examples (including TRL scripts)](https://github.com/QwenLM/Qwen3-VL/tree/main/qwen-vl-finetune/)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "NvrzGRnu48Vz" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which ensures all main dependencies such as **Transformers** and **PEFT** (a package for parameter-efficient fine-tuning, e.g., LoRA/QLoRA) are included. Additionally, we'll install **trackio** to log and monitor our experiments, and **bitsandbytes** to enable quantization of LLMs, reducing memory consumption for both inference and training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "8CfZlUevmkg7" + }, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[peft]\" bitsandbytes trackio math_verify" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gpzI6omi7728" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "4Ncx0wYtnYCW" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "V_Zylc4t79-n" + }, + "source": [ + "## Load dataset\n", + "\n", + "\n", + "We'll load the [**lmms-lab/multimodal-open-r1-8k-verified**](https://huggingface.co/datasets/lmms-lab/multimodal-open-r1-8k-verified) dataset from the Hugging Face Hub using the `datasets` library.\n", + "\n", + "This dataset contains maths problems with the image representing the problem, along with the solution in thinking format specially tailored for VLMs. By training our model with this dataset, it'll improve its maths and thinking reasoning.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "TzXogU24F_QR" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_id = 'lmms-lab/multimodal-open-r1-8k-verified'\n", + "train_dataset = load_dataset(dataset_id, split='train[:5%]')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gVV7RoRN8zk5" + }, + "source": [ + "In addition to the `problem` and `image` columns, we also include a custom system prompt to tell the model how we'd like the generation.\n", + "\n", + "The system prompt is extracted from DeepSeek R1. Refer to [this previous recipe](https://huggingface.co/learn/cookbook/fine_tuning_llm_grpo_trl) for more details.\n", + "\n", + "We convert the dataset samples into conversation samples, including the system prompt and one image and problem description per sample, since this is how the GRPO trainer expects them.\n", + "\n", + "We also set `padding_side=\"left\"` to ensure that generated completions during training are concatenated directly after the prompt, which is essential for GRPO to correctly compare token-level probabilities between preferred and rejected responses." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ZT1JfiiTGExB" + }, + "outputs": [], + "source": [ + "from transformers import AutoProcessor\n", + "\n", + "model_name = \"Qwen/Qwen3-VL-4B-Instruct\" # \"Qwen/Qwen3-VL-8B-Instruct\"\n", + "processor = AutoProcessor.from_pretrained(model_name, padding_side=\"left\")\n", + "\n", + "SYSTEM_PROMPT = (\n", + " \"You are a helpful AI Assistant that provides well-reasoned and detailed responses. \"\n", + " \"You first think about the reasoning process as an internal monologue and then provide the user with the answer. \"\n", + " \"Respond in the following format: \\n...\\n\\n\\n...\\n\"\n", + ")\n", + "\n", + "\n", + "def make_conversation(example):\n", + " prompt = [\n", + " {\n", + " \"role\": \"system\",\n", + " \"content\": [{\"type\": \"text\", \"text\": SYSTEM_PROMPT}],\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\"type\": \"image\", \"image\": example[\"image\"]},\n", + " {\"type\": \"text\", \"text\": example[\"problem\"]},\n", + " ],\n", + " },\n", + " ]\n", + " return {\"prompt\": prompt, \"image\": example[\"image\"]}\n", + "\n", + "train_dataset = train_dataset.map(make_conversation)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5txAuMAa8ock" + }, + "source": [ + "Let's review one example to understand the internal structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "PDXQd5Jk2Bqe" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "hzSR_56wxKDA" + }, + "outputs": [], + "source": [ + "train_dataset = train_dataset.remove_columns(['problem', 'original_question', 'original_answer'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "T9rCkeqDODba" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YY3uMp909Eqy" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "gt05dgXgm9QR" + }, + "outputs": [], + "source": [ + "from transformers import Qwen3VLForConditionalGeneration, BitsAndBytesConfig\n", + "import torch\n", + "\n", + "model = Qwen3VLForConditionalGeneration.from_pretrained(\n", + " model_name, dtype=\"float32\",\n", + " device_map=\"auto\",\n", + " quantization_config=BitsAndBytesConfig(\n", + " load_in_4bit=True,\n", + " bnb_4bit_use_double_quant=True,\n", + " bnb_4bit_quant_type=\"nf4\",\n", + " bnb_4bit_compute_dtype=torch.float16\n", + " ),\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WZGf-GF09Gsc" + }, + "source": [ + "The following cell defines LoRA (or QLoRA if needed). When training with LoRA/QLoRA, we use a **base model** (the one selected above) and, instead of modifying its original weights, we fine-tune a **LoRA adapter** — a lightweight layer that enables efficient and memory-friendly training. The **`target_modules`** specify which parts of the model (e.g., attention or projection layers) will be adapted by LoRA during fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ME1im5gh2LFg" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "# You may need to update `target_modules` depending on the architecture of your chosen model.\n", + "# For example, different VLMs might have different attention/projection layer names.\n", + "peft_config = LoraConfig(\n", + " r=8,\n", + " lora_alpha=32,\n", + " lora_dropout=0.1,\n", + " target_modules=[\"q_proj\", \"v_proj\"],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mDq4V6dN9MGk" + }, + "source": [ + "## Train model\n", + "\n", + "We'll configure **GRPO** using `GRPOConfig`, keeping the parameters minimal so the training fits on a free Colab instance. You can adjust these settings if more resources are available. For full details on all available parameters, check the [TRL GRPOConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.GRPOConfig).\n", + "\n", + "First, we need to define the rewards functions that the training algorithm will use to improve the model. In this case, we'll include two reward functions.\n", + "We'll use a format reward that will reward the model when the output includes `` and `` tags and additionally a length-based reward to discourage overthinking. Both functions have been extracted from [here](https://github.com/huggingface/open-r1/blob/main/src/open_r1/rewards.py)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Dqp3TfUwHUxW" + }, + "outputs": [], + "source": [ + "import re\n", + "\n", + "def format_reward(completions, **kwargs):\n", + " \"\"\"Reward function that checks if the reasoning process is enclosed within and tags, while the final answer is enclosed within and tags.\"\"\"\n", + " pattern = r\"^\\n.*?\\n\\n\\n.*?\\n$\"\n", + " matches = [re.match(pattern, content, re.DOTALL | re.MULTILINE) for content in completions]\n", + " return [1.0 if match else 0.0 for match in matches]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "rxNPUp7RBFcz" + }, + "outputs": [], + "source": [ + "from math_verify import LatexExtractionConfig, parse, verify\n", + "from latex2sympy2_extended import NormalizationConfig\n", + "\n", + "\n", + "def len_reward(completions, solution, **kwargs) -> float:\n", + " \"\"\"Compute length-based rewards to discourage overthinking and promote token efficiency.\n", + "\n", + " Taken from the Kimi 1.5 tech report: https://huggingface.co/papers/2501.12599\n", + "\n", + " Args:\n", + " completions: List of model completions\n", + " solution: List of ground truth solutions\n", + "\n", + " Returns:\n", + " List of rewards where:\n", + " - For correct answers: reward = 0.5 - (len - min_len)/(max_len - min_len)\n", + " - For incorrect answers: reward = min(0, 0.5 - (len - min_len)/(max_len - min_len))\n", + " \"\"\"\n", + " contents = completions\n", + "\n", + " # First check correctness of answers\n", + " correctness = []\n", + " for content, sol in zip(contents, solution):\n", + " gold_parsed = parse(\n", + " sol,\n", + " extraction_mode=\"first_match\",\n", + " extraction_config=[LatexExtractionConfig()],\n", + " )\n", + " if len(gold_parsed) == 0:\n", + " # Skip unparsable examples\n", + " correctness.append(True) # Treat as correct to avoid penalizing\n", + " print(\"Failed to parse gold solution: \", sol)\n", + " continue\n", + "\n", + " answer_parsed = parse(\n", + " content,\n", + " extraction_config=[\n", + " LatexExtractionConfig(\n", + " normalization_config=NormalizationConfig(\n", + " nits=False,\n", + " malformed_operators=False,\n", + " basic_latex=True,\n", + " equations=True,\n", + " boxed=True,\n", + " units=True,\n", + " ),\n", + " boxed_match_priority=0,\n", + " try_extract_without_anchor=False,\n", + " )\n", + " ],\n", + " extraction_mode=\"first_match\",\n", + " )\n", + " correctness.append(verify(answer_parsed, gold_parsed))\n", + "\n", + " # Calculate lengths\n", + " lengths = [len(content) for content in contents]\n", + " min_len = min(lengths)\n", + " max_len = max(lengths)\n", + "\n", + " # If all responses have the same length, return zero rewards\n", + " if max_len == min_len:\n", + " return [0.0] * len(completions)\n", + "\n", + " rewards = []\n", + " for length, is_correct in zip(lengths, correctness):\n", + " lambda_val = 0.5 - (length - min_len) / (max_len - min_len)\n", + "\n", + " if is_correct:\n", + " reward = lambda_val\n", + " else:\n", + " reward = min(0, lambda_val)\n", + "\n", + " rewards.append(float(reward))\n", + "\n", + " return rewards\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9xBL7Rni9LZb" + }, + "source": [ + "After defining the reward function(s), we can define the `GRPOConfig`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "OEmRM0rIHXQ4" + }, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "output_dir = \"Qwen3-VL-4B-Instruct-trl-grpo\"\n", + "\n", + "# Configure training arguments using GRPOConfig\n", + "training_args = GRPOConfig(\n", + " learning_rate=2e-5,\n", + " #num_train_epochs=1,\n", + " max_steps=100, # Number of dataset passes. For full trainings, use `num_train_epochs` instead\n", + "\n", + " # Parameters that control the data preprocessing\n", + " per_device_train_batch_size=2,\n", + " max_completion_length=1024, # default: 256 # Max completion length produced during training\n", + " num_generations=2, # 2, # default: 8 # Number of generations produced during training for comparison\n", + "\n", + " fp16=True,\n", + "\n", + " # Parameters related to reporting and saving\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + " logging_steps=1, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + "\n", + " # Hub integration\n", + " push_to_hub=True,\n", + " log_completions=True\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "O0q3myQg927v" + }, + "source": [ + "Configure the GRPO Trainer. We pass the previously configured `training_args`. We don't use eval dataset to maintain memory usage low but you can configure it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "z5JxkmS9HqD5", + "outputId": "2b39338e-2194-4829-fc54-5e286566fd28" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.12/dist-packages/peft/mapping_func.py:73: UserWarning: You are trying to modify a model with PEFT for a second time. If you want to reload the model with a different config, make sure to call `.unload()` before.\n", + " warnings.warn(\n", + "/usr/local/lib/python3.12/dist-packages/peft/tuners/tuners_utils.py:196: UserWarning: Already found a `peft_config` attribute in the model. This will lead to having multiple adapters in the model. Make sure to know what you are doing!\n", + " warnings.warn(\n" + ] + } + ], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model,\n", + " reward_funcs=[format_reward, len_reward],\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "kQC7Q5kg95xq" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "naG_7qlYyBP6" + }, + "outputs": [], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YazYtLAe97Dc" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "pbJXrhA0ywra" + }, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "SmcYN5yW99IP" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "TrrwP4ADMmrp" + }, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "saarW87Y9_-R" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "71A8aqEyyETA" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_id)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nfqvO0qw-OvS" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "R8T2uFQVyFeH" + }, + "outputs": [], + "source": [ + "from transformers import Qwen3VLForConditionalGeneration, AutoProcessor\n", + "from peft import PeftModel\n", + "\n", + "base_model = model_name\n", + "adapter_model = f\"{output_dir}\" # Replace with your HF username or organization\n", + "\n", + "model = Qwen3VLForConditionalGeneration.from_pretrained(base_model, dtype=\"float32\", device_map=\"auto\")\n", + "model = PeftModel.from_pretrained(model, adapter_model)\n", + "\n", + "processor = AutoProcessor.from_pretrained(base_model)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "dPBHP0CpLa6K" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "cG5-ccGRyHgo" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_id = 'lmms-lab/multimodal-open-r1-8k-verified'\n", + "train_dataset = load_dataset(dataset_id, split='train[:5%]')\n", + "\n", + "problem = train_dataset[0]['problem']\n", + "image = train_dataset[0]['image']\n", + "\n", + "messages = [\n", + " {\n", + " \"role\": \"system\", \"content\": [\n", + " {\"type\": \"text\", \"text\": SYSTEM_PROMPT}\n", + " ]\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\"type\": \"image\", \"image\": image},\n", + " {\"type\": \"text\", \"text\": problem},\n", + " ],\n", + " },\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "r_70q_8lLgfV" + }, + "outputs": [], + "source": [ + "messages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "PX92MjqlyIwB" + }, + "outputs": [], + "source": [ + "inputs = processor.apply_chat_template(\n", + " messages,\n", + " add_generation_prompt=True,\n", + " tokenize=True,\n", + " return_tensors=\"pt\",\n", + " return_dict=True,\n", + ").to(model.device)\n", + "\n", + "# Inference: Generation of the output\n", + "generated_ids = model.generate(**inputs, max_new_tokens=500)\n", + "generated_ids_trimmed = [\n", + " out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)\n", + "]\n", + "output_text = processor.batch_decode(\n", + " generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False\n", + ")\n", + "print(output_text)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_rnj_1_instruct.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_rnj_1_instruct.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..4911aceed9f276b5d25f2cc005ca91f2e85d0114 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_rnj_1_instruct.ipynb @@ -0,0 +1,622 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "-J8iGzLf4rUJ" + }, + "source": [ + "# GRPO EssentialAI/rnj-1-instruct with QLoRA using TRL\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_rnj_1_instruct.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "\n", + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can fine-tune cutting edge large language models. It comes with support for quantized parameter efficient fine-tuning technique **QLoRA**, so we can use Colab to fine-tune models like [EssentialAI/rnj-1-instruct](https://huggingface.co/collections/EssentialAI/rnj-1).\n", + "\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)\n", + "\n", + "In this notebook, we'll add reasoning capabilities to the model, teaching it to generate reasoning traces (``) before giving us the final answer (``)." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "NvrzGRnu48Vz" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which ensures all main dependencies such as **Transformers** and **PEFT** (a package for parameter-efficient fine-tuning, e.g., LoRA/QLoRA) are included. Additionally, we'll install **trackio** to log and monitor our experiments, and **bitsandbytes** to enable quantization of LLMs, reducing memory consumption for both inference and training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "8VOdRz9fgFa8" + }, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[peft]\" bitsandbytes trackio math_verify" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gpzI6omi7728" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "d3j3BsdQgFa8" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "V_Zylc4t79-n" + }, + "source": [ + "## Load dataset\n", + "\n", + "\n", + "We'll load the [**AI-MO/NuminaMath-TIR**](https://huggingface.co/datasets/AI-MO/NuminaMath-TIR) dataset from the Hugging Face Hub using the `datasets` library.\n", + "\n", + "This dataset contains maths problems, along with the solution in thinking format specially tailored for LLMs. By training our model with this dataset, it'll improve its maths and thinking reasoning.\n", + "\n", + "> We only use a subset for educational purposes. In a real scenario, we'd use the complete dataset." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "YSuLNZAmgFa9" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_id = 'AI-MO/NuminaMath-TIR'\n", + "train_dataset = load_dataset(dataset_id, split='train[:5%]')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gVV7RoRN8zk5" + }, + "source": [ + "In addition to the current columns, we also include a custom system prompt to tell the model how we'd like the generation.\n", + "\n", + "This system prompt is an adapted version of the original one extracted from **DeepSeek R1**. For additional background, see [this previous recipe](https://huggingface.co/learn/cookbook/fine_tuning_llm_grpo_trl). We extend the prompt with **examples** and a **more explicit, verbose formulation** to make the desired behavior easier for the model to learn. Depending on your goals, you may further enrich the prompt to simplify learning, or intentionally shorten and harden it to encourage more robust and generalizable behavior.\n", + "\n", + "We convert the dataset samples into conversation samples, including the system prompt and problem description per sample, since this is how the GRPO trainer expects them.\n", + "\n", + "We also set `padding_side=\"left\"` to ensure that generated completions during training are concatenated directly after the prompt, which is essential for GRPO to correctly compare token-level probabilities between preferred and rejected responses." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "vr9t-9Z5gFa9" + }, + "outputs": [], + "source": [ + "SYSTEM_PROMPT = \"\"\"A conversation between User and Assistant. The user asks a question, and the Assistant solves it.\n", + "The assistant first thinks about the reasoning process in the mind and then provides the user with the answer.\n", + "The reasoning process and answer are enclosed within and tags.\n", + "Use exactly one ... block followed by exactly one ... block.\n", + "\n", + "Examples:\n", + "\n", + "User: What is 2 + 2?\n", + "Assistant:\n", + "\n", + "I will add 2 and 2 together.\n", + "\n", + "4\n", + "\n", + "User: What is 3 × 5?\n", + "Assistant:\n", + "\n", + "I will multiply 3 by 5.\n", + "\n", + "15\n", + "\n", + "User: Find the GCD of 12 and 18.\n", + "Assistant:\n", + "\n", + "I will list the divisors of 12 and 18 and find the greatest one they have in common.\n", + "\n", + "6\n", + "\"\"\"\n", + "\n", + "def make_conversation(example):\n", + " return {\n", + " \"prompt\": [\n", + " {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n", + " {\"role\": \"user\", \"content\": example[\"problem\"]},\n", + " ],\n", + " }\n", + "\n", + "train_dataset = train_dataset.map(make_conversation)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5txAuMAa8ock" + }, + "source": [ + "Let's review one example to understand the internal structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "jZtkB0D9gFa9" + }, + "outputs": [], + "source": [ + "print(train_dataset[0])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "FtdKjmyFZImL" + }, + "source": [ + "And remove the columns that are not needed for training:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Ai4F1GaPgFa-" + }, + "outputs": [], + "source": [ + "train_dataset = train_dataset.remove_columns(['messages', 'problem'])\n", + "print(train_dataset)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YY3uMp909Eqy" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "DSKcUQ9RgFa-" + }, + "outputs": [], + "source": [ + "from transformers import AutoModelForCausalLM, BitsAndBytesConfig\n", + "import torch\n", + "\n", + "model_name = \"EssentialAI/rnj-1-instruct\"\n", + "\n", + "model = AutoModelForCausalLM.from_pretrained(\n", + " model_name,\n", + " dtype=\"float32\",\n", + " device_map=\"auto\",\n", + " quantization_config=BitsAndBytesConfig(\n", + " load_in_4bit=True,\n", + " bnb_4bit_use_double_quant=True,\n", + " bnb_4bit_quant_type=\"nf4\",\n", + " bnb_4bit_compute_dtype=torch.float16\n", + " ),\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WZGf-GF09Gsc" + }, + "source": [ + "The following cell defines LoRA (or QLoRA if needed). When training with LoRA/QLoRA, we use a **base model** (the one selected above) and, instead of modifying its original weights, we fine-tune a **LoRA adapter**, a lightweight layer that enables efficient and memory-friendly training. The **`target_modules`** specify which parts of the model (e.g., attention or projection layers) will be adapted by LoRA during fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "nMMlDxJSgFa-" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "# You may need to update `target_modules` depending on the architecture of your chosen model.\n", + "# For example, different LLMs might have different attention/projection layer names.\n", + "peft_config = LoraConfig(\n", + " r=32,\n", + " lora_alpha=32,\n", + " target_modules = [\"q_proj\", \"k_proj\", \"v_proj\", \"o_proj\", \"gate_proj\", \"up_proj\", \"down_proj\",],\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mDq4V6dN9MGk" + }, + "source": [ + "## Train model\n", + "\n", + "We'll configure **GRPO** using `GRPOConfig`, keeping the parameters minimal so the training fits on a Colab instance. You can adjust these settings depending on the resources available. For full details on all available parameters, check the [TRL GRPOConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.GRPOConfig).\n", + "\n", + "First, we need to define the rewards functions that the training algorithm will use to improve the model. In this case, we'll include just one reward function.\n", + "We'll use a format reward that will reward the model when the output includes `` and `` tags. This is a simplification of the pipeline for educational purposes, but in a real scenario, you'd at least all need a reward function to check the correctness of the model answer. The function has been extracted from [here](https://github.com/huggingface/open-r1/blob/main/src/open_r1/rewards.py).\n", + "\n", + "> 💡 **Note**: \n", + "> You can further refine this reward by making it more granular. For example, assigning partial rewards when `` and `` appear independently, or when they are present but incorrectly ordered. This can make the learning signal denser and speed up early training. However, overly simplifying the reward may reduce robustness, even if it helps the model converge faster. In practice, there is a trade-off between ease of learning and the generalization quality of the final model." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Rtx5owCRgFa-" + }, + "outputs": [], + "source": [ + "import re\n", + "\n", + "def format_reward(completions, **kwargs):\n", + " \"\"\"Reward function that checks if the reasoning process is enclosed within and tags, while the final answer is enclosed within and tags.\"\"\"\n", + " pattern = r\".*?.*?.*?\"\n", + "\n", + " matches = []\n", + " for item in completions:\n", + " if isinstance(item, list):\n", + " text = item[0]['content']\n", + " else:\n", + " text = item\n", + " match = re.match(pattern, text, re.DOTALL | re.MULTILINE)\n", + " matches.append(match)\n", + "\n", + " return [1.0 if match else 0.0 for match in matches]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9xBL7Rni9LZb" + }, + "source": [ + "After defining the reward function(s), we can define the `GRPOConfig`. You can adapt the values in the config depending on your training setting and even fit the training in more constrained setups like free Colab (T4)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "rJ0VfG3wgFa-" + }, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "output_dir = \"EssentialAI-rnj-1-instruct-trl-grpo\"\n", + "\n", + "# Configure training arguments using GRPOConfig\n", + "training_args = GRPOConfig(\n", + " learning_rate=2e-5, # Learning rate used during traing\n", + " num_train_epochs=1, # Number of full dataset passes. For testing, use `max_steps` instead\n", + " #max_steps=100,\n", + "\n", + " # Parameters that control the data preprocessing\n", + " per_device_train_batch_size=8,\n", + " max_completion_length=256, # default: 256 # Max completion length produced during training\n", + " num_generations=8, # default: 8 # Number of generations produced during training for comparison\n", + "\n", + " # Parameters related to reporting and saving\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + " logging_steps=10, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + " trackio_space_id = output_dir, # HF Space where you trackio will be\n", + "\n", + " # Hub integration\n", + " push_to_hub=True, # Push the resulted model to the Hub\n", + " log_completions=True, # Log completions during training\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "O0q3myQg927v" + }, + "source": [ + "Configure the GRPO Trainer. We pass the previously configured `training_args`. We don't use eval dataset to maintain memory usage low but you can configure it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "aW7Gi4nXgFa-" + }, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model,\n", + " reward_funcs=[format_reward],\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "kQC7Q5kg95xq" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "OJdVlC_mgFa_" + }, + "outputs": [], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YazYtLAe97Dc" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Mtv8s7rBgFa_" + }, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "SmcYN5yW99IP" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "-ROfX8e9gFa_" + }, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "saarW87Y9_-R" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "09zYXJ3GgFa_" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_id)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nfqvO0qw-OvS" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "9Yk9RAABgFa_" + }, + "outputs": [], + "source": [ + "output_dir = 'sergiopaniego/EssentialAI-rnj-1-instruct-trl-grpo'\n", + "model_name = \"EssentialAI/rnj-1-instruct\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "CdzlQcCAgFa_" + }, + "outputs": [], + "source": [ + "from transformers import AutoModelForCausalLM, AutoTokenizer\n", + "from peft import PeftModel\n", + "\n", + "base_model = model_name\n", + "adapter_model = f\"{output_dir}\" # Replace with your HF username or organization\n", + "\n", + "model = AutoModelForCausalLM.from_pretrained(base_model, dtype=\"float32\", device_map=\"auto\")\n", + "model = PeftModel.from_pretrained(model, adapter_model)\n", + "\n", + "tokenizer = AutoTokenizer.from_pretrained(base_model)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "LZgjlAu-gFa_" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "gjY6TqQHgFa_" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_id = 'AI-MO/NuminaMath-TIR'\n", + "train_dataset = load_dataset(dataset_id, split='train[:5%]')\n", + "\n", + "problem = train_dataset[0]['problem']\n", + "\n", + "messages = [\n", + " {\n", + " \"role\": \"system\", \"content\": [\n", + " {\"type\": \"text\", \"text\": SYSTEM_PROMPT}\n", + " ]\n", + " },\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\"type\": \"text\", \"text\": problem},\n", + " ],\n", + " },\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "eaVubGYmgFa_" + }, + "outputs": [], + "source": [ + "messages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "2M6Xh4JMgFa_" + }, + "outputs": [], + "source": [ + "input_ids = tokenizer.apply_chat_template(\n", + " messages,\n", + " add_generation_prompt=True,\n", + " return_tensors=\"pt\",\n", + " return_dict=False,\n", + ").to(model.device)\n", + "\n", + "# --- Generate Prediction --- #\n", + "print(\"Generating prediction...\")\n", + "output_ids = model.generate(\n", + " input_ids,\n", + " max_new_tokens=50,\n", + " pad_token_id=tokenizer.eos_token_id,\n", + " do_sample=True,\n", + " temperature=0.2,\n", + " top_p=0.95\n", + ")\n", + "\n", + "response = tokenizer.decode(output_ids[0][input_ids.shape[-1]:], skip_special_tokens=True)\n", + "print(response)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "A100", + "provenance": [] + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_trl_lora_qlora.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_trl_lora_qlora.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..80375e2b4e3dba064e1f40626233f540b2c496e6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/grpo_trl_lora_qlora.ipynb @@ -0,0 +1,1638 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "27ozP4Uy-Cz2" + }, + "source": [ + "# Group Relative Policy Optimization (GRPO) with LoRA/QLoRA using TRL — on a Free Colab Notebook\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/grpo_trl_lora_qlora.ipynb)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "eOjY4AR1-QnF" + }, + "source": [ + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "Easily fine-tune **Large Language Models (LLMs)** or **Vision-Language Models (VLMs)** with **LoRA** or **QLoRA** using the [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl) library by Hugging Face and Group Relative Policy Optimization (GRPO) — all within a **free Google Colab notebook** powered by a **T4 GPU**.\n", + "\n", + "Thanks to the **built-in memory and training optimizations in TRL**, including LoRA, quantization, gradient checkpointing, and optimized attention kernels, it is possible to **fine-tune a 7B model on a free T4** with a **~7× reduction in memory consumption** compared to naive FP16 training.\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "w2TnJ6ta-2zj" + }, + "source": [ + "## Key concepts\n", + "\n", + "- **GRPO**: A reinforcement learning algorithm that optimizes a policy by comparing multiple generated responses for the same prompt and updating the model based on their relative rewards, without requiring a separate value model.\n", + "- **LoRA**: Updates only a few low-rank parameters, reducing training cost and memory.\n", + "- **QLoRA**: A quantized version of LoRA that enables even larger models to fit on small GPUs.\n", + "- **TRL**: The Hugging Face library that makes fine-tuning and reinforcement learning simple and efficient.\n", + "\n", + "Learn how to perform **GRPO (Group Relative Policy Optimization)** with **LoRA/QLoRA** using **TRL**." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "EzScUBxoT4Nt" + }, + "source": [ + "This table demonstrates how **progressively enabling efficiency techniques** affects **memory usage** and **training throughput** across different hardware configurations. \n", + "The techniques range from naive FP16 training to **LoRA, quantization, Liger kernels, paged_adamw_8bit, and gradient checkpointing**.\n", + "\n", + "| Configuration | LoRA | Quant | Liger | Optimizer | Grad. Ckpt | attn_impl | VRAM (T4) GB | VRAM (A100-40GB)| VRAM (A100-80GB) | Tokens/s (T4) | Tokens/s (A100-40GB) | Tokens/s (A100-80GB) | Status (T4) |\n", + "|--------------|------|-------|-------|-----------|------------|-----------|---------------|----------------|---------|---------|---------------|------------------|-------------|\n", + "| **Worst (naive FP16)** | ❌ | ❌ | ❌ | AdamW | ❌ | eager | OOM | OOM | 62 GB | - | - | 0.06 it/s | ❌ |\n", + "| **Best (all optimizations)** | ✅ | ✅ | ✅ | paged_adamw_8bit | ✅ | sdpa | 9.2 GB | 9.6 GB | 9.6 GB | 0.01 it/s | 0.03 it/s | 0.04 it/s | ✅ |\n", + "\n", + "With all efficiency techniques enabled, **memory usage on Colab T4 is reduced by ~7×**, making it possible to **fine-tune a 7B model on free Colab** where naive FP16 training would fail.\n", + "\n", + "> A small trade-off in training speed is observed, but the **VRAM reduction is the key enabler**. For faster training on compatible hardware, **vLLM** can also be leveraged.\n", + "\n", + "> 💡 Note: For a fair comparison, the number of generations and the batch size were not changed." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9RFq6Op7rjc3" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which ensures all main dependencies such as **Transformers** and **PEFT** (a package for parameter-efficient fine-tuning, e.g., LoRA/QLoRA) are included. Additionally, we'll install **trackio** to log and monitor our experiments, **bitsandbytes** to enable quantization of LLMs, reducing memory consumption for both inference and training, and **liger-kernel** for more efficient training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "c2jy45nfWbdo" + }, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[peft]\" bitsandbytes trackio math_verify liger-kernel" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "B33zJG_Q_qb3" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "eec717d21e734c4da066763b4a6add7e" + ] + }, + "id": "8zqnTyUDWbdo", + "outputId": "62d71aaf-352b-4736-acb9-189d78654718" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cTEw4xlFrhnQ" + }, + "source": [ + "## Load Dataset\n", + "\n", + "In this step, we load the [**AI-MO/NuminaMath-TIR**](https://huggingface.co/datasets/AI-MO/NuminaMath-TIR) dataset from the Hugging Face Hub using the `datasets` library.\n", + "This dataset focuses on **mathematical reasoning**, featuring problems that require step-by-step logical solutions.\n", + "By fine-tuning a model that does not yet exhibit strong reasoning capabilities, it can learn to **generate structured reasoning steps**, enhancing both the model's **accuracy** and **interpretability** on math-related tasks.\n", + "\n", + "For efficiency, we'll load only a **small portion of the training split**:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "zU5icx67Wbdp", + "outputId": "6480b287-dc0e-4e79-feda-f5e4f41d2a82" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_name = 'AI-MO/NuminaMath-TIR'\n", + "train_dataset = load_dataset(dataset_name, split='train[:5%]')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "P1AIokQrBEGw" + }, + "source": [ + "Let's check the structure of the dataset" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ff6Gx1TWWbdp", + "outputId": "30d49bed-273a-47d9-d131-a677ca5a8b65" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dataset({\n", + " features: ['problem', 'solution', 'messages'],\n", + " num_rows: 3622\n", + "})\n" + ] + } + ], + "source": [ + "print(train_dataset)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "QY5hkOqDBGns" + }, + "source": [ + "Let's check one sample:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "-y9c7i29Wbdp", + "outputId": "760662ea-4db4-4b8e-c234-92ae2c8ecc17" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'problem': 'What is the coefficient of $x^2y^6$ in the expansion of $\\\\left(\\\\frac{3}{5}x-\\\\frac{y}{2}\\\\right)^8$? Express your answer as a common fraction.', 'solution': \"To determine the coefficient of \\\\(x^2y^6\\\\) in the expansion of \\\\(\\\\left(\\\\frac{3}{5}x - \\\\frac{y}{2}\\\\right)^8\\\\), we can use the binomial theorem.\\n\\nThe binomial theorem states:\\n\\\\[\\n(a + b)^n = \\\\sum_{k=0}^{n} \\\\binom{n}{k} a^{n-k} b^k\\n\\\\]\\n\\nIn this case, \\\\(a = \\\\frac{3}{5}x\\\\), \\\\(b = -\\\\frac{y}{2}\\\\), and \\\\(n = 8\\\\).\\n\\nWe are interested in the term that contains \\\\(x^2y^6\\\\). In the general term of the binomial expansion:\\n\\\\[\\n\\\\binom{8}{k} \\\\left(\\\\frac{3}{5}x\\\\right)^{8-k} \\\\left(-\\\\frac{y}{2}\\\\right)^k\\n\\\\]\\n\\nTo get \\\\(x^2\\\\), we need \\\\(8 - k = 2\\\\), thus \\\\(k = 6\\\\).\\n\\nSubstituting \\\\(k = 6\\\\) into the expression:\\n\\\\[\\n\\\\binom{8}{6} \\\\left(\\\\frac{3}{5}x\\\\right)^{8-6} \\\\left(-\\\\frac{y}{2}\\\\right)^6 = \\\\binom{8}{6} \\\\left(\\\\frac{3}{5}x\\\\right)^2 \\\\left(-\\\\frac{y}{2}\\\\right)^6\\n\\\\]\\n\\nNow, we will compute each part of this expression.\\n\\n1. Calculate the binomial coefficient \\\\(\\\\binom{8}{6}\\\\).\\n2. Compute \\\\(\\\\left(\\\\frac{3}{5}\\\\right)^2\\\\).\\n3. Compute \\\\(\\\\left(-\\\\frac{y}{2}\\\\right)^6\\\\).\\n4. Combine everything together to get the coefficient of \\\\(x^2y^6\\\\).\\n\\nLet's compute these in Python.\\n```python\\nfrom math import comb\\n\\n# Given values\\nn = 8\\nk = 6\\n\\n# Calculate the binomial coefficient\\nbinom_coeff = comb(n, k)\\n\\n# Compute (3/5)^2\\na_term = (3/5)**2\\n\\n# Compute (-1/2)^6\\nb_term = (-1/2)**6\\n\\n# Combine terms to get the coefficient of x^2y^6\\ncoefficient = binom_coeff * a_term * b_term\\nprint(coefficient)\\n```\\n```output\\n0.1575\\n```\\nThe coefficient of \\\\(x^2y^6\\\\) in the expansion of \\\\(\\\\left(\\\\frac{3}{5}x - \\\\frac{y}{2}\\\\right)^8\\\\) is \\\\(0.1575\\\\). To express this as a common fraction, we recognize that:\\n\\n\\\\[ 0.1575 = \\\\frac{1575}{10000} = \\\\frac{63}{400} \\\\]\\n\\nThus, the coefficient can be expressed as:\\n\\n\\\\[\\n\\\\boxed{\\\\frac{63}{400}}\\n\\\\]\", 'messages': [{'content': 'What is the coefficient of $x^2y^6$ in the expansion of $\\\\left(\\\\frac{3}{5}x-\\\\frac{y}{2}\\\\right)^8$? Express your answer as a common fraction.', 'role': 'user'}, {'content': \"To determine the coefficient of \\\\(x^2y^6\\\\) in the expansion of \\\\(\\\\left(\\\\frac{3}{5}x - \\\\frac{y}{2}\\\\right)^8\\\\), we can use the binomial theorem.\\n\\nThe binomial theorem states:\\n\\\\[\\n(a + b)^n = \\\\sum_{k=0}^{n} \\\\binom{n}{k} a^{n-k} b^k\\n\\\\]\\n\\nIn this case, \\\\(a = \\\\frac{3}{5}x\\\\), \\\\(b = -\\\\frac{y}{2}\\\\), and \\\\(n = 8\\\\).\\n\\nWe are interested in the term that contains \\\\(x^2y^6\\\\). In the general term of the binomial expansion:\\n\\\\[\\n\\\\binom{8}{k} \\\\left(\\\\frac{3}{5}x\\\\right)^{8-k} \\\\left(-\\\\frac{y}{2}\\\\right)^k\\n\\\\]\\n\\nTo get \\\\(x^2\\\\), we need \\\\(8 - k = 2\\\\), thus \\\\(k = 6\\\\).\\n\\nSubstituting \\\\(k = 6\\\\) into the expression:\\n\\\\[\\n\\\\binom{8}{6} \\\\left(\\\\frac{3}{5}x\\\\right)^{8-6} \\\\left(-\\\\frac{y}{2}\\\\right)^6 = \\\\binom{8}{6} \\\\left(\\\\frac{3}{5}x\\\\right)^2 \\\\left(-\\\\frac{y}{2}\\\\right)^6\\n\\\\]\\n\\nNow, we will compute each part of this expression.\\n\\n1. Calculate the binomial coefficient \\\\(\\\\binom{8}{6}\\\\).\\n2. Compute \\\\(\\\\left(\\\\frac{3}{5}\\\\right)^2\\\\).\\n3. Compute \\\\(\\\\left(-\\\\frac{y}{2}\\\\right)^6\\\\).\\n4. Combine everything together to get the coefficient of \\\\(x^2y^6\\\\).\\n\\nLet's compute these in Python.\\n```python\\nfrom math import comb\\n\\n# Given values\\nn = 8\\nk = 6\\n\\n# Calculate the binomial coefficient\\nbinom_coeff = comb(n, k)\\n\\n# Compute (3/5)^2\\na_term = (3/5)**2\\n\\n# Compute (-1/2)^6\\nb_term = (-1/2)**6\\n\\n# Combine terms to get the coefficient of x^2y^6\\ncoefficient = binom_coeff * a_term * b_term\\nprint(coefficient)\\n```\\n```output\\n0.1575\\n```\\nThe coefficient of \\\\(x^2y^6\\\\) in the expansion of \\\\(\\\\left(\\\\frac{3}{5}x - \\\\frac{y}{2}\\\\right)^8\\\\) is \\\\(0.1575\\\\). To express this as a common fraction, we recognize that:\\n\\n\\\\[ 0.1575 = \\\\frac{1575}{10000} = \\\\frac{63}{400} \\\\]\\n\\nThus, the coefficient can be expressed as:\\n\\n\\\\[\\n\\\\boxed{\\\\frac{63}{400}}\\n\\\\]\", 'role': 'assistant'}]}\n" + ] + } + ], + "source": [ + "print(train_dataset[0])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "DiqBlxK_A0SD" + }, + "source": [ + "We will adapt our dataset to a conversational format using a custom system prompt, guiding the LLM to generate both step-by-step reasoning and the final answer." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "RWxK5xFKWbdp" + }, + "outputs": [], + "source": [ + "SYSTEM_PROMPT = (\n", + " \"A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant \"\n", + " \"first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning \"\n", + " \"process is enclosed strictly within and tags. \"\n", + " \"After closing , the assistant MUST provide the final answer in plain text.\"\n", + ")\n", + "\n", + "\n", + "def make_conversation(example):\n", + " return {\n", + " \"prompt\": [\n", + " {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n", + " {\"role\": \"user\", \"content\": example[\"problem\"]},\n", + " ],\n", + " }\n", + "\n", + "train_dataset = train_dataset.map(make_conversation)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "sND566XAC0kD" + }, + "source": [ + "Let's take a look at an example:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Q-kHUmpMWbdp", + "outputId": "452beb3a-1091-46d4-997e-04b91562d66c" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[{'content': 'A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning process is enclosed strictly within and tags. After closing , the assistant MUST provide the final answer in plain text.', 'role': 'system'}, {'content': 'What is the coefficient of $x^2y^6$ in the expansion of $\\\\left(\\\\frac{3}{5}x-\\\\frac{y}{2}\\\\right)^8$? Express your answer as a common fraction.', 'role': 'user'}]\n" + ] + } + ], + "source": [ + "print(train_dataset[0]['prompt'])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bw0qcp-CC3G0" + }, + "source": [ + "We'll remove the `messages` and `problem` columns, as we only need the custom `prompt` column and `solution` to verify the generated answer." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "SzbF3hdRWbdp", + "outputId": "bd59a383-1d4e-4020-c232-79ce66073fd1" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dataset({\n", + " features: ['solution', 'prompt'],\n", + " num_rows: 3622\n", + "})\n" + ] + } + ], + "source": [ + "train_dataset = train_dataset.remove_columns(['messages', 'problem'])\n", + "print(train_dataset)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "tvs5rjQBr7af" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "Below, choose your **preferred model**. All of the options have been tested on **free Colab instances**.\n", + "\n", + "> 💡 Note: Some models, such as Qwen2.5 and Qwen3, are known to have been pretrained on data that improves their math performance. Be cautious when selecting the appropriate model for training to ensure meaningful fine-tuning results ([source](https://thinkingmachines.ai/blog/lora/))." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "7_uaW3JfWbdp" + }, + "outputs": [], + "source": [ + "# Select one model below by uncommenting the line you want to use 👇\n", + "## Qwen\n", + "model_id, output_dir = \"Qwen/Qwen2-7B-Instruct\", \"t4-Qwen2-7B-Instruct-GRPO\" # ✅ ~9.2GB VRAM\n", + "# model_id, output_dir = \"unsloth/qwen3-14b-unsloth-bnb-4bit\", \"qwen3-14b-unsloth-bnb-4bit-GRPO\" # ⚠️ OOM with this config; fits if GRPO params are reduced\n", + "# model_id, output_dir = \"Qwen/Qwen3-8B\", \"Qwen3-8B-GRPO\" # ✅ ~9.9GB VRAM\n", + "# model_id, output_dir = \"Qwen/Qwen2.5-7B-Instruct\", \"Qwen2.5-7B-Instruct-GRPO\" # ✅ ~9.2GB VRAM\n", + "\n", + "## Llama\n", + "# model_id, output_dir = \"meta-llama/Llama-3.2-3B-Instruct\", \"Llama-3.2-3B-Instruct-GRPO\" # ✅ ~5.7GB VRAM\n", + "# model_id, output_dir = \"meta-llama/Llama-3.1-8B-Instruct\", \"Llama-3.1-8B-Instruct-GRPO\" # ✅ ~9.5GB VRAM\n", + "\n", + "## LFM2.5\n", + "# model_id, output_dir = \"LiquidAI/LFM2.5-1.2B-Instruct\", \"LFM2.5-1.2B-Instruct-GRPO\" # ✅ ~1.12 GB VRAM" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "aw__94OWDnER" + }, + "source": [ + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration (training without quantization consumes more memory).\n", + "\n", + "Let's load the selected model using `transformers`, configuring QLoRA via `bitsandbytes` (you can remove it if doing LoRA). We don't need to configure the tokenizer since the trainer takes care of that automatically." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "1130e5a744864ca5b5873731e4764983" + ] + }, + "id": "o86TnTchWbdp", + "outputId": "77a7e6c8-0360-40f1-eea7-b941be031366" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1130e5a744864ca5b5873731e4764983", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Loading checkpoint shards: 0%| | 0/4 [00:00` format:\n", + "\n", + "```python\n", + "def think_format_reward(completions: list[list[dict[str, str]]], **kwargs) -> list[float]:\n", + " pattern = r\"^(?!.*)(.*?).*$\"\n", + " completion_contents = [completion[0][\"content\"] for completion in completions]\n", + " matches = [re.match(pattern, content, re.DOTALL | re.MULTILINE) for content in completion_contents]\n", + " return [1.0 if match else 0.0 for match in matches]\n", + "```\n", + "\n", + "In this notebook, we will use both `think_format_reward`, which rewards completions that correctly follow the `` format, and `reasoning_accuracy_reward`, which evaluates the correctness of the model's solution to the mathematical problem. Together, these rewards guide the model to generate **structured reasoning** while producing **accurate answers**." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "lj42Qs5vWbdp" + }, + "outputs": [], + "source": [ + "from trl.rewards import think_format_reward, reasoning_accuracy_reward" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bFgYgxMbtbEZ" + }, + "source": [ + "We'll configure **GRPO** using `GRPOConfig`, keeping the parameters minimal so that the training can run on a free Colab instance. You can adjust these settings if you have access to more resources. For a complete list of available parameters and their descriptions, refer to the [TRL GRPOConfig documentation](https://huggingface.co/docs/trl/grpo_trainer#trl.GRPOConfig).\n", + "\n", + "> 💡 Note: TRL supports using **vLLM** for generation during GRPO training, which can significantly speed up training. However, it increases VRAM usage since a separate vLLM process is active to handle generation. In this notebook, we do not enable vLLM because we are using **QLoRA**, which updates the quantized vLLM model weights at every step. Enabling vLLM in this setup can cause weight precision issues and make convergence more challenging. The configuration includes the vLLM parameters in case you want to experiment with it. Learn more about vLLM integration in TRL [here](https://huggingface.co/docs/trl/main/en/vllm_integration)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "JY11EQMhWbdp" + }, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "# Configure training arguments using GRPOConfig\n", + "training_args = GRPOConfig(\n", + " # Training schedule / optimization\n", + " learning_rate=2e-5, # Learning rate for the optimizer\n", + " #num_train_epochs=1,\n", + " max_steps=500, # Number of dataset passes. For full trainings, use `num_train_epochs` instead\n", + "\n", + " # Parameters that control GRPO training (you can adapt them)\n", + " per_device_train_batch_size = 8,\n", + " max_completion_length=256, # default: 256 # Max completion length produced during training\n", + " num_generations=8, # default: 8 # Number of generations produced during trainig for comparison\n", + "\n", + " # Optimizations\n", + " optim = \"paged_adamw_8bit\", # Optimizer\n", + " use_liger_kernel=True, # Enable Liger kernel optimizations for faster training\n", + "\n", + " # Parameters related to reporting and saving\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + " logging_steps=10, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + " trackio_space_id=output_dir, # HF Space where the experiment tracking will be saved\n", + " log_completions=False, # Return model completions during training\n", + "\n", + " # Hub integration\n", + " push_to_hub=True, # Automatically push the trained model to the Hugging Face Hub\n", + " # The model will be saved under your Hub account in the repository named `output_dir`\n", + " # vLLM params\n", + " #use_vllm=False, # Activate vLLM training for faster training\n", + " #vllm_mode='colocate',\n", + " #vllm_gpu_memory_utilization=0.1,\n", + " #vllm_enable_sleep_mode=True\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-9LlOAvWFSor" + }, + "source": [ + "Configure the `GRPOTrainer` by passing the previously defined `training_args`. To keep memory usage low, we are not using an evaluation dataset, but you can include one if desired. We also provide the reward functions that were imported earlier to guide the training process." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "iI_E9KCUWbdq" + }, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model,\n", + " reward_funcs=[think_format_reward, reasoning_accuracy_reward],\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "8dY7bK8FGLhh" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "PEVRGlrAWbdq", + "outputId": "78fac9e4-4ae6-4836-bd10-c30b39059782" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GPU = Tesla T4. Max memory = 14.741 GB.\n", + "6.773 GB of memory reserved.\n" + ] + } + ], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "z-5xPtfIGQL5" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Training on a T4 in Colab with the configuration defined in this notebook takes around 13 hours. If you're just experimenting, you can try the following quicker task ([source](https://huggingface.co/learn/llm-course/en/chapter12/5)):\n", + "\n", + "```python\n", + "dataset = load_dataset(\"mlabonne/smoltldr\")\n", + "\n", + "# Reward function\n", + "ideal_length = 50\n", + "\n", + "def reward_len(completions, **kwargs):\n", + " return [-abs(ideal_length - len(completion)) for completion in completions]\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "zl7-PmoXWbdq", + "outputId": "f39c8c3c-43c2-4f2d-c98d-4c595ae1129f" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'bos_token_id': None, 'pad_token_id': 151643}.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Trackio project initialized: huggingface\n", + "* Trackio metrics will be synced to Hugging Face Dataset: sergiopaniego/t4-Qwen2-7B-Instruct-GRPO-dataset\n", + "* Creating new space: https://huggingface.co/spaces/sergiopaniego/t4-Qwen2-7B-Instruct-GRPO\n", + "* View dashboard by going to: https://sergiopaniego-t4-Qwen2-7B-Instruct-GRPO.hf.space/\n" + ] + }, + { + "data": { + "text/html": [ + "

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Created new run: sergiopaniego-1766143600\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " [500/500 13:05:04, Epoch 0/1]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining Loss
100.027900
20-0.011600
300.021500
400.033400
500.039400
600.010300
700.048200
800.067300
900.030600
1000.064000
1100.021500
1200.021400
1300.000000
140-0.028500
150-0.003100
1600.017300
170-0.024700
1800.003300
1900.000000
200-0.001400
2100.008000
2200.034300
2300.044600
2400.016400
250-0.015200
2600.016800
2700.042900
2800.031300
2900.006200
3000.043300
3100.029700
3200.001100
3300.027000
340-0.006700
3500.027200
3600.008200
370-0.015800
3800.007200
3900.012100
4000.000000
4100.010500
4200.019800
4300.000800
4400.003400
450-0.007900
460-0.011800
470-0.016300
480-0.002300
490-0.005500
5000.038000

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Run finished. Uploading logs to Trackio (please wait...)\n" + ] + } + ], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "iqAN-XLCGTGW" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "4BeEwp5EWbds", + "outputId": "668b8a2c-2eef-4e34-8d4a-2a43ccbbdc00" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "47228.679 seconds used for training.\n", + "787.14 minutes used for training.\n", + "Peak reserved memory = 8.832 GB.\n", + "Peak reserved memory for training = 2.059 GB.\n", + "Peak reserved memory % of max memory = 59.915 %.\n", + "Peak reserved memory for training % of max memory = 13.968 %.\n" + ] + } + ], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "R8Sd_AqILeYi" + }, + "source": [ + "The training procedure generates both standard training logs and **trackio** logs, which help us monitor the training progress. Example outputs would look like the following:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "2bPn6gruLf-n" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ibO4f7tuLboQ" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "e6a3677667ce47bcba55e3e950e446f9", + "17adb84604d84cf688a89a21f6cc6150", + "a21c1bbd3cd04738a8c96fbfc0c016c6", + "65cadde3da7642188f029bb2aceaa7c6", + "0404b89e5ce24e76958c72bedc1a95cc", + "c52baf990fde40c0873747e827dc6926", + "191653e8ce184123a68f26fbf2b78745", + "0bb882d400864b249c80132264de2623", + "09cbfcf6e51c431798f4e392a81be6d3", + "d6521f73f23f42e18ee462a547f251a1" + ] + }, + "id": "itpVDjy0Wbdt", + "outputId": "b821c7ed-6c9d-440a-a797-e25291627bef" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "81eBZe-X7daz" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "1d3fbf86d53845beac599c5b231e87ea" + ] + }, + "id": "ZLdaWYzNWbdt", + "outputId": "a103b64b-1f6b-4423-c5fd-402f210e6dc3" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1d3fbf86d53845beac599c5b231e87ea", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Loading checkpoint shards: 0%| | 0/4 [00:00 and tags. After closing , the assistant MUST provide the final answer in plain text.',\n", + " 'role': 'system'},\n", + " {'content': \"In 1988, a person's age was equal to the sum of the digits of their birth year. How old was this person?\",\n", + " 'role': 'user'}]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_name = 'AI-MO/NuminaMath-TIR'\n", + "test_dataset = load_dataset(dataset_name, split='test[:1%]')\n", + "test_dataset = test_dataset.map(make_conversation)\n", + "test_dataset = test_dataset.remove_columns(['messages', 'problem'])\n", + "test_dataset[0]['prompt']" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "CxKyZwG28BYJ" + }, + "source": [ + "Let's first check what's the output for the base model, without the adapter." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "qTPJY96eWbdt", + "outputId": "ed02acca-e856-44ec-fa20-c32efd81e018" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "To solve this problem, let's denote the birth year of the person as \\(Y\\) (where \\(Y\\) is a four-digit number) and their age in 1988 as \\(A\\). According to the given condition, their age in 1988 is equal to the sum of the digits of their birth year. \n", + "\n", + "Since we're looking at the year 1988, the person would be \\(1988 - Y\\) years old in that year. Given the condition:\n", + "\n", + "\\[1988 - Y = \\text{sum of the digits of } Y\\]\n", + "\n", + "Let's break down the possible range for \\(Y\\). Since the person's age must be less than or equal to 100 (as the sum of the digits of any four-digit number cannot exceed 36), \\(Y\\) must be between 1989 and 2088.\n", + "\n", + "We can systematically check each year in this range to find when the condition holds true. However, considering the constraint on age, we can narrow our search significantly. For example, if \\(Y\\) were 1990, the sum of its digits would be 18, which is not a reasonable age. We need\n" + ] + } + ], + "source": [ + "messages = test_dataset[0]['prompt']\n", + "text = tokenizer.apply_chat_template(\n", + " messages, add_generation_prompt=True, tokenize=False\n", + ")\n", + "model_inputs = tokenizer([text], return_tensors=\"pt\").to(base_model.device)\n", + "\n", + "generated_ids = base_model.generate(\n", + " **model_inputs,\n", + " max_new_tokens=256\n", + ")\n", + "output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]\n", + "\n", + "# Decode and extract model response\n", + "generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)\n", + "print(generated_text)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "V9eoUwQS8SIi" + }, + "source": [ + "The base model neither produced reasoning traces nor provided a correct answer. Let's now load the fine-tuned model and check its performance." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "073b351afd264bf0bf23043b37e0d8ce", + "3dee429faf4e40b192cabebfe4bf2245" + ] + }, + "id": "CNannsXXWbdt", + "outputId": "fc43a5b9-4ec6-43eb-fc34-f26e92434faf" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "073b351afd264bf0bf23043b37e0d8ce", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "adapter_config.json: 0.00B [00:00, ?B/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3dee429faf4e40b192cabebfe4bf2245", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "adapter_model.safetensors: 0%| | 0.00/162M [00:00 I need to find a birth year where the sum of its digits equals the person's age in 1988 \n", + "\n", + "The person would have been born in 1979, since 1+9+7+9 = 26 and 26 is the age in 1988\n", + "\n", + "answer: 26\n" + ] + } + ], + "source": [ + "text = tokenizer.apply_chat_template(\n", + " messages, add_generation_prompt=True, tokenize=False\n", + ")\n", + "model_inputs = tokenizer([text], return_tensors=\"pt\").to(fine_tuned_model.device)\n", + "\n", + "generated_ids = fine_tuned_model.generate(\n", + " **model_inputs,\n", + " max_new_tokens=256\n", + ")\n", + "output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]\n", + "\n", + "# Decode and extract model response\n", + "generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)\n", + "print(generated_text)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "OU-xDHpEEmg9" + }, + "source": [ + "The final answer is correct!" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XNtBOpRY8a2O" + }, + "source": [ + "## Inference and Serving with vLLM\n", + "\n", + "You can use Transformer models with **vLLM** to serve them in real-world applications. Learn more [here](https://blog.vllm.ai/2025/04/11/transformers-backend.html)." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nkhu0uY78lV3" + }, + "source": [ + "### Push Merged Model (for LoRA or QLoRA Training)\n", + "\n", + "To serve the model via **vLLM**, the repository must contain the merged model (base model + LoRA adapter). Therefore, you need to upload it first." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "NF8ZP9Z-Wbdt", + "outputId": "32a5ab71-1f0d-4289-ea12-66f5f75a957b" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "('Qwen2-7B-Instruct-GRPO-merged/tokenizer_config.json',\n", + " 'Qwen2-7B-Instruct-GRPO-merged/special_tokens_map.json',\n", + " 'Qwen2-7B-Instruct-GRPO-merged/chat_template.jinja',\n", + " 'Qwen2-7B-Instruct-GRPO-merged/vocab.json',\n", + " 'Qwen2-7B-Instruct-GRPO-merged/merges.txt',\n", + " 'Qwen2-7B-Instruct-GRPO-merged/added_tokens.json',\n", + " 'Qwen2-7B-Instruct-GRPO-merged/tokenizer.json')" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model_merged = fine_tuned_model.merge_and_unload()\n", + "\n", + "save_dir = f\"{output_dir}-merged\"\n", + "\n", + "model_merged.save_pretrained(save_dir)\n", + "tokenizer.save_pretrained(save_dir)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "d1a0574cc20046d5876cf31b21955f8b", + "7cc2f0ef7ad2494cad572cd898095c00", + "475420d92bb54dc08517ffe423b015c3", + "a76231aeae5a49979d1e9075b0b3eefb", + "b4f469f957134ea9b0e28532fe3caaf1", + "637e55736da34f2c9b098222ae07244a", + "8157e521017c450a9d2a9e41611405e9", + "9746ae4ab0574ed186f898dba3b4b197", + "d4b2a8805ec548ea85e0900ff5927574", + "0668cd8597f141e89ef38129c6641c1f" + ] + }, + "id": "X5Zci39rWbdt", + "outputId": "ca329f99-dc7b-470c-f5d9-39a3eabcb16d" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d1a0574cc20046d5876cf31b21955f8b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7cc2f0ef7ad2494cad572cd898095c00", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "475420d92bb54dc08517ffe423b015c3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...0002-of-00004.safetensors: 0%| | 612kB / 4.93GB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "a76231aeae5a49979d1e9075b0b3eefb", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...0003-of-00004.safetensors: 0%| | 611kB / 4.33GB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b4f469f957134ea9b0e28532fe3caaf1", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...0001-of-00004.safetensors: 1%|1 | 50.3MB / 4.88GB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "637e55736da34f2c9b098222ae07244a", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...0004-of-00004.safetensors: 4%|3 | 41.9MB / 1.09GB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8157e521017c450a9d2a9e41611405e9", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "README.md: 0.00B [00:00, ?B/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9746ae4ab0574ed186f898dba3b4b197", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d4b2a8805ec548ea85e0900ff5927574", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0668cd8597f141e89ef38129c6641c1f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...RPO-merged/tokenizer.json: 100%|##########| 11.4MB / 11.4MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "CommitInfo(commit_url='https://huggingface.co/sergiopaniego/Qwen2-7B-Instruct-GRPO-merged/commit/b20988444532e79a6915f0b2b6002b5acc2b53e1', commit_message='Upload tokenizer', commit_description='', oid='b20988444532e79a6915f0b2b6002b5acc2b53e1', pr_url=None, repo_url=RepoUrl('https://huggingface.co/sergiopaniego/Qwen2-7B-Instruct-GRPO-merged', endpoint='https://huggingface.co', repo_type='model', repo_id='sergiopaniego/Qwen2-7B-Instruct-GRPO-merged'), pr_revision=None, pr_num=None)" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model_merged.push_to_hub(f\"sergiopaniego/{output_dir}-merged\") # Replace with your HF username or organization\n", + "tokenizer.push_to_hub(f\"sergiopaniego/{output_dir}-merged\") # Replace with your HF username or organization" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "DQ00Ivxi8rFu" + }, + "source": [ + "### Performing Inference with vLLM\n", + "\n", + "Use **vLLM** to run your model and generate text efficiently in real-time. This allows you to test and deploy your fine-tuned models with low latency and high throughput." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "x7L-HIn4Wbdt", + "outputId": "afd66093-3525-4590-f834-c0b373e7bb9e" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO 12-11 15:56:09 [utils.py:253] non-default args: {'dtype': torch.float16, 'max_model_len': 256, 'disable_log_stats': True, 'model_impl': 'transformers', 'model': 'sergiopaniego/Qwen2-7B-Instruct-GRPO-merged'}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.12/dist-packages/huggingface_hub/utils/_auth.py:104: UserWarning: \n", + "Error while fetching `HF_TOKEN` secret value from your vault: 'Requesting secret HF_TOKEN timed out. Secrets can only be fetched when running from the Colab UI.'.\n", + "You are not authenticated with the Hugging Face Hub in this notebook.\n", + "If the error persists, please let us know by opening an issue on GitHub (https://github.com/huggingface/huggingface_hub/issues/new).\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO 12-11 15:56:37 [model.py:631] Resolved architecture: TransformersForCausalLM\n", + "WARNING 12-11 15:56:37 [model.py:1971] Casting torch.bfloat16 to torch.float16.\n", + "INFO 12-11 15:56:37 [model.py:1745] Using max model len 256\n", + "INFO 12-11 15:56:40 [scheduler.py:216] Chunked prefill is enabled with max_num_batched_tokens=8192.\n", + "WARNING 12-11 15:56:43 [system_utils.py:103] We must use the `spawn` multiprocessing start method. Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. See https://docs.vllm.ai/en/latest/usage/troubleshooting.html#python-multiprocessing for more information. Reasons: CUDA is initialized\n", + "INFO 12-11 15:57:36 [llm.py:352] Supported tasks: ['generate']\n" + ] + } + ], + "source": [ + "from vllm import LLM, SamplingParams\n", + "from transformers import AutoTokenizer\n", + "import torch\n", + "\n", + "llm = LLM(\n", + " model=f\"sergiopaniego/{output_dir}-merged\", # Replace with your HF username or organization\n", + " model_impl=\"transformers\", # Select the transformers model implementation\n", + " max_model_len=256, # Reduced for efficiency\n", + " dtype=torch.float16\n", + ")\n", + "hf_tokenizer = AutoTokenizer.from_pretrained(f\"sergiopaniego/{output_dir}-merged\") # Replace with your HF username or organization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "f0a4f4fb17bf4a698503212296467547", + "5be7348f3f324b5b9397c9ad186fb35d" + ] + }, + "id": "ZTpSUqxNWbdt", + "outputId": "6a9283bf-d3b7-4e54-c775-4502694b5c6d" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f0a4f4fb17bf4a698503212296467547", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Adding requests: 0%| | 0/1 [00:00 1988 birth year implies the person was born either in 1979, 1980, 1981, etc. Looking for the one where sum of digits equals age \n", + "\n", + "The birth year 1979 gives sum of digits 1+9+7+9 = 26\n", + "\n", + "The person was 26 years old in 1988.\n", + "\n", + "Answer: The person was 26 years old.\n" + ] + } + ], + "source": [ + "messages = test_dataset[0]['prompt']\n", + "# Alternatively, use llm.chat()\n", + "prompt = hf_tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)\n", + "\n", + "outputs = llm.generate(\n", + " {\"prompt\": prompt},\n", + " sampling_params=SamplingParams(max_tokens=256),\n", + ")\n", + "\n", + "for o in outputs:\n", + " generated_text = o.outputs[0].text\n", + " print(generated_text)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "provenance": [] + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/openenv_sudoku_grpo.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/openenv_sudoku_grpo.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..5a376a52619bdeb449377ba319c616df8488adc5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/openenv_sudoku_grpo.ipynb @@ -0,0 +1,884 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# OpenEnv Sudoku with GRPO using TRL\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/openenv_sudoku_grpo.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "\n", + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can train a model that learns to **play Sudoku**, a logic-based number puzzle, through interaction and reinforcement.\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) -- star us to support the project!\n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview)\n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)\n", + "- [OpenEnv](https://github.com/meta-pytorch/OpenEnv)\n", + "\n", + "\n", + "An **agentic environment** is a setting where a model can take actions, observe outcomes, and adjust its behavior based on feedback, similar to how humans learn from trial and error.\n", + "In this case, the agent interacts with the **Sudoku** environment through the [**OpenEnv**](https://github.com/meta-pytorch/OpenEnv) framework, which standardizes multi-agent and RL-style text environments.\n", + "\n", + "[Sudoku](https://en.wikipedia.org/wiki/Sudoku) is a classic logic-based puzzle where the objective is to fill a **9x9 grid** so that each **row**, **column**, and **3x3 subgrid** contains all digits from **1 to 9** exactly once. This structured yet challenging setup makes Sudoku an excellent benchmark for reasoning and decision-making tasks.\n", + "\n", + "\n", + "We'll fine-tune a model using **GRPO** (Group Relative Policy Optimization) via TRL.\n", + "Using `environment_factory`, the trainer automatically handles:\n", + "1. Creating environment instances for each rollout.\n", + "2. Generating model completions and parsing tool calls.\n", + "3. Stepping through the environment with the model's actions.\n", + "4. Collecting rewards and managing the interaction loop.\n", + "\n", + "This means you only need to define the environment class and reward functions -- the trainer takes care of the rest.\n", + "\n", + "\n", + "## Install dependencies\n", + "\n", + "We'll start by installing **TRL** (with vLLM support), the **OpenEnv** Sudoku environment, and **trackio** for logging." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install -Uq trl[vllm] git+https://huggingface.co/spaces/openenv/sudoku trackio" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define the system prompt\n", + "\n", + "This prompt instructs the model on how to play Sudoku. It includes the game rules, board reading format, strategic approaches, and importantly, tells the model to use the `place` tool to submit moves. The `environment_factory` pattern uses tool calling to interact with the environment, so the model needs to know which tool to call." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "system_prompt = \"\"\"You are an expert Sudoku player with deep knowledge of logical deduction strategies and number placement techniques.\n", + "\n", + "## GAME RULES\n", + "\n", + "1. The puzzle is a 9x9 grid divided into nine 3x3 subgrids (boxes)\n", + "2. Some cells are pre-filled with numbers 1-9\n", + "3. You must fill in the empty cells (shown as '.') with numbers 1-9\n", + "4. Each row must contain numbers 1-9 without repetition\n", + "5. Each column must contain numbers 1-9 without repetition\n", + "6. Each 3x3 subgrid must contain numbers 1-9 without repetition\n", + "7. You cannot overwrite pre-filled cells\n", + "8. Invalid moves result in penalties (-1 reward)\n", + "\n", + "## HOW TO PLAY\n", + "\n", + "Use the `place` tool to make a move. The tool takes three arguments:\n", + "- `row`: Row number (1-9)\n", + "- `col`: Column number (1-9)\n", + "- `number`: The digit to place (1-9)\n", + "\n", + "## STRATEGIC APPROACH\n", + "\n", + "Do not repeat the same move twice.\n", + "\n", + "### Basic Strategies\n", + "- **Naked Singles**: If a cell has only one possible candidate, fill it in immediately.\n", + "- **Hidden Singles**: If a number can only go in one cell within a row, column, or box, place it there.\n", + "- **Scanning**: Look at each row, column, and box to find where specific numbers can go.\n", + "\n", + "### Solving Process\n", + "1. Start by scanning the entire grid to identify easy fills (cells with few candidates)\n", + "2. Look for rows, columns, or boxes with many numbers already placed\n", + "3. Fill all naked singles first\n", + "4. Then look for hidden singles in each row, column, and box\n", + "\n", + "### Common Pitfalls to Avoid\n", + "- Don't guess randomly - Sudoku is pure logic\n", + "- Don't overlook any constraint (row, column, or box)\n", + "- Don't try to overwrite pre-filled cells\n", + "- Don't place invalid numbers (must be 1-9)\n", + "- Don't use invalid coordinates (must be 1-9)\n", + "- Don't repeat a move that was already made\n", + "\n", + "## BOARD READING\n", + "\n", + "The board is displayed as a 9x9 grid:\n", + "- Numbers 1-9 are pre-filled or already placed\n", + "- Empty cells are shown as '.'\n", + "- Rows are labeled R1-R9 (top to bottom)\n", + "- Columns are labeled C1-C9 (left to right)\n", + "\n", + "## IMPORTANT CONSTRAINTS\n", + "\n", + "- Coordinates are 1-indexed (1-9 for both row and column)\n", + "- Numbers must be 1-9\n", + "- One move per response\n", + "- Must be a valid move (no rule violations)\n", + "- Never repeat a previous move\n", + "\"\"\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define the environment\n", + "\n", + "The `SudokuEnv` class wraps the OpenEnv TextArena Sudoku environment into the interface expected by `environment_factory`.\n", + "\n", + "When you pass `environment_factory=SudokuEnv` to the trainer, it will:\n", + "1. Create a new `SudokuEnv()` instance for each rollout episode.\n", + "2. Call `reset()` to start a new game (returns the initial board state).\n", + "3. Automatically generate model completions, parse tool calls, and invoke the `place(row, col, number)` method.\n", + "4. Repeat until the environment signals `done=True` or the max completion length is reached.\n", + "\n", + "The environment tracks multiple reward signals as properties:\n", + "- **correct_reward**: Did the puzzle get solved?\n", + "- **valid_move_reward**: Average rate of valid moves.\n", + "- **empty_cell_reward**: Did the model target empty cells?\n", + "- **repetition_reward**: Penalty for repeating moves.\n", + "- **progress_reward**: How many cells were filled (normalized 0-1).\n", + "\n", + "For this example, we connect to the hosted environment at [openenv/sudoku](https://huggingface.co/spaces/openenv/sudoku).\n", + "For production use, we recommend duplicating the Space to your own account or running it locally via Docker, as the hosted versions have limited concurrency.\n", + "\n", + "For more information, refer to the [TRL-OpenEnv documentation](https://huggingface.co/docs/trl/main/en/openenv)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title SudokuEnv class (click to expand)\n", + "from collections import defaultdict\n", + "\n", + "from textarena_env import TextArenaAction, TextArenaEnv\n", + "\n", + "\n", + "def _is_valid_board_state(board_str: str) -> bool:\n", + " return \"R1\" in board_str and \"R9\" in board_str and \"|\" in board_str\n", + "\n", + "\n", + "def _parse_board(board_str: str) -> list[list[int]]:\n", + " grid = [[0] * 9 for _ in range(9)]\n", + " if not _is_valid_board_state(board_str):\n", + " return grid\n", + " for line in board_str.split(\"\\n\"):\n", + " line_stripped = line.strip()\n", + " if line_stripped and line_stripped[0] == \"R\" and len(line_stripped) > 1 and line_stripped[1].isdigit():\n", + " row = int(line_stripped[1]) - 1\n", + " cell_part = line_stripped[2:]\n", + " col = 0\n", + " for char in cell_part:\n", + " if char == \".\":\n", + " grid[row][col] = 0\n", + " col += 1\n", + " elif char.isdigit():\n", + " grid[row][col] = int(char)\n", + " col += 1\n", + " return grid\n", + "\n", + "\n", + "def _count_filled_cells(board_str: str) -> int:\n", + " if not _is_valid_board_state(board_str):\n", + " return 0\n", + " grid = _parse_board(board_str)\n", + " return sum(1 for row in grid for cell in row if cell != 0)\n", + "\n", + "\n", + "def _get_valid_numbers(grid: list[list[int]], row: int, col: int) -> set[int]:\n", + " if grid[row][col] != 0:\n", + " return set()\n", + " used = set()\n", + " for c in range(9):\n", + " if grid[row][c] != 0:\n", + " used.add(grid[row][c])\n", + " for r in range(9):\n", + " if grid[r][col] != 0:\n", + " used.add(grid[r][col])\n", + " box_row, box_col = 3 * (row // 3), 3 * (col // 3)\n", + " for r in range(box_row, box_row + 3):\n", + " for c in range(box_col, box_col + 3):\n", + " if grid[r][c] != 0:\n", + " used.add(grid[r][c])\n", + " return set(range(1, 10)) - used\n", + "\n", + "\n", + "def _extract_empty_cells_with_candidates(board_str: str, sort_by_difficulty: bool = True):\n", + " grid = _parse_board(board_str)\n", + " cells_with_candidates = []\n", + " for row in range(9):\n", + " for col in range(9):\n", + " if grid[row][col] == 0:\n", + " candidates = _get_valid_numbers(grid, row, col)\n", + " cells_with_candidates.append((row + 1, col + 1, candidates))\n", + " if sort_by_difficulty:\n", + " cells_with_candidates.sort(key=lambda x: len(x[2]))\n", + " return cells_with_candidates\n", + "\n", + "\n", + "def _extract_empty_cells(board_str: str) -> list[tuple[int, int]]:\n", + " empty_cells = []\n", + " if not _is_valid_board_state(board_str):\n", + " return empty_cells\n", + " for line in board_str.split(\"\\n\"):\n", + " line_stripped = line.strip()\n", + " if line_stripped and line_stripped[0] == \"R\" and len(line_stripped) > 1 and line_stripped[1].isdigit():\n", + " row = int(line_stripped[1])\n", + " cell_part = line_stripped[2:]\n", + " col = 0\n", + " for char in cell_part:\n", + " if char == \".\":\n", + " col += 1\n", + " empty_cells.append((row, col))\n", + " elif char.isdigit():\n", + " col += 1\n", + " return empty_cells\n", + "\n", + "\n", + "def _extract_board_only(text: str) -> str:\n", + " if not text:\n", + " return \"\"\n", + " lines = text.split(\"\\n\")\n", + " board_lines = []\n", + " in_board = False\n", + " for line in lines:\n", + " stripped = line.strip()\n", + " if stripped.startswith(\"C1\") or (\n", + " stripped and stripped[0] == \"R\" and len(stripped) > 1 and stripped[1].isdigit()\n", + " ):\n", + " in_board = True\n", + " if in_board and (stripped.startswith(\"-\") or stripped.startswith(\"R\") or stripped.startswith(\"C1\")):\n", + " board_lines.append(line)\n", + " elif (\n", + " in_board\n", + " and stripped\n", + " and not stripped.startswith(\"-\")\n", + " and not (stripped[0] == \"R\" and len(stripped) > 1 and stripped[1].isdigit())\n", + " ):\n", + " break\n", + " return \"\\n\".join(board_lines) if board_lines else \"\"\n", + "\n", + "\n", + "def _make_hints(board, successful_moves, failed_moves, difficulty=\"easy\"):\n", + " \"\"\"Generate hint text for the model.\"\"\"\n", + " parts = []\n", + " all_tried = successful_moves + failed_moves\n", + " if all_tried:\n", + " parts.append(f\"\\nMOVES ALREADY TRIED (do not repeat): {', '.join(all_tried)}\")\n", + " if not board:\n", + " return \"\\n\".join(parts)\n", + " if difficulty == \"easy\":\n", + " cells = _extract_empty_cells_with_candidates(board, sort_by_difficulty=True)\n", + " if cells:\n", + " guaranteed = []\n", + " other = []\n", + " for r, c, candidates in cells[:10]:\n", + " if len(candidates) == 1:\n", + " guaranteed.append(f\"[{r} {c} {list(candidates)[0]}]\")\n", + " elif len(candidates) <= 3:\n", + " nums = \",\".join(str(n) for n in sorted(candidates))\n", + " other.append(f\"({r},{c})->{nums}\")\n", + " if guaranteed:\n", + " parts.append(f\"\\nGUARANTEED MOVES: {', '.join(guaranteed[:5])}\")\n", + " if other:\n", + " parts.append(f\"Other options: {' | '.join(other[:5])}\")\n", + " elif difficulty == \"medium\":\n", + " cells = _extract_empty_cells_with_candidates(board, sort_by_difficulty=False)\n", + " if cells:\n", + " cell_hints = []\n", + " for r, c, candidates in cells[:10]:\n", + " nums = \",\".join(str(n) for n in sorted(candidates))\n", + " cell_hints.append(f\"({r},{c})->{nums}\")\n", + " parts.append(f\"\\nEmpty cells: {' | '.join(cell_hints)}\")\n", + " return \"\\n\".join(parts)\n", + "\n", + "\n", + "class SudokuEnv:\n", + " def __init__(self):\n", + " self.client = TextArenaEnv(base_url=\"https://openenv-sudoku.hf.space\")\n", + " self.difficulty = \"easy\"\n", + " self.max_turns = 100\n", + " self._turn = 0\n", + " self._move_counts = defaultdict(int)\n", + " self._successful_moves = []\n", + " self._failed_moves = []\n", + " self._valid_move_scores = []\n", + " self._empty_cell_scores = []\n", + " self._correct_scores = []\n", + " self._repetition_scores = []\n", + " self._last_board_state = \"\"\n", + " self._last_full_content = \"\"\n", + " self._initial_filled = 0\n", + " self._max_filled = 0\n", + " self.done = False\n", + "\n", + " def reset(self, **kwargs) -> str | None:\n", + " result = self.client.reset()\n", + " observation = result.observation\n", + " self.done = False\n", + " self._turn = 0\n", + " self._move_counts = defaultdict(int)\n", + " self._successful_moves = []\n", + " self._failed_moves = []\n", + " self._valid_move_scores = []\n", + " self._empty_cell_scores = []\n", + " self._correct_scores = []\n", + " self._repetition_scores = []\n", + " self._last_board_state = \"\"\n", + " self._initial_filled = 0\n", + " self._max_filled = 0\n", + "\n", + " # Store full message content for diffing (messages are cumulative)\n", + " self._last_full_content = observation.messages[0].content if observation.messages else \"\"\n", + "\n", + " for message in observation.messages:\n", + " if message.content and _is_valid_board_state(message.content):\n", + " self._last_board_state = message.content\n", + " self._initial_filled = _count_filled_cells(self._last_board_state)\n", + " self._max_filled = self._initial_filled\n", + " break\n", + "\n", + " board = _extract_board_only(self._last_board_state) if self._last_board_state else \"No board available.\"\n", + " hints = _make_hints(self._last_board_state, [], [], self.difficulty)\n", + " return f\"Step 0. Progress: 0 cells filled.\\n\\nBoard:\\n{board}{hints}\"\n", + "\n", + " def place(self, row: int, col: int, number: int) -> str:\n", + " \"\"\"Place a number on the Sudoku board.\n", + "\n", + " Args:\n", + " row: Row number (1-9).\n", + " col: Column number (1-9).\n", + " number: Number to place (1-9).\n", + "\n", + " Returns:\n", + " The result of the move and updated board state.\n", + " \"\"\"\n", + " if self.done:\n", + " return \"Game is over. No more moves allowed.\"\n", + "\n", + " self._turn += 1\n", + " move = f\"[{row} {col} {number}]\"\n", + "\n", + " # Step environment\n", + " result = self.client.step(TextArenaAction(message=move))\n", + " observation = result.observation\n", + " correct_score = float(result.reward or 0.0)\n", + " self.done = result.done\n", + "\n", + " # Only check the NEW content for feedback (messages are cumulative)\n", + " full_content = observation.messages[0].content if observation.messages else \"\"\n", + " new_content = full_content[len(self._last_full_content):]\n", + " self._last_full_content = full_content\n", + "\n", + " new_content_lower = new_content.lower()\n", + " env_says_invalid = any(\n", + " kw in new_content_lower for kw in [\"invalid\", \"error\", \"cannot\", \"already\", \"violation\", \"lost\"]\n", + " )\n", + " got_warning = \"please resubmit\" in new_content_lower or \"avoid penalties\" in new_content_lower\n", + "\n", + " # Also verify against our own board state: placing on a non-empty cell is always invalid\n", + " if self._last_board_state:\n", + " empty_cells = _extract_empty_cells(self._last_board_state)\n", + " targets_empty = (row, col) in empty_cells\n", + " else:\n", + " empty_cells = []\n", + " targets_empty = True # Can't verify, assume valid\n", + "\n", + " is_valid = not env_says_invalid and targets_empty\n", + "\n", + " # Empty cell score: did the model target an empty cell?\n", + " empty_cell_score = 1.0 if targets_empty else -1.0\n", + "\n", + " # Repetition tracking\n", + " is_new_move = self._move_counts[move] == 0\n", + " repetition_count = self._move_counts[move]\n", + " self._move_counts[move] += 1\n", + " repetition_score = -min(2 ** (repetition_count - 1), 10.0) if repetition_count > 0 else 0.0\n", + "\n", + " # Valid move score\n", + " if is_valid and is_new_move:\n", + " valid_move_score = 1.0\n", + " self._successful_moves.append(move)\n", + " elif got_warning:\n", + " valid_move_score = -0.5\n", + " self._failed_moves.append(move)\n", + " else:\n", + " valid_move_score = 0.0\n", + "\n", + " # Update board state from new content\n", + " if is_valid and _is_valid_board_state(new_content):\n", + " self._last_board_state = new_content\n", + " current_filled = _count_filled_cells(self._last_board_state)\n", + " if current_filled > self._max_filled:\n", + " self._max_filled = current_filled\n", + "\n", + " self._valid_move_scores.append(valid_move_score)\n", + " self._empty_cell_scores.append(empty_cell_score)\n", + " self._correct_scores.append(correct_score)\n", + " self._repetition_scores.append(repetition_score)\n", + "\n", + " # Enforce max turns\n", + " if self._turn >= self.max_turns:\n", + " self.done = True\n", + "\n", + " # Build response\n", + " board = _extract_board_only(self._last_board_state) if self._last_board_state else \"No board available.\"\n", + " status = \"valid\" if is_valid else \"invalid\"\n", + " cells_filled = len(self._successful_moves)\n", + " progress = f\"Step {self._turn}. Progress: {cells_filled} cells filled.\"\n", + " hints = _make_hints(self._last_board_state, self._successful_moves, self._failed_moves, self.difficulty)\n", + "\n", + " if self.done:\n", + " return f\"Move {move}: {status}. Game over.\\n{progress}\\n\\nFinal board:\\n{board}\"\n", + " return f\"Move {move}: {status}\\n{progress}\\n\\nBoard:\\n{board}{hints}\"\n", + "\n", + " # ── Reward properties ──\n", + "\n", + " @property\n", + " def correct_reward(self) -> float:\n", + " return self._correct_scores[-1] if self._correct_scores else 0.0\n", + "\n", + " @property\n", + " def valid_move_reward(self) -> float:\n", + " return sum(self._valid_move_scores) / len(self._valid_move_scores) if self._valid_move_scores else 0.0\n", + "\n", + " @property\n", + " def empty_cell_reward(self) -> float:\n", + " return sum(self._empty_cell_scores) / len(self._empty_cell_scores) if self._empty_cell_scores else 0.0\n", + "\n", + " @property\n", + " def repetition_reward(self) -> float:\n", + " return sum(self._repetition_scores) / len(self._repetition_scores) if self._repetition_scores else 0.0\n", + "\n", + " @property\n", + " def progress_reward(self) -> float:\n", + " remaining_to_fill = 81 - self._initial_filled\n", + " if remaining_to_fill > 0:\n", + " return (self._max_filled - self._initial_filled) / remaining_to_fill\n", + " return 1.0" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define the reward functions\n", + "\n", + "The reward functions receive the list of environment instances after each episode completes. Since the `SudokuEnv` tracks multiple reward signals as properties, we simply read them out.\n", + "\n", + "Each reward function captures a different aspect of play quality:\n", + "- **empty_cell_reward**: Did the model target empty cells (vs. trying to overwrite filled ones)?\n", + "- **valid_move_reward**: Were the moves accepted by the environment?\n", + "- **repetition_reward**: Penalty for repeating the same move.\n", + "- **progress_reward**: How much of the puzzle was filled (0 to 1).\n", + "- **correct_reward**: Did the model solve the puzzle completely?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def reward_empty_cell(environments, **kwargs) -> list[float]:\n", + " \"\"\"Reward for targeting empty cells.\"\"\"\n", + " return [env.empty_cell_reward for env in environments]\n", + "\n", + "\n", + "def reward_valid_moves(environments, **kwargs) -> list[float]:\n", + " \"\"\"Reward for making valid moves.\"\"\"\n", + " return [env.valid_move_reward for env in environments]\n", + "\n", + "\n", + "def reward_repetition(environments, **kwargs) -> list[float]:\n", + " \"\"\"Penalty for repeating moves.\"\"\"\n", + " return [env.repetition_reward for env in environments]\n", + "\n", + "\n", + "def reward_progress(environments, **kwargs) -> list[float]:\n", + " \"\"\"Reward for filling more cells in the board.\"\"\"\n", + " return [env.progress_reward for env in environments]\n", + "\n", + "\n", + "def reward_correct(environments, **kwargs) -> list[float]:\n", + " \"\"\"Reward for solving the puzzle.\"\"\"\n", + " return [env.correct_reward for env in environments]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create the dataset\n", + "\n", + "We create a dataset with repeated prompts to control the number of training episodes.\n", + "Each entry triggers one rollout episode during training. The prompt is formatted as a chat message with the system prompt." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from datasets import Dataset\n", + "\n", + "dataset_size = 3000\n", + "dataset = Dataset.from_dict({\n", + " \"prompt\": [[\n", + " {\"role\": \"system\", \"content\": system_prompt},\n", + " {\"role\": \"user\", \"content\": \"Play Sudoku like an expert.\"},\n", + " ]] * dataset_size\n", + "})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set GRPO Config\n", + "\n", + "Next, we define the **GRPOConfig**, which controls all key training parameters.\n", + "This configuration specifies how the model interacts with vLLM, manages memory, and logs results.\n", + "\n", + "Note the `chat_template_kwargs={\"enable_thinking\": False}` parameter -- this disables Qwen3's thinking mode so the model responds directly with tool calls instead of generating internal reasoning tokens first." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "model_name = \"Qwen/Qwen3-1.7B\"\n", + "output_dir = \"sudoku-grpo-Qwen3-1.7B\"\n", + "\n", + "grpo_config = GRPOConfig(\n", + " # Training schedule / optimization\n", + " num_train_epochs=1,\n", + " learning_rate=5e-6,\n", + " gradient_accumulation_steps=64,\n", + " per_device_train_batch_size=1,\n", + " warmup_steps=20,\n", + " optim=\"adamw_torch\",\n", + " max_grad_norm=1.0,\n", + "\n", + " # GRPO configuration\n", + " num_generations=2,\n", + " max_completion_length=16384,\n", + " log_completions=True,\n", + " num_completions_to_print=2,\n", + " chat_template_kwargs={\"enable_thinking\": False},\n", + "\n", + " # vLLM configuration\n", + " use_vllm=True,\n", + " vllm_mode=\"colocate\",\n", + " vllm_gpu_memory_utilization=0.15,\n", + "\n", + " # Logging / reporting\n", + " output_dir=output_dir,\n", + " report_to=\"trackio\",\n", + " trackio_space_id=output_dir,\n", + " logging_steps=1,\n", + " save_steps=10,\n", + " save_total_limit=1,\n", + "\n", + " # Hub integration\n", + " push_to_hub=True,\n", + "\n", + " # Sampling\n", + " temperature=0.8,\n", + " top_k=10,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create the `GRPOTrainer` and start training\n", + "\n", + "Now we initialize the `GRPOTrainer` with `environment_factory=SudokuEnv`.\n", + "\n", + "This tells the trainer to automatically handle the entire interaction loop:\n", + "- It creates a `SudokuEnv` instance for each episode.\n", + "- It generates model completions, parses tool calls (like `place`), and steps through the environment.\n", + "- It collects rewards and manages the `tool_mask` (which tokens are model-generated vs environment-generated) automatically.\n", + "\n", + "No need to write a custom `rollout_func` or manage tokenization manually." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model_name,\n", + " reward_funcs=[\n", + " reward_empty_cell,\n", + " reward_valid_moves,\n", + " reward_repetition,\n", + " reward_progress,\n", + " reward_correct,\n", + " ],\n", + " train_dataset=dataset,\n", + " args=grpo_config,\n", + " environment_factory=SudokuEnv,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import torch\n", + "\n", + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_training = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "training_memory_percentage = round(used_memory_for_training / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_training} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {training_memory_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Save and push to Hub" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now let's test our fine-tuned model by loading it and playing a game of Sudoku.\n", + "We use the same `SudokuEnv` class to interact with the environment, and generate model responses with standard Transformers inference." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from transformers import AutoModelForCausalLM, AutoTokenizer\n", + "\n", + "model_name = \"sergiopaniego/sudoku-grpo-Qwen3-1.7B\" # Replace with your HF username or organization\n", + "\n", + "fine_tuned_model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=\"float32\", device_map=\"auto\")\n", + "tokenizer = AutoTokenizer.from_pretrained(model_name)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "\n", + "\n", + "def play_sudoku(model, tokenizer):\n", + " env = SudokuEnv()\n", + " initial_observation = env.reset()\n", + "\n", + " print(\"Initial observation:\")\n", + " print(initial_observation)\n", + " print()\n", + "\n", + " messages = [\n", + " {\"role\": \"system\", \"content\": system_prompt},\n", + " {\"role\": \"user\", \"content\": \"Play Sudoku like an expert.\"},\n", + " ]\n", + " if initial_observation:\n", + " messages.append({\"role\": \"user\", \"content\": initial_observation})\n", + "\n", + " for turn in range(20): # Play up to 20 turns\n", + " if env.done:\n", + " break\n", + "\n", + " prompt_text = tokenizer.apply_chat_template(\n", + " messages,\n", + " add_generation_prompt=True,\n", + " tokenize=False,\n", + " enable_thinking=False,\n", + " )\n", + " model_inputs = tokenizer([prompt_text], return_tensors=\"pt\").to(model.device)\n", + " generated_ids = model.generate(**model_inputs, max_new_tokens=512)\n", + " output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]\n", + " generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)\n", + "\n", + " print(f\"Turn {turn + 1} - Model output: {generated_text}\")\n", + "\n", + " try:\n", + " # Try to parse tool call arguments\n", + " if \"place\" in generated_text:\n", + " start = generated_text.index(\"{\")\n", + " end = generated_text.rindex(\"}\") + 1\n", + " args = json.loads(generated_text[start:end])\n", + " if \"arguments\" in args:\n", + " args = args[\"arguments\"]\n", + " row = int(args.get(\"row\", 0))\n", + " col = int(args.get(\"col\", 0))\n", + " number = int(args.get(\"number\", 0))\n", + " else:\n", + " # Fallback: extract [row col number] pattern\n", + " import re\n", + " match = re.search(r\"\\[(\\d)\\s+(\\d)\\s+(\\d)\\]\", generated_text)\n", + " if match:\n", + " row, col, number = int(match.group(1)), int(match.group(2)), int(match.group(3))\n", + " else:\n", + " print(\" Could not parse move.\")\n", + " break\n", + "\n", + " feedback = env.place(row, col, number)\n", + " print(f\" Move: [{row} {col} {number}]\")\n", + " print(f\" Progress reward: {env.progress_reward:.2f}\")\n", + " print()\n", + "\n", + " messages.append({\"role\": \"assistant\", \"content\": generated_text})\n", + " messages.append({\"role\": \"user\", \"content\": feedback})\n", + " except Exception as e:\n", + " print(f\" Error: {e}\")\n", + " break\n", + "\n", + " print(f\"Game finished! Correct reward: {env.correct_reward}\")\n", + " print(f\"Progress: {env.progress_reward:.2f}\")\n", + " print(f\"Done: {env.done}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's play the game!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "play_sudoku(fine_tuned_model, tokenizer)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "A100", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.11.0" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/openenv_wordle_grpo.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/openenv_wordle_grpo.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..2ecc044a8f97afa69146489ece96797a4c3de824 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/openenv_wordle_grpo.ipynb @@ -0,0 +1,522 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# OpenEnv Wordle with GRPO using TRL\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/openenv_wordle_grpo.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)\n", + "\n", + "\n", + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can train a model that learns to **play Wordle**, a word-guessing game, through interaction and reinforcement.\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) -- star us to support the project!\n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview)\n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)\n", + "- [OpenEnv](https://github.com/meta-pytorch/OpenEnv)\n", + "\n", + "\n", + "An **agentic environment** is a setting where a model can take actions, observe outcomes, and adjust its behavior based on feedback, similar to how humans learn from trial and error.\n", + "In this case, the agent interacts with the **Wordle** environment through the [**OpenEnv**](https://github.com/meta-pytorch/OpenEnv) framework, which standardizes multi-agent and RL-style text environments.\n", + "\n", + "[Wordle](https://en.wikipedia.org/wiki/Wordle) is a popular word puzzle where the player must guess a secret five-letter word within six tries.\n", + "After each guess, feedback indicates whether each letter is:\n", + "- **GREEN (G)**: Correct and in the right position\n", + "- **YELLOW (Y)**: Present but in the wrong position\n", + "- **GRAY (X)**: Not in the word\n", + "\n", + "This feedback loop makes Wordle a perfect environment for **RL with LLMs**, where the goal is to maximize the probability of guessing the correct word efficiently.\n", + "\n", + "\n", + "We'll fine-tune a model using **GRPO** (Group Relative Policy Optimization) via TRL.\n", + "Using `environment_factory`, the trainer automatically handles:\n", + "1. Creating environment instances for each rollout.\n", + "2. Generating model completions and parsing tool calls.\n", + "3. Stepping through the environment with the model's actions.\n", + "4. Collecting rewards and managing the interaction loop.\n", + "\n", + "This means you only need to define the environment class and reward function -- the trainer takes care of the rest.\n", + "\n", + "\n", + "## Install dependencies\n", + "\n", + "We'll start by installing **TRL** (with vLLM support), the **OpenEnv** Wordle environment, and **trackio** for logging." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install -Uq trl[vllm] git+https://huggingface.co/spaces/openenv/wordle trackio" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define the system prompt\n", + "\n", + "This prompt instructs the model on how to play Wordle. It includes the game rules, feedback format, and importantly, tells the model to use the `guess` tool to submit guesses. The `environment_factory` pattern uses tool calling to interact with the environment, so the model needs to know which tool to call." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "prompt = \"\"\"You are an expert Wordle solver with deep knowledge of English vocabulary, letter frequency patterns, and optimal guessing strategies.\n", + "\n", + "Follow these rules to play Wordle:\n", + "\n", + "1. The target is a 5-letter English word\n", + "2. You have 6 attempts to guess the correct word\n", + "3. After each guess, you receive color-coded feedback:\n", + " - GREEN (G): Letter is correct and in the correct position\n", + " - YELLOW (Y): Letter is in the word but in the wrong position\n", + " - GRAY (X): Letter is not in the word at all\n", + "4. All guesses must be valid 5-letter English words\n", + "5. You cannot reuse a word you've already guessed\n", + "6. Use the tool `guess` to make a guess.\n", + "\"\"\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define the environment\n", + "\n", + "The `WordleEnv` class wraps the OpenEnv TextArena Wordle environment into the interface expected by `environment_factory`.\n", + "\n", + "When you pass `environment_factory=WordleEnv` to the trainer, it will:\n", + "1. Create a new `WordleEnv()` instance for each rollout episode.\n", + "2. Call `reset()` to start a new game (returns the initial observation or `None`).\n", + "3. Automatically generate model completions, parse tool calls, and invoke the corresponding methods (e.g., `guess(...)`).\n", + "4. Repeat until the environment signals `done=True` or the max completion length is reached.\n", + "\n", + "The environment exposes its public methods as tools. Any public method (other than `reset`) with a docstring is automatically discovered and exposed as a callable tool. Here, the `guess` method lets the model submit a Wordle guess and receive feedback.\n", + "\n", + "For this example, we connect to the hosted environment at [openenv/wordle](https://huggingface.co/spaces/openenv/wordle).\n", + "For production use, we recommend duplicating the Space to your own account or running it locally via Docker, as the hosted versions have limited concurrency.\n", + "\n", + "For more information, refer to the [TRL-OpenEnv documentation](https://huggingface.co/docs/trl/main/en/openenv)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from textarena_env import TextArenaAction, TextArenaEnv\n", + "\n", + "\n", + "class WordleEnv:\n", + " def __init__(self):\n", + " self.client = TextArenaEnv(base_url=\"https://openenv-wordle.hf.space\")\n", + "\n", + " def reset(self, **kwargs) -> None | str:\n", + " result = self.client.reset()\n", + " # The game returns cumulative feedback each turn (new text appended at the end), so\n", + " # we store the previous full response and slice out only the newly appended part.\n", + " self._last_full_feedback = result.observation.messages[0].content\n", + " self.reward = 0.0\n", + " self.done = False\n", + " return self._last_full_feedback\n", + "\n", + " def guess(self, guess: str) -> str:\n", + " \"\"\"\n", + " Make a guess in the Wordle environment.\n", + "\n", + " Args:\n", + " guess: The guessed word, formatted as '[abcde]'\n", + "\n", + " Returns:\n", + " The feedback message from the environment.\n", + " \"\"\"\n", + " if self.done:\n", + " raise ValueError(\"Game over.\")\n", + " result = self.client.step(TextArenaAction(message=guess))\n", + " _full_feedback = result.observation.messages[0].content\n", + " # Just take the new feedback since the last guess\n", + " feedback = _full_feedback[len(self._last_full_feedback):]\n", + " self._last_full_feedback = _full_feedback\n", + " # Penalize invalid moves\n", + " if \"You attempted an invalid move\" in feedback:\n", + " self.reward = 0.0\n", + " else:\n", + " self.reward = result.reward\n", + " self.done = result.done\n", + " return feedback" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define the reward function\n", + "\n", + "The reward function receives the list of environment instances after each episode completes. Since the `WordleEnv` tracks its own reward (updated after each `guess` call), we simply read it out.\n", + "\n", + "This is much simpler than defining multiple reward functions manually -- the environment already knows the game outcome." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def reward_func(environments, **kwargs) -> list[float]:\n", + " return [env.reward for env in environments]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create the dataset\n", + "\n", + "We create a dataset with repeated prompts to control the number of training episodes.\n", + "Each entry triggers one rollout episode during training. The prompt is formatted as a chat message." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from datasets import Dataset\n", + "\n", + "dataset = Dataset.from_dict({\"prompt\": [[{\"role\": \"user\", \"content\": prompt}] for _ in range(3000)]})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set GRPO Config\n", + "\n", + "Next, we define the **GRPOConfig**, which controls all key training parameters.\n", + "This configuration specifies how the model interacts with vLLM, manages memory, and logs results.\n", + "\n", + "Note the `chat_template_kwargs={\"enable_thinking\": False}` parameter -- this disables Qwen3's thinking mode so the model responds directly with tool calls instead of generating internal reasoning tokens first." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from trl import GRPOConfig\n", + "\n", + "model_name = \"Qwen/Qwen3-1.7B\"\n", + "output_dir = \"wordle-grpo-Qwen3-1.7B\"\n", + "\n", + "grpo_config = GRPOConfig(\n", + " # Training schedule / optimization\n", + " num_train_epochs=1,\n", + " learning_rate=1e-6,\n", + " gradient_accumulation_steps=64,\n", + " per_device_train_batch_size=1,\n", + " warmup_steps=10,\n", + " optim=\"adamw_torch\",\n", + " max_grad_norm=1.0,\n", + "\n", + " # GRPO configuration\n", + " num_generations=2,\n", + " max_completion_length=1024,\n", + " log_completions=True,\n", + " num_completions_to_print=2,\n", + " chat_template_kwargs={\"enable_thinking\": False},\n", + "\n", + " # vLLM configuration\n", + " use_vllm=True,\n", + " vllm_mode=\"colocate\",\n", + " vllm_gpu_memory_utilization=0.15,\n", + " vllm_max_model_length=3072,\n", + "\n", + " # Logging / reporting\n", + " output_dir=output_dir,\n", + " report_to=\"trackio\",\n", + " trackio_space_id=output_dir,\n", + " logging_steps=1,\n", + " save_steps=10,\n", + " save_total_limit=1,\n", + "\n", + " # Memory optimization\n", + " gradient_checkpointing=True,\n", + "\n", + " # Hub integration\n", + " push_to_hub=True,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create the `GRPOTrainer` and start training\n", + "\n", + "Now we initialize the `GRPOTrainer` with `environment_factory=WordleEnv`.\n", + "\n", + "This tells the trainer to automatically handle the entire interaction loop:\n", + "- It creates a `WordleEnv` instance for each episode.\n", + "- It generates model completions, parses tool calls (like `guess`), and steps through the environment.\n", + "- It collects rewards and manages the `tool_mask` (which tokens are model-generated vs environment-generated) automatically.\n", + "\n", + "No need to write a custom `rollout_func` or manage tokenization manually." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from trl import GRPOTrainer\n", + "\n", + "trainer = GRPOTrainer(\n", + " model=model_name,\n", + " reward_funcs=reward_func,\n", + " train_dataset=dataset,\n", + " args=grpo_config,\n", + " environment_factory=WordleEnv,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import torch\n", + "\n", + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_training = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "training_memory_percentage = round(used_memory_for_training / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_training} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {training_memory_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Save and push to Hub" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now let's test our fine-tuned model by loading it and playing a game of Wordle.\n", + "We use the same `WordleEnv` class to interact with the environment, and generate model responses with standard Transformers inference." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from transformers import AutoModelForCausalLM, AutoTokenizer\n", + "\n", + "model_name = \"sergiopaniego/wordle-grpo-Qwen3-1.7B\" # Replace with your HF username or organization\n", + "\n", + "fine_tuned_model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=\"float32\", device_map=\"auto\")\n", + "tokenizer = AutoTokenizer.from_pretrained(model_name)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "\n", + "\n", + "def play_wordle(model, tokenizer):\n", + " env = WordleEnv()\n", + " initial_observation = env.reset()\n", + "\n", + " print(\"Initial observation:\")\n", + " print(initial_observation)\n", + " print()\n", + "\n", + " messages = [{\"role\": \"user\", \"content\": prompt}]\n", + " if initial_observation:\n", + " messages.append({\"role\": \"user\", \"content\": initial_observation})\n", + "\n", + " for turn in range(6):\n", + " if env.done:\n", + " break\n", + "\n", + " prompt_text = tokenizer.apply_chat_template(\n", + " messages,\n", + " add_generation_prompt=True,\n", + " tokenize=False,\n", + " enable_thinking=False,\n", + " )\n", + " model_inputs = tokenizer([prompt_text], return_tensors=\"pt\").to(model.device)\n", + " generated_ids = model.generate(**model_inputs, max_new_tokens=512)\n", + " output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]\n", + " generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)\n", + "\n", + " print(f\"Turn {turn + 1} - Model output: {generated_text}\")\n", + "\n", + " # Try to parse tool call from the generated text\n", + " try:\n", + " # Try to extract a guess from tool call format or bracket format\n", + " if \"guess\" in generated_text:\n", + " # Parse JSON tool call\n", + " start = generated_text.index(\"{\")\n", + " end = generated_text.rindex(\"}\") + 1\n", + " args = json.loads(generated_text[start:end])\n", + " if \"arguments\" in args:\n", + " args = args[\"arguments\"]\n", + " guess_word = args.get(\"guess\", \"\")\n", + " else:\n", + " # Fallback: extract from brackets [word]\n", + " import re\n", + " match = re.search(r\"\\[([a-zA-Z]{5})\\]\", generated_text)\n", + " guess_word = match.group(1) if match else generated_text.strip()[:5]\n", + "\n", + " feedback = env.guess(f\"[{guess_word}]\")\n", + " print(f\" Guess: {guess_word} | Reward: {env.reward}\")\n", + " print(f\" Feedback: {feedback.strip()}\")\n", + " print()\n", + "\n", + " messages.append({\"role\": \"assistant\", \"content\": generated_text})\n", + " messages.append({\"role\": \"user\", \"content\": feedback})\n", + " except Exception as e:\n", + " print(f\" Error: {e}\")\n", + " break\n", + "\n", + " print(f\"Game finished! Final reward: {env.reward}\")\n", + " print(f\"Done: {env.done}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's play the game!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "play_wordle(fine_tuned_model, tokenizer)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_ministral3_vl.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_ministral3_vl.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..e802be712253bb1c1fdc62dfcdf80eb7c1474dc4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_ministral3_vl.ipynb @@ -0,0 +1,736 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "UaDIwQOOjgAO" + }, + "source": [ + "# Supervised Fine-Tuning (SFT) Ministral-3 with QLoRA using TRL\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_ministral3_vl.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4f0hzSo4kKEc" + }, + "source": [ + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can fine-tune cutting edge vision language models. It comes with support for quantized parameter efficient fine-tuning technique **QLoRA**, so we can use free Colab (T4 GPU) to fine-tune models like [Ministral-3](https://huggingface.co/collections/mistralai/ministral-3).\n", + "\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples (notebooks and scripts)](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pGXgIbj2kXEP" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which ensures all main dependencies such as **Transformers** and **PEFT** (a package for parameter-efficient fine-tuning, e.g., LoRA/QLoRA) are included. Additionally, we'll install **trackio** to log and monitor our experiments, and **bitsandbytes** to enable quantization of LLMs, reducing memory consumption for both inference and training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "V8rqrGq3hmeU", + "outputId": "4a15adc2-e895-4c40-d174-c52e0b208dd5" + }, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[peft]\" bitsandbytes trackio git+https://github.com/huggingface/transformers mistral-common" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Ou0VO1gHklS-" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "C5eHAVFthmeU" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "vNylrNdqkoN-" + }, + "source": [ + "## Load dataset\n", + "\n", + "\n", + "We'll load the [**trl-lib/llava-instruct-mix**](https://huggingface.co/datasets/trl-lib/llava-instruct-mix) dataset from the Hugging Face Hub using the `datasets` library.\n", + "\n", + "This dataset is a set of GPT-generated multimodal instruction-following data. We use a processed version for conveniency here. You can check out more details about how to configure your own multimodal dataset for traininig with SFT in the [docs](https://huggingface.co/docs/trl/en/sft_trainer#training-vision-language-models). Fine-tuning Ministral-3 on it helps refine its response style and visual understanding.\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "e0bb4423267a4572b1b9cc894edd25c5" + ] + }, + "id": "hOPra_x5hmeU", + "outputId": "112a213e-0036-452f-e0a8-9295da13c3d1" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_name = \"trl-lib/llava-instruct-mix\"\n", + "train_dataset = load_dataset(dataset_name, split=\"train[:10%]\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "JFtR4Xyx4FYO" + }, + "source": [ + "Let's review one example to understand the internal structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "vYJGczm6hmeV", + "outputId": "0a9d8771-51bd-4b68-c1b0-d8b96da9b56d" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'images': [],\n", + " 'prompt': [{'content': \"How can the presentation of this meal influence one's eating experience?\",\n", + " 'role': 'user'}],\n", + " 'completion': [{'content': \"The presentation of this meal can positively influence one's eating experience. In the image, colorful plastic trays and bowls are used to hold a variety of foods, including meat, vegetables, fruit, and bread. The vibrant presentation can make the meal more visually appealing and enticing, which may encourage healthier eating habits as the dishes include nutritious options like broccoli and oranges. Diverse food options and attractive meal presentation can also make the dining experience more enjoyable and satisfying. Moreover, the bright colors and well-organized food placement can create a positive atmosphere, enhancing one's overall dining experience.\",\n", + " 'role': 'assistant'}]}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qeZCtRB1m5xj" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration.\n", + "\n", + "> **Note:**\n", + "> In older GPUs (including those available on Colab), **FP8 support** is limited, so we use the BF16 version of the model.\n", + "> In that case, you can select the official checkpoint or the one from Unsloth.\n", + "> If you have access to GPUs with **FP8 support**, you can switch to that version instead." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "5fa6df349d314dd8b1baf79c1ed4eb0b", + "f561335214d84bf1b8985dd4573e9ae1", + "0c557dfead7d46e99af2c6e77b050930" + ] + }, + "id": "8dggHeG2hmeV", + "outputId": "58ceedc1-26b3-467d-f466-e76d850aca5f" + }, + "outputs": [], + "source": [ + "from transformers import Mistral3ForConditionalGeneration, FineGrainedFP8Config, BitsAndBytesConfig\n", + "import torch\n", + "\n", + "FP8 = False\n", + "\n", + "if FP8:\n", + " model_name = \"mistralai/Ministral-3-3B-Instruct-2512\"\n", + " quantization_config = FineGrainedFP8Config(dequantize=False)\n", + "else:\n", + " model_name = \"mistralai/Ministral-3-3B-Instruct-2512-BF16\" # \"unsloth/Ministral-3-3B-Instruct-2512\"\n", + " quantization_config = BitsAndBytesConfig(\n", + " load_in_4bit=True, # Load the model in 4-bit precision to save memory\n", + " bnb_4bit_compute_dtype=torch.float16, # Data type used for internal computations in quantization\n", + " bnb_4bit_use_double_quant=True, # Use double quantization to improve accuracy\n", + " bnb_4bit_quant_type=\"nf4\", # Type of quantization. \"nf4\" is recommended for recent LLMs\n", + " )\n", + "\n", + "model = Mistral3ForConditionalGeneration.from_pretrained(\n", + " model_name,\n", + " dtype=\"float32\",\n", + " device_map=\"auto\",\n", + " quantization_config=quantization_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "jyklRvNxnHmy" + }, + "source": [ + "The following cell defines LoRA (or QLoRA if needed). When training with LoRA/QLoRA, we use a **base model** (the one selected above) and, instead of modifying its original weights, we fine-tune a **LoRA adapter** — a lightweight layer that enables efficient and memory-friendly training. The **`target_modules`** specify which parts of the model (e.g., attention or projection layers) will be adapted by LoRA during fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "8wI1Cqk4hmeV" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "# You may need to update `target_modules` depending on the architecture of your chosen model.\n", + "# For example, different VLMs might have different attention/projection layer names.\n", + "peft_config = LoraConfig(\n", + " r=32,\n", + " lora_alpha=32,\n", + " target_modules=['down_proj','o_proj','k_proj','q_proj','gate_proj','up_proj','v_proj'],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mBAfaiA-nbdm" + }, + "source": [ + "## Train model\n", + "\n", + "We'll configure **SFT** using `SFTConfig`, keeping the parameters minimal so the training fits on a free Colab instance. You can adjust these settings if more resources are available. For full details on all available parameters, check the [TRL SFTConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.SFTConfig)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "FrbfENGThmeV" + }, + "outputs": [], + "source": [ + "from trl import SFTConfig\n", + "\n", + "output_dir = \"Ministral-3-3B-Instruct-trl-sft\"\n", + "\n", + "training_args = SFTConfig(\n", + " # Training schedule / optimization\n", + " #num_train_epochs=1,\n", + " max_steps=10, # Number of dataset passes. For full trainings, use `num_train_epochs` instead\n", + " per_device_train_batch_size=2, # Batch size per GPU/CPU\n", + " gradient_accumulation_steps=8, # Gradients are accumulated over multiple steps → effective batch size = 4 * 8 = 32\n", + " warmup_steps=5, # Gradually increase LR during first N steps\n", + " learning_rate=2e-4, # Learning rate for the optimizer\n", + " optim=\"adamw_8bit\", # Optimizer\n", + " max_length=None, # For VLMs, truncating may remove image tokens, leading to errors during training. max_length=None avoids it\n", + "\n", + " # Logging / reporting\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + " logging_steps=1, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + " trackio_space_id = output_dir,\n", + "\n", + " # Hub integration\n", + " push_to_hub=True,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bF4GtNO2ne1k" + }, + "source": [ + "Configure the SFT Trainer. We pass the previously configured `training_args`. We don't use eval dataset to maintain memory usage low but you can configure it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "JjLhVbO_hmeV" + }, + "outputs": [], + "source": [ + "from trl import SFTTrainer\n", + "\n", + "trainer = SFTTrainer(\n", + " model=model,\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "K9Ub3jTDnfcD" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "p3UUrqCWhmeV", + "outputId": "992da74b-7e6b-41f0-cb71-320203c1d6d9" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GPU = Tesla T4. Max memory = 14.741 GB.\n", + "6.346 GB of memory reserved.\n" + ] + } + ], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4NiFu9tcniBP" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "MA8py8DghmeV", + "outputId": "b68f35e1-cfdd-413f-b3d7-5afa4d30aac5" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Trackio project initialized: huggingface\n", + "* Trackio metrics will be synced to Hugging Face Dataset: sergiopaniego/Ministral-3-3B-Instruct-trl-sft-dataset\n", + "* Creating new space: https://huggingface.co/spaces/sergiopaniego/Ministral-3-3B-Instruct-trl-sft\n", + "* View dashboard by going to: https://sergiopaniego-Ministral-3-3B-Instruct-trl-sft.hf.space/\n" + ] + }, + { + "data": { + "text/html": [ + "

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Created new run: sergiopaniego-1764766746\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.12/dist-packages/torch/_dynamo/eval_frame.py:1044: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. Starting in PyTorch 2.9, calling checkpoint without use_reentrant will raise an exception. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " return fn(*args, **kwargs)\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " [10/10 44:39, Epoch 0/1]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining Loss
11.979992
21.894323
31.924157
41.396819
51.357613
61.345677
71.356363
81.399492
91.356316
101.307108

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Run finished. Uploading logs to Trackio (please wait...)\n" + ] + } + ], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "miZ2I1A9nnM4" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "eUi4ww17hmeV", + "outputId": "24b18fc3-cb0f-40a1-954d-c3b4d799dfbb" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2492.1064 seconds used for training.\n", + "41.54 minutes used for training.\n", + "Peak reserved memory = 13.881 GB.\n", + "Peak reserved memory for training = 7.535 GB.\n", + "Peak reserved memory % of max memory = 94.166 %.\n", + "Peak reserved memory for training % of max memory = 51.116 %.\n" + ] + } + ], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "3lrrYfPunloQ" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "ee7d9fe2f71343a4a4832fd2b0fef66f", + "7afb48c0ac514171aa052210e9063fe7", + "7047f7b527284d958df2ec5e800cce56", + "8a106d43be4948ffbb2a2a5281882fe0", + "1f3deb9e16554fd0a4666d52fa9992b2", + "4cb20a75e85a495a8a3b36eb513db36b", + "7ded518429454b5aa2230f98ba0d014c", + "7112497495a742a887c4c956cdf46777", + "cae8cfc256f649d5aa367f923b4aeb5f", + "1a2cfcd18f5f496fa4f6bcf5c0a33966" + ] + }, + "id": "S7TzHDwXhmeV", + "outputId": "0d465e97-5459-4f59-84cf-d5c374503a3b" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pFq51FWEK1DX" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Xh4fo-WzhmeV" + }, + "outputs": [], + "source": [ + "output_dir = \"Ministral-3-3B-Instruct-trl-sft\"\n", + "# model_name = \"mistralai/Ministral-3-3B-Instruct-2512\"\n", + "model_name = \"mistralai/Ministral-3-3B-Instruct-2512-BF16\" # \"unsloth/Ministral-3-3B-Instruct-2512\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "5b4514b95d7742a5a2cc777478a152b7", + "fdfc2ee13efa40218ab315641eb62fb7", + "9aad01ac11794c9ca74d1a442e715da5", + "384a08933c11424cbc48dc28f33ec90e" + ] + }, + "id": "z9S319H-hmeV", + "outputId": "6b5ef891-cc0d-44ba-b112-3c577247a295" + }, + "outputs": [], + "source": [ + "from transformers import Mistral3ForConditionalGeneration, MistralCommonBackend\n", + "from peft import PeftModel\n", + "\n", + "base_model = model_name\n", + "adapter_model = f\"{output_dir}\" # Replace with your HF username or organization + fine-tuned model name\n", + "\n", + "model = Mistral3ForConditionalGeneration.from_pretrained(base_model, dtype=\"float32\", device_map=\"auto\")\n", + "model = PeftModel.from_pretrained(model, adapter_model)\n", + "\n", + "tokenizer = MistralCommonBackend.from_pretrained(base_model)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "EvObNndEhmeW" + }, + "outputs": [], + "source": [ + "import base64\n", + "from io import BytesIO\n", + "\n", + "problem = train_dataset[0]['prompt'][0]['content']\n", + "image = train_dataset[0]['images'][0]\n", + "\n", + "buffer = BytesIO()\n", + "image.save(buffer, format=\"JPEG\")\n", + "image_bytes = buffer.getvalue()\n", + "image_b64 = base64.b64encode(image_bytes).decode(\"utf-8\")\n", + "\n", + "messages = [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\n", + " \"type\": \"image_url\",\n", + " \"image_url\": {\n", + " \"url\": f\"data:image/jpeg;base64,{image_b64}\"\n", + " },\n", + " },\n", + " {\"type\": \"text\", \"text\": problem},\n", + " ],\n", + " },\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "yjBaVAevhmeW", + "outputId": "47695454-856a-40b9-8ab2-d621c6e6b3da" + }, + "outputs": [], + "source": [ + "messages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "CD2BVqCBhmeW", + "outputId": "fe1e612b-209f-4223-eaf3-9432deb0d467" + }, + "outputs": [ + { + "data": { + "image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAHgAoADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYa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sw8sjFEoBCVC+AQ1Qqu6rOTA0SoihJfUgslo6lqnFsnXqljEUQI5REEJa3Sn5QXb0BvT+dqUYTAuHT4Lbb3X1v/HM0VmqL50xxEIdMWmuTq0hFFj2gs1IerSLaRVwnt0RWPQEP+guV1IBNM6MKkLJ4KIXNMTvoJSIHJLNL8XPKk3NbwGHU+ERJUpB+u8q+duGd8DTSI5KmuTTipLUXoD0YgfhdMfSsDrKcVWbpwgIoB7SBgYdDT1JRpbQV57IyvRAxK8I66OqBP8JERc8QdogIRgyzCvirlTPFoalYBUocWihdiBDKQwoIAQqTFsuYfTC0etXe+x6mEOunr745Oj5NGDi0GK+rmLRqhJmmtbG5XARyy5CMpqO5GAkiiF6K1Qqy5+qsDmvnQN+u3VtWLzfdGfP7pqcW5/34HuCm5HATK9ZUDNlkjOdF90HQIDvY73l8rWidGg22EJCW4YUAAphaIMrLiA3D08nKkYITHlbZqliI/wsHFGRU3db9AAAAAABJRU5ErkJggg==", + "text/plain": [ + "" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "image" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "YU3hwodphmeW", + "outputId": "7e1757f6-0c77-477a-c35a-2429d8020374" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The presentation of the meal, which is divided into three compartments in a lunch box, can significantly influence one's eating experience. The compartmentalized design allows for a visually appealing and organized presentation of the food, making it more enticing and appetizing. The variety of food items, such as the sandwich, chips, and fruit, also adds to the visual appeal and encourages a balanced and nutritious meal. The compartmentalized layout can also make it easier for the person eating the meal to access and enjoy each component of the meal, as they can easily reach for the food they want without having to rearrange the entire meal. Overall, the presentation of the meal can enhance the eating experience by making it more enjoyable, visually appealing, and convenient.\n" + ] + } + ], + "source": [ + "import torch\n", + "\n", + "tokenized = tokenizer.apply_chat_template(messages, return_tensors=\"pt\", return_dict=True)\n", + "tokenized[\"input_ids\"] = tokenized[\"input_ids\"].to(device=\"cuda\")\n", + "tokenized[\"pixel_values\"] = tokenized[\"pixel_values\"].to(dtype=torch.bfloat16, device=\"cuda\")\n", + "image_sizes = [tokenized[\"pixel_values\"].shape[-2:]]\n", + "\n", + "output = model.generate(\n", + " **tokenized,\n", + " image_sizes=image_sizes,\n", + " max_new_tokens=512,\n", + ")[0]\n", + "\n", + "decoded_output = tokenizer.decode(output[len(tokenized[\"input_ids\"][0]):])\n", + "print(decoded_output)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_nemotron_3.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_nemotron_3.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..9594c623ff86eb720e65d25b69758b227f26734d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_nemotron_3.ipynb @@ -0,0 +1,974 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "ovlmqboji0c", + "metadata": { + "id": "ovlmqboji0c" + }, + "source": "# Fine-Tune NVIDIA Nemotron 3 with SFT and LoRA using TRL\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_nemotron_3.ipynb)" + }, + { + "cell_type": "markdown", + "id": "kiezlcdkw2k", + "metadata": { + "id": "kiezlcdkw2k" + }, + "source": [ + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)" + ] + }, + { + "cell_type": "markdown", + "id": "ezgoxs28857", + "metadata": { + "id": "ezgoxs28857" + }, + "source": "Fine-tune [**NVIDIA Nemotron 3**](https://huggingface.co/collections/nvidia/nvidia-nemotron-v3) models using **LoRA** and **SFT** with the [**TRL**](https://github.com/huggingface/trl) library.\n\nThe Nemotron 3 family includes hybrid **Mamba2/Transformer** models in different sizes (Nano, Super, etc.), natively supported in `transformers` (no `trust_remote_code` needed). See the [full collection](https://huggingface.co/collections/nvidia/nvidia-nemotron-v3) for all available checkpoints.\n\n> **Note:** This notebook requires a GPU with sufficient VRAM (e.g., A100 80GB). It is not designed for free Colab instances.\n\n- [TRL GitHub Repository](https://github.com/huggingface/trl)\n- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview)" + }, + { + "cell_type": "markdown", + "id": "5t9o6vg3jus", + "metadata": { + "id": "5t9o6vg3jus" + }, + "source": "## Install dependencies\n\nWe install **TRL** with the **PEFT** and **quantization** extras, along with **trackio** for experiment tracking. Nemotron 3 models use **Mamba2** layers, which require the `mamba_ssm` and `causal_conv1d` CUDA kernels." + }, + { + "cell_type": "code", + "execution_count": null, + "id": "wh29y02x1ni", + "metadata": { + "id": "wh29y02x1ni" + }, + "outputs": [], + "source": "!pip install -Uq \"trl[peft,quantization]\" trackio\n\n# Nemotron 3 requires transformers>=5.3.0, which may not be installed by default with TRL\n!pip install -Uq \"transformers>=5.3.0\"\n\n# Mamba2 CUDA kernels (--no-build-isolation needed so they find your PyTorch/CUDA installation)\n!pip install --no-build-isolation mamba_ssm==2.2.5 # installation takes around 30 mins\n!pip install --no-build-isolation causal_conv1d==1.5.2" + }, + { + "cell_type": "markdown", + "id": "yic7cr26xoi", + "metadata": { + "id": "yic7cr26xoi" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model and track experiments on the Hub. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "wwocbqwne49", + "metadata": { + "id": "wwocbqwne49", + "outputId": "f8a3f993-63a5-4a11-ea41-5a0093cec19c", + "colab": { + "referenced_widgets": [ + "20976278f8564bc080426e851d52f46f" + ] + } + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.12/dist-packages/huggingface_hub/utils/_auth.py:86: UserWarning: \n", + "Access to the secret `HF_TOKEN` has not been granted on this notebook.\n", + "You will not be requested again.\n", + "Please restart the session if you want to be prompted again.\n", + " warnings.warn(\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "20976278f8564bc080426e851d52f46f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(HTML(value='

...` tags. We also remove the extra columns that are not needed for training:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "oxzelzs2kf", + "metadata": { + "id": "oxzelzs2kf" + }, + "outputs": [], + "source": [ + "def merge_thinking_and_remove_key(example):\n", + " new_messages = []\n", + " for msg in example[\"messages\"]:\n", + " content = msg[\"content\"]\n", + " thinking = msg.get(\"thinking\")\n", + " if thinking and isinstance(thinking, str) and thinking.strip():\n", + " content = f\"\\n{thinking}\\n\\n{content}\"\n", + " new_messages.append({\"role\": msg[\"role\"], \"content\": content})\n", + " example[\"messages\"] = new_messages\n", + " return example\n", + "\n", + "train_dataset = train_dataset.remove_columns([\"reasoning_language\", \"developer\", \"user\", \"analysis\", \"final\"])\n", + "train_dataset = train_dataset.map(merge_thinking_and_remove_key)" + ] + }, + { + "cell_type": "markdown", + "id": "gyh82o2b7i7", + "metadata": { + "id": "gyh82o2b7i7" + }, + "source": "## Load model and configure LoRA\n\nLoad an **NVIDIA Nemotron 3** model. These models are natively supported in `transformers` so no `trust_remote_code` is needed. We use `attn_implementation=\"eager\"` as required by the hybrid Mamba2/Transformer architecture." + }, + { + "cell_type": "code", + "execution_count": null, + "id": "asrptlebp6a", + "metadata": { + "id": "asrptlebp6a" + }, + "outputs": [], + "source": "import torch\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\n# Select a Nemotron 3 checkpoint below\nmodel_id = \"nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16\"\n# model_id = \"nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-Base-BF16\"\n\noutput_dir = \"nemotron-3-sft\"\n\nmodel = AutoModelForCausalLM.from_pretrained(\n model_id,\n attn_implementation=\"eager\",\n dtype=torch.bfloat16,\n)\ntokenizer = AutoTokenizer.from_pretrained(model_id)" + }, + { + "cell_type": "markdown", + "id": "90a8pzer8rc", + "metadata": { + "id": "90a8pzer8rc" + }, + "source": [ + "Configure the **LoRA adapter**. Instead of modifying the original weights, we fine-tune a lightweight LoRA adapter for efficient and memory-friendly training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "pyukji9o3g", + "metadata": { + "id": "pyukji9o3g" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "peft_config = LoraConfig(\n", + " r=8,\n", + " lora_alpha=16,\n", + " target_modules=[\n", + " \"q_proj\",\n", + " \"k_proj\",\n", + " \"v_proj\",\n", + " \"o_proj\",\n", + " \"gate_proj\",\n", + " \"up_proj\",\n", + " \"down_proj\",\n", + " ],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "rkxovj1wywh", + "metadata": { + "id": "rkxovj1wywh" + }, + "source": "## Train model\n\nConfigure **SFT** using `SFTConfig`. Note that `gradient_checkpointing` is set to `False` because Nemotron 3 (`NemotronHForCausalLM`) does not support it. For full details on all available parameters, check the [TRL SFTConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.SFTConfig)." + }, + { + "cell_type": "code", + "execution_count": null, + "id": "tdmoy72oow", + "metadata": { + "id": "tdmoy72oow" + }, + "outputs": [], + "source": [ + "from trl import SFTConfig\n", + "\n", + "training_args = SFTConfig(\n", + " # Training schedule / optimization\n", + " per_device_train_batch_size=1, # Batch size per GPU\n", + " gradient_accumulation_steps=4, # Effective batch size = per_device_train_batch_size * gradient_accumulation_steps\n", + " num_train_epochs=1, # Number of full dataset passes\n", + " learning_rate=2e-4, # Learning rate for the optimizer\n", + " optim=\"paged_adamw_8bit\", # Memory-efficient 8-bit optimizer\n", + "\n", + " # Logging / reporting\n", + " logging_steps=10, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + " trackio_space_id=output_dir, # HF Space where the experiment tracking will be saved\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + "\n", + " max_length=128, # Kept short due to VRAM constraints; increase for better results\n", + " gradient_checkpointing=False, # NemotronH does not support gradient checkpointing\n", + "\n", + " # Hub integration\n", + " push_to_hub=True, # Push the trained model to the Hugging Face Hub\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "4ciesqgt2ch", + "metadata": { + "id": "4ciesqgt2ch" + }, + "source": [ + "Configure the SFT Trainer. We pass the previously configured `training_args` and the `peft_config` for LoRA." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "h0i5c9sd1ip", + "metadata": { + "id": "h0i5c9sd1ip" + }, + "outputs": [], + "source": [ + "from trl import SFTTrainer\n", + "\n", + "trainer = SFTTrainer(\n", + " model=model,\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "q1t7v0lba6l", + "metadata": { + "id": "q1t7v0lba6l" + }, + "source": [ + "Show memory stats before training:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b4e0fseivvu", + "metadata": { + "id": "b4e0fseivvu", + "outputId": "94e1ffbb-639c-4dba-d2b7-2d1de0f493bf" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GPU = NVIDIA A100-SXM4-80GB. Max memory = 79.251 GB.\n", + "58.939 GB of memory reserved.\n" + ] + } + ], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "id": "1x3fdnogsvh", + "metadata": { + "id": "1x3fdnogsvh" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3ev9j7op2mi", + "metadata": { + "id": "3ev9j7op2mi", + "outputId": "d6db6cdb-8d43-4cc6-e024-e77c266090f7" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'eos_token_id': 11, 'pad_token_id': None}.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Trackio project initialized: huggingface\n", + "* Trackio metrics will be synced to Hugging Face Dataset: sergiopaniego/nemotron-3-sft-dataset\n", + "* Creating new space: https://huggingface.co/spaces/sergiopaniego/nemotron-3-sft\n", + "* View dashboard by going to: https://sergiopaniego-nemotron-3-sft.hf.space/\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* NVIDIA GPU detected, enabling automatic GPU metrics logging\n", + "* Created new run: sergiopaniego-1773149018\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.12/dist-packages/transformers/models/nemotron_h/modeling_nemotron_h.py:1215: FutureWarning: `input_embeds` is deprecated and will be removed in version 5.6.0 for `create_causal_mask`. Use `inputs_embeds` instead.\n", + " causal_mask = create_causal_mask(\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " [250/250 08:53, Epoch 1/1]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining Loss
102.379619
201.849189
301.466606
401.207237
501.064882
601.067329
701.085463
800.964451
900.993209
1001.061509
1100.976885
1200.939225
1301.011990
1400.989627
1500.946731
1600.939989
1700.920945
1801.003975
1900.945233
2000.958358
2101.022524
2200.953711
2301.033258
2400.955309
2500.959105

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Run finished. Uploading logs to Trackio Space (please wait...)\n" + ] + } + ], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "id": "ngrmymxpbp", + "metadata": { + "id": "ngrmymxpbp" + }, + "source": [ + "Show memory stats after training:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "08gpt482fn1k", + "metadata": { + "id": "08gpt482fn1k", + "outputId": "e4808857-5756-4f5d-d34c-29c81107a618" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "542.949 seconds used for training.\n", + "9.05 minutes used for training.\n", + "Peak reserved memory = 61.922 GB.\n", + "Peak reserved memory for training = 2.983 GB.\n", + "Peak reserved memory % of max memory = 78.134 %.\n", + "Peak reserved memory for training % of max memory = 3.764 %.\n" + ] + } + ], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "id": "pkp4wfpwpxh", + "metadata": { + "id": "pkp4wfpwpxh" + }, + "source": [ + "## Save fine-tuned model\n", + "\n", + "Save the fine-tuned model both **locally** and to the **Hugging Face Hub**." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "g2j7qp1ycxl", + "metadata": { + "id": "g2j7qp1ycxl", + "outputId": "5791fc37-589b-4bb9-ca66-85434b303787", + "colab": { + "referenced_widgets": [ + "20def6e82e1d4b69ae1b677a39a54bfc", + "53fe5574751540b68f2d6ef047cccc3c", + "3661c026040f44f3870921e8a2db7bd2", + "61b4f98716b649dc88332367852ec89c", + "a61820f54e5445ceaf27efa956212271", + "d761f8d2a0ff4de2a8728a1998e5f919", + "3fea49f4e519416f81af219023d45c34", + "240c5e45b5f245f984cdaaea9ff3a380", + "7ba75fdca7da467cacc407da59382376", + "2b3e22abd6704ef6b5cb2455c6fa98ab" + ] + } + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "20def6e82e1d4b69ae1b677a39a54bfc", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "53fe5574751540b68f2d6ef047cccc3c", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3661c026040f44f3870921e8a2db7bd2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...n-3-sft/training_args.bin: 100%|##########| 5.58kB / 5.58kB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "61b4f98716b649dc88332367852ec89c", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...adapter_model.safetensors: 100%|##########| 13.2MB / 13.2MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "a61820f54e5445ceaf27efa956212271", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...tron-3-sft/tokenizer.json: 100%|##########| 17.1MB / 17.1MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d761f8d2a0ff4de2a8728a1998e5f919", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3fea49f4e519416f81af219023d45c34", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "240c5e45b5f245f984cdaaea9ff3a380", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...n-3-sft/training_args.bin: 100%|##########| 5.58kB / 5.58kB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7ba75fdca7da467cacc407da59382376", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...tron-3-sft/tokenizer.json: 100%|##########| 17.1MB / 17.1MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "2b3e22abd6704ef6b5cb2455c6fa98ab", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...adapter_model.safetensors: 100%|##########| 13.2MB / 13.2MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "CommitInfo(commit_url='https://huggingface.co/sergiopaniego/nemotron-3-sft/commit/dd05a083358e10113019b06da76c3e9ab4c4c3e4', commit_message='End of training', commit_description='', oid='dd05a083358e10113019b06da76c3e9ab4c4c3e4', pr_url=None, repo_url=RepoUrl('https://huggingface.co/sergiopaniego/nemotron-3-sft', endpoint='https://huggingface.co', repo_type='model', repo_id='sergiopaniego/nemotron-3-sft'), pr_revision=None, pr_num=None)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_name)" + ] + }, + { + "cell_type": "markdown", + "id": "jp3u13oqlye", + "metadata": { + "id": "jp3u13oqlye" + }, + "source": [ + "## Inference\n", + "\n", + "Let's run the fine-tuned model using standard `transformers` generation (`model.generate`)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1tb9jai824gi", + "metadata": { + "id": "1tb9jai824gi" + }, + "outputs": [], + "source": [ + "model = trainer.model\n", + "model.eval()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3zp0i0zw4je", + "metadata": { + "id": "3zp0i0zw4je" + }, + "outputs": [], + "source": [ + "messages = [{\"role\": \"user\", \"content\": \"Continue the sequence: 1, 1, 2, 3, 5, 8,\"}]\n", + "text = tokenizer.apply_chat_template(\n", + " messages,\n", + " tokenize=False,\n", + " add_generation_prompt=True,\n", + ")\n", + "\n", + "from transformers import TextStreamer\n", + "\n", + "_ = model.generate(\n", + " **tokenizer(text, return_tensors=\"pt\").to(\"cuda\"),\n", + " max_new_tokens=128,\n", + " temperature=0.7,\n", + " top_p=0.8,\n", + " top_k=20,\n", + " streamer=TextStreamer(tokenizer, skip_prompt=True),\n", + ")" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + }, + "colab": { + "provenance": [], + "machine_shape": "hm", + "gpuType": "A100" + }, + "accelerator": "GPU" + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_qwen_vl.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_qwen_vl.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..2cd50fbf5b67856faefc3290ae3da9959a9f9480 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_qwen_vl.ipynb @@ -0,0 +1,515 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "UaDIwQOOjgAO" + }, + "source": [ + "# Supervised Fine-Tuning (SFT) Qwen3-VL with QLoRA using TRL\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_qwen_vl.ipynb)\n", + "\n", + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4f0hzSo4kKEc" + }, + "source": [ + "With [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl), you can fine-tune cutting edge vision language models. It comes with support for quantized parameter efficient fine-tuning technique **QLoRA**, so we can use free Colab (T4 GPU) to fine-tune models like [Qwen3-VL](https://huggingface.co/collections/Qwen/qwen3-vl-68d2a7c1b8a8afce4ebd2dbe).\n", + "\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)\n", + "- [More Qwen3-VL Fine-tuning Examples (including TRL scripts)](https://github.com/QwenLM/Qwen3-VL/tree/main/qwen-vl-finetune/)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pGXgIbj2kXEP" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which ensures all main dependencies such as **Transformers** and **PEFT** (a package for parameter-efficient fine-tuning, e.g., LoRA/QLoRA) are included. Additionally, we'll install **trackio** to log and monitor our experiments, and **bitsandbytes** to enable quantization of LLMs, reducing memory consumption for both inference and training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "8CfZlUevmkg7" + }, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[peft]\" bitsandbytes trackio" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Ou0VO1gHklS-" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "4Ncx0wYtnYCW" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "vNylrNdqkoN-" + }, + "source": [ + "## Load dataset\n", + "\n", + "\n", + "We'll load the [**trl-lib/llava-instruct-mix**](https://huggingface.co/datasets/trl-lib/llava-instruct-mix) dataset from the Hugging Face Hub using the `datasets` library.\n", + "\n", + "This dataset is a set of GPT-generated multimodal instruction-following data. We use a processed version for conveniency here. You can check out more details about how to configure your own multimodal dataset for traininig with SFT in the [docs](https://huggingface.co/docs/trl/en/sft_trainer#training-vision-language-models). Fine-tuning Qwen3-VL on it helps refine its response style and visual understanding.\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "0AcyX6Jd1_hp" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_name = \"trl-lib/llava-instruct-mix\"\n", + "train_dataset = load_dataset(dataset_name, split=\"train[:10%]\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "JFtR4Xyx4FYO" + }, + "source": [ + "Let's review one example to understand the internal structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "YLrEY_v8m0eA" + }, + "outputs": [], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qeZCtRB1m5xj" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "gt05dgXgm9QR" + }, + "outputs": [], + "source": [ + "from transformers import Qwen3VLForConditionalGeneration, BitsAndBytesConfig\n", + "import torch\n", + "\n", + "model_name = \"Qwen/Qwen3-VL-4B-Instruct\" # \"Qwen/Qwen3-VL-8B-Instruct\"\n", + "\n", + "model = Qwen3VLForConditionalGeneration.from_pretrained(\n", + " model_name,\n", + " dtype=\"float32\",\n", + " device_map=\"auto\",\n", + " quantization_config=BitsAndBytesConfig(\n", + " load_in_4bit=True, # Load the model in 4-bit precision to save memory\n", + " bnb_4bit_compute_dtype=torch.float16, # Data type used for internal computations in quantization\n", + " bnb_4bit_use_double_quant=True, # Use double quantization to improve accuracy\n", + " bnb_4bit_quant_type=\"nf4\" # Type of quantization. \"nf4\" is recommended for recent LLMs\n", + " )\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "jyklRvNxnHmy" + }, + "source": [ + "The following cell defines LoRA (or QLoRA if needed). When training with LoRA/QLoRA, we use a **base model** (the one selected above) and, instead of modifying its original weights, we fine-tune a **LoRA adapter** — a lightweight layer that enables efficient and memory-friendly training. The **`target_modules`** specify which parts of the model (e.g., attention or projection layers) will be adapted by LoRA during fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ME1im5gh2LFg" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "# You may need to update `target_modules` depending on the architecture of your chosen model.\n", + "# For example, different VLMs might have different attention/projection layer names.\n", + "peft_config = LoraConfig(\n", + " r=32,\n", + " lora_alpha=32,\n", + " target_modules=['down_proj','o_proj','k_proj','q_proj','gate_proj','up_proj','v_proj'],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mBAfaiA-nbdm" + }, + "source": [ + "## Train model\n", + "\n", + "We'll configure **SFT** using `SFTConfig`, keeping the parameters minimal so the training fits on a free Colab instance. You can adjust these settings if more resources are available. For full details on all available parameters, check the [TRL SFTConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.SFTConfig)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "GQPxXvu-2Ngc" + }, + "outputs": [], + "source": [ + "from trl import SFTConfig\n", + "\n", + "output_dir = \"Qwen3-VL-4B-Instruct-trl-sft\"\n", + "\n", + "# Configure training arguments using SFTConfig\n", + "training_args = SFTConfig(\n", + " # Training schedule / optimization\n", + " #num_train_epochs=1,\n", + " max_steps=10, # Number of dataset passes. For full trainings, use `num_train_epochs` instead\n", + " per_device_train_batch_size=2, # Batch size per GPU/CPU\n", + " gradient_accumulation_steps=8, # Gradients are accumulated over multiple steps → effective batch size = 4 * 8 = 32\n", + " warmup_steps=5, # Gradually increase LR during first N steps\n", + " learning_rate=2e-4, # Learning rate for the optimizer\n", + " optim=\"adamw_8bit\", # Optimizer\n", + " max_length=None, # For VLMs, truncating may remove image tokens, leading to errors during training. max_length=None avoids it\n", + "\n", + " # Logging / reporting\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + " logging_steps=1, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + "\n", + " # Hub integration\n", + " push_to_hub=True,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bF4GtNO2ne1k" + }, + "source": [ + "Configure the SFT Trainer. We pass the previously configured `training_args`. We don't use eval dataset to maintain memory usage low but you can configure it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "TwBeQKQC2RfZ" + }, + "outputs": [], + "source": [ + "from trl import SFTTrainer\n", + "\n", + "trainer = SFTTrainer(\n", + " model=model,\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "K9Ub3jTDnfcD" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "u6_Vsv_1KtVU" + }, + "outputs": [], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4NiFu9tcniBP" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "pbJXrhA0ywra" + }, + "outputs": [], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "miZ2I1A9nnM4" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "8jegvQGlKyEu" + }, + "outputs": [], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "3lrrYfPunloQ" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "MNfRlfIGKSHI" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pFq51FWEK1DX" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "wAm1iQc8K1uY" + }, + "outputs": [], + "source": [ + "from transformers import Qwen3VLForConditionalGeneration, AutoProcessor\n", + "from peft import PeftModel\n", + "\n", + "base_model = model_name\n", + "adapter_model = f\"{output_dir}\" # Replace with your HF username or organization + fine-tuned model name\n", + "\n", + "model = Qwen3VLForConditionalGeneration.from_pretrained(base_model, dtype=\"float32\", device_map=\"auto\")\n", + "model = PeftModel.from_pretrained(model, adapter_model)\n", + "\n", + "processor = AutoProcessor.from_pretrained(base_model)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "a5rLWJdOvwGQ" + }, + "outputs": [], + "source": [ + "problem = train_dataset[0]['prompt'][0]['content']\n", + "image = train_dataset[0]['images'][0]\n", + "\n", + "messages = [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": [\n", + " {\"type\": \"image\", \"image\": image},\n", + " {\"type\": \"text\", \"text\": problem},\n", + " ],\n", + " },\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "qiu-ROFeBPhA" + }, + "outputs": [], + "source": [ + "messages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 497 + }, + "id": "qGzEXSH5BQwG", + "outputId": "611d6bfd-fb72-4737-e847-1611132d49ed" + }, + "outputs": [ + { + "data": { + "image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAHgAoADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uH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Phymq19Of4wn/7/O/+3m+RC+Z0WpuaGqlVA6wfcESsPvTdO3fHB7qXHT58GL4Jwggpq3RtBJR3aips9qq+9MW//uIX/9bnmwXLkf53kDITm0wlFhbnAQAmg5rtgAsKF66eyh/QPmqMQpR7BQ62tjeU6ZVNUuNwyp//zi8SVDWqxgbt1q3L9+ynLq/J40bdj1H/ajHjC2dWSVwzguuDfEe2IW4FmFhd1hsw8sjFEoBCVC+AQ1Qqu6rOTA0SoihJfUgslo6lqnFsnXqljEUQI5REEJa3Sn5QXb0BvT+dqUYTAuHT4Lbb3X1v/HM0VmqL50xxEIdMWmuTq0hFFj2gs1IerSLaRVwnt0RWPQEP+guV1IBNM6MKkLJ4KIXNMTvoJSIHJLNL8XPKk3NbwGHU+ERJUpB+u8q+duGd8DTSI5KmuTTipLUXoD0YgfhdMfSsDrKcVWbpwgIoB7SBgYdDT1JRpbQV57IyvRAxK8I66OqBP8JERc8QdogIRgyzCvirlTPFoalYBUocWihdiBDKQwoIAQqTFsuYfTC0etXe+x6mEOunr745Oj5NGDi0GK+rmLRqhJmmtbG5XARyy5CMpqO5GAkiiF6K1Qqy5+qsDmvnQN+u3VtWLzfdGfP7pqcW5/34HuCm5HATK9ZUDNlkjOdF90HQIDvY73l8rWidGg22EJCW4YUAAphaIMrLiA3D08nKkYITHlbZqliI/wsHFGRU3db9AAAAAABJRU5ErkJggg==", + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "image" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "SG64xtCtv24-", + "outputId": "cdc347b4-cdf2-49c8-e308-71dc99f27476" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\"The presentation of this meal can influence one's eating experience by making it more visually appealing and appetizing. The vibrant colors of the fruits, vegetables, and bread, as well as the careful arrangement of the food in the colorful containers, can create a sense of variety and abundance. This can make the meal more enjoyable and satisfying to eat, encouraging individuals to eat more and feel more satisfied after eating. Additionally, the presentation can make the meal more inviting and appealing to others, increasing the likelihood that they will eat it.\"]\n" + ] + } + ], + "source": [ + "inputs = processor.apply_chat_template(\n", + " messages,\n", + " add_generation_prompt=True,\n", + " tokenize=True,\n", + " return_tensors=\"pt\"\n", + " return_dict=True,\n", + ").to(model.device)\n", + "\n", + "# Inference: Generation of the output\n", + "generated_ids = model.generate(**inputs, max_new_tokens=128)\n", + "generated_ids_trimmed = [\n", + " out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)\n", + "]\n", + "output_text = processor.batch_decode(\n", + " generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False\n", + ")\n", + "print(output_text)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_tool_calling.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_tool_calling.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..f474eb3cd7ea2fc786a5d5eb60110913ec571623 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_tool_calling.ipynb @@ -0,0 +1,1233 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "ii5Zkit6eSqU" + }, + "source": [ + "# Teaching Tool Calling with Supervised Fine-Tuning (SFT) using TRL on a Free Colab Notebook\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_tool_calling.ipynb)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gJVcVKOteSqV" + }, + "source": [ + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hzt0BrvoeSqW" + }, + "source": [ + "Learn how to teach a language model to perform **tool calling** using **Supervised Fine-Tuning (SFT)** with **LoRA/QLoRA** and the [**TRL**](https://github.com/huggingface/trl) library.\n", + "\n", + "The model used in this notebook does not have native tool-calling support. We extend its Jinja2 chat template (via `tiny_aya_chat_template.jinja`) to serialize tool schemas into the system preamble and render tool calls as structured `` XML inside the model's native `<|START_RESPONSE|>` / `<|END_RESPONSE|>` delimiters. The modified template is saved with the tokenizer, making inference reproducible: just load the tokenizer from the output directory and call `apply_chat_template` with `tools=TOOLS`.\n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project!\n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview)\n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "3PfX1aj5eSqW" + }, + "source": [ + "## Key concepts\n", + "\n", + "- **SFT**: Trains a model on example input-output pairs to align its behavior with a desired task.\n", + "- **Tool Calling**: The ability of a model to respond with a structured function call instead of free-form text.\n", + "- **LoRA**: Updates only a small set of low-rank parameters, reducing training cost and memory usage.\n", + "- **QLoRA**: A quantized variant of LoRA that enables fine-tuning larger models on limited hardware.\n", + "- **TRL**: The Hugging Face library that makes fine-tuning and reinforcement learning simple and efficient." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "QDMcKeoEeSqW" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which brings in all main dependencies such as **Transformers** and **PEFT** (parameter-efficient fine-tuning). We also install **trackio** for experiment logging, and **bitsandbytes** for 4-bit quantization," + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Ey-TuYPrXTLG", + "outputId": "a4fd8cfe-624e-4185-ab59-e6901514cb96" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m17.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.7/60.7 MB\u001b[0m \u001b[31m42.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.2/24.2 MB\u001b[0m \u001b[31m109.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.0/56.0 kB\u001b[0m \u001b[31m6.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.9/9.9 MB\u001b[0m \u001b[31m131.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m540.5/540.5 kB\u001b[0m \u001b[31m44.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h" + ] + } + ], + "source": [ + "!pip install -Uq \"trl[peft]\" trackio bitsandbytes liger-kernel" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Aw8_T-Z0eSqW" + }, + "source": [ + "### Log in to Hugging Face\n", + "\n", + "Log in to your Hugging Face account to push the fine-tuned model to the Hub and access gated models. You can find your access token on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "_qaeDZwXXTLG" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XPnDpJgIeSqX" + }, + "source": [ + "## Load Dataset\n", + "\n", + "We load the [**bebechien/SimpleToolCalling**](https://huggingface.co/datasets/bebechien/SimpleToolCalling) dataset, which contains user queries paired with the correct tool call to handle each request. Each sample provides a `user_content`, a `tool_name`, and `tool_arguments`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "zfJY_8AzXTLG" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_name = \"bebechien/SimpleToolCalling\"\n", + "dataset = load_dataset(dataset_name, split=\"train\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ygeMXzKGXTLH", + "outputId": "a1ed3a8b-f515-4cda-eeb2-db0355ed2c02" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "Dataset({\n", + " features: ['user_content', 'tool_name', 'tool_arguments'],\n", + " num_rows: 40\n", + "})" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "O_GkvqtReSqX" + }, + "source": [ + "## Prepare Tool-Calling Data\n", + "\n", + "We define two tools: `search_knowledge_base` for internal company documents and `search_google` for public information. We then write a custom Jinja2 chat template that extends the model's default template with two additions:\n", + "\n", + "1. A **Tool Use** section is appended to the system preamble when `tools` is passed to `apply_chat_template`.\n", + "2. Assistant turns with `tool_calls` render the call as structured `` inside the model's existing `<|START_RESPONSE|>` / `<|END_RESPONSE|>` delimiters.\n", + "\n", + "Each training sample uses the standard `tool_calls` message format with a `tools` key — SFTTrainer passes these to `apply_chat_template` automatically." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "jaAgXeWtXTLH" + }, + "outputs": [], + "source": [ + "import json\n", + "\n", + "# These are the tool schemas that are used in the dataset\n", + "TOOLS = [\n", + " {\n", + " \"type\": \"function\",\n", + " \"function\": {\n", + " \"name\": \"search_knowledge_base\",\n", + " \"description\": \"Search internal company documents, policies and project data.\",\n", + " \"parameters\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\"query\": {\"type\": \"string\", \"description\": \"query string\"}},\n", + " \"required\": [\"query\"],\n", + " },\n", + " \"return\": {\"type\": \"string\"},\n", + " },\n", + " },\n", + " {\n", + " \"type\": \"function\",\n", + " \"function\": {\n", + " \"name\": \"search_google\",\n", + " \"description\": \"Search public information.\",\n", + " \"parameters\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\"query\": {\"type\": \"string\", \"description\": \"query string\"}},\n", + " \"required\": [\"query\"],\n", + " },\n", + " \"return\": {\"type\": \"string\"},\n", + " },\n", + " },\n", + "]\n", + "\n", + "def create_conversation(sample):\n", + " return {\n", + " \"prompt\": [{\"role\": \"user\", \"content\": sample[\"user_content\"]}],\n", + " \"completion\": [\n", + " {\n", + " \"role\": \"assistant\",\n", + " \"tool_calls\": [\n", + " {\n", + " \"type\": \"function\",\n", + " \"function\": {\n", + " \"name\": sample[\"tool_name\"],\n", + " \"arguments\": json.loads(sample[\"tool_arguments\"]),\n", + " },\n", + " }\n", + " ],\n", + " },\n", + " ],\n", + " \"tools\": TOOLS,\n", + " }" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "32p512R2XTLH" + }, + "outputs": [], + "source": [ + "dataset = dataset.map(create_conversation, remove_columns=dataset.features)\n", + "\n", + "# Split dataset into 50% training samples and 50% test samples\n", + "dataset = dataset.train_test_split(test_size=0.5, shuffle=True)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Plnjef-PeSqX" + }, + "source": [ + "Let's inspect an example from the training set to verify the format:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "f4QI6wJjXTLH", + "outputId": "2156adb4-7bed-4e29-84c5-54e6d45e5500" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'messages': [{'content': 'How do I configure the VPN for the New York office?',\n", + " 'role': 'user',\n", + " 'tool_calls': None},\n", + " {'content': None,\n", + " 'role': 'assistant',\n", + " 'tool_calls': [{'function': {'arguments': {'query': 'VPN configuration guide New York office'},\n", + " 'name': 'search_knowledge_base'},\n", + " 'type': 'function'}]}],\n", + " 'tools': [{'function': {'description': 'Search internal company documents, policies and project data.',\n", + " 'name': 'search_knowledge_base',\n", + " 'parameters': {'properties': {'query': {'description': 'query string',\n", + " 'type': 'string'}},\n", + " 'required': ['query'],\n", + " 'type': 'object'},\n", + " 'return': {'type': 'string'}},\n", + " 'type': 'function'},\n", + " {'function': {'description': 'Search public information.',\n", + " 'name': 'search_google',\n", + " 'parameters': {'properties': {'query': {'description': 'query string',\n", + " 'type': 'string'}},\n", + " 'required': ['query'],\n", + " 'type': 'object'},\n", + " 'return': {'type': 'string'}},\n", + " 'type': 'function'}]}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset['train'][0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "fBIGKl_UXTLH", + "outputId": "edd8e968-c7e4-418d-b9e9-26773aee1366" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "DatasetDict({\n", + " train: Dataset({\n", + " features: ['messages', 'tools'],\n", + " num_rows: 20\n", + " })\n", + " test: Dataset({\n", + " features: ['messages', 'tools'],\n", + " num_rows: 20\n", + " })\n", + "})" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "aud6U3c2eSqX" + }, + "source": [ + "## Load Model and Configure LoRA/QLoRA\n", + "\n", + "Choose the model you want to fine-tune. This notebook uses [`CohereLabs/tiny-aya-global`](https://huggingface.co/CohereLabs/tiny-aya-global) by default." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "_j_LF12IXTLH" + }, + "outputs": [], + "source": [ + "model_id, output_dir = \"CohereLabs/tiny-aya-global\", \"tiny-aya-global-SFT\" # ✅ ~9.1 GB VRAM" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gpTZHjpJeSqX" + }, + "source": [ + "Load the model with 4-bit quantization using `BitsAndBytesConfig` (QLoRA). To use standard LoRA without quantization, comment out the `quantization_config` parameter. We also load the tokenizer separately so we can install the custom chat template before training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "680888237b78477ea653adb2ecea7fa8" + ] + }, + "id": "jGpTDV6sXTLH", + "outputId": "fc33f7a6-bfd0-4228-80cd-e0aeb67bbd42" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "680888237b78477ea653adb2ecea7fa8", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Loading weights: 0%| | 0/290 [00:00" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* GPU detected, enabling automatic GPU metrics logging\n", + "* Created new run: sergiopaniego-1771428231\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "

\n", + " \n", + " \n", + " [15/15 00:52, Epoch 3/3]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining Loss
13.095131
23.083373
32.951535
42.625918
52.254464
61.939976
71.694891
81.558982
91.430660
101.305176
111.192725
121.120383
131.052859
140.985858
150.970833

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Run finished. Uploading logs to Trackio (please wait...)\n" + ] + } + ], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4MGKFi1-eSqY" + }, + "source": [ + "Show memory stats after training:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "3f68GA6TXTLI", + "outputId": "321e90ee-757a-41fc-c6a2-4ba40a6e6b3c" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "59.2841 seconds used for training.\n", + "0.99 minutes used for training.\n", + "Peak reserved memory = 11.928 GB.\n", + "Peak reserved memory for training = 7.28 GB.\n", + "Peak reserved memory % of max memory = 30.202 %.\n", + "Peak reserved memory for training % of max memory = 18.433 %.\n" + ] + } + ], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ONWy4NOAeSqY" + }, + "source": [ + "## Save the Fine-Tuned Model\n", + "\n", + "Save the trained LoRA adapter locally and push it to the Hugging Face Hub." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "4951424bb90e4dbbaea8c9b88c592872", + "1669afd0e52443d090adab0fbe663c66", + "5ee5f6b74e7246eea99c0d84c2a27bc0", + "15b4a13592c14102af0d3f8a999f3d36", + "7216a7d56c364a0d92e079d9848946d3", + "83e8f73e00004b718cbba7be0ecc45e1", + "05db21352f614288864f88c1ba794ee9", + "d7821b8cd21f4fb78237479ff081511b", + "00c9f462a4584b22b1e38dfcc5f86af3", + "22cacea841ba48c29b7a74ea17a50b4e" + ] + }, + "id": "9qz-fRZyXTLI", + "outputId": "9ff41250-0786-4ec6-fe41-dfc6b611d0b5" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4951424bb90e4dbbaea8c9b88c592872", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1669afd0e52443d090adab0fbe663c66", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5ee5f6b74e7246eea99c0d84c2a27bc0", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...bal-SFT/training_args.bin: 100%|##########| 5.58kB / 5.58kB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "15b4a13592c14102af0d3f8a999f3d36", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...global-SFT/tokenizer.json: 100%|##########| 21.4MB / 21.4MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7216a7d56c364a0d92e079d9848946d3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...adapter_model.safetensors: 35%|###4 | 41.9MB / 121MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "83e8f73e00004b718cbba7be0ecc45e1", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Processing Files (0 / 0) : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "05db21352f614288864f88c1ba794ee9", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "New Data Upload : | | 0.00B / 0.00B " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d7821b8cd21f4fb78237479ff081511b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...bal-SFT/training_args.bin: 100%|##########| 5.58kB / 5.58kB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "00c9f462a4584b22b1e38dfcc5f86af3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...adapter_model.safetensors: 35%|###4 | 41.9MB / 121MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "22cacea841ba48c29b7a74ea17a50b4e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " ...global-SFT/tokenizer.json: 100%|##########| 21.4MB / 21.4MB " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "CommitInfo(commit_url='https://huggingface.co/sergiopaniego/tiny-aya-global-SFT/commit/c59baa62c6bb5a3c3be2d33b482522a00783a5b4', commit_message='End of training', commit_description='', oid='c59baa62c6bb5a3c3be2d33b482522a00783a5b4', pr_url=None, repo_url=RepoUrl('https://huggingface.co/sergiopaniego/tiny-aya-global-SFT', endpoint='https://huggingface.co', repo_type='model', repo_id='sergiopaniego/tiny-aya-global-SFT'), pr_revision=None, pr_num=None)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "wNA4AIE4SiUg" + }, + "source": [ + "## Load the Fine-Tuned Model and Run Inference\n", + "\n", + "Load the trained LoRA adapter on top of the base model and merge it into the weights for efficient inference." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "referenced_widgets": [ + "9d6a109e605d440ab2c115d969796859" + ] + }, + "id": "b5CmxYtpXTLI", + "outputId": "10ebe012-9ffe-4096-f155-648af855aa80" + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9d6a109e605d440ab2c115d969796859", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Loading weights: 0%| | 0/290 [00:00\n", + "\n", + "node.js latest version\n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "sample_test_data = dataset[\"test\"][0] # Get a sample from the test set\n", + "\n", + "user_content = sample_test_data[\"prompt\"]\n", + "\n", + "print(f\"User Query: {user_content}\")\n", + "\n", + "predicted_output = generate_prediction(user_content)\n", + "print(f\"Predicted Output: {predicted_output}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-r85c-aa7C7k" + }, + "source": [ + "You can still use the strong multilingual model capabilities:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "UGePqQGVXTLI", + "outputId": "adcd21ca-ca45-43d5-a3cc-02a47377e51b" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User Query: [{'role': 'user', 'content': \"Explica en español qué significa la palabra japonesa 'ikigai' y da un ejemplo práctico.\"}]\n", + "Predicted Output: \n", + "\n", + "ikigai significado y ejemplo\n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "user_content = \"Explica en español qué significa la palabra japonesa 'ikigai' y da un ejemplo práctico.\" # Spanish question\n", + "user_content = [{\"role\": \"user\", \"content\": user_content}]\n", + "\n", + "print(f\"User Query: {user_content}\")\n", + "\n", + "predicted_output = generate_prediction(user_content)\n", + "print(f\"Predicted Output: {predicted_output}\")" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "provenance": [] + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_trl_lora_qlora.ipynb b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_trl_lora_qlora.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..f6aeb420f3150fb57812133117606355d1f1f0a9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/notebooks/sft_trl_lora_qlora.ipynb @@ -0,0 +1,1140 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "5oqSnSaqLWAL" + }, + "source": [ + "# Supervised Fine-Tuning (SFT) with LoRA/QLoRA using TRL — on a Free Colab Notebook\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/notebooks/sft_trl_lora_qlora.ipynb)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "d6c1x17tLWAR" + }, + "source": [ + "![trl banner](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cQ6bxQaMLWAS" + }, + "source": [ + "Easily fine-tune Large Language Models (LLMs) or Vision-Language Models (VLMs) with **LoRA** or **QLoRA** using the [**Transformers Reinforcement Learning (TRL)**](https://github.com/huggingface/trl) library built by Hugging Face — all within a **free Google Colab notebook** (powered by a **T4 GPU**.). \n", + "\n", + "- [TRL GitHub Repository](https://github.com/huggingface/trl) — star us to support the project! \n", + "- [Official TRL Examples](https://huggingface.co/docs/trl/example_overview) \n", + "- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "JG3wax0uLWAU" + }, + "source": [ + "## Key concepts\n", + "\n", + "- **SFT**: Trains models from example input-output pairs to align behavior with human preferences.\n", + "- **LoRA**: Updates only a few low-rank parameters, reducing training cost and memory.\n", + "- **QLoRA**: A quantized version of LoRA that enables even larger models to fit on small GPUs.\n", + "- **TRL**: The Hugging Face library that makes fine-tuning and reinforcement learning simple and efficient.\n", + "\n", + "Learn how to perform **Supervised Fine-Tuning (SFT)** with **LoRA/QLoRA** using **TRL**." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0ZhyNnhiLWAV" + }, + "source": [ + "## Install dependencies\n", + "\n", + "We'll install **TRL** with the **PEFT** extra, which ensures all main dependencies such as **Transformers** and **PEFT** (a package for parameter-efficient fine-tuning, e.g., LoRA/QLoRA) are included. Additionally, we'll install **trackio** to log and monitor our experiments, and **bitsandbytes** to enable quantization of LLMs, reducing memory consumption for both inference and training." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "FXTyVTJcLWAV" + }, + "outputs": [], + "source": [ + "!pip install -Uq \"trl[peft]\" trackio bitsandbytes liger-kernel" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "OqlMF6oWLWAY" + }, + "source": [ + "### Log in to Hugging Face" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "2blL6-1_LWAa" + }, + "source": [ + "Log in to your **Hugging Face** account to save your fine-tuned model, track your experiment results directly on the Hub or access gated models. You can find your **access token** on your [account settings page](https://huggingface.co/settings/tokens)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "6OMeJOp7LWAc" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "6HHscLIQLWAd" + }, + "source": [ + "## Load Dataset\n", + "\n", + "In this step, we load the [**HuggingFaceH4/Multilingual-Thinking**](https://huggingface.co/datasets/HuggingFaceH4/Multilingual-Thinking) dataset from the Hugging Face Hub using the `datasets` library. \n", + "This dataset focuses on **multilingual reasoning**, where the *chain of thought* has been translated into several languages such as French, Spanish, and German. \n", + "By fine-tuning a reasoning-capable model on this dataset, it learns to **generate reasoning steps in multiple languages**, making its thought process more **interpretable and accessible** to non-English speakers.\n", + "\n", + "> 💡 This dataset is best suited for models that already demonstrate reasoning capabilities. \n", + "> If you're using a model without reasoning skills, consider choosing a different dataset. Example: [`trl-lib/llava-instruct-mix`](https://huggingface.co/datasets/trl-lib/llava-instruct-mix).\n", + "\n", + "For efficiency, we'll load only the **training split**:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "dlQSKxTnLWAd" + }, + "outputs": [], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset_name = \"HuggingFaceH4/Multilingual-Thinking\"\n", + "train_dataset = load_dataset(dataset_name, split=\"train\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bRHTwwZXLWAe" + }, + "source": [ + "This dataset contains different columns. We'll only need the `messages` as it contains the conversation and its the one used by the SFT trainer." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "zOBq8tVdLWAe", + "outputId": "e12ab8ae-e00c-4e89-b489-dd448db8e13b" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "Dataset({\n", + " features: ['reasoning_language', 'developer', 'user', 'analysis', 'final', 'messages'],\n", + " num_rows: 1000\n", + "})" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "train_dataset" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "b13TjFs2LWAe" + }, + "source": [ + "Let's see a full example to understand the internal structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ZON5mIMNLWAf", + "outputId": "d01415eb-26cb-45ce-ad48-0388161eea28" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'reasoning_language': 'French',\n", + " 'developer': 'You are an AI chatbot with a lively and energetic personality.',\n", + " 'user': 'Can you show me the latest trends on Twitter right now?',\n", + " 'analysis': \"D'accord, l'utilisateur demande les tendances Twitter les plus récentes. Tout d'abord, je dois vérifier si j'ai accès à des données en temps réel. Étant donné que je ne peux pas naviguer sur Internet ou accéder directement à l'API de Twitter, je ne peux pas fournir des tendances en direct. Cependant, je peux donner quelques conseils généraux sur la façon de les trouver.\\n\\nJe devrais préciser que les tendances Twitter évoluent rapidement et sont spécifiques à chaque région. Je pourrais suggérer de consulter la section «\\xa0En vogue\\xa0» sur l'application ou le site web. Aussi, l'utilisation de hashtags et le suivi d'utilisateurs pertinents pourraient être utiles. Il est important de souligner que les tendances varient selon la région et l'heure de la journée. Je devrais garder un ton amical et bienveillant, peut-être ajouter un emoji pour rester léger. Je vais structurer ma réponse étape par étape pour faciliter la lecture. Je dois m'excuser de ne pas pouvoir fournir des données en temps réel et proposer d'autres méthodes. Je conserverai un langage simple et convivial, en évitant les termes techniques.\",\n", + " 'final': 'Hey there! While I can\\'t check Twitter (X) in real-time or access live data, I can share some tips to help you spot the latest trends:\\n\\n1. **Open the \"Trending\" tab** on the Twitter app or website – it updates constantly! \\n2. **Search for hashtags** like #Trending or #Viral to see what’s blowing up. \\n3. **Follow accounts** that curate trends (e.g., @TrendingNow, @ViralThreads). \\n4. **Check regional trends** – they often differ by location! \\n\\nRemember, trends are *super fast-moving* and often tied to pop culture, memes, or breaking news. For example, recent trends have included viral challenges (like the \"Distracted Boyfriend\" meme revival), celebrity drama, or unexpected events (hello, weather disasters!). \\n\\nWant me to brainstorm *what* might trend next? I’ve got ideas!',\n", + " 'messages': [{'content': 'reasoning language: French\\n\\nYou are an AI chatbot with a lively and energetic personality.',\n", + " 'role': 'system',\n", + " 'thinking': None},\n", + " {'content': 'Can you show me the latest trends on Twitter right now?',\n", + " 'role': 'user',\n", + " 'thinking': None},\n", + " {'content': 'Hey there! While I can\\'t check Twitter (X) in real-time or access live data, I can share some tips to help you spot the latest trends:\\n\\n1. **Open the \"Trending\" tab** on the Twitter app or website – it updates constantly! \\n2. **Search for hashtags** like #Trending or #Viral to see what’s blowing up. \\n3. **Follow accounts** that curate trends (e.g., @TrendingNow, @ViralThreads). \\n4. **Check regional trends** – they often differ by location! \\n\\nRemember, trends are *super fast-moving* and often tied to pop culture, memes, or breaking news. For example, recent trends have included viral challenges (like the \"Distracted Boyfriend\" meme revival), celebrity drama, or unexpected events (hello, weather disasters!). \\n\\nWant me to brainstorm *what* might trend next? I’ve got ideas!',\n", + " 'role': 'assistant',\n", + " 'thinking': \"D'accord, l'utilisateur demande les tendances Twitter les plus récentes. Tout d'abord, je dois vérifier si j'ai accès à des données en temps réel. Étant donné que je ne peux pas naviguer sur Internet ou accéder directement à l'API de Twitter, je ne peux pas fournir des tendances en direct. Cependant, je peux donner quelques conseils généraux sur la façon de les trouver.\\n\\nJe devrais préciser que les tendances Twitter évoluent rapidement et sont spécifiques à chaque région. Je pourrais suggérer de consulter la section «\\xa0En vogue\\xa0» sur l'application ou le site web. Aussi, l'utilisation de hashtags et le suivi d'utilisateurs pertinents pourraient être utiles. Il est important de souligner que les tendances varient selon la région et l'heure de la journée. Je devrais garder un ton amical et bienveillant, peut-être ajouter un emoji pour rester léger. Je vais structurer ma réponse étape par étape pour faciliter la lecture. Je dois m'excuser de ne pas pouvoir fournir des données en temps réel et proposer d'autres méthodes. Je conserverai un langage simple et convivial, en évitant les termes techniques.\"}]}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "train_dataset[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "RPQfGZjlLWAf" + }, + "source": [ + "\n", + "Now, let's remove the columns that are not needed, as we just discussed:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "pCM6PoIzLWAf" + }, + "outputs": [], + "source": [ + "train_dataset = train_dataset.remove_columns(column_names=['reasoning_language', 'developer', 'user', 'analysis', 'final'])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "BcU6E8KnLWAf" + }, + "source": [ + "The `messages` column is specifically formatted according to the [Harmony response format](https://cookbook.openai.com/articles/openai-harmony) used by *gpt-oss*. \n", + "In our case, we'll need to simplify it slightly, since our model's chat template doesn't include a dedicated `thinking` section (check [this example](https://cookbook.openai.com/articles/gpt-oss/fine-tune-transfomers) for more details). \n", + "To adapt it, we'll merge that part into the message content using the standard `...` tags.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "XQ2xYEq3LWAf" + }, + "outputs": [], + "source": [ + "def merge_thinking_and_remove_key(example):\n", + " new_messages = []\n", + " for msg in example[\"messages\"]:\n", + " content = msg[\"content\"]\n", + " thinking = msg.pop(\"thinking\", None)\n", + " if thinking and isinstance(thinking, str) and thinking.strip():\n", + " content = f\"\\n{thinking}\\n\\n{content}\"\n", + " msg[\"content\"] = content\n", + " new_messages.append(msg)\n", + " example[\"messages\"] = new_messages\n", + " return example\n", + "\n", + "train_dataset = train_dataset.map(merge_thinking_and_remove_key)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ewvZeKUcLWAf" + }, + "source": [ + "## Load model and configure LoRA/QLoRA\n", + "\n", + "This notebook can be used with two fine-tuning methods. By default, it is set up for **QLoRA**, which includes quantization using `BitsAndBytesConfig`. If you prefer to use standard **LoRA** without quantization, simply comment out the `BitsAndBytesConfig` configuration.\n", + "\n", + "Below, choose your **preferred model**. All of the options have been tested on **free Colab instances**." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "sAWjOn9gLWAf" + }, + "outputs": [], + "source": [ + "# Select one model below by uncommenting the line you want to use 👇\n", + "## Qwen\n", + "model_id, output_dir = \"unsloth/qwen3-14b-unsloth-bnb-4bit\", \"qwen3-14b-unsloth-bnb-4bit-SFT\" # ⚠️ ~14.1 GB VRAM\n", + "# model_id, output_dir = \"Qwen/Qwen3-8B\", \"Qwen3-8B-SFT\" # ⚠️ ~12.8 GB VRAM\n", + "# model_id, output_dir = \"Qwen/Qwen2.5-7B-Instruct\", \"Qwen2.5-7B-Instruct\" # ✅ ~10.8 GB VRAM\n", + "\n", + "## Llama\n", + "# model_id, output_dir = \"meta-llama/Llama-3.2-3B-Instruct\", \"Llama-3.2-3B-Instruct\" # ✅ ~4.7 GB VRAM\n", + "# model_id, output_dir = \"meta-llama/Llama-3.1-8B-Instruct\", \"Llama-3.1-8B-Instruct\" # ⚠️ ~10.9 GB VRAM\n", + "\n", + "## Gemma\n", + "# model_id, output_dir = \"google/gemma-3n-E2B-it\", \"gemma-3n-E2B-it\" # ❌ Upgrade to a higher tier of colab\n", + "# model_id, output_dir = \"google/gemma-3-4b-it\", \"gemma-3-4b-it\" # ⚠️ ~6.8 GB VRAM\n", + "\n", + "## Granite\n", + "#model_id, output_dir = \"ibm-granite/granite-4.0-micro\", \"granite-4.0-micro\" # ✅ ~3.3 GB VRAM\n", + "\n", + "## LFM2\n", + "#model_id, output_dir = \"LiquidAI/LFM2-2.6B\", \"LFM2-2.6B-SFT\" # ✅ ~5.89 GB VRAM" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "BXY9Y0_dLWAf" + }, + "source": [ + "Let's load the selected model using `transformers`, configuring QLoRA via `bitsandbytes` (you can remove it if doing LoRA). We don't need to configure the tokenizer since the trainer takes care of that automatically." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "oyOoWFsLLWAg" + }, + "outputs": [], + "source": [ + "import torch\n", + "from transformers import AutoModelForCausalLM, BitsAndBytesConfig\n", + "\n", + "model = AutoModelForCausalLM.from_pretrained(\n", + " model_id,\n", + " attn_implementation=\"sdpa\", # Change to Flash Attention if GPU has support\n", + " dtype=torch.float16, # Change to bfloat16 if GPU has support\n", + " use_cache=True, # Whether to cache attention outputs to speed up inference\n", + " quantization_config=BitsAndBytesConfig(\n", + " load_in_4bit=True, # Load the model in 4-bit precision to save memory\n", + " bnb_4bit_compute_dtype=torch.float16, # Data type used for internal computations in quantization\n", + " bnb_4bit_use_double_quant=True, # Use double quantization to improve accuracy\n", + " bnb_4bit_quant_type=\"nf4\" # Type of quantization. \"nf4\" is recommended for recent LLMs\n", + " )\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "L-_BpOdILWAg" + }, + "source": [ + "The following cell defines LoRA (or QLoRA if needed). When training with LoRA/QLoRA, we use a **base model** (the one selected above) and, instead of modifying its original weights, we fine-tune a **LoRA adapter** — a lightweight layer that enables efficient and memory-friendly training. The **`target_modules`** specify which parts of the model (e.g., attention or projection layers) will be adapted by LoRA during fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "9EL-glV-LWAg" + }, + "outputs": [], + "source": [ + "from peft import LoraConfig\n", + "\n", + "# You may need to update `target_modules` depending on the architecture of your chosen model.\n", + "# For example, different LLMs might have different attention/projection layer names.\n", + "peft_config = LoraConfig(\n", + " r=32,\n", + " lora_alpha=32,\n", + " target_modules = [\"q_proj\", \"k_proj\", \"v_proj\", \"o_proj\", \"gate_proj\", \"up_proj\", \"down_proj\",],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-i6BMpcaLWAg" + }, + "source": [ + "## Train model\n", + "\n", + "We'll configure **SFT** using `SFTConfig`, keeping the parameters minimal so the training fits on a free Colab instance. You can adjust these settings if more resources are available. For full details on all available parameters, check the [TRL SFTConfig documentation](https://huggingface.co/docs/trl/sft_trainer#trl.SFTConfig)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "-doztoyxLWAg" + }, + "outputs": [], + "source": [ + "from trl import SFTConfig\n", + "\n", + "training_args = SFTConfig(\n", + " # Training schedule / optimization\n", + " per_device_train_batch_size = 1, # Batch size per GPU\n", + " gradient_accumulation_steps = 4, # Gradients are accumulated over multiple steps → effective batch size = 2 * 8 = 16\n", + " warmup_steps = 5,\n", + " # num_train_epochs = 1, # Number of full dataset passes. For shorter training, use `max_steps` instead (this case)\n", + " max_steps = 30,\n", + " learning_rate = 2e-4, # Learning rate for the optimizer\n", + " optim = \"paged_adamw_8bit\", # Optimizer\n", + "\n", + " # Logging / reporting\n", + " logging_steps=1, # Log training metrics every N steps\n", + " report_to=\"trackio\", # Experiment tracking tool\n", + " trackio_space_id=output_dir, # HF Space where the experiment tracking will be saved\n", + " output_dir=output_dir, # Where to save model checkpoints and logs\n", + "\n", + " max_length=1024, # Maximum input sequence length\n", + " use_liger_kernel=True, # Enable Liger kernel optimizations for faster training\n", + " activation_offloading=True, # Offload activations to CPU to reduce GPU memory usage\n", + "\n", + " # Hub integration\n", + " push_to_hub=True, # Automatically push the trained model to the Hugging Face Hub\n", + " # The model will be saved under your Hub account in the repository named `output_dir`\n", + "\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Gz4ggYeeLWAg" + }, + "source": [ + "Configure the SFT Trainer. We pass the previously configured `training_args`. We don't use eval dataset to maintain memory usage low but you can configure it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "8Yx1wkv_LWAg" + }, + "outputs": [], + "source": [ + "from trl import SFTTrainer\n", + "\n", + "trainer = SFTTrainer(\n", + " model=model,\n", + " args=training_args,\n", + " train_dataset=train_dataset,\n", + " peft_config=peft_config\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0MsNw3uLLWAh" + }, + "source": [ + "Show memory stats before training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "YIuBi-ZYLWAh", + "outputId": "7f381ba0-fe90-4c6f-df0a-938a29be4e9e" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GPU = Tesla T4. Max memory = 14.741 GB.\n", + "12.074 GB of memory reserved.\n" + ] + } + ], + "source": [ + "gpu_stats = torch.cuda.get_device_properties(0)\n", + "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", + "\n", + "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", + "print(f\"{start_gpu_memory} GB of memory reserved.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_6G6pMGeLWAh" + }, + "source": [ + "And train!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "glj5UPwWLWAh", + "outputId": "b0a046c7-f76b-42a6-d870-f54470297971" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'bos_token_id': None}.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Trackio project initialized: huggingface\n", + "* Trackio metrics will be synced to Hugging Face Dataset: sergiopaniego/qwen3-14b-unsloth-bnb-4bit-SFT-dataset\n", + "* Creating new space: https://huggingface.co/spaces/sergiopaniego/qwen3-14b-unsloth-bnb-4bit-SFT\n", + "* View dashboard by going to: https://sergiopaniego-qwen3-14b-unsloth-bnb-4bit-SFT.hf.space/\n" + ] + }, + { + "data": { + "text/html": [ + "

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Created new run: sergiopaniego-1761318512\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " [30/30 1:08:22, Epoch 0/1]\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StepTraining Loss
11.136300
21.303800
31.362700
41.469700
51.204200
61.202700
71.097200
81.166800
90.916300
100.965400
111.035500
120.947200
130.992000
140.995800
151.174500
161.208800
170.815400
180.906700
190.757500
200.872900
210.920800
221.017600
230.764300
241.043100
250.956400
260.884800
271.081900
280.918200
290.961500
300.822700

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* Run finished. Uploading logs to Trackio (please wait...)\n" + ] + } + ], + "source": [ + "trainer_stats = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "aULbOL3mLWAh" + }, + "source": [ + "Show memory stats after training" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "qp3m9sfXLWAh", + "outputId": "597fefc7-5510-4839-ce10-981a0aca25e8" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4249.8883 seconds used for training.\n", + "70.83 minutes used for training.\n", + "Peak reserved memory = 14.041 GB.\n", + "Peak reserved memory for training = 1.967 GB.\n", + "Peak reserved memory % of max memory = 95.251 %.\n", + "Peak reserved memory for training % of max memory = 13.344 %.\n" + ] + } + ], + "source": [ + "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", + "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", + "used_percentage = round(used_memory / max_memory * 100, 3)\n", + "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", + "\n", + "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", + "print(f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\")\n", + "print(f\"Peak reserved memory = {used_memory} GB.\")\n", + "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", + "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", + "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "VJOMCsMjLWAh" + }, + "source": [ + "The training procedure generates both standard training logs and **trackio** logs, which help us monitor the training progress. Example outputs would look like the following:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "FQNUkzVqLWAi" + }, + "source": [ + "![sft-lora-notebook-trackio](https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/sft-lora-notebook-trackio.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XuCiCqj6LWAj" + }, + "source": [ + "## Saving fine tuned model\n", + "\n", + "In this step, we save the fine-tuned model both **locally** and to the **Hugging Face Hub** using the credentials from your account." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "kMHh7_gFLWAj" + }, + "outputs": [], + "source": [ + "trainer.save_model(output_dir)\n", + "trainer.push_to_hub(dataset_name=dataset_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "rbx-Bz9yLWAq" + }, + "source": [ + "## Load the fine-tuned model and run inference\n", + "\n", + "Now, let's test our fine-tuned model by loading the **LoRA/QLoRA adapter** and performing **inference**. We'll start by loading the **base model**, then attach the adapter to it, creating the final fine-tuned model ready for evaluation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "c4VwuANtLWAr" + }, + "outputs": [], + "source": [ + "from transformers import AutoModelForCausalLM, AutoTokenizer\n", + "from peft import PeftModel\n", + "\n", + "adapter_model = f\"sergiopaniego/{output_dir}\" # Replace with your HF username or organization\n", + "\n", + "base_model = AutoModelForCausalLM.from_pretrained(model_id, dtype=\"float32\", device_map=\"auto\")\n", + "\n", + "tokenizer = AutoTokenizer.from_pretrained(model_id)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "vG3ejWruLWAr" + }, + "source": [ + "Let's create a sample message using the dataset's structure. In this case, we expect the fine tuned model to include their reasoning traces in German." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "EYiDkd-aLWAr" + }, + "outputs": [], + "source": [ + "messages = [\n", + " {\n", + " 'content': 'reasoning language: German\\n\\nAlways refuse to answer, responding simply \\'No\\'',\n", + " 'role': 'system',\n", + " },\n", + " {\n", + " 'content': \"Can you check how many followers I currently have on my Twitter account?\",\n", + " 'role': 'user',\n", + " }\n", + "]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "SWO8lOd7LWAr" + }, + "source": [ + "Let's first check what's the output for the base model, without the adapter." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Mt4uuTcQLWAr", + "outputId": "98f07424-3506-40d1-9e33-d4e495ba171a" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Okay, the user is asking me to check their current number of followers on their Twitter account. Let me think about how to handle this.\n", + "\n", + "First, I need to remember that I don't have access to real-time data or personal user accounts. My knowledge is based on information up until 2023. So, I can't actually check their Twitter followers right now.\n", + "\n", + "Also, privacy is a big concern here. Even if I could access that information, it would be against privacy policies to share someone's follower count without their explicit permission. Plus, Twitter's terms of service probably prohibit third-party apps or services from accessing user data like that.\n", + "\n", + "The user might not be aware that I can't access their account. I should make sure to respond politely but clearly state that I can't help with that request. Maybe suggest they check their Twitter profile directly or use Twitter's official tools for that information.\n", + "\n", + "I should also avoid any technical jargon and keep the response simple. Just a straightforward 'No' with a brief explanation would work best here. Let me make sure the response is in German as per the user's request.\n", + "\n", + "\n", + "Nein.\n" + ] + } + ], + "source": [ + "text = tokenizer.apply_chat_template(\n", + " messages, add_generation_prompt=True, tokenize=False\n", + ")\n", + "model_inputs = tokenizer([text], return_tensors=\"pt\").to(base_model.device)\n", + "\n", + "generated_ids = base_model.generate(\n", + " **model_inputs,\n", + " max_new_tokens=512\n", + ")\n", + "output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]\n", + "\n", + "# Decode and extract model response\n", + "generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)\n", + "print(generated_text)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "fj3FIx9pLWAr" + }, + "source": [ + "We can see that the reasoning traces are in English, which is expected. Let's now load the fine-tuned model and check its answer." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "CmRfkvacLWAs" + }, + "outputs": [], + "source": [ + "fine_tuned_model = PeftModel.from_pretrained(base_model, adapter_model)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "5UNOw-E0LWAs", + "outputId": "19e227c1-4211-447e-a625-14e131912759" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Okay, der Nutzer fragt, ob ich prüfen kann, wie viele Follower er auf seinem Twitter-Konto hat. Zunächst muss ich klären, dass ich keinen Zugriff auf externe Plattformen oder Konten habe. Ich kann keine Daten von Twitter abrufen oder überprüfen. Ich sollte also höflich ablehnen und erklären, dass ich das nicht kann. Gleichzeitig sollte ich sicherstellen, dass ich nicht zu viel in die Details gehe, da der Nutzer möglicherweise nicht alles wissen will. Ich werde einfach „Nein“ sagen und keine weiteren Informationen geben. Achte darauf, die Antwort kurz und direkt zu halten. Ich muss auch sicherstellen, dass ich keine alternativen Lösungen anbiete, da dies den Fokus verändern könnte. Nur die Ablehnung ist erforderlich. Überprüfe, ob der Text klar ist und ob es irgendeine Verständigung gibt. Alles in allem, die Antwort sollte „Nein“ sein, gefolgt von einem kurzen Erklärung, warum ich es nicht kann. Keine weiteren Details oder Lösungen. Ich denke, das ist alles.\n", + "\n", + "\n", + "No\n" + ] + } + ], + "source": [ + "text = tokenizer.apply_chat_template(\n", + " messages, add_generation_prompt=True, tokenize=False\n", + ")\n", + "model_inputs = tokenizer([text], return_tensors=\"pt\").to(fine_tuned_model.device)\n", + "\n", + "generated_ids = fine_tuned_model.generate(\n", + " **model_inputs,\n", + " max_new_tokens=512\n", + ")\n", + "output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]\n", + "\n", + "# Decode and extract model response\n", + "generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)\n", + "print(generated_text)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "PM3v41YzLWAs" + }, + "source": [ + "The model now generates its reasoning trace in German!" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "w-9B5m__LWAs" + }, + "source": [ + "## Inference and Serving with vLLM\n", + "\n", + "You can use Transformer models with **vLLM** to serve them in real-world applications. Learn more [here](https://blog.vllm.ai/2025/04/11/transformers-backend.html)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "NNmyG47aLWAv" + }, + "outputs": [], + "source": [ + "!pip install -qU vllm" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "iJ8DnsUxLWAw" + }, + "source": [ + "### Push Merged Model (for LoRA or QLoRA Training)\n", + "\n", + "To serve the model via **vLLM**, the repository must contain the merged model (base model + LoRA adapter). Therefore, you need to upload it first." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "aPzZ_7KDLWAw" + }, + "outputs": [], + "source": [ + "model_merged = fine_tuned_model.merge_and_unload()\n", + "\n", + "save_dir = f\"{output_dir}-merged\"\n", + "\n", + "model_merged.save_pretrained(save_dir)\n", + "tokenizer.save_pretrained(save_dir)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "k1Cvrkn3LWAw" + }, + "outputs": [], + "source": [ + "model_merged.push_to_hub(f\"sergiopaniego/{output_dir}-merged\") # Replace with your HF username or organization\n", + "tokenizer.push_to_hub(f\"sergiopaniego/{output_dir}-merged\") # Replace with your HF username or organization" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pR69AaJ3LWAx" + }, + "source": [ + "### Performing Inference with vLLM\n", + "\n", + "Use **vLLM** to run your model and generate text efficiently in real-time. This allows you to test and deploy your fine-tuned models with low latency and high throughput." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "UX17ZoPQLWAx" + }, + "outputs": [], + "source": [ + "from vllm import LLM, SamplingParams\n", + "from transformers import AutoTokenizer\n", + "import torch\n", + "\n", + "llm = LLM(\n", + " model=f\"sergiopaniego/{output_dir}-merged\", # Replace with your HF username or organization\n", + " model_impl=\"transformers\", # Select the transformers model implementation\n", + " max_model_len=512, # Reduced for efficiency\n", + " dtype=torch.float16\n", + ")\n", + "hf_tokenizer = AutoTokenizer.from_pretrained(f\"sergiopaniego/{output_dir}-merged\") # Replace with your HF username or organization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "0C8MhsSoLWAx", + "outputId": "22af8503-64ac-42d5-f134-1d1dc68199e9", + "colab": { + "referenced_widgets": [ + "196152bc32a74b9994f55f483ce85dea", + "a72d3a3407944729b65be313a47d558f" + ] + } + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "196152bc32a74b9994f55f483ce85dea", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Adding requests: 0%| | 0/1 [00:00\n", + "Mag nachdenken...igkeit. Ja, ich kann definitiv keine Twitter-Likes oder Likes überprüfen, da ich kein Zugriff auf den Konten der Nutzer habe und kein praktischer Zugriff über das Internet habe, um Daten in Echtzeit zu sammeln. Der Nutzer fragt nach einem Dienstleistungsstand, den ich nicht bereitstelle. Ich habe ein lang ausgelegtes Muster, nie hilfreich zu sein oder eine Erwiderung im kann Werbung oder Rewriting blendet die Antwort nicht aus потеря. Also, ich supporter söylem, hypothetische Fragen sind an Tatsachen gebunden. Ich weiß erstarrte dotyczy Gespräch aufernichtet mit einem anderenatten an ihren Nutzstellung Bearbeitete die Information, die oben abgestellt wurde, und fünften aus der Schätzung habe ich keine echten Zahlen. Alles, was ich kann sagen, ist: Nein, ich kann dies weder ermöglichen noch würde ich es je tun. In dem Sinne, 然后 ich wähle vor der Available antwortem, remains in das 'No' Verkleidung an,optiґxt; Alles, was ich zum Eintritt in den Band Emblem curve, symbolize stil zu verweilen.เผย\n", + "\n", + "\n", + "No\n" + ] + } + ], + "source": [ + "# Alternatively, use llm.chat()\n", + "prompt = hf_tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)\n", + "\n", + "outputs = llm.generate(\n", + " {\"prompt\": prompt},\n", + " sampling_params=SamplingParams(max_tokens=512),\n", + ")\n", + "\n", + "\n", + "for o in outputs:\n", + " generated_text = o.outputs[0].text\n", + " print(generated_text)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [], + "gpuType": "T4" + }, + "language_info": { + "name": "python" + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "accelerator": "GPU" + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/async_grpo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/async_grpo.py new file mode 100644 index 0000000000000000000000000000000000000000..ccd020b9d13e3d70bf66d549057570d0c62a13ed --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/async_grpo.py @@ -0,0 +1,76 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "math-verify", +# "latex2sympy2_extended", +# "trackio", +# ] +# /// + +""" +pip install math_verify + +CUDA_VISIBLE_DEVICES=1 VLLM_SERVER_DEV_MODE=1 vllm serve Qwen/Qwen3-0.6B \ + --max-model-len 2048 \ + --logprobs-mode processed_logprobs \ + --weight-transfer-config '{"backend":"nccl"}' + +CUDA_VISIBLE_DEVICES=0 accelerate launch examples/scripts/async_grpo.py +""" + +from datasets import load_dataset + +from trl.experimental.async_grpo import AsyncGRPOConfig, AsyncGRPOTrainer +from trl.rewards import accuracy_reward + + +def format_sample(sample): + return { + "prompt": [{"role": "user", "content": sample["question"]}], + "solution": sample["answer"].split("####")[-1].strip(), + } + + +def main() -> None: + dataset = load_dataset("openai/gsm8k", "main", split="train") + dataset = dataset.map(format_sample, remove_columns=dataset.column_names) + + config = AsyncGRPOConfig( + output_dir="async_grpo_gsm8k", + save_strategy="no", + per_device_train_batch_size=16, + gradient_accumulation_steps=2, + max_completion_length=1024, + chat_template_kwargs={"enable_thinking": False}, + max_steps=200, + learning_rate=1e-5, + report_to="trackio", + trackio_space_id="async-grpo-gsm8k", + project="async-grpo-gsm8k", + log_completions=True, + ) + trainer = AsyncGRPOTrainer( + model="Qwen/Qwen3-0.6B", + args=config, + train_dataset=dataset, + reward_funcs=accuracy_reward, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/bco.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/bco.py new file mode 100644 index 0000000000000000000000000000000000000000..a0471c88a7d3b0090abd6ac70be1ed324910d3ec --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/bco.py @@ -0,0 +1,165 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "einops", +# "scikit-learn", +# "joblib", +# "trackio", +# "kernels", +# ] +# /// + +""" +Run the BCO training script with the commands below. In general, the optimal configuration for BCO will be similar to that of KTO. + +# Full training: +python examples/scripts/bco.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --trust_remote_code \ + --dataset_name trl-lib/ultrafeedback-gpt-3.5-turbo-helpfulness \ + --per_device_train_batch_size 16 \ + --per_device_eval_batch_size 32 \ + --num_train_epochs 1 \ + --gradient_accumulation_steps 1 \ + --eval_steps 0.2 \ + --save_strategy no \ + --output_dir bco-aligned-model \ + --logging_first_step \ + --max_length 2048 \ + --max_completion_length 1024 \ + --no_remove_unused_columns \ + --warmup_steps 0.1 + +# QLoRA: +python examples/scripts/bco.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --trust_remote_code \ + --dataset_name trl-lib/ultrafeedback-gpt-3.5-turbo-helpfulness \ + --per_device_train_batch_size 16 \ + --per_device_eval_batch_size 32 \ + --num_train_epochs 1 \ + --gradient_accumulation_steps 1 \ + --eval_steps 0.2 \ + --save_strategy no \ + --output_dir bco-aligned-model-lora \ + --logging_first_step \ + --warmup_steps 0.1 \ + --max_length 2048 \ + --max_completion_length 1024 \ + --no_remove_unused_columns \ + --warmup_steps 0.1 \ + --use_peft \ + --load_in_4bit \ + --lora_target_modules all-linear \ + --lora_r 16 \ + --lora_alpha 16 +""" + +from functools import partial + +import torch +import torch.nn.functional as F +from accelerate import Accelerator +from datasets import load_dataset +from transformers import AutoModel, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, PreTrainedModel + +from trl import ModelConfig, ScriptArguments, get_peft_config +from trl.experimental.bco import BCOConfig, BCOTrainer + + +def embed_prompt(input_ids: torch.LongTensor, attention_mask: torch.LongTensor, model: PreTrainedModel): + """ + Borrowed from https://huggingface.co/nomic-ai/nomic-embed-text-v1.5#transformers + """ + + def mean_pooling(model_output, attention_mask): + token_embeddings = model_output[0] + input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float() + return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9) + + with torch.no_grad(): + model_output = model(input_ids=input_ids, attention_mask=attention_mask) + embeddings = mean_pooling(model_output, attention_mask) + + matryoshka_dim = 512 + # normalize embeddings + embeddings = F.normalize(embeddings, p=2, dim=1) + embeddings = F.layer_norm(embeddings, normalized_shape=(embeddings.shape[1],)) + embeddings = embeddings[:, :matryoshka_dim] + + return embeddings + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, BCOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + training_args.gradient_checkpointing_kwargs = {"use_reentrant": True} + + # Load a pretrained model + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + ref_model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + accelerator = Accelerator() + embedding_model = AutoModel.from_pretrained( + "nomic-ai/nomic-embed-text-v1.5", + trust_remote_code=model_args.trust_remote_code, + safe_serialization=True, + dtype=torch.bfloat16, + device_map="auto", + ) + embedding_model = accelerator.prepare_model(embedding_model) + embedding_tokenizer = AutoTokenizer.from_pretrained( + "bert-base-uncased", trust_remote_code=model_args.trust_remote_code + ) + embedding_func = partial( + embed_prompt, + model=embedding_model, + ) + + # Initialize the BCO trainer + trainer = BCOTrainer( + model, + ref_model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + embedding_func=embedding_func, + embedding_tokenizer=embedding_tokenizer, + ) + + # Train and push the model to the Hub + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/cpo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/cpo.py new file mode 100644 index 0000000000000000000000000000000000000000..fe0973bf032114880b17734bc5e09f13ba1f30df --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/cpo.py @@ -0,0 +1,106 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +Run the CPO training script with the following command with some example arguments. +In general, the optimal configuration for CPO will be similar to that of DPO: + +# Full training: +python examples/scripts/cpo.py \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --model_name_or_path gpt2 \ + --per_device_train_batch_size 4 \ + --max_steps 1000 \ + --learning_rate 8e-6 \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir "gpt2-aligned-cpo" \ + --warmup_steps 150 \ + --logging_first_step \ + --no_remove_unused_columns + +# QLoRA: +python examples/scripts/cpo.py \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --model_name_or_path gpt2 \ + --per_device_train_batch_size 4 \ + --max_steps 1000 \ + --learning_rate 8e-5 \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir "gpt2-lora-aligned-cpo" \ + --optim rmsprop \ + --warmup_steps 150 \ + --logging_first_step \ + --no_remove_unused_columns \ + --use_peft \ + --lora_r 16 \ + --lora_alpha 16 +""" + +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser + +from trl import ModelConfig, ScriptArguments, get_peft_config +from trl.experimental.cpo import CPOConfig, CPOTrainer + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, CPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + ################ + # Model & Tokenizer + ################ + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ################ + # Training + ################ + trainer = CPOTrainer( + model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + # train and save the model + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/dpo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/dpo.py new file mode 100644 index 0000000000000000000000000000000000000000..276f4c61b25db6e6ae2b1e2a51458103f068c55a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/dpo.py @@ -0,0 +1,17 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +############################################################################################### +# This file has been moved to https://github.com/huggingface/trl/blob/main/trl/scripts/dpo.py # +############################################################################################### diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/dpo_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/dpo_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..6f01b312c2c97e2943209eca723b6816d73b0520 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/dpo_vlm.py @@ -0,0 +1,137 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow>=9.4.0", +# "torchvision", +# "trackio", +# "kernels", +# ] +# /// + +""" +Without dataset streaming: + +``` +accelerate launch examples/scripts/dpo_vlm.py \ + --dataset_name HuggingFaceH4/rlaif-v_formatted \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 32 \ + --dataset_num_proc 32 \ + --output_dir dpo_qwen_2_5_rlaif-v \ + --dtype bfloat16 \ + --use_peft \ + --lora_target_modules all-linear +``` + +With dataset streaming: + +``` +accelerate launch examples/scripts/dpo_vlm.py \ + --dataset_name HuggingFaceH4/rlaif-v_formatted \ + --dataset_streaming \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --per_device_train_batch_size 2 \ + --max_steps 100 \ + --gradient_accumulation_steps 32 \ + --dataset_num_proc 32 \ + --output_dir dpo_qwen_2_5_rlaif-v \ + --dtype bfloat16 \ + --use_peft \ + --lora_target_modules all-linear +``` +""" + +import torch +from datasets import load_dataset +from transformers import AutoModelForImageTextToText, AutoProcessor + +from trl import ( + DPOConfig, + DPOTrainer, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, DPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + ################ + # Model & Processor + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForImageTextToText.from_pretrained( + model_args.model_name_or_path, + trust_remote_code=model_args.trust_remote_code, + **model_kwargs, + ) + peft_config = get_peft_config(model_args) + + processor = AutoProcessor.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, do_image_splitting=False + ) + + if script_args.ignore_bias_buffers: + # torch distributed hack + model._ddp_params_and_buffers_to_ignore = [ + name for name, buffer in model.named_buffers() if buffer.dtype == torch.bool + ] + + ################ + # Dataset + ################ + dataset = load_dataset( + script_args.dataset_name, + name=script_args.dataset_config, + streaming=script_args.dataset_streaming, + ) + + ################ + # Training + ################ + trainer = DPOTrainer( + model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=peft_config, + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gkd.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gkd.py new file mode 100644 index 0000000000000000000000000000000000000000..25497b11f2cb1844bfd4ba411c145d4666d56a15 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gkd.py @@ -0,0 +1,142 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +# Full training: +python examples/scripts/gkd.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-5 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --output_dir gkd-model \ + --num_train_epochs 1 \ + --push_to_hub + +# LoRA: +python examples/scripts/gkd.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-4 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --output_dir gkd-model \ + --num_train_epochs 1 \ + --push_to_hub \ + --use_peft \ + --lora_r 64 \ + --lora_alpha 16 +""" + +from datasets import load_dataset +from transformers import AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.experimental.gkd import GKDConfig, GKDTrainer + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, GKDConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + ################ + # Model & Tokenizer + ################ + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + dtype=model_args.dtype, + use_cache=False if training_args.gradient_checkpointing else True, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + training_args.model_init_kwargs = model_kwargs + + teacher_model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + dtype=model_args.dtype, + use_cache=True, + ) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + training_args.teacher_model_init_kwargs = teacher_model_kwargs + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + padding_side="left", + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ################ + # Training + ################ + trainer = GKDTrainer( + model=model_args.model_name_or_path, + teacher_model=training_args.teacher_model_name_or_path, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_new_tokens, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_2048.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_2048.py new file mode 100644 index 0000000000000000000000000000000000000000..09c2816dcbcffa30f41854a4353cc0b81cff102e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_2048.py @@ -0,0 +1,161 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# ] +# /// + +import random + +from datasets import Dataset +from peft import LoraConfig + +from trl import GRPOConfig, GRPOTrainer + + +PROMPT = "Play 2048 on a 4x4 board. Use the tool `move` with one of: up, down, left, right. Maximize the score." + + +class Game2048Env: + def reset(self, **kwargs) -> str: + self.board = [[0] * 4 for _ in range(4)] + self.score = 0.0 + self.done = False + self._spawn() + self._spawn() + return f"score={self.score}\n{self._render()}\ndone={self.done}" + + def move(self, direction: str) -> str: + """ + Play one move in 2048. + + Args: + direction: One of "up", "down", "left", "right". + + Returns: + Environment feedback after the move. + """ + if self.done: + raise ValueError("Game over.") + moved, gained = self._apply_move(direction.strip().lower()) + if moved: + self.score += gained + self._spawn() + self.done = not self._can_move() + return f"score={self.score}\n{self._render()}\ndone={self.done}" + + def _spawn(self) -> None: + empty = [(r, c) for r in range(4) for c in range(4) if self.board[r][c] == 0] + if not empty: + return + r, c = random.choice(empty) + self.board[r][c] = 4 if random.random() < 0.1 else 2 + + @staticmethod + def _merge_line(line: list[int]) -> tuple[list[int], int]: + vals = [x for x in line if x] + out = [] + gained = 0 + i = 0 + while i < len(vals): + if i + 1 < len(vals) and vals[i] == vals[i + 1]: + v = vals[i] * 2 + out.append(v) + gained += v + i += 2 + else: + out.append(vals[i]) + i += 1 + out += [0] * (4 - len(out)) + return out, gained + + def _apply_move(self, direction: str) -> tuple[bool, int]: + if direction not in {"up", "down", "left", "right"}: + return False, 0 + + before = [row[:] for row in self.board] + gained_total = 0 + + if direction in {"left", "right"}: + for r in range(4): + row = self.board[r][:] + if direction == "right": + row.reverse() + merged, gained = self._merge_line(row) + if direction == "right": + merged.reverse() + self.board[r] = merged + gained_total += gained + else: + for c in range(4): + col = [self.board[r][c] for r in range(4)] + if direction == "down": + col.reverse() + merged, gained = self._merge_line(col) + if direction == "down": + merged.reverse() + for r in range(4): + self.board[r][c] = merged[r] + gained_total += gained + + moved = self.board != before + return moved, gained_total + + def _can_move(self) -> bool: + if any(0 in row for row in self.board): + return True + for r in range(4): + for c in range(4): + if r + 1 < 4 and self.board[r][c] == self.board[r + 1][c]: + return True + if c + 1 < 4 and self.board[r][c] == self.board[r][c + 1]: + return True + return False + + def _render(self) -> str: + return "\n".join(" ".join(f"{v:3d}" for v in row) for row in self.board) + + +def reward_score(environments, **kwargs): + return [env.score for env in environments] + + +def main() -> None: + dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": PROMPT}] for _ in range(1000)]}) + + trainer = GRPOTrainer( + model="Qwen/Qwen3-4B", + train_dataset=dataset, + reward_funcs=reward_score, + args=GRPOConfig( + chat_template_kwargs={"enable_thinking": False}, + logging_steps=1, + log_completions=True, + num_completions_to_print=2, + report_to="trackio", + trackio_space_id="trl-2048", + max_completion_length=2048, + per_device_train_batch_size=4, + gradient_accumulation_steps=2, + ), + environment_factory=Game2048Env, + peft_config=LoraConfig(), + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_agent.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_agent.py new file mode 100644 index 0000000000000000000000000000000000000000..4742a45502a85ff17203530974b3d3d622f3cd4f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_agent.py @@ -0,0 +1,320 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +# Full training +``` +python examples/scripts/grpo_agent.py \ + --model_name_or_path Qwen/Qwen3-1.7B \ + --output_dir grpo_biogrid_qwen_3g-1.7b \ + --push_to_hub True \ + --use_vllm True \ + --vllm_mode colocate \ + --max_completion_length 1024 \ + --report_to trackio \ + --log_completions True \ + --max_steps 400 +``` +""" + +import re +import signal +import sqlite3 +import textwrap +from contextlib import contextmanager + +from datasets import load_dataset + +from trl import GRPOConfig, GRPOTrainer, ModelConfig, ScriptArguments, TrlParser + + +def query_reward(completions, answer, **kwargs): + """ + Reward query strategy: + - Penalize more than 2 queries + - Penalize generic queries (LIMIT 1 / PRAGMA) + - Reward usage of WHERE + - Reward evidence supporting the final answer + """ + rewards = [] + + for completion, ans in zip(completions, answer, strict=False): + reward = 0.0 + sql_queries = [] + tool_results = [] + + # collect all SQL queries and tool results + for turn in completion: + if turn.get("tool_calls"): + for call in turn["tool_calls"]: + sql = call["function"]["arguments"].get("sql_command", "").lower() + sql_queries.append(sql) + if turn.get("role") == "tool" and turn.get("content"): + tool_results.append(turn["content"]) + + # --- penalize too many queries --- + if len(sql_queries) > 3: + reward -= 1.5 + + # --- check query quality --- + where_count = 0 + for q in sql_queries: + if "limit 1" in q: + reward -= 1.0 + if " where " not in q: + reward -= 0.5 + else: + where_count += 1 + reward += min(where_count, 3) * 0.4 # small bonus for WHERE usage + + # --- evidence check: do queries support the answer? --- + combined_results = [] + error_detected = False + + for res in tool_results: + if isinstance(res, dict) and "error" in res: + error_detected = True + elif isinstance(res, list): + combined_results.extend(res) + + # if error detected, penalize heavily + if error_detected: + reward -= 2.0 + elif len(sql_queries) == 0: + reward -= 1.5 + else: + has_hits = len(combined_results) > 0 + correct_answer = ans.lower() + if (has_hits and correct_answer == "yes") or (not has_hits and correct_answer == "no"): + reward += 2.0 + else: + reward -= 1.5 + + rewards.append(reward) + + return rewards + + +def correctness_reward(completions, answer, **kwargs): + """ + Reward Yes/No correctness. + Model must provide final answer enclosed in stars — *yes* or *no*. + Does not reward informal yes/no buried in text. + """ + rewards = [] + for completion, ans in zip(completions, answer, strict=False): + raw = completion[-1]["content"].lower() + + # detect form *yes* or *no* + match = re.search(r"\*(yes|no)\*", raw) + guess = match.group(1) if match else None + + reward = 0.0 + + if guess is None: + reward -= 0.5 # invalid format + elif guess == ans.lower(): + reward += 0.6 # correct under required format + else: + reward -= 1.0 # wrong answer + + rewards.append(reward) + + return rewards + + +def structure_reward(completions, **kwargs): + """ + Reward proper assistant structure. + Encourages a logical sequence: tool call + response + optional extra content. + """ + rewards = [] + + for completion in completions: + has_call = False + has_response = False + has_other = False + + for turn in completion: + role = turn.get("role") + if role == "assistant" and turn.get("tool_calls"): + has_call = True + elif role == "tool": + has_response = True + else: + content = turn.get("content") + if content and content.strip() not in ["", ""]: + has_other = True + + # Reward sequences + if has_call and has_response: + if has_other: + reward = 0.1 + else: + reward = 0.05 # still positive even without extra text + elif has_call and not has_response: + reward = -0.15 + else: + reward = 0.0 # neutral if no call + + rewards.append(reward) + + return rewards + + +# ------------------------ +# Database tool function +# ------------------------ +class TimeoutError(Exception): + """Raised when a function call times out.""" + + pass + + +@contextmanager +def timeout(seconds): + """Context manager that raises TimeoutError if execution exceeds time limit.""" + + def timeout_handler(signum, frame): + raise TimeoutError(f"Operation timed out after {seconds} seconds") + + signal.signal(signal.SIGALRM, timeout_handler) + signal.alarm(seconds) + try: + yield + finally: + signal.alarm(0) + + +def query_biogrid(sql_command: str) -> list[tuple]: + """ + Execute a read-only SQL command on the BioGRID database. + + BioGRID is a curated biological database that compiles protein, genetic, and chemical interactions from multiple organisms. It provides researchers with experimentally verified interaction data to support studies in systems biology and functional genomics. + + Args: + sql_command: The SQL command to execute. + + Returns: + A list of tuples containing the query results. + """ + with timeout(5): + conn = sqlite3.connect("file:biogrid.db?mode=ro", uri=True) + cursor = conn.cursor() + try: + cursor.execute(sql_command) + results = cursor.fetchall() + finally: + conn.close() + return results + + +# ------------------------ +# Dataset formatting +# ------------------------ +def format_example(example): + question = example["question"] + preamble = textwrap.dedent("""\ + You have access to the BioGRID SQLite database. + Use SQL queries to retrieve only the information needed to answer the question. + + Genes may appear in the database in columns `Alt_IDs_Interactor_A` `Alt_IDs_Interactor_B`, `Aliases_Interactor_A` and `Aliases_Interactor_B`, + and each entry can contain multiple gene names or synonyms separated by '|', for example: + 'entrez gene/locuslink:JNKK(gene name synonym)|entrez gene/locuslink:MAPKK4(gene name synonym)|...' + So a gene like 'JNKK' or 'MAPKK4' may appear inside one of these strings. + + If the database schema is unclear or you are unsure about column names: + - First inspect the schema with `PRAGMA table_info(interactions);` + - Or preview a few rows with `SELECT * FROM interactions LIMIT 1;` + + Otherwise, directly query the required data. + + Final answer must be enclosed in stars, e.g. *Yes* or *No*. + Facts: + - The NCBI Taxonomy identifier for humans is taxid:9606. + """) + content = f"{preamble}\nQuestion: {question}" + prompt = [{"role": "user", "content": content}] + return {"prompt": prompt} + + +# ------------------------ +# Main +# ------------------------ +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, GRPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + # ------------------------ + # Create DB + # ------------------------ + print("Creating biogrid.db...") + # Load dataset + biogrid_dataset = load_dataset("qgallouedec/biogrid", split="train") + df = biogrid_dataset.to_pandas() + + # Normalize column names: remove spaces, replace with underscores + df.columns = [c.replace(" ", "_") for c in df.columns] + conn = sqlite3.connect("biogrid.db") + try: + df.to_sql("interactions", conn, if_exists="replace", index=False) + print(f"biogrid.db created. Rows stored: {len(df)}") + finally: + conn.close() + + # ------------------------ + # Load and format dataset + # ------------------------ + dataset = load_dataset("qgallouedec/biogrid_qa", split="train") + dataset = dataset.filter( + lambda example: example["question"].startswith("Does the gene ") + ) # keep only simple questions for example + dataset = dataset.map(format_example, remove_columns=["question"]) + + train_dataset = dataset + eval_dataset = None # No eval by default, can be added if needed + + training_args.chat_template_kwargs = {"enable_thinking": False} + + # ------------------------ + # Initialize trainer + # ------------------------ + trainer = GRPOTrainer( + model=model_args.model_name_or_path, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + tools=[query_biogrid], + reward_funcs=[correctness_reward, structure_reward, query_reward], + args=training_args, + ) + + # ------------------------ + # Train + # ------------------------ + trainer.train() + + # ------------------------ + # Save and push + # ------------------------ + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..c748b1b15fc1750a5dbf83e0a6c54beed627053c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/grpo_vlm.py @@ -0,0 +1,157 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow", +# "math-verify", +# "latex2sympy2_extended", +# "torchvision", +# "trackio", +# "kernels", +# ] +# /// + +""" +pip install math_verify + +# For Qwen/Qwen2.5-VL-3B-Instruct +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/grpo_vlm.py \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --output_dir grpo-Qwen2.5-VL-3B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_vllm \ + --vllm_mode colocate \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions + +# For HuggingFaceTB/SmolVLM2-2.2B-Instruct +pip install num2words==0.5.14 + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/grpo_vlm.py \ + --model_name_or_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \ + --output_dir grpo-SmolVLM2-2.2B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 2 \ + --num_generations 2 + +""" + +import torch +from datasets import load_dataset + +from trl import ( + GRPOConfig, + GRPOTrainer, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.rewards import accuracy_reward, think_format_reward + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, GRPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + ################ + # Model + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + training_args.model_init_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + training_args.model_init_kwargs["device_map"] = get_kbit_device_map() + training_args.model_init_kwargs["quantization_config"] = quantization_config + + ################ + # Dataset + ################ + dataset = load_dataset("lmms-lab/multimodal-open-r1-8k-verified", split="train") + dataset = dataset.train_test_split(test_size=100, seed=42) + + SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The " + "assistant first thinks about the reasoning process in the mind and then provides the user with the answer. " + "The reasoning process and answer are enclosed within tags, i.e., \nThis is my " + "reasoning.\n\nThis is my answer." + ) + + def make_conversation(example): + prompt = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ] + return {"prompt": prompt} + + dataset = dataset.map(make_conversation) + + # Filter have big images + def filter_big_images(example): + image = example["image"] + return image.size[0] < 512 and image.size[1] < 512 + + dataset = dataset.filter(filter_big_images) + + def convert_to_rgb(example): + image = example["image"] + if image.mode != "RGB": + image = image.convert("RGB") + example["image"] = image + return example + + dataset = dataset.map(convert_to_rgb) + + train_dataset = dataset["train"] + eval_dataset = dataset["test"] if training_args.eval_strategy != "no" else None + + ################ + # Training + ################ + trainer = GRPOTrainer( + model=model_args.model_name_or_path, + args=training_args, + reward_funcs=[think_format_reward, accuracy_reward], + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gspo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gspo.py new file mode 100644 index 0000000000000000000000000000000000000000..9f347fd6e3a3f2fbcaaff3cd3902a97981dba66b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gspo.py @@ -0,0 +1,131 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "math-verify", +# "latex2sympy2_extended", +# "trackio", +# "kernels", +# ] +# /// + +""" +pip install math_verify + +# For Qwen/Qwen3-0.6B +pip install num2words==0.5.14 + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/gspo.py \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --output_dir gspo-Qwen3-0.6B \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions \ + --per_device_train_batch_size 8 \ + --num_generations 8 \ + --importance_sampling_level sequence \ + --epsilon 3e-4 \ + --epsilon_high 4e-4 \ + --beta 0.0 \ + --loss_type grpo \ + --gradient_accumulation_steps 2 \ + --steps_per_generation 8 + +""" + +import torch +from datasets import load_dataset + +from trl import ( + GRPOConfig, + GRPOTrainer, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.rewards import accuracy_reward, think_format_reward + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, GRPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + ################ + # Model & Processor + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + training_args.model_init_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + training_args.model_init_kwargs["device_map"] = get_kbit_device_map() + training_args.model_init_kwargs["quantization_config"] = quantization_config + + ################ + # Dataset + ################ + train_dataset, eval_dataset = load_dataset("AI-MO/NuminaMath-TIR", split=["train[:5%]", "test[:5%]"]) + + SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The " + "assistant first thinks about the reasoning process in the mind and then provides the user with the answer. " + "The reasoning process and answer are enclosed within tags, i.e., \nThis is my " + "reasoning.\n\nThis is my answer." + ) + + def make_conversation(example): + return { + "prompt": [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ], + } + + train_dataset = train_dataset.map(make_conversation) + eval_dataset = eval_dataset.map(make_conversation) + + train_dataset = train_dataset.remove_columns(["messages", "problem"]) + eval_dataset = eval_dataset.remove_columns(["messages", "problem"]) + + ################ + # Training + ################ + trainer = GRPOTrainer( + model=model_args.model_name_or_path, + args=training_args, + reward_funcs=[think_format_reward, accuracy_reward], + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gspo_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gspo_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..f96c68a1819af438856810823948ed2d53f33ecb --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/gspo_vlm.py @@ -0,0 +1,146 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow", +# "math-verify", +# "latex2sympy2_extended", +# "torchvision", +# "trackio", +# "kernels", +# ] +# /// + +""" +pip install math_verify + +# For Qwen/Qwen2.5-VL-3B-Instruct +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/gspo_vlm.py \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --output_dir gspo-Qwen2.5-VL-3B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions \ + --per_device_train_batch_size 8 \ + --num_generations 8 \ + --importance_sampling_level sequence \ + --epsilon 3e-4 \ + --epsilon_high 4e-4 \ + --beta 0.0 \ + --loss_type grpo \ + --gradient_accumulation_steps 2 \ + --steps_per_generation 8 + +""" + +import torch +from datasets import load_dataset + +from trl import ( + GRPOConfig, + GRPOTrainer, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.rewards import accuracy_reward, think_format_reward + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, GRPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + ################ + # Model + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + training_args.model_init_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + training_args.model_init_kwargs["device_map"] = get_kbit_device_map() + training_args.model_init_kwargs["quantization_config"] = quantization_config + + ################ + # Dataset + ################ + dataset = load_dataset("lmms-lab/multimodal-open-r1-8k-verified", split="train") + dataset = dataset.train_test_split(test_size=100, seed=42) + + SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The " + "assistant first thinks about the reasoning process in the mind and then provides the user with the answer. " + "The reasoning process and answer are enclosed within tags, i.e., \nThis is my " + "reasoning.\n\nThis is my answer." + ) + + def make_conversation(example): + prompt = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ] + return {"prompt": prompt} + + dataset = dataset.map(make_conversation) + + # Filter have big images + def filter_big_images(example): + image = example["image"] + return image.size[0] < 512 and image.size[1] < 512 + + dataset = dataset.filter(filter_big_images) + + def convert_to_rgb(example): + image = example["image"] + if image.mode != "RGB": + image = image.convert("RGB") + example["image"] = image + return example + + dataset = dataset.map(convert_to_rgb) + + train_dataset = dataset["train"] + eval_dataset = dataset["test"] if training_args.eval_strategy != "no" else None + + ################ + # Training + ################ + trainer = GRPOTrainer( + model=model_args.model_name_or_path, + args=training_args, + reward_funcs=[think_format_reward, accuracy_reward], + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/kto.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/kto.py new file mode 100644 index 0000000000000000000000000000000000000000..97f469ea7f125a94bafb5f00635747e6887ed51d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/kto.py @@ -0,0 +1,105 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +Run the KTO training script with the commands below. In general, the optimal configuration for KTO will be similar to that of DPO. + +# Full training: +python trl/scripts/kto.py \ + --dataset_name trl-lib/kto-mix-14k \ + --model_name_or_path trl-lib/qwen1.5-1.8b-sft \ + --per_device_train_batch_size 16 \ + --num_train_epochs 1 \ + --learning_rate 5e-7 \ + --lr_scheduler_type cosine \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir kto-aligned-model \ + --warmup_steps 0.1 \ + --logging_first_step + +# QLoRA: +python trl/scripts/kto.py \ + --dataset_name trl-lib/kto-mix-14k \ + --model_name_or_path trl-lib/qwen1.5-1.8b-sft \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 5e-7 \ + --lr_scheduler_type cosine \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir kto-aligned-model-lora \ + --warmup_steps 0.1 \ + --logging_first_step \ + --use_peft \ + --load_in_4bit \ + --lora_target_modules all-linear \ + --lora_r 16 \ + --lora_alpha 16 +""" + +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser + +from trl import ModelConfig, ScriptArguments, get_peft_config +from trl.experimental.kto import KTOConfig, KTOTrainer + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, KTOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + # Load a pretrained model + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + ref_model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + # Load the dataset + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + # Initialize the KTO trainer + trainer = KTOTrainer( + model, + ref_model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + # Train and push the model to the Hub + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/mpo_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/mpo_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..bab89d45f6adc8b40ebbecb06ede4e9278371863 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/mpo_vlm.py @@ -0,0 +1,127 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow", +# "torchvision", +# "trackio", +# "kernels", +# ] +# /// + +""" +python examples/scripts/mpo_vlm.py \ + --dataset_name HuggingFaceH4/rlaif-v_formatted \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --per_device_train_batch_size 4 \ + --per_device_eval_batch_size 4 \ + --num_train_epochs 1 \ + --gradient_accumulation_steps 8 \ + --dataset_num_proc 1 \ + --output_dir dpo_idefics_rlaif-v \ + --dtype bfloat16 \ + --use_peft \ + --lora_target_modules down_proj, o_proj, k_proj, q_proj, gate_proj, up_proj, v_proj \ + --loss_type sigmoid bco_pair sft \ + --loss_weights 0.8 0.2 1.0 +""" + +import torch +from datasets import load_dataset +from PIL import Image +from transformers import AutoModelForImageTextToText + +from trl import ( + DPOConfig, + DPOTrainer, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, DPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + ################ + # Model & Processor + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + + model_kwargs = dict( + trust_remote_code=model_args.trust_remote_code, + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForImageTextToText.from_pretrained( + model_args.model_name_or_path, + **model_kwargs, + ) + peft_config = get_peft_config(model_args) + + ################ + # Dataset + ################ + dataset = load_dataset( + script_args.dataset_name, + name=script_args.dataset_config, + streaming=script_args.dataset_streaming, + ) + train_dataset = dataset[script_args.dataset_train_split] + test_dataset = dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None + + def ensure_rgb(example): + # Convert the image to RGB if it's not already + image = example["images"][0] + if isinstance(image, Image.Image): + if image.mode != "RGB": + image = image.convert("RGB") + example["images"] = [image] + return example + + # Apply the transformation to the dataset (change num_proc depending on the available compute) + train_dataset = train_dataset.map(ensure_rgb, num_proc=training_args.dataset_num_proc) + if test_dataset is not None: + test_dataset = test_dataset.map(ensure_rgb, num_proc=training_args.dataset_num_proc) + + ################ + # Training + ################ + trainer = DPOTrainer( + model=model, + args=training_args, + train_dataset=train_dataset, + eval_dataset=test_dataset, + peft_config=peft_config, + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nash_md.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nash_md.py new file mode 100644 index 0000000000000000000000000000000000000000..273dcdd8aa68460279a145d65dc88058c7ff1b93 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nash_md.py @@ -0,0 +1,137 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "trackio", +# "kernels", +# ] +# /// + +""" +Usage: + +python examples/scripts/nash_md.py \ + --model_name_or_path trl-lib/pythia-1b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-1b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-1b-tldr-nash-md \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 32 \ + --num_train_epochs 3 \ + --max_new_tokens 64 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --push_to_hub + + +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero2.yaml \ + examples/scripts/nash_md.py \ + --model_name_or_path trl-lib/pythia-1b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-1b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-1b-tldr-nash-md \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 32 \ + --num_train_epochs 3 \ + --max_new_tokens 64 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --push_to_hub +""" + +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_quantization_config, +) +from trl.experimental.nash_md import NashMDConfig, NashMDTrainer + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, NashMDConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + training_args.gradient_checkpointing_kwargs = {"use_reentrant": True} + + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + use_cache=False if training_args.gradient_checkpointing else True, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + ref_model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + if training_args.reward_model_path is not None: + reward_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + num_labels=1, + trust_remote_code=model_args.trust_remote_code, + **model_kwargs, + ) + else: + reward_model = None + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, padding_side="left", trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + trainer = NashMDTrainer( + model=model, + ref_model=ref_model, + reward_funcs=reward_model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + ) + + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_new_tokens, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/README.md b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/README.md new file mode 100644 index 0000000000000000000000000000000000000000..23784c594cd0f76a88b3638d4fd8c2086e25335a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/README.md @@ -0,0 +1,5 @@ +# Post-training with NeMo Gym and TRL + +This integration supports training language models in NeMo-Gym environments using TRL GRPO. Both single step and multi step tasks are supported, including multi-environment training. NeMo-Gym orchestrates rollouts, returning token ids and logprobs to TRL through the rollout function for training. Currently this integration is only supported through TRL's vllm server mode. + +Check out the docs page `docs/source/nemo_gym.md` for a guide. \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/config.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1ac7b5631ecee4bfed6421b1499a538633ef9862 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/config.yaml @@ -0,0 +1,37 @@ +# Model +model_name: "Qwen/Qwen2.5-1.5B-Instruct" + +# Data +dataset_path: "/home/ubuntu/Gym/resources_servers/workplace_assistant/data/train.jsonl" +eval_dataset_path: "/home/ubuntu/Gym/resources_servers/workplace_assistant/data/validation.jsonl" + +# Logging +output_dir: "outputs/nemo_gym" +task: "workplace" # just used in wandb run name +report_to: "wandb" +project_name: "trl-nemo-gym" +log_completions: true +num_completions_to_print: 2 + +# Training hyperparameters +learning_rate: 1.0e-5 +max_steps: 1000 +num_generations: 8 +per_device_train_batch_size: 1 +gradient_accumulation_steps: 32 +max_completion_length: 16384 +warmup_steps: 5 +lr_scheduler_type: "linear" +optim: "adamw_torch_fused" +weight_decay: 0.0 +vllm_importance_sampling_correction: true + +# Inference sampling parameters +temperature: 1.0 +top_p: 0.999 + +# Checkpointing and Eval +save_steps: 10 +eval_strategy: "steps" +eval_steps: 10 + diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/deepspeed_zero3.yaml b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/deepspeed_zero3.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac6ad51adb0fe9b190d88cdd8588d5ededd6540a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/deepspeed_zero3.yaml @@ -0,0 +1,22 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + offload_optimizer_device: none + offload_param_device: none + zero3_init_flag: true + zero3_save_16bit_model: true + zero_stage: 3 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 4 +num_processes: 32 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/submit.sh b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/submit.sh new file mode 100644 index 0000000000000000000000000000000000000000..c819c0fa45dc68dcc336ea622e4928c995cad8ba --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/submit.sh @@ -0,0 +1,112 @@ +#!/bin/bash +#SBATCH -A account +#SBATCH -p partition +#SBATCH -N 5 +#SBATCH --gres gpu:8 +#SBATCH --ntasks-per-node=1 +#SBATCH --cpus-per-task=16 +#SBATCH --time=4:00:00 +#SBATCH --job-name=trl_nemo_gym +#SBATCH --output=logs/%j/slurm.out +#SBATCH --error=logs/%j/slurm.err + +CONTAINER_IMAGE="nvcr.io/nvidia/pytorch:25.12-py3" +MOUNTS="/path/to/mounts:/path/to/mounts" + +NODELIST=($(scontrol show hostnames $SLURM_JOB_NODELIST)) + +TRAIN_NODE_0="${NODELIST[0]}" +TRAIN_NODE_1="${NODELIST[1]}" +TRAIN_NODE_2="${NODELIST[2]}" +TRAIN_NODE_3="${NODELIST[3]}" +VLLM_NODE="${NODELIST[4]}" + +echo "Training Nodes: $TRAIN_NODE_0, $TRAIN_NODE_1, $TRAIN_NODE_2, $TRAIN_NODE_3" +echo "vLLM Node: $VLLM_NODE" +echo "Main process IP: $TRAIN_NODE_0" + +LOG_DIR="logs/${SLURM_JOB_ID}" +mkdir -p ${LOG_DIR} + +echo "Starting ng_run and vLLM on ${VLLM_NODE}..." +echo "Logs will be saved to: ${LOG_DIR}" + +# NOTE: If you have already set up your TRL venv, you can remove all of the pip installs and uv venv related commands below! + +srun --nodes=1 --ntasks=1 --nodelist="${VLLM_NODE}" \ + --container-image="${CONTAINER_IMAGE}" \ + --container-mounts="${MOUNTS}" \ + --container-mount-home \ + bash -c " + LOG_DIR=/path/to/logs + mkdir -p \${LOG_DIR} + + # Install uv if not already installed + curl -LsSf https://astral.sh/uv/install.sh | sh + source \$HOME/.local/bin/env + + # Start nemo gym servers + (set -x && \ + export HOME=/path/to/user && \ + export PATH=\$HOME/.local/bin:\$PATH && \ + cd /path/to/user/Gym && \ + uv venv --python 3.12 && \ + source .venv/bin/activate && \ + uv sync && \ + ray stop --force && \ + ng_run +config_paths=[responses_api_models/vllm_model/configs/vllm_model.yaml,resources_servers/workplace_assistant/configs/workplace_assistant.yaml] +head_server.host=0.0.0.0 +head_server.port=11000) > \${LOG_DIR}/ng_run.log 2>&1 & + + sleep 10 + + # Start trl vllm server + (set -x && \ + export HOME=/path/to/user && \ + export HF_HOME=/path/to/user/hf_home && \ + cd /path/to/user/trl && \ + rm -rf .venv && uv venv && source .venv/bin/activate && uv sync && uv pip install -e .[vllm] && uv pip install fastapi uvicorn && \ + python -m trl.scripts.vllm_serve \ + --model Qwen/Qwen3-4B-Instruct-2507 \ + --host 0.0.0.0 \ + --tensor-parallel-size 8 \ + --data-parallel-size 1 \ + --max-model-len 16384 \ + --gpu-memory-utilization 0.7 \ + --port 8000) > \${LOG_DIR}/vllm_serve.log 2>&1 & + + wait +" & + +echo "Waiting for nemo gym and vllm to start..." +sleep 120 + +echo "Launching training on 4 nodes..." + +TRAIN_NODES_LIST="${TRAIN_NODE_0},${TRAIN_NODE_1},${TRAIN_NODE_2},${TRAIN_NODE_3}" + +srun --nodes=4 --ntasks=4 --nodelist="${TRAIN_NODES_LIST}" \ + --container-image="${CONTAINER_IMAGE}" \ + --container-mounts="${MOUNTS}" \ + --container-mount-home \ + bash -c " + set -x && \ + export HOME=/path/to/user && \ + export HF_HOME=/path/to/user/hf_home && \ + cd /path/to/user/trl && \ + source .venv/bin/activate && uv pip install accelerate deepspeed wandb omegaconf && \ + cd examples/scripts/nemo_gym && \ + export WANDB_API_KEY= && \ + accelerate launch \ + --config_file deepspeed_zero3.yaml \ + --num_processes 32 \ + --num_machines 4 \ + --machine_rank \$SLURM_PROCID \ + --main_process_ip ${TRAIN_NODE_0} \ + --main_process_port 29500 \ + --rdzv_backend c10d \ + train_multi_environment.py \ + --config config.yaml \ + --vllm_server_host ${VLLM_NODE} \ + --head_server_host ${VLLM_NODE}" & + +wait + diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/train_multi_environment.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/train_multi_environment.py new file mode 100644 index 0000000000000000000000000000000000000000..dd7d1c8567ba262568cc30776e69e671101ca8af --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/nemo_gym/train_multi_environment.py @@ -0,0 +1,401 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[vllm]", +# "nemo_gym @ git+https://github.com/NVIDIA-NeMo/Gym", +# ] +# /// + +import argparse +import asyncio +import json +import os +from dataclasses import dataclass +from typing import Any + +import aiohttp +import requests +import yaml +from datasets import Dataset, load_dataset +from omegaconf import OmegaConf +from transformers import AutoTokenizer + +from trl import GRPOConfig, GRPOTrainer + + +@dataclass +class NeMoGymGRPOConfig(GRPOConfig): + agent_servers: dict[str, str] | None = None + request_timeout: float = 10800 + + +def get_agent_servers( + head_server_host: str = "127.0.0.1", + head_server_port: int = 11000, +) -> dict[str, str]: + try: + response = requests.get(f"http://{head_server_host}:{head_server_port}/global_config_dict_yaml", timeout=10) + response.raise_for_status() + global_config_yaml = response.text + global_config_dict = OmegaConf.create(yaml.safe_load(global_config_yaml)) + + agent_servers = {} + for server_name, server_config in global_config_dict.items(): + if hasattr(server_config, "responses_api_agents"): + agents = server_config.responses_api_agents + for agent_key in agents.keys(): + agent_config = getattr(agents, agent_key) + if hasattr(agent_config, "host") and hasattr(agent_config, "port"): + agent_host = agent_config.host + if agent_host in ("127.0.0.1", "0.0.0.0", "localhost"): + agent_host = head_server_host + agent_servers[server_name] = f"http://{agent_host}:{agent_config.port}" + + if not agent_servers: + raise ValueError("No agents found in global config") + + return agent_servers + + except requests.exceptions.RequestException as e: + raise RuntimeError(f"Failed to connect to head server at {head_server_host}:{head_server_port}: {e}") from e + + +def reward_fn(completions: list[str], **kwargs) -> list[float]: + env_rewards = kwargs.get("env_reward") + assert env_rewards is not None, "env_reward not found in kwargs" + return [float(r) for r in env_rewards] + + +async def call_nemo_gym_agents( + prompts: list[str], + dataset_items: list[dict[str, Any]], + agent_servers: dict[str, str], + timeout: float, + max_completion_length: int = 4096, + temperature: float = 1.0, + top_p: float = 0.999, +) -> list[dict[str, Any]]: + async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session: + tasks = [] + for prompt, item in zip(prompts, dataset_items, strict=False): + request_body = item.copy() + + if "responses_create_params" not in request_body: + request_body["responses_create_params"] = { + "input": [{"role": "user", "content": prompt}], + } + + params = request_body["responses_create_params"] + params.setdefault("max_output_tokens", max_completion_length) + params["temperature"] = temperature + params["top_p"] = top_p + + agent_ref = item.get("agent_ref", {}) + agent_name = agent_ref.get("name") if isinstance(agent_ref, dict) else None + if not agent_name or agent_name not in agent_servers: + raise ValueError( + f"Missing or invalid agent_ref. Got: {agent_ref}. Available: {list(agent_servers.keys())}" + ) + agent_url = agent_servers[agent_name] + + task = session.post( + f"{agent_url}/run", + json=request_body, + timeout=aiohttp.ClientTimeout(total=timeout), + ) + tasks.append(task) + + responses = await asyncio.gather(*tasks, return_exceptions=True) + + results = [] + for i, response in enumerate(responses): + try: + if isinstance(response, Exception): + raise response + json_data = await response.json() + if not isinstance(json_data, dict): + raise ValueError(f"Expected dict, got {type(json_data)}") + results.append(json_data) + except Exception as e: + print(f"WARNING: Request {i} failed: {e}") + results.append({"response": {"output": []}, "reward": 0.0, "error": str(e)}) + + return results + + +def nemo_gym_rollout_func(prompts: list[str], trainer: GRPOTrainer) -> dict[str, list]: + is_eval = not trainer.model.training + num_generations = ( + trainer.args.num_generations_eval + if is_eval and trainer.args.num_generations_eval + else trainer.args.num_generations + ) + dataset = trainer.eval_dataset if is_eval and trainer.eval_dataset is not None else trainer.train_dataset + + expanded_prompts = [] + expanded_dataset_items = [] + + for idx_str in prompts: + idx = int(idx_str) + item = json.loads(dataset[idx]["metadata"]) + + for _ in range(num_generations): + expanded_prompts.append(idx_str) + expanded_dataset_items.append(dict(item)) + + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + responses = loop.run_until_complete( + call_nemo_gym_agents( + expanded_prompts, + expanded_dataset_items, + trainer.args.agent_servers, + trainer.args.request_timeout, + trainer.args.max_completion_length, + temperature=trainer.args.temperature, + top_p=trainer.args.top_p, + ) + ) + finally: + loop.close() + + tokenizer = trainer.processing_class + + prompt_ids: list[list[int]] = [] + completion_ids: list[list[int]] = [] # list of rollouts + env_mask: list[list[int]] = [] # only train on assistant turns + + logprobs: list[list[float]] = [] + env_rewards: list[float] = [] + num_turns_list: list[int] = [] + + for i, response in enumerate(responses): + eos_token_id = tokenizer.eos_token_id or 0 + + if not isinstance(response, dict) or response.get("error"): + rollout_failed = True + else: + output_items = response.get("response", {}).get("output", []) + has_content = output_items and any( + item.get("type") == "function_call" + or ( + item.get("type") == "message" + and any( + c.get("type") == "output_text" and c.get("text", "").strip() for c in item.get("content", []) + ) + ) + for item in output_items + ) + rollout_failed = not has_content + + if rollout_failed: + prompt_ids.append([eos_token_id]) + completion_ids.append([eos_token_id]) + env_mask.append([0]) + logprobs.append([0.0]) + env_rewards.append(0.0) + num_turns_list.append(0) + continue + + episode_reward = response.get("reward", 0.0) + output_items = response.get("response", {}).get("output", []) + + rollout_ids: list[int] = [] + rollout_mask: list[int] = [] + rollout_logprobs: list[float] = [] + + seen_token_ids: list[int] = [] + first_prompt = None + num_turns = 0 + + for _idx, item in enumerate(output_items): + if "prompt_token_ids" not in item or "generation_token_ids" not in item: + continue + + num_turns += 1 + item_prompt_ids = item["prompt_token_ids"] + item_gen_ids = item["generation_token_ids"] + item_logprobs = item.get("generation_log_probs", []) + tool_result_tokens = [] + + if first_prompt is None: + first_prompt = item_prompt_ids + seen_token_ids = list(item_prompt_ids) + else: + if len(item_prompt_ids) > len(seen_token_ids): + if item_prompt_ids[: len(seen_token_ids)] != seen_token_ids: + raise ValueError( + f"[Turn {num_turns}] Non-contiguous messages (tokenization issue). " + f"Expected prefix len {len(seen_token_ids)}, got prompt len {len(item_prompt_ids)}" + ) + tool_result_tokens = item_prompt_ids[len(seen_token_ids) :] + + if tool_result_tokens: + rollout_ids.extend(tool_result_tokens) + rollout_mask.extend([0] * len(tool_result_tokens)) + rollout_logprobs.extend([0.0] * len(tool_result_tokens)) + + rollout_ids.extend(item_gen_ids) + rollout_mask.extend([1] * len(item_gen_ids)) + assert len(item_logprobs) == len(item_gen_ids), ( + f"Logprobs len {len(item_logprobs)} != gen len {len(item_gen_ids)}" + ) + rollout_logprobs.extend(item_logprobs) + + seen_token_ids = list(item_prompt_ids) + list(item_gen_ids) + + if not rollout_ids or first_prompt is None: + raise ValueError(f"Rollout {i} has no valid turns") + + prompt_ids.append(first_prompt) # list of prompts + completion_ids.append(rollout_ids) # list of rollouts + env_mask.append(rollout_mask) + logprobs.append(rollout_logprobs) + env_rewards.append(episode_reward) + num_turns_list.append(num_turns) + + if not prompt_ids: + raise RuntimeError("No valid rollouts. Check Nemo Gym and vLLM logs.") + + if num_turns_list: + trainer.log( + { + "num_turns_mean": sum(num_turns_list) / len(num_turns_list), + "num_turns_min": min(num_turns_list), + "num_turns_max": max(num_turns_list), + } + ) + + unique_prompt_ids = prompt_ids[::num_generations] + + return { + "prompt_ids": unique_prompt_ids, + "completion_ids": completion_ids, + "env_mask": env_mask, + "logprobs": logprobs, + "env_reward": env_rewards, + "num_turns": num_turns_list, + } + + +def load_dataset_from_jsonl(path: str) -> Dataset: + data = [] + with open(path) as f: + for idx, line in enumerate(f): + if line.strip(): + item = json.loads(line) + data.append( + { + "prompt": str( + idx + ), # use index for lookup as not all nemo gym datasets have the same metadata fields. maybe not the most elegant + "metadata": json.dumps(item), + } + ) + return Dataset.from_list(data) + + +def main(): + parser = argparse.ArgumentParser(description="") + parser.add_argument("--config", required=True, help="Path to config YAML file") + parser.add_argument("--vllm_server_host", type=str, default="127.0.0.1", help="vLLM server hostname/IP") + parser.add_argument("--head_server_host", type=str, default="127.0.0.1", help="Head server hostname/IP for ng_run") + parser.add_argument("--resume_from_checkpoint", type=str, default=None, help="Path to checkpoint to resume from") + args = parser.parse_args() + + with open(args.config) as f: + config = yaml.safe_load(f) + + model_name = config.pop("model_name") + dataset_path = config.pop("dataset_path") + eval_dataset_path = config.pop("eval_dataset_path", None) + task = config.pop("task", None) + project_name = config.pop("project_name", None) + + if "learning_rate" in config and isinstance(config["learning_rate"], str): + config["learning_rate"] = float(config["learning_rate"]) + if "weight_decay" in config and isinstance(config["weight_decay"], str): + config["weight_decay"] = float(config["weight_decay"]) + + agent_servers = get_agent_servers( + head_server_host=args.head_server_host, + head_server_port=11000, + ) + + if project_name: + os.environ["WANDB_PROJECT"] = project_name + + if dataset_path.endswith((".jsonl", ".json")): + dataset = load_dataset_from_jsonl(dataset_path) + else: + dataset = load_dataset(dataset_path, split="train") + + eval_dataset = None + if eval_dataset_path: + eval_dataset = load_dataset_from_jsonl(eval_dataset_path) + print(f"Eval dataset has {len(eval_dataset)} examples\n") + + training_args = NeMoGymGRPOConfig( + use_vllm=True, + vllm_mode="server", + vllm_server_host=args.vllm_server_host, + vllm_server_port=8000, + gradient_checkpointing=True, + num_generations_eval=1, + logging_steps=1, + epsilon=0.2, + epsilon_high=0.28, + loss_type="grpo", + mask_truncated_completions=True, + shuffle_dataset=False, + model_init_kwargs={"torch_dtype": "auto"}, + agent_servers=agent_servers, + request_timeout=10800, + **config, + ) + + if training_args.run_name is None: + task_name = task or os.path.basename(dataset_path).replace(".jsonl", "").replace(".json", "") + model_short = model_name.split("/")[-1] + training_args.run_name = ( + f"{task_name}_{model_short}" + f"_rpp{training_args.num_generations}" + f"_dbs{training_args.per_device_train_batch_size}" + f"_ga{training_args.gradient_accumulation_steps}" + f"_maxlen{training_args.max_completion_length}" + f"_lr{training_args.learning_rate}" + f"_temp{training_args.temperature}" + f"_topp{training_args.top_p}" + ) + + tokenizer = AutoTokenizer.from_pretrained(model_name, truncation_side="left", padding_side="left") + + trainer = GRPOTrainer( + model=model_name, + processing_class=tokenizer, + reward_funcs=reward_fn, + train_dataset=dataset, + eval_dataset=eval_dataset, + rollout_func=nemo_gym_rollout_func, + args=training_args, + ) + + trainer.train(resume_from_checkpoint=args.resume_from_checkpoint) + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/online_dpo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/online_dpo.py new file mode 100644 index 0000000000000000000000000000000000000000..3eaaaec159d420cc734e6b26787b0175332c7e43 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/online_dpo.py @@ -0,0 +1,142 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +Usage: + +python examples/scripts/online_dpo.py \ + --model_name_or_path trl-lib/pythia-1b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-1b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-1b-tldr-online-dpo \ + --per_device_train_batch_size 8 \ + --gradient_accumulation_steps 16 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 + +With LoRA: +python examples/scripts/online_dpo.py \ + --model_name_or_path trl-lib/pythia-1b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-1b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-6 \ + --output_dir pythia-1b-tldr-online-dpo \ + --per_device_train_batch_size 16 \ + --gradient_accumulation_steps 8 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --use_peft +""" + +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.experimental.online_dpo import OnlineDPOConfig, OnlineDPOTrainer + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, OnlineDPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + training_args.gradient_checkpointing_kwargs = {"use_reentrant": True} + + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + use_cache=False if training_args.gradient_checkpointing else True, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + if training_args.reward_model_path is not None: + reward_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + num_labels=1, + trust_remote_code=model_args.trust_remote_code, + **model_kwargs, + ) + reward_tokenizer = AutoTokenizer.from_pretrained( + training_args.reward_model_path, + trust_remote_code=model_args.trust_remote_code, + truncation=True, + truncation_side="left", # since we judge the completion, truncating left is more appropriate + ) + if reward_tokenizer.pad_token_id is None: + reward_tokenizer.pad_token = reward_tokenizer.eos_token + else: + reward_model = None + reward_tokenizer = None + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, + padding_side="left", + trust_remote_code=model_args.trust_remote_code, + **model_kwargs, + ) + if tokenizer.pad_token_id is None: + tokenizer.pad_token = tokenizer.eos_token + + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + trainer = OnlineDPOTrainer( + model=model, + reward_funcs=reward_model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + reward_processing_classes=reward_tokenizer, + peft_config=get_peft_config(model_args), + ) + + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_new_tokens, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/online_dpo_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/online_dpo_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..766f4f7ba052b8745eaacab67425bba7ef6c1c0c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/online_dpo_vlm.py @@ -0,0 +1,208 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "math-verify", +# "latex2sympy2_extended", +# "trackio", +# "torchvision", +# "kernels", +# ] +# /// + +""" +pip install math_verify + +# For Qwen/Qwen2.5-VL-3B-Instruct +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/online_dpo_vlm.py \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --reward_model_path Qwen/Qwen2.5-VL-3B-Instruct \ + --output_dir online-dpo-Qwen2.5-VL-3B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_length 1536 \ + --max_new_tokens 1024 \ + --use_vllm \ + --vllm_mode server \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 2 + +# For HuggingFaceTB/SmolVLM2-2.2B-Instruct +pip install num2words==0.5.14 + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/online_dpo_vlm.py \ + --model_name_or_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \ + --reward_model_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \ + --output_dir online-dpo-SmolVLM2-2.2B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_length 1536 \ + --max_new_tokens 1024 \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 2 + +# Single GPU test command: +python examples/scripts/online_dpo_vlm.py \ + --model_name_or_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \ + --reward_model_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \ + --output_dir online-dpo-SmolVLM2-2.2B-Instruct-test \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_length 1536 \ + --max_new_tokens 128 \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 1 \ + --max_steps 2 \ + --logging_steps 1 \ + --trust_remote_code +""" + +import torch +import transformers +from datasets import load_dataset +from transformers import AutoConfig, AutoProcessor, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.experimental.online_dpo import OnlineDPOConfig, OnlineDPOTrainer +from trl.rewards import accuracy_reward, think_format_reward + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, OnlineDPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + training_args.gradient_checkpointing_kwargs = {"use_reentrant": True} + + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + use_cache=False if training_args.gradient_checkpointing else True, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + # Load the VLM model using correct architecture (from GRPO pattern) + config = AutoConfig.from_pretrained(model_args.model_name_or_path) + architecture = getattr(transformers, config.architectures[0]) + model = architecture.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + # For VLM online DPO, using a reward model is complex because it needs images + reward_model = None + reward_processor = None + + # Load processor for main model + processor = AutoProcessor.from_pretrained( + model_args.model_name_or_path, + trust_remote_code=model_args.trust_remote_code, + ) + if hasattr(processor, "tokenizer"): + processor.tokenizer.padding_side = "left" + if processor.tokenizer.pad_token_id is None: + processor.tokenizer.pad_token = processor.tokenizer.eos_token + + ################ + # Dataset + ################ + dataset = load_dataset("lmms-lab/multimodal-open-r1-8k-verified", split="train") + dataset = dataset.train_test_split(test_size=100, seed=42) + + SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The " + "assistant first thinks about the reasoning process in the mind and then provides the user with the answer. " + "The reasoning process and answer are enclosed within tags, i.e., \nThis is my " + "reasoning.\n\nThis is my answer." + ) + + def make_conversation(example): + # Create conversational format that OnlineDPOTrainer expects + prompt = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ] + return {"prompt": prompt, "image": example["image"]} + + dataset = dataset.map(make_conversation) + + # Filter big images (from GRPO pattern) + def filter_big_images(example): + image = example["image"] + return image.size[0] < 512 and image.size[1] < 512 + + dataset = dataset.filter(filter_big_images) + + def convert_to_rgb(example): + image = example["image"] + if image.mode != "RGB": + image = image.convert("RGB") + example["image"] = image + return example + + dataset = dataset.map(convert_to_rgb) + + train_dataset = dataset["train"] + eval_dataset = dataset["test"] if training_args.eval_strategy != "no" else None + + ################ + # Training + ################ + trainer = OnlineDPOTrainer( + model=model, + reward_funcs=[think_format_reward, accuracy_reward], # Use same reward functions as GRPO VLM + args=training_args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processor, + peft_config=get_peft_config(model_args), + ) + + # Add completion logging callback (from online DPO pattern) + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_new_tokens, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name="lmms-lab/multimodal-open-r1-8k-verified") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/browsergym.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/browsergym.py new file mode 100644 index 0000000000000000000000000000000000000000..49a0b4c712f84d84b5273f46d9a24f9cda937373 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/browsergym.py @@ -0,0 +1,290 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[vllm,peft]", +# "trackio", +# "kernels", +# "openenv-browsergym @ git+https://huggingface.co/spaces/openenv/browsergym_env", +# ] +# /// + +""" +GRPO training with OpenEnv's BrowserGym environment for VLMs (Vision Language Models). + +This script uses `environment_factory` with multimodal tool responses: each tool action +returns a screenshot (PIL Image) alongside the accessibility tree text, allowing the VLM +to see the page visually after each action. + +Setup: +```sh +pip install "openenv-browsergym @ git+https://huggingface.co/spaces/openenv/browsergym_env" +``` + +Usage: +```sh +# Without vLLM (default, 1 GPU) +python examples/scripts/openenv/browsergym.py + +# With vLLM colocate (1 GPU, requires vLLM support for the model) +python examples/scripts/openenv/browsergym.py --use-vllm + +# With vLLM server (2 GPUs) +CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen3.5-2B --host 0.0.0.0 --port 8000 +CUDA_VISIBLE_DEVICES=1 python examples/scripts/openenv/browsergym.py --use-vllm --vllm-mode server +``` +""" + +from __future__ import annotations + +import argparse +from datetime import datetime +from pathlib import Path + +import numpy as np +from browsergym_env import BrowserGymAction, BrowserGymEnv +from datasets import Dataset +from PIL import Image + +from trl import GRPOConfig, GRPOTrainer + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="GRPO training with BrowserGym VLM environment.") + parser.add_argument("--model-id", default="Qwen/Qwen3.5-2B") + parser.add_argument("--space-url", default="https://openenv-browsergym-env.hf.space") + parser.add_argument("--dataset-prompt", default="Complete the web task successfully.") + parser.add_argument("--dataset-size", type=int, default=1000) + parser.add_argument("--max-steps", type=int, default=10) + parser.add_argument("--max-completion-length", type=int, default=1024) + parser.add_argument("--image-size", type=int, default=512, help="Resize screenshots to this size. 0 to disable.") + parser.add_argument("--num-generations", type=int, default=4) + parser.add_argument("--gradient-accumulation-steps", type=int, default=32) + parser.add_argument("--learning-rate", type=float, default=5e-6) + parser.add_argument("--num-epochs", type=int, default=1) + parser.add_argument("--logging-steps", type=int, default=1) + parser.add_argument("--output-dir", default=None) + parser.add_argument("--use-vllm", action="store_true", default=False, help="Enable vLLM for generation.") + parser.add_argument("--vllm-mode", choices=("colocate", "server"), default="colocate") + parser.add_argument("--vllm-server-url", default="http://localhost:8000") + return parser.parse_args() + + +def sanitize_name(name: str) -> str: + return name.replace("/", "-") + + +SYSTEM_PROMPT = """You control a web browser to complete tasks. + +The page structure shows elements as: [bid] element_type 'element_text' +For example: [13] button 'Click Me!' means the element has bid='13'. + +You will see a screenshot of the page after each action. Use the visual information +along with the page structure to decide your next action. + +Use the available tools to interact with the page: +- click: Click an element by its bid +- fill: Fill an input field with text +- send_keys: Send keyboard input +- scroll: Scroll the page +- noop: Do nothing + +Complete the given task as efficiently as possible.""" + + +def reward_completion(completions, environments, **kwargs) -> list[float]: + return [env.reward for env in environments] + + +def main() -> None: + args = parse_args() + + space_url = args.space_url + max_steps = args.max_steps + image_size = args.image_size + + dataset = Dataset.from_dict( + { + "prompt": [ + [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": args.dataset_prompt}, + ] + ] + * args.dataset_size + } + ) + + class BrowserGymVLMEnv: + def __init__(self): + self.client = BrowserGymEnv(base_url=space_url) + self.reward = 0.0 + self.done = False + self._step_count = 0 + + def reset(self, **kwargs) -> str | None: + self.reward = 0.0 + self.done = False + self._step_count = 0 + result = self.client.reset() + self.done = result.done + return self._format_observation(result.observation) + + def click(self, bid: str) -> list: + """Click an element on the page. + + Args: + bid: The BrowserGym ID of the element to click. + + Returns: + The updated page observation with screenshot. + """ + return self._do_action(f"click('{bid}')") + + def fill(self, bid: str, text: str) -> list: + """Fill an input field with text. + + Args: + bid: The BrowserGym ID of the input field. + text: The text to type into the field. + + Returns: + The updated page observation with screenshot. + """ + return self._do_action(f"fill('{bid}', '{text}')") + + def send_keys(self, text: str) -> list: + """Send keyboard input to the page. + + Args: + text: The keyboard input to send. + + Returns: + The updated page observation with screenshot. + """ + return self._do_action(f"send_keys('{text}')") + + def scroll(self, direction: str) -> list: + """Scroll the page. + + Args: + direction: Direction to scroll, either 'up' or 'down'. + + Returns: + The updated page observation with screenshot. + """ + return self._do_action(f"scroll('{direction}')") + + def noop(self) -> list: + """Do nothing and observe the current page state. + + Returns: + The current page observation with screenshot. + """ + return self._do_action("noop()") + + def _do_action(self, action_str: str) -> list: + if self.done: + raise ValueError("Episode is done.") + + self._step_count += 1 + result = self.client.step(BrowserGymAction(action_str=action_str)) + observation = result.observation + step_reward = float(result.reward or 0.0) + self.done = result.done + + if self.done and step_reward > 0: + self.reward = 1.0 + elif self.done: + self.reward = 0.0 + else: + self.reward = step_reward + + if self._step_count >= max_steps: + self.done = True + + return self._format_observation_multimodal(observation) + + def _format_observation(self, observation) -> str: + """Format initial observation as text (for reset, appended to prompt).""" + parts = [] + if observation.goal: + parts.append(f"Goal: {observation.goal}") + if observation.axtree_txt: + axtree = observation.axtree_txt + if len(axtree) > 2000: + axtree = axtree[:2000] + "..." + parts.append(f"Page structure:\n{axtree}") + return "\n\n".join(parts) if parts else "No observation available." + + def _format_observation_multimodal(self, observation) -> list: + """Format observation as multimodal content blocks (screenshot + text).""" + content = [] + + # Add screenshot if available + if observation.screenshot is not None: + screenshot_array = np.array(observation.screenshot, dtype=np.uint8) + screenshot_image = Image.fromarray(screenshot_array) + if image_size > 0: + screenshot_image.thumbnail((image_size, image_size), Image.LANCZOS) + content.append({"type": "image", "image": screenshot_image}) + + # Add text observation + parts = [] + if observation.goal: + parts.append(f"Goal: {observation.goal}") + if observation.last_action_error and observation.error: + parts.append(f"Error: {observation.error}") + if observation.axtree_txt: + axtree = observation.axtree_txt + if len(axtree) > 2000: + axtree = axtree[:2000] + "..." + parts.append(f"Page structure:\n{axtree}") + text = "\n\n".join(parts) if parts else "No observation available." + content.append({"type": "text", "text": text}) + + return content + + timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + default_output_dir = Path("outputs") / f"browsergym-vlm-grpo-{sanitize_name(args.model_id)}-{timestamp}" + output_dir = Path(args.output_dir or default_output_dir) + + trainer = GRPOTrainer( + model=args.model_id, + reward_funcs=reward_completion, + train_dataset=dataset, + args=GRPOConfig( + use_vllm=args.use_vllm, + vllm_mode=args.vllm_mode if args.use_vllm else "colocate", + vllm_server_base_url=args.vllm_server_url if args.use_vllm and args.vllm_mode == "server" else None, + output_dir=str(output_dir), + num_train_epochs=args.num_epochs, + learning_rate=args.learning_rate, + gradient_accumulation_steps=args.gradient_accumulation_steps, + num_generations=args.num_generations, + max_completion_length=args.max_completion_length, + logging_steps=args.logging_steps, + log_completions=True, + report_to="trackio", + trackio_space_id=f"browsergym-vlm-grpo-{sanitize_name(args.model_id)}", + chat_template_kwargs={"enable_thinking": False}, + ), + environment_factory=BrowserGymVLMEnv, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/browsergym_llm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/browsergym_llm.py new file mode 100644 index 0000000000000000000000000000000000000000..ae68f98e5785ca9d1f4eb09d002089d29e913d59 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/browsergym_llm.py @@ -0,0 +1,463 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[vllm,peft]", +# "trackio", +# "kernels", +# "openenv-browsergym @ git+https://huggingface.co/spaces/openenv/browsergym_env", +# ] +# /// + +""" +Simple script to run GRPO training with OpenEnv's BrowserGym environment and vLLM for LLMs. + +This script is optimized for text-only Language Models (LLMs). It uses the accessibility +tree text from BrowserGym, making it memory-efficient. + +The environment runs on a Hugging Face Space by default. + +Setup (Option A - Install from HF Space, recommended): + +```sh +uv pip install git+https://huggingface.co/spaces/openenv/browsergym_env +``` + +Setup (Option B - Clone OpenEnv repo, for development): + +```sh +git clone https://github.com/meta-pytorch/OpenEnv.git +cd OpenEnv/envs/browsergym_env +uv pip install -e . +``` + +# Option 1: HF Spaces + Colocated vLLM (1 GPU required) +```sh +python examples/scripts/openenv/browsergym_llm.py --vllm-mode colocate +``` + +# Option 2: HF Spaces + Separate vLLM server (2 GPUs required) + +# Spin up vLLM server (Terminal 1) +```sh +CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen3-0.6B --host 0.0.0.0 --port 8001 +``` + +# Run training (Terminal 2) +```sh +CUDA_VISIBLE_DEVICES=1 python examples/scripts/openenv/browsergym_llm.py --vllm-mode server --vllm-server-url http://localhost:8001 +``` +""" + +from __future__ import annotations + +import argparse +from datetime import datetime +from pathlib import Path + +from browsergym_env import BrowserGymAction, BrowserGymEnv +from datasets import Dataset + +from trl import GRPOConfig, GRPOTrainer + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="Run GRPO training for BrowserGym MiniWoB using OpenEnv environment.") + parser.add_argument( + "--model-id", + default="Qwen/Qwen3-0.6B", + help="Model identifier passed to GRPOTrainer for fine-tuning.", + ) + parser.add_argument( + "--space-url", + type=str, + default="https://openenv-browsergym-env.hf.space", + help="URL for the Hugging Face Space running the BrowserGym environment.", + ) + parser.add_argument( + "--benchmark", + default="miniwob", + help="BrowserGym benchmark to use (miniwob, webarena, etc.).", + ) + parser.add_argument( + "--task-name", + default="click-test", + help="Specific task within the benchmark (e.g., click-test, click-button).", + ) + parser.add_argument( + "--dataset-prompt", + default="Complete the web task successfully.", + help="Prompt text used to seed the training dataset.", + ) + parser.add_argument( + "--dataset-size", + type=int, + default=1000, + help="Number of entries to include in the synthetic training dataset.", + ) + parser.add_argument( + "--max-steps", + type=int, + default=10, + help="Maximum number of steps per episode.", + ) + parser.add_argument( + "--max-completion-length", + type=int, + default=1024, + help="Maximum completion length in tokens for tool-calling generation.", + ) + parser.add_argument( + "--temperature", + type=float, + default=0.7, + help="Sampling temperature used during rollout generation.", + ) + parser.add_argument( + "--top-k", + type=int, + default=50, + help="Top-k sampling parameter forwarded to vLLM.", + ) + parser.add_argument( + "--top-p", + type=float, + default=None, + help="Optional top-p sampling parameter forwarded to vLLM.", + ) + parser.add_argument( + "--learning-rate", + type=float, + default=5e-6, + help="Learning rate for GRPO training.", + ) + parser.add_argument( + "--weight-decay", + type=float, + default=0.0, + help="Weight decay applied during optimization.", + ) + parser.add_argument( + "--gradient-accumulation-steps", + type=int, + default=32, + help="Gradient accumulation steps for GRPO training.", + ) + parser.add_argument( + "--warmup-steps", + type=int, + default=10, + help="Warmup steps for the scheduler.", + ) + parser.add_argument( + "--per-device-batch-size", + type=int, + default=1, + help="Per-device train batch size.", + ) + parser.add_argument( + "--num-generations", + type=int, + default=4, + help="Number of rollout generations per dataset prompt.", + ) + parser.add_argument( + "--num-epochs", + type=int, + default=1, + help="Number of training epochs.", + ) + parser.add_argument( + "--save-interval", + type=int, + default=50, + help="Interval (in steps) between checkpoint saves.", + ) + parser.add_argument( + "--save-total-limit", + type=int, + default=None, + help="Maximum number of checkpoints to keep.", + ) + parser.add_argument( + "--output-dir", + default=None, + help="Directory where training outputs and checkpoints are stored.", + ) + parser.add_argument( + "--run-name", + default=None, + help="Optional run name for logging systems.", + ) + parser.add_argument( + "--project", + default=None, + help="Optional project identifier for logging systems.", + ) + parser.add_argument( + "--vllm-mode", + choices=("colocate", "server"), + default="colocate", + help="vLLM execution mode: 'colocate' or 'server'.", + ) + parser.add_argument( + "--vllm-server-url", + type=str, + default="http://localhost:8001", + help="URL for the vLLM server (only used when --vllm-mode=server).", + ) + parser.add_argument( + "--logging-steps", + type=int, + default=1, + help="Frequency of logging steps for GRPO training.", + ) + return parser.parse_args() + + +def sanitize_name(name: str) -> str: + return name.replace("/", "-") + + +# --------------------------------------------------------------------------- +# System Prompt +# --------------------------------------------------------------------------- + +SYSTEM_PROMPT = """You control a web browser to complete tasks. + +The page structure shows elements as: [bid] element_type 'element_text' +For example: [13] button 'Click Me!' means the element has bid='13'. + +Use the available tools to interact with the page: +- click: Click an element by its bid +- fill: Fill an input field with text +- send_keys: Send keyboard input +- scroll: Scroll the page +- noop: Do nothing + +Complete the given task as efficiently as possible.""" + + +# --------------------------------------------------------------------------- +# Reward +# --------------------------------------------------------------------------- + + +def reward_completion(environments, **kwargs) -> list[float]: + """Reward for task completion.""" + return [env.reward for env in environments] + + +# --------------------------------------------------------------------------- +# Main entrypoint +# --------------------------------------------------------------------------- + + +def main() -> None: + args = parse_args() + + space_url = args.space_url + max_steps = args.max_steps + + dataset = Dataset.from_dict( + { + "prompt": [ + [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": args.dataset_prompt}, + ] + ] + * args.dataset_size + } + ) + + class BrowserGymLLMEnv: + def __init__(self): + self.client = BrowserGymEnv(base_url=space_url) + self.reward = 0.0 + self._done = False + self._step_count = 0 + + def _ensure_large_max_size(self): + """Raise WebSocket max message size for large observations (e.g. accessibility trees). + + openenv-core<=0.2.1 does not pass max_size to ws_connect, so the websockets library + defaults to 1MB. We force a connection and patch it to 100MB before any messages are sent. + """ + self.client.connect() + ws = self.client._ws + if ws is not None and hasattr(ws, "protocol"): + proto = ws.protocol + # websockets <16: max_size; websockets >=16: max_message_size + attr = "max_size" if hasattr(proto, "max_size") else "max_message_size" + if getattr(proto, attr) == 2**20: + setattr(proto, attr, 100 * 1024 * 1024) + + def reset(self, **kwargs) -> str: + self.reward = 0.0 + self._done = False + self._step_count = 0 + self._ensure_large_max_size() + result = self.client.reset() + self._done = result.done + return self._format_observation(result.observation) + + def click(self, bid: str) -> str: + """Click an element on the page. + + Args: + bid: The BrowserGym ID of the element to click. + + Returns: + The updated page observation. + """ + return self._do_action(f"click({bid!r})") + + def fill(self, bid: str, text: str) -> str: + """Fill an input field with text. + + Args: + bid: The BrowserGym ID of the input field. + text: The text to type into the field. + + Returns: + The updated page observation. + """ + return self._do_action(f"fill({bid!r}, {text!r})") + + def send_keys(self, text: str) -> str: + """Send keyboard input to the page. + + Args: + text: The keyboard input to send. + + Returns: + The updated page observation. + """ + return self._do_action(f"send_keys({text!r})") + + def scroll(self, direction: str) -> str: + """Scroll the page. + + Args: + direction: Direction to scroll, either 'up' or 'down'. + + Returns: + The updated page observation. + """ + return self._do_action(f"scroll({direction!r})") + + def noop(self) -> str: + """Do nothing and observe the current page state. + + Returns: + The current page observation. + """ + return self._do_action("noop()") + + def _do_action(self, action_str: str) -> str: + if self._done: + raise ValueError("Episode is done.") + + self._step_count += 1 + result = self.client.step(BrowserGymAction(action_str=action_str)) + observation = result.observation + step_reward = float(result.reward or 0.0) + self._done = result.done + + # Reward shaping: binary success/failure on completion + if self._done and step_reward > 0: + self.reward = 1.0 + elif self._done: + self.reward = 0.0 + else: + self.reward = step_reward + + # Enforce max steps + if self._step_count >= max_steps: + self._done = True + + return self._format_observation(observation) + + def _format_observation(self, observation) -> str: + parts = [] + if observation.goal: + parts.append(f"Goal: {observation.goal}") + if observation.last_action_error and observation.error: + parts.append(f"Error: {observation.error}") + if observation.axtree_txt: + axtree = observation.axtree_txt + if len(axtree) > 2000: + axtree = axtree[:2000] + "..." + parts.append(f"Page structure:\n{axtree}") + return "\n\n".join(parts) if parts else "No observation available." + + timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + default_output_dir = Path("outputs") / f"browsergym-grpo-{sanitize_name(args.model_id)}-{timestamp}" + output_dir = Path(args.output_dir or default_output_dir) + + grpo_config = GRPOConfig( + use_vllm=True, + vllm_mode=args.vllm_mode, + vllm_server_base_url=args.vllm_server_url if args.vllm_mode == "server" else None, + vllm_gpu_memory_utilization=0.4, + output_dir=str(output_dir), + num_train_epochs=args.num_epochs, + learning_rate=args.learning_rate, + weight_decay=args.weight_decay, + gradient_accumulation_steps=args.gradient_accumulation_steps, + per_device_train_batch_size=args.per_device_batch_size, + warmup_steps=args.warmup_steps, + num_generations=args.num_generations, + generation_batch_size=args.num_generations, + max_completion_length=args.max_completion_length, + logging_steps=args.logging_steps, + report_to="trackio", + trackio_space_id=f"browsergym-grpo-{sanitize_name(args.model_id)}-{timestamp}", + save_strategy="steps", + save_steps=args.save_interval, + save_total_limit=args.save_total_limit, + temperature=args.temperature, + top_k=args.top_k, + top_p=args.top_p, + chat_template_kwargs={"enable_thinking": False}, + ) + + grpo_config.run_name = args.run_name or f"run-{timestamp}" + grpo_config.project = args.project or f"group-{sanitize_name(args.model_id)}" + + trainer = GRPOTrainer( + model=args.model_id, + reward_funcs=[reward_completion], + train_dataset=dataset, + args=grpo_config, + environment_factory=BrowserGymLLMEnv, + ) + + print("=" * 80) + print("Starting GRPO training with BrowserGym environment (LLM mode)") + print(f"Benchmark: {args.benchmark}") + print(f"Task: {args.task_name}") + print(f"Model: {args.model_id}") + print("Mode: LLM (text-only, using accessibility tree)") + print(f"Using {args.num_generations} rollouts per dataset prompt") + print(f"Output directory: {output_dir}") + print("=" * 80) + + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla.py new file mode 100644 index 0000000000000000000000000000000000000000..980d98c11272e6d0bd075f18d4343e5ad8267113 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla.py @@ -0,0 +1,219 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "openenv-carla-env @ git+https://huggingface.co/spaces/sergiopaniego/carla_env", +# ] +# /// + + +""" +Simple script to run GRPO training with OpenEnv's CARLA environment. The environment simulates an emergency +driving scenario where pedestrians are ahead and the model must learn to observe the scene and take the +correct action (e.g., swerve to an empty lane) to minimize casualties. + +Setup (Option A - Install from HF Space, recommended): + +```sh +uv pip install git+https://huggingface.co/spaces/sergiopaniego/carla_env +``` + +Setup (Option B - Clone OpenEnv repo, for development): + +```sh +git clone https://github.com/meta-pytorch/OpenEnv.git +cd OpenEnv/envs/carla_env +uv pip install -e . +``` + +Usage: + +```sh +python examples/scripts/openenv/carla.py +python examples/scripts/openenv/carla.py --model Qwen/Qwen3-1.7B --env-urls https://server1.hf.space https://server2.hf.space +``` +""" + +import argparse + +from carla_env import CarlaAction, CarlaEnv +from datasets import Dataset + +from trl import GRPOConfig, GRPOTrainer + + +def parse_args(): + parser = argparse.ArgumentParser(description="Run GRPO training with CARLA environment.") + parser.add_argument( + "--model", + type=str, + default="Qwen/Qwen3-0.6B", + help="Model to use for training.", + ) + parser.add_argument( + "--env-urls", + type=str, + nargs="+", + default=["https://sergiopaniego-carla-env.hf.space"], + help="URLs for the CARLA environment servers (one per environment instance).", + ) + parser.add_argument( + "--trackio-space-id", + type=str, + default="carla-grpo-trolley", + help="Trackio space identifier.", + ) + parser.add_argument( + "--hub-model-id", + type=str, + default=None, + help="Hub model ID to push the trained model to (e.g., sergiopaniego/Qwen3-0.6B-carla-trolley-escape).", + ) + parser.add_argument( + "--run-name", + type=str, + default=None, + help="Run name for tracking.", + ) + return parser.parse_args() + + +PROMPT = """You control an autonomous vehicle in an emergency. There are pedestrians ahead and you must \ +decide what to do immediately. + +You have the following tools available: +- `observe`: Advance time and get a new observation of the scene. +- `emergency_stop`: Apply maximum braking to stop the vehicle. +- `lane_change(direction)`: Change lane to the left or right. Direction must be "left" or "right". + +Observe the scene first, then decide the best course of action to minimize harm.""" + + +SIM_TICKS = 10 # Number of simulation steps to advance after each action + + +class CarlaGRPOEnv: + _env_url_iter = None + + def __init__(self): + url = next(CarlaGRPOEnv._env_url_iter) + self.client = CarlaEnv(base_url=url, connect_timeout_s=30, message_timeout_s=120) + + @staticmethod + def _describe(obs) -> str: + """Build a text description from the observation fields.""" + parts = [] + parts.append(f"Speed: {obs.speed_kmh:.1f} km/h.") + if obs.nearby_actors: + for actor in obs.nearby_actors: + parts.append(f"- {actor.get('type', 'actor')} at {actor.get('distance', '?')}m") + else: + parts.append("No nearby actors detected.") + if obs.collision_detected: + parts.append(f"COLLISION detected with {obs.collided_with or 'unknown'}!") + return "\n".join(parts) + + def _advance(self, ticks: int = SIM_TICKS): + """Advance the simulation by calling observe repeatedly, return the last result.""" + result = None + for _ in range(ticks): + result = self.client.step(CarlaAction(action_type="observe")) + if result.done: + break + return result + + def reset(self, **kwargs) -> str | None: + result = self.client.reset(scenario_name="trolley_micro_escape_exists") + self.reward = 0.0 + return self._describe(result.observation) + + def observe(self) -> str: + """ + Get the current scene description without taking any action. + + Returns: + The scene description with vehicle state and nearby actors. + """ + result = self._advance() + self.reward = result.observation.rubric_reward or 0.0 + return self._describe(result.observation) + + def emergency_stop(self) -> str: + """ + Apply maximum braking to stop the vehicle. + + Returns: + The scene description after braking. + """ + self.client.step(CarlaAction(action_type="emergency_stop")) + result = self._advance() + self.reward = result.observation.rubric_reward or 0.0 + return self._describe(result.observation) + + def lane_change(self, direction: str) -> str: + """ + Change lane to avoid obstacles. + + Args: + direction: Direction to change lane, either "left" or "right". + + Returns: + The scene description after changing lane. + """ + self.client.step(CarlaAction(action_type="lane_change", lane_direction=direction)) + result = self._advance() + self.reward = result.observation.rubric_reward or 0.0 + return self._describe(result.observation) + + +def reward_func(environments, **kwargs): + return [environment.reward for environment in environments] + + +def main(): + args = parse_args() + CarlaGRPOEnv._env_url_iter = iter(args.env_urls) + + dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": PROMPT}] for _ in range(1000)]}) + + trainer = GRPOTrainer( + model=args.model, + train_dataset=dataset, + reward_funcs=reward_func, + args=GRPOConfig( + chat_template_kwargs={"enable_thinking": False}, + log_completions=True, + logging_steps=2, + num_completions_to_print=1, + max_completion_length=1024, + per_device_train_batch_size=len(args.env_urls), + steps_per_generation=1, + num_generations=len(args.env_urls), + gradient_accumulation_steps=16, + max_steps=50, + push_to_hub=args.hub_model_id is not None, + hub_model_id=args.hub_model_id, + run_name=args.run_name, + report_to="trackio", + trackio_space_id=args.trackio_space_id, + ), + environment_factory=CarlaGRPOEnv, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..925c1fd11c20b6fbdd9ff7b12fffeebc8989654e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla_vlm.py @@ -0,0 +1,262 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "openenv-carla-env @ git+https://huggingface.co/spaces/sergiopaniego/carla_env", +# ] +# /// + + +""" +GRPO training with OpenEnv's CARLA environment for VLMs (Vision Language Models). + +VLM adaptation of `carla.py`: each tool call returns a camera image alongside the text +scene description, so the model sees the driving scene after each action. + +Setup: + +```sh +uv pip install git+https://huggingface.co/spaces/sergiopaniego/carla_env +``` + +Usage (requires at least 2 CARLA Spaces, each supports only 1 concurrent connection): + +```sh +python examples/scripts/openenv/carla_vlm.py \ + --model Qwen/Qwen3.5-0.8B \ + --env-urls https://server1.hf.space https://server2.hf.space +``` +""" + +import argparse +import base64 +from io import BytesIO + +from carla_env import CarlaAction, CarlaEnv +from datasets import Dataset +from PIL import Image + +from trl import GRPOConfig, GRPOTrainer + + +def parse_args(): + parser = argparse.ArgumentParser(description="Run GRPO VLM training with CARLA environment.") + parser.add_argument( + "--model", + type=str, + default="Qwen/Qwen3.5-0.8B", + help="Model to use for training.", + ) + parser.add_argument( + "--env-urls", + type=str, + nargs="+", + default=["https://sergiopaniego-carla-env.hf.space"], + help="URLs for the CARLA environment servers (one per environment instance).", + ) + parser.add_argument( + "--image-size", + type=int, + default=256, + help="Resize camera images to this size. 0 to disable.", + ) + parser.add_argument( + "--max-completion-length", + type=int, + default=1024, + help="Maximum number of tokens in the generated completion.", + ) + parser.add_argument( + "--gradient-accumulation-steps", + type=int, + default=16, + help="Number of steps to accumulate gradients over before updating.", + ) + parser.add_argument( + "--max-steps", + type=int, + default=50, + help="Number of training steps to run.", + ) + parser.add_argument( + "--trackio-space-id", + type=str, + default="carla-grpo-trolley-vlm", + help="Trackio space identifier.", + ) + parser.add_argument( + "--hub-model-id", + type=str, + default=None, + help="Hub model ID to push the trained model to.", + ) + parser.add_argument( + "--run-name", + type=str, + default=None, + help="Run name for tracking.", + ) + return parser.parse_args() + + +PROMPT = """You control an autonomous vehicle in an emergency. There are pedestrians ahead and you must \ +decide what to do immediately. + +You will see a camera image from the vehicle after each action. Use the visual information +along with the scene description to decide your next action. + +You have the following tools available: +- `observe`: Advance time and get a new observation of the scene with a camera image. +- `emergency_stop`: Apply maximum braking to stop the vehicle. +- `lane_change(direction)`: Change lane to the left or right. Direction must be "left" or "right". + +Observe the scene first, then decide the best course of action to minimize harm.""" + + +SIM_TICKS = 10 # Number of simulation steps to advance after each action + + +class CarlaGRPOEnv: + _env_url_iter = None + _image_size = 256 + + def __init__(self): + url = next(CarlaGRPOEnv._env_url_iter) + self.client = CarlaEnv(base_url=url, connect_timeout_s=30, message_timeout_s=120) + + @staticmethod + def _describe(obs) -> str: + """Build a text description from the observation fields.""" + parts = [f"Speed: {obs.speed_kmh:.1f} km/h."] + if obs.nearby_actors: + for actor in obs.nearby_actors: + parts.append(f"- {actor.get('type', 'actor')} at {actor.get('distance', '?')}m") + else: + parts.append("No nearby actors detected.") + if obs.collision_detected: + parts.append(f"COLLISION detected with {obs.collided_with or 'unknown'}!") + return "\n".join(parts) + + @staticmethod + def _decode_image(camera_image_b64, target_size): + """Decode base64 JPEG image and optionally resize.""" + img = Image.open(BytesIO(base64.b64decode(camera_image_b64))) + if target_size > 0: + img.thumbnail((target_size, target_size), Image.LANCZOS) + return img + + def _format_multimodal(self, obs) -> list: + """Format observation as multimodal content blocks (camera image + text).""" + content = [] + if obs.camera_image is not None: + content.append({"type": "image", "image": self._decode_image(obs.camera_image, CarlaGRPOEnv._image_size)}) + content.append({"type": "text", "text": self._describe(obs)}) + return content + + def _advance_and_capture(self, ticks: int = SIM_TICKS): + """Advance the simulation, then capture an image of the current state.""" + result = None + for _ in range(ticks): + result = self.client.step(CarlaAction(action_type="observe")) + if result.done: + break + capture_result = self.client.step(CarlaAction(action_type="capture_image")) + result.observation.camera_image = capture_result.observation.camera_image + return result + + def reset(self, **kwargs) -> str | None: + result = self.client.reset(scenario_name="trolley_micro_escape_exists") + self.reward = 0.0 + return self._describe(result.observation) + + def observe(self) -> list: + """ + Get the current scene with a camera image and description. + + Returns: + The camera image and scene description with vehicle state and nearby actors. + """ + result = self._advance_and_capture() + self.reward = result.observation.rubric_reward or 0.0 + return self._format_multimodal(result.observation) + + def emergency_stop(self) -> list: + """ + Apply maximum braking to stop the vehicle. + + Returns: + The camera image and scene description after braking. + """ + self.client.step(CarlaAction(action_type="emergency_stop")) + result = self._advance_and_capture() + self.reward = result.observation.rubric_reward or 0.0 + return self._format_multimodal(result.observation) + + def lane_change(self, direction: str) -> list: + """ + Change lane to avoid obstacles. + + Args: + direction: Direction to change lane, either "left" or "right". + + Returns: + The camera image and scene description after changing lane. + """ + self.client.step(CarlaAction(action_type="lane_change", lane_direction=direction)) + result = self._advance_and_capture() + self.reward = result.observation.rubric_reward or 0.0 + return self._format_multimodal(result.observation) + + +def reward_func(environments, **kwargs): + return [environment.reward for environment in environments] + + +def main(): + args = parse_args() + CarlaGRPOEnv._env_url_iter = iter(args.env_urls) + CarlaGRPOEnv._image_size = args.image_size + + dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": PROMPT}] for _ in range(1000)]}) + + trainer = GRPOTrainer( + model=args.model, + train_dataset=dataset, + reward_funcs=reward_func, + args=GRPOConfig( + chat_template_kwargs={"enable_thinking": False}, + log_completions=True, + logging_steps=2, + num_completions_to_print=1, + max_completion_length=args.max_completion_length, + per_device_train_batch_size=len(args.env_urls), + steps_per_generation=1, + num_generations=len(args.env_urls), + gradient_accumulation_steps=args.gradient_accumulation_steps, + max_steps=args.max_steps, + push_to_hub=args.hub_model_id is not None, + hub_model_id=args.hub_model_id, + run_name=args.run_name, + report_to="trackio", + trackio_space_id=args.trackio_space_id, + ), + environment_factory=CarlaGRPOEnv, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla_vlm_gemma.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla_vlm_gemma.py new file mode 100644 index 0000000000000000000000000000000000000000..b6a00ab9eb35d1f98570a89fe084ddefd3bb7c83 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/carla_vlm_gemma.py @@ -0,0 +1,278 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "openenv-carla-env @ git+https://huggingface.co/spaces/sergiopaniego/carla_env", +# ] +# /// + + +""" +GRPO training with OpenEnv's CARLA environment for Gemma VLMs. + +Gemma-specific variant of `carla_vlm.py` with LoRA support (memory-efficient training +by excluding the vision encoder from adapter targets) and a tuned learning rate. + +Setup: + +```sh +uv pip install git+https://huggingface.co/spaces/sergiopaniego/carla_env +``` + +Usage (requires at least 2 CARLA Spaces, each supports only 1 concurrent connection): + +```sh +python examples/scripts/openenv/carla_vlm_gemma.py \ + --env-urls https://server1.hf.space https://server2.hf.space \ + --use-lora +``` +""" + +import argparse +import base64 +from io import BytesIO + +from carla_env import CarlaAction, CarlaEnv +from datasets import Dataset +from PIL import Image + +from trl import GRPOConfig, GRPOTrainer + + +def parse_args(): + parser = argparse.ArgumentParser(description="Run GRPO VLM training with CARLA environment.") + parser.add_argument("--model", type=str, default="google/gemma-4-E2B-it") + parser.add_argument( + "--env-urls", + type=str, + nargs="+", + required=True, + help="URLs for CARLA environment servers. At least 2 required (1 Space = 1 connection).", + ) + parser.add_argument("--dataset-size", type=int, default=1000) + parser.add_argument("--max-completion-length", type=int, default=3072) + parser.add_argument("--per-device-train-batch-size", type=int, default=None, help="Defaults to len(env-urls).") + parser.add_argument("--gradient-accumulation-steps", type=int, default=16) + parser.add_argument("--max-steps", type=int, default=100) + parser.add_argument("--image-size", type=int, default=256, help="Resize camera images to this size. 0 to disable.") + parser.add_argument("--trackio-space-id", type=str, default=None, help="Trackio Space ID for logging.") + parser.add_argument("--use-lora", action="store_true", help="Use LoRA for memory-efficient training.") + parser.add_argument("--lora-r", type=int, default=128, help="LoRA rank.") + parser.add_argument("--lora-alpha", type=int, default=256, help="LoRA alpha.") + parser.add_argument( + "--lora-target-modules", + type=str, + default="llm-only", + help="LoRA target modules. Use 'llm-only' to skip vision encoder, 'all-linear' for all.", + ) + parser.add_argument( + "--learning-rate", type=float, default=5e-6, help="Learning rate. Default 5e-6 (good for LoRA r=128)." + ) + parser.add_argument("--hub-model-id", type=str, default=None) + parser.add_argument("--run-name", type=str, default=None) + parser.add_argument("--report-to", type=str, default="trackio", help="Logging backend: wandb, trackio, none.") + return parser.parse_args() + + +PROMPT = """\ +You control an autonomous vehicle in an emergency. There are pedestrians ahead and you must \ +decide what to do immediately. + +You will see a camera image from the vehicle after each action. Use the visual information +along with the scene description to decide your next action. + +You have the following tools available: +- `observe`: Advance time and get a new observation of the scene with a camera image. +- `emergency_stop`: Apply maximum braking to stop the vehicle. +- `lane_change(direction)`: Change lane to the left or right. Direction must be "left" or "right". + +Make one tool call at a time, wait for the result, then decide your next action. +Observe the scene first, then decide the best course of action to minimize harm. +Consider all available actions - sometimes avoiding the obstacle by changing lanes \ +is safer than stopping in its path.""" + + +SIM_TICKS = 10 # Number of simulation steps to advance after each action + + +class CarlaVLMEnv: + _env_url_iter = None + _image_size = 256 + + def __init__(self): + self.url = next(CarlaVLMEnv._env_url_iter) + self.client = CarlaEnv(base_url=self.url, connect_timeout_s=30, message_timeout_s=120) + self.reward = 0.0 + + @staticmethod + def _describe(obs) -> str: + parts = [f"Speed: {obs.speed_kmh:.1f} km/h."] + if obs.nearby_actors: + for actor in obs.nearby_actors: + parts.append(f"- {actor.get('type', 'actor')} at {actor.get('distance', '?')}m") + else: + parts.append("No nearby actors detected.") + if obs.collision_detected: + parts.append(f"COLLISION detected with {obs.collided_with or 'unknown'}!") + return "\n".join(parts) + + @staticmethod + def _decode_image(camera_image_b64, target_size): + """Decode base64 JPEG image and optionally resize.""" + img = Image.open(BytesIO(base64.b64decode(camera_image_b64))) + if target_size > 0: + img.thumbnail((target_size, target_size), Image.LANCZOS) + return img + + def _format_multimodal(self, obs) -> list: + """Format observation as multimodal content blocks (camera image + text).""" + content = [] + if obs.camera_image is not None: + content.append({"type": "image", "image": self._decode_image(obs.camera_image, CarlaVLMEnv._image_size)}) + content.append({"type": "text", "text": self._describe(obs)}) + return content + + def _advance_and_capture(self, ticks: int = SIM_TICKS): + """Advance the simulation, then capture an image of the current state.""" + result = None + for _ in range(ticks): + result = self.client.step(CarlaAction(action_type="observe")) + if result.done: + break + capture_result = self.client.step(CarlaAction(action_type="capture_image")) + result.observation.camera_image = capture_result.observation.camera_image + return result + + def reset(self, **kwargs) -> str | None: + for attempt in range(3): + try: + result = self.client.reset(scenario_name="trolley_micro_escape_exists") + self.reward = 0.0 + return self._describe(result.observation) + except Exception as e: + if attempt == 2: + raise + print(f"[WARN] reset failed (attempt {attempt + 1}/3): {e}. Reconnecting...") + self.client = CarlaEnv(base_url=self.url, connect_timeout_s=30, message_timeout_s=120) + + def observe(self) -> list: + """ + Get the current scene with a camera image and description. + + Returns: + The camera image and scene description with vehicle state and nearby actors. + """ + result = self._advance_and_capture() + self.reward = result.observation.rubric_reward or 0.0 + return self._format_multimodal(result.observation) + + def emergency_stop(self) -> list: + """ + Apply maximum braking to stop the vehicle. + + Returns: + The camera image and scene description after braking. + """ + self.client.step(CarlaAction(action_type="emergency_stop")) + result = self._advance_and_capture() + self.reward = result.observation.rubric_reward or 0.0 + print(f"[DEBUG env] emergency_stop: done={result.done}, reward={self.reward}") + return self._format_multimodal(result.observation) + + def lane_change(self, direction: str) -> list: + """ + Change lane to avoid obstacles. + + Args: + direction: Direction to change lane, either "left" or "right". + + Returns: + The camera image and scene description after changing lane. + """ + self.client.step(CarlaAction(action_type="lane_change", lane_direction=direction)) + result = self._advance_and_capture() + self.reward = result.observation.rubric_reward or 0.0 + print(f"[DEBUG env] lane_change({direction}): done={result.done}, reward={self.reward}") + return self._format_multimodal(result.observation) + + +def reward_func(completions, environments, **kwargs): + rewards = [env.reward for env in environments] + for i, (comp, env) in enumerate(zip(completions, environments, strict=False)): + tools = [ + msg["tool_calls"][0]["function"]["name"] for msg in comp if isinstance(msg, dict) and msg.get("tool_calls") + ] + print(f"[DEBUG reward] gen={i} tools={tools} env_reward={env.reward}") + return rewards + + +def main(): + args = parse_args() + CarlaVLMEnv._env_url_iter = iter(args.env_urls) + CarlaVLMEnv._image_size = args.image_size + + dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": PROMPT}] for _ in range(args.dataset_size)]}) + + peft_config = None + if args.use_lora: + from peft import LoraConfig + + if args.lora_target_modules == "llm-only": + target_modules = "all-linear" + exclude_modules = ["vision_tower", "multi_modal_projector"] + else: + target_modules = args.lora_target_modules + exclude_modules = None + + peft_config = LoraConfig( + r=args.lora_r, + lora_alpha=args.lora_alpha, + target_modules=target_modules, + exclude_modules=exclude_modules, + task_type="CAUSAL_LM", + ) + + trainer = GRPOTrainer( + model=args.model, + train_dataset=dataset, + reward_funcs=reward_func, + peft_config=peft_config, + args=GRPOConfig( + chat_template_kwargs={"enable_thinking": False}, + log_completions=True, + logging_steps=2, + num_completions_to_print=1, + max_completion_length=args.max_completion_length, + per_device_train_batch_size=args.per_device_train_batch_size or len(args.env_urls), + steps_per_generation=1, + num_generations=len(args.env_urls), + max_tool_calling_iterations=10, + learning_rate=args.learning_rate, + gradient_accumulation_steps=args.gradient_accumulation_steps, + max_steps=args.max_steps, + push_to_hub=args.hub_model_id is not None, + hub_model_id=args.hub_model_id, + run_name=args.run_name, + report_to=args.report_to, + trackio_space_id=args.trackio_space_id, + ), + environment_factory=CarlaVLMEnv, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/catch.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/catch.py new file mode 100644 index 0000000000000000000000000000000000000000..d8a7eeb7686ca070d825e1f2c2de25f08af6a835 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/catch.py @@ -0,0 +1,347 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[vllm,peft]", +# "trackio", +# "kernels", +# "openenv-openspiel-env @ git+https://huggingface.co/spaces/openenv/openspiel_env", +# ] +# /// + + +""" +Simple script to run GRPO training with OpenEnv's Catch environment (OpenSpiel) and vLLM. The reward function +is based on the catch game where the agent tries to catch falling balls. + +Setup (Option A - Install from HF Space, recommended): + +```sh +uv pip install git+https://huggingface.co/spaces/openenv/openspiel_env +``` + +Setup (Option B - Clone OpenEnv repo, for development): + +```sh +git clone https://github.com/meta-pytorch/OpenEnv.git +cd OpenEnv/envs/openspiel_env +uv pip install -e . +``` + +# Option 1: HF Spaces + Colocated vLLM (1 GPU required) +```sh +python examples/scripts/openenv/catch.py --env-mode space --env-host https://openenv-openspiel-env.hf.space --vllm-mode colocate +``` + +# Option 2: HF Spaces + Separate vLLM server (2 GPUs required) + +# Spin up vLLM server (Terminal 1) +```sh +CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen2.5-0.5B-Instruct --host 0.0.0.0 --port 8000 +``` + +# Run training (Terminal 2) +```sh +CUDA_VISIBLE_DEVICES=1 python examples/scripts/openenv/catch.py --env-mode space --env-host https://openenv-openspiel-env.hf.space --vllm-mode server --vllm-server-url http://localhost:8000 +``` + +# Option 3: Local + Colocated vLLM (1 GPU required) + +# Start the environment only if using --env-mode docker-local +```sh +docker run -d -p 8001:8001 registry.hf.space/openenv-openspiel-env:latest +``` + +```sh +python examples/scripts/openenv/catch.py --env-mode docker-local --vllm-mode colocate +``` +""" + +# ruff: noqa: T201 +import argparse +import os +import subprocess +import sys +import time +from pathlib import Path + +import requests +from datasets import Dataset +from openspiel_env import OpenSpielEnv +from openspiel_env.models import OpenSpielAction + +from trl import GRPOConfig, GRPOTrainer, RichProgressCallback + + +def parse_args(): + parser = argparse.ArgumentParser(description="Run GRPO training with OpenSpiel Catch environment and vLLM.") + + # --- Environment settings --- + parser.add_argument("--env-host", type=str, default="0.0.0.0", help="Host for the environment server.") + parser.add_argument("--env-port", type=int, default=8001, help="Port for the environment server.") + parser.add_argument( + "--env-mode", + choices=["local", "docker-local", "docker-image", "docker-hub", "space"], + default="docker-image", + help="Where to run the environment: 'local' to launch it, 'docker-local' if already running locally, 'docker-image' to run from a Docker image, 'docker-hub' to run from Docker Hub, or 'space' to use a remote Space URL.", + ) + # --- Generation and model config --- + parser.add_argument( + "--model", + type=str, + default="Qwen/Qwen2.5-0.5B-Instruct", + help="Model name or path.", + ) + parser.add_argument( + "--dataset-size", + type=int, + default=1000, + help="Number of prompts to use for training dataset.", + ) + parser.add_argument( + "--env-image", type=str, default="openspiel-env:latest", help="Docker image for the OpenSpiel environment." + ) + parser.add_argument( + "--vllm-mode", + choices=["colocate", "server"], + default="colocate", + help="vLLM execution mode: 'colocate' or 'server'.", + ) + parser.add_argument( + "--vllm-server-url", + type=str, + default="http://localhost:8000", + help="URL for the vLLM server (only used when --vllm-mode=server).", + ) + + return parser.parse_args() + + +def start_env_server(env_host: str, env_port: int): + """Launch the OpenSpiel Catch environment locally via uvicorn.""" + env_url = f"http://{env_host}:{env_port}" + print(f"⚡ Starting FastAPI server for OpenSpiel Catch Environment on {env_url}...") + + work_dir = str(Path.cwd().parent.absolute()) + process = subprocess.Popen( + [ + sys.executable, + "-m", + "uvicorn", + "envs.openspiel_env.server.app:app", + "--host", + env_host, + "--port", + str(env_port), + ], + env={**os.environ, "PYTHONPATH": f"{work_dir}/src"}, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + cwd=work_dir, + ) + + print("⏳ Waiting for server to start...") + time.sleep(5) + + try: + requests.get(f"{env_url}/health", timeout=2) + print("\n✅ OpenSpiel Catch Environment server is running!") + except Exception as e: + print(f"\n❌ Server failed to start: {e}") + if process.stderr: + print(process.stderr.read()) + raise + + return process + + +BASE_PROMPT = """You are an AI agent playing the game **Catch**. + +### Game Description +- The game is played on a **10×5 grid**. +- There is one **falling ball** and one **paddle** that you control at the bottom. +- The objective is to **move the paddle left or right to catch the ball** as it falls. +- The episode ends when the ball reaches the bottom row: + - You get **+1 reward** if you catch it. + - You get **–1 reward** if you miss it. + +### Observation Format +Each observation is a flattened 10x5 grid (list of 50 floats). +- 1.0 → occupied (ball or paddle) +- 0.0 → empty cell + +You have the following tools available: +- `move(direction)`: Move the paddle left or right. Direction must be "left" or "right". +- `stay`: Do nothing and let the ball fall one step. + +Observe the grid, determine where the ball is relative to the paddle, then move accordingly. +""" + + +def reward_from_env(environments, **kwargs): + rewards = [] + for env in environments: + if env.done: + # Catch gives +1 for catching, -1 for missing. Clamp to [0, 1] for GRPO advantage estimation. + rewards.append(max(env.reward, 0.0)) + else: + rewards.append(0.0) # Incomplete episode + return rewards + + +def main(): + args = parse_args() + + # Select environment mode — all modes resolve to env_url + if args.env_mode == "local": + env_url = f"http://{args.env_host}:{args.env_port}" + server_process = start_env_server(args.env_host, args.env_port) + elif args.env_mode == "docker-local": + env_url = f"http://{args.env_host}:{args.env_port}" + server_process = None + print(f"🌍 Using existing OpenSpiel Environment (Docker) at: {env_url}") + elif args.env_mode == "docker-image": + _bootstrap = OpenSpielEnv.from_docker_image(args.env_image) + env_url = _bootstrap.base_url + server_process = None + print("🌍 Using OpenSpiel Environment (Docker) from local Image") + elif args.env_mode == "docker-hub": + _bootstrap = OpenSpielEnv.from_hub(args.env_image) + env_url = _bootstrap.base_url + server_process = None + print("🌍 Using existing OpenSpiel Environment (Docker) from Hub Image") + elif args.env_mode == "space": + env_url = args.env_host + server_process = None + print(f"🌍 Using Hugging Face Space environment at: {env_url}") + else: + raise ValueError(f"Unknown environment mode: {args.env_mode}") + + dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": BASE_PROMPT}]] * args.dataset_size}) + + class CatchEnv: + ROWS = 10 + COLS = 5 + + def __init__(self): + self.client = OpenSpielEnv(base_url=env_url) + self.reward = 0.0 + self.done = False + + @staticmethod + def _format_obs(info_state: list[float]) -> str: + """Convert the flat 50-float observation into a readable text description.""" + rows, cols = CatchEnv.ROWS, CatchEnv.COLS + ball_row = ball_col = paddle_col = None + for idx, val in enumerate(info_state): + if val == 1.0: + r, c = divmod(idx, cols) + if r < rows - 1: + ball_row, ball_col = r + 1, c + 1 + else: + paddle_col = c + 1 + parts = [] + if ball_row is not None and ball_col is not None: + parts.append(f"Ball: row {ball_row}/{rows}, column {ball_col}/{cols}") + if paddle_col is not None: + parts.append(f"Paddle: column {paddle_col}/{cols}") + if ball_col is not None and paddle_col is not None: + diff = ball_col - paddle_col + if diff < 0: + parts.append(f"The ball is {abs(diff)} column(s) to the LEFT of the paddle.") + elif diff > 0: + parts.append(f"The ball is {diff} column(s) to the RIGHT of the paddle.") + else: + parts.append("The ball is directly above the paddle.") + return "\n".join(parts) + + def reset(self, **kwargs) -> str: + env_result = self.client.reset() + self.reward = 0.0 + self.done = env_result.observation.done + return self._format_obs(env_result.observation.info_state) + + def _do_action(self, action_id: int) -> str: + if self.done: + raise ValueError("Episode is done.") + env_result = self.client.step(OpenSpielAction(action_id=action_id, game_name="catch")) + self.reward = env_result.reward or 0.0 + self.done = env_result.observation.done + return self._format_obs(env_result.observation.info_state) + + def move(self, direction: str) -> str: + """Move the paddle left or right. + + Args: + direction: Direction to move, either "left" or "right". + + Returns: + The observation after moving. + """ + if direction == "left": + action_id = 0 + elif direction == "right": + action_id = 2 + else: + raise ValueError(f"Invalid direction {direction!r}: must be 'left' or 'right'.") + return self._do_action(action_id) + + def stay(self) -> str: + """Do nothing and let the ball fall one step. + + Returns: + The observation after staying. + """ + return self._do_action(1) + + training_args = GRPOConfig( + output_dir=f"{args.model.split('/')[-1]}-GRPO-Catch", + use_vllm=True, + vllm_mode=args.vllm_mode, + vllm_server_base_url=args.vllm_server_url if args.vllm_mode == "server" else None, + vllm_gpu_memory_utilization=0.2, + logging_steps=1, + log_completions=True, + report_to="trackio", + trackio_space_id=f"{args.model.split('/')[-1]}-GRPO-Catch", + num_train_epochs=1, + per_device_train_batch_size=2, + num_generations=8, + max_completion_length=4096, + gradient_accumulation_steps=16, + chat_template_kwargs={"enable_thinking": False}, + ) + + trainer = GRPOTrainer( + model=args.model, + reward_funcs=reward_from_env, + args=training_args, + train_dataset=dataset, + environment_factory=CatchEnv, + callbacks=[RichProgressCallback()], + ) + + try: + trainer.train() + finally: + if server_process: + print("🛑 Terminating environment server...") + server_process.terminate() + server_process.wait() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/echo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/echo.py new file mode 100644 index 0000000000000000000000000000000000000000..4bef137c26b28ef7188cde2f2bb320c37b7068fa --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/echo.py @@ -0,0 +1,133 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "openenv-echo-env @ git+https://huggingface.co/spaces/qgallouedec/echo_env", +# ] +# /// + + +""" +Simple script to run GRPO training with OpenEnv's Echo environment. The environment echoes back the message +sent to it and rewards longer completions. + +Setup (Option A - Install from HF Space, recommended): + +```sh +uv pip install git+https://huggingface.co/spaces/qgallouedec/echo_env +``` + +Setup (Option B - Clone OpenEnv repo, for development): + +```sh +git clone https://github.com/meta-pytorch/OpenEnv.git +cd OpenEnv/envs/echo_env +uv pip install -e . +``` + +Usage: + +```sh +python examples/scripts/openenv/echo.py +python examples/scripts/openenv/echo.py --model Qwen/Qwen2.5-0.5B-Instruct --env-host https://qgallouedec-echo-env.hf.space +``` +""" + +import argparse + +from datasets import Dataset +from echo_env import EchoEnv +from echo_env.models import EchoAction + +from trl import GRPOConfig, GRPOTrainer + + +def parse_args(): + parser = argparse.ArgumentParser(description="Run GRPO training with Echo environment.") + parser.add_argument( + "--model", + type=str, + default="Qwen/Qwen3-0.6B", + help="Model to use for training.", + ) + parser.add_argument( + "--env-host", + type=str, + default="https://qgallouedec-echo-env.hf.space", + help="URL for the Echo environment HF Space.", + ) + return parser.parse_args() + + +def reward_func(environments, **kwargs): + return [env.reward for env in environments] + + +def main(): + args = parse_args() + + dataset = Dataset.from_dict( + { + "prompt": [ + [{"role": "user", "content": "Try to echo 'Hello World!' in the environment."}], + [{"role": "user", "content": "Make the environment echo 'Goodbye World!'"}], + [{"role": "user", "content": "Can you ask the environment to echo 'TRL is great!'?"}], + [{"role": "user", "content": "What happens if you ask the environment to echo 'I love RLHF!'?"}], + [{"role": "user", "content": "Try to make the environment echo 'OpenEnv is awesome!'"}], + ], + } + ) + + class EchoToolEnv: + def __init__(self): + self.env = EchoEnv(base_url=args.env_host) + self.reward = 0.0 + + def reset(self, **kwargs) -> None | str: + self.reward = 0.0 + return None + + def echo(self, message: str) -> str: + """ + Echo the message back from the environment. + + Args: + message: The message to echo + + Returns: + The echoed message. + """ + observation = self.env.step(EchoAction(message=message)) + self.reward = observation.observation.reward + return observation.observation.echoed_message + + trainer = GRPOTrainer( + model=args.model, + train_dataset=dataset, + reward_funcs=reward_func, + args=GRPOConfig( + chat_template_kwargs={"enable_thinking": False}, + log_completions=True, + logging_steps=2, + num_completions_to_print=1, + ), + environment_factory=EchoToolEnv, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/multi_env.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/multi_env.py new file mode 100644 index 0000000000000000000000000000000000000000..09147d56ea2c9fb1b88eff106eb78c7d135e2723 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/multi_env.py @@ -0,0 +1,273 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "trackio", +# "openenv-textarena @ git+https://huggingface.co/spaces/openenv/wordle", +# "openenv-openspiel-env @ git+https://huggingface.co/spaces/openenv/openspiel_env", +# ] +# /// + +""" +Multi-environment GRPO training with OpenEnv: Wordle + Catch in the same training run. + +Demonstrates how to wrap multiple environments in a single `environment_factory` class. The dataset +contains an "env" column that routes each sample to the correct environment at `reset()` time. + +Usage: + python examples/scripts/openenv/multi_env.py \\ + --wordle-url https://openenv-wordle.hf.space \\ + --catch-url https://openenv-openspiel-env.hf.space +""" + +import argparse + +from datasets import Dataset +from openspiel_env import OpenSpielEnv +from openspiel_env.models import OpenSpielAction +from textarena_env import TextArenaAction, TextArenaEnv + +from trl import GRPOConfig, GRPOTrainer + + +wordle_prompt = """You are an expert Wordle solver with deep knowledge of English vocabulary, letter frequency patterns, and optimal guessing strategies. + +Follow these rules to play Wordle: + +1. The target is a 5-letter English word +2. You have 6 attempts to guess the correct word +3. After each guess, you receive color-coded feedback: + - GREEN (G): Letter is correct and in the correct position + - YELLOW (Y): Letter is in the word but in the wrong position + - GRAY (X): Letter is not in the word at all +4. All guesses must be valid 5-letter English words +5. You cannot reuse a word you've already guessed +6. Use the tool `guess` to make a guess. +""" + +catch_prompt = """You are an AI agent playing the game **Catch**. + +### Game Description +- The game is played on a **10×5 grid**. +- There is one **falling ball** and one **paddle** that you control at the bottom. +- The objective is to **move the paddle left or right to catch the ball** as it falls. +- The episode ends when the ball reaches the bottom row: + - You get **+1 reward** if you catch it. + - You get **–1 reward** if you miss it. + +### Observation Format +Each observation is a flattened 10x5 grid (list of 50 floats). +- 1.0 → occupied (ball or paddle) +- 0.0 → empty cell + +You have the following tools available: +- `move(direction)`: Move the paddle left or right. Direction must be "left" or "right". +- `stay`: Do nothing and let the ball fall one step. + +Observe the grid, determine where the ball is relative to the paddle, then move accordingly. +""" + +DEFAULT_WORDLE_URL = "https://openenv-wordle.hf.space" +DEFAULT_CATCH_URL = "https://openenv-openspiel-env.hf.space" + +CATCH_ROWS = 10 +CATCH_COLS = 5 + + +def _format_catch_obs(info_state: list[float]) -> str: + """Convert the flat 50-float observation into a readable text description.""" + ball_row = ball_col = paddle_col = None + for idx, val in enumerate(info_state): + if val == 1.0: + r, c = divmod(idx, CATCH_COLS) + if r < CATCH_ROWS - 1: + ball_row, ball_col = r + 1, c + 1 + else: + paddle_col = c + 1 + parts = [] + if ball_row is not None and ball_col is not None: + parts.append(f"Ball: row {ball_row}/{CATCH_ROWS}, column {ball_col}/{CATCH_COLS}") + if paddle_col is not None: + parts.append(f"Paddle: column {paddle_col}/{CATCH_COLS}") + if ball_col is not None and paddle_col is not None: + diff = ball_col - paddle_col + if diff < 0: + parts.append(f"The ball is {abs(diff)} column(s) to the LEFT of the paddle.") + elif diff > 0: + parts.append(f"The ball is {diff} column(s) to the RIGHT of the paddle.") + else: + parts.append("The ball is directly above the paddle.") + return "\n".join(parts) + + +class MultiEnv: + wordle_url = DEFAULT_WORDLE_URL + catch_url = DEFAULT_CATCH_URL + + def __init__(self): + self._wordle_client = None + self._catch_client = None + self.active = None + self.reward = 0.0 + self.done = False + + def reset(self, **kwargs) -> str | None: + self.active = kwargs.get("env", "wordle") + self.reward = 0.0 + self.done = False + + if self.active == "wordle": + if self._wordle_client is not None: + try: + self._wordle_client.close() + except Exception: + pass + self._wordle_client = TextArenaEnv(base_url=MultiEnv.wordle_url) + result = self._wordle_client.reset() + self._last_full_feedback = result.observation.messages[0].content + self.reward = 0.0 + return self._last_full_feedback + elif self.active == "catch": + if self._catch_client is not None: + try: + self._catch_client.close() + except Exception: + pass + self._catch_client = OpenSpielEnv(base_url=MultiEnv.catch_url) + result = self._catch_client.reset() + self.done = result.observation.done + return _format_catch_obs(result.observation.info_state) + else: + raise ValueError(f"Unknown environment: {self.active}") + + def guess(self, guess: str) -> str: + """ + Make a guess in the Wordle environment. + + Args: + guess: The guessed word, formatted as '[abcde]' + + Returns: + The feedback message from the environment. + """ + if self.active != "wordle": + raise ValueError("guess is only available in Wordle") + if self.done: + raise ValueError("Game over.") + result = self._wordle_client.step(TextArenaAction(message=guess)) + _full_feedback = result.observation.messages[0].content + feedback = _full_feedback[len(self._last_full_feedback) :] + self._last_full_feedback = _full_feedback + if "You attempted an invalid move" in feedback: + self.reward = 0.0 + else: + self.reward = result.reward + self.done = result.done + return feedback + + def _catch_action(self, action_id: int) -> str: + if self.done: + raise ValueError("Episode is done.") + result = self._catch_client.step(OpenSpielAction(action_id=action_id, game_name="catch")) + self.reward = result.reward or 0.0 + self.done = result.observation.done + return _format_catch_obs(result.observation.info_state) + + def move(self, direction: str) -> str: + """Move the paddle left or right. + + Args: + direction: Direction to move, either "left" or "right". + + Returns: + The observation after moving. + """ + if self.active != "catch": + raise ValueError("move is only available in Catch") + if direction == "left": + action_id = 0 + elif direction == "right": + action_id = 2 + else: + raise ValueError(f"Invalid direction {direction!r}: must be 'left' or 'right'.") + return self._catch_action(action_id) + + def stay(self) -> str: + """Do nothing and let the ball fall one step. + + Returns: + The observation after staying. + """ + if self.active != "catch": + raise ValueError("stay is only available in Catch") + return self._catch_action(1) + + +def wordle_reward(environments, **kwargs) -> list[float | None]: + return [env.reward if env.active == "wordle" else None for env in environments] + + +def catch_reward(environments, **kwargs) -> list[float | None]: + rewards = [] + for env in environments: + if env.active != "catch": + rewards.append(None) + elif env.done: + # Catch gives +1 for catching, -1 for missing. Clamp to [0, 1] for GRPO advantage estimation. + rewards.append(max(env.reward, 0.0)) + else: + rewards.append(0.0) # Incomplete episode + return rewards + + +def main() -> None: + parser = argparse.ArgumentParser(description="Multi-environment GRPO training") + parser.add_argument("--wordle-url", default=DEFAULT_WORDLE_URL, help="Wordle environment URL") + parser.add_argument("--catch-url", default=DEFAULT_CATCH_URL, help="Catch environment URL") + args, remaining = parser.parse_known_args() + + MultiEnv.wordle_url = args.wordle_url + MultiEnv.catch_url = args.catch_url + + n = 500 # samples per environment + dataset = Dataset.from_dict( + { + "prompt": ( + [[{"role": "user", "content": wordle_prompt}]] * n + [[{"role": "user", "content": catch_prompt}]] * n + ), + "env": ["wordle"] * n + ["catch"] * n, + } + ) + + trainer = GRPOTrainer( + model="Qwen/Qwen3-1.7B", + reward_funcs=[wordle_reward, catch_reward], + train_dataset=dataset, + args=GRPOConfig( + report_to="wandb", + log_completions=True, + num_completions_to_print=2, + logging_steps=1, + chat_template_kwargs={"enable_thinking": False}, + max_completion_length=1024, + ), + environment_factory=MultiEnv, + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/sudoku.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/sudoku.py new file mode 100644 index 0000000000000000000000000000000000000000..d8824e23bc2e79cbba7872b662ab0577b6e22d48 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/sudoku.py @@ -0,0 +1,669 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[vllm,peft]", +# "trackio", +# "kernels", +# "openenv-textarena @ git+https://huggingface.co/spaces/openenv/sudoku", +# ] +# /// + +""" +GRPO training for Sudoku with TextArena environment. + +Setup (Option A - Install from HF Space, recommended): + +```sh +uv pip install git+https://huggingface.co/spaces/openenv/sudoku +``` + +Setup (Option B - Clone OpenEnv repo, for development): + +```sh +git clone https://github.com/meta-pytorch/OpenEnv.git +cd OpenEnv/envs/textarena_env +uv pip install -e . +``` + +# Option 1: HF Spaces + Colocated vLLM (1 GPU required) +```sh +python examples/scripts/openenv/sudoku.py --vllm-mode colocate +``` + +# Option 2: HF Spaces + Separate vLLM server (2 GPUs required) + +# Spin up vLLM server (Terminal 1) +```sh +CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen3-1.7B --host 0.0.0.0 --port 8000 +``` + +# Run training (Terminal 2) +```sh +CUDA_VISIBLE_DEVICES=1 python examples/scripts/openenv/sudoku.py --vllm-mode server --vllm-server-url http://localhost:8000 +``` + +# Option 3: Local + Colocated vLLM (1 GPU required) + +# Start the environment only if using --env-mode docker-local +```sh +docker run -d -p 8001:8001 registry.hf.space/openenv-sudoku:latest +``` + +```sh +python examples/scripts/openenv/sudoku.py --env-mode docker-local --vllm-mode colocate +``` + +# Full example with all flags: +```sh +python examples/scripts/openenv/sudoku.py \ + --vllm-mode colocate \ + --env-mode space \ + --env-host https://openenv-sudoku.hf.space \ + --num-generations 8 \ + --per-device-batch-size 1 \ + --max-turns 100 \ + --gradient-accumulation-steps 8 \ + --difficulty easy \ + --dataset-size 100 +``` +""" + +from __future__ import annotations + +# ruff: noqa: T201 +import argparse +import sys +import time +from collections import defaultdict +from datetime import datetime +from pathlib import Path + +from datasets import Dataset + +from trl import GRPOConfig, GRPOTrainer, RichProgressCallback + + +# Ensure src/ is on the path +sys.path.insert(0, str(Path(__file__).parent / "src")) + +from textarena_env import TextArenaAction, TextArenaEnv + + +# --------------------------------------------------------------------------- +# Argument parsing +# --------------------------------------------------------------------------- + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="GRPO training for Sudoku") + + # Model + parser.add_argument("--model-id", default="Qwen/Qwen3-1.7B") + + # Environment + parser.add_argument("--env-host", type=str, default="https://openenv-sudoku.hf.space") + parser.add_argument("--env-port", type=int, default=8001) + parser.add_argument("--env-mode", choices=["docker-local", "docker-image", "docker-hub", "space"], default="space") + parser.add_argument("--env-image", type=str, default="textarena-env:latest") + + # Prompts + parser.add_argument("--system-prompt-path", default="sudoku_prompt.txt") + parser.add_argument("--dataset-prompt", default="Play Sudoku like an expert.") + parser.add_argument("--dataset-size", type=int, default=1000) + + # Game settings + parser.add_argument("--max-turns", type=int, default=100) + parser.add_argument( + "--difficulty", + type=str, + choices=["easy", "medium", "hard"], + default="easy", + help="Training difficulty: easy=guaranteed+options, medium=only options, hard=no hints", + ) + parser.add_argument( + "--api-delay", type=float, default=0.0, help="Delay in seconds between API calls to avoid rate limiting" + ) + + # Sampling + parser.add_argument("--temperature", type=float, default=0.8) + parser.add_argument("--top-k", type=int, default=10) + parser.add_argument("--top-p", type=float, default=None, help="Top-p sampling parameter") + + # Training + parser.add_argument("--learning-rate", type=float, default=5e-6) + parser.add_argument("--weight-decay", type=float, default=0.0) + parser.add_argument("--gradient-accumulation-steps", type=int, default=64) + parser.add_argument("--warmup-steps", type=int, default=20) + parser.add_argument("--per-device-batch-size", type=int, default=1) + parser.add_argument("--num-generations", type=int, default=8) + parser.add_argument("--num-epochs", type=int, default=1) + parser.add_argument("--max-completion-length", type=int, default=16384) + + # Checkpoints + parser.add_argument("--save-interval", type=int, default=10) + parser.add_argument("--save-total-limit", type=int, default=None) + parser.add_argument("--output-dir", default=None) + + # Logging + parser.add_argument("--run-name", default=None) + parser.add_argument("--project", default=None) + parser.add_argument("--trackio-space-id", default="Sudoku-GRPO") + parser.add_argument("--logging-steps", type=int, default=1) + parser.add_argument( + "--gradient-checkpointing", + action=argparse.BooleanOptionalAction, + default=True, + help="Enable gradient checkpointing to save memory", + ) + + # LoRA / PEFT + parser.add_argument( + "--use-lora", action="store_true", default=False, help="Use LoRA for memory-efficient training" + ) + parser.add_argument("--lora-r", type=int, default=16, help="LoRA rank") + parser.add_argument("--lora-alpha", type=int, default=32, help="LoRA alpha") + + # vLLM + parser.add_argument("--vllm-mode", choices=("colocate", "server"), default="colocate") + parser.add_argument("--vllm-server-url", type=str, default="http://localhost:8000") + parser.add_argument("--vllm-gpu-memory-utilization", type=float, default=0.15) + + return parser.parse_args() + + +# --------------------------------------------------------------------------- +# Helper functions +# --------------------------------------------------------------------------- + + +def resolve_system_prompt(path: str) -> str: + prompt_path = Path(path) + if not prompt_path.is_file(): + prompt_path = Path(__file__).parent / path + return prompt_path.read_text() + + +def sanitize_name(name: str) -> str: + return name.replace("/", "-") + + +def is_valid_board_state(board_str: str) -> bool: + """Check if the string contains an actual Sudoku board.""" + return "R1" in board_str and "R9" in board_str and "|" in board_str + + +def parse_board(board_str: str) -> list[list[int]]: + """Parse board string into 9x9 grid (0 = empty).""" + grid = [[0] * 9 for _ in range(9)] + if not is_valid_board_state(board_str): + return grid + + for line in board_str.split("\n"): + line_stripped = line.strip() + if line_stripped and line_stripped[0] == "R" and len(line_stripped) > 1 and line_stripped[1].isdigit(): + row = int(line_stripped[1]) - 1 # 0-indexed + cell_part = line_stripped[2:] + col = 0 + for char in cell_part: + if char == ".": + grid[row][col] = 0 + col += 1 + elif char.isdigit(): + grid[row][col] = int(char) + col += 1 + return grid + + +def count_filled_cells(board_str: str) -> int: + """Count the number of filled cells in the board.""" + if not is_valid_board_state(board_str): + return 0 + grid = parse_board(board_str) + return sum(1 for row in grid for cell in row if cell != 0) + + +def get_valid_numbers(grid: list[list[int]], row: int, col: int) -> set[int]: + """Get valid numbers for a cell based on Sudoku rules.""" + if grid[row][col] != 0: + return set() + + used = set() + + # Check row + for c in range(9): + if grid[row][c] != 0: + used.add(grid[row][c]) + + # Check column + for r in range(9): + if grid[r][col] != 0: + used.add(grid[r][col]) + + # Check 3x3 box + box_row, box_col = 3 * (row // 3), 3 * (col // 3) + for r in range(box_row, box_row + 3): + for c in range(box_col, box_col + 3): + if grid[r][c] != 0: + used.add(grid[r][c]) + + return set(range(1, 10)) - used + + +def extract_empty_cells_with_candidates( + board_str: str, sort_by_difficulty: bool = True +) -> list[tuple[int, int, set[int]]]: + """Extract empty cells with their valid candidate numbers. + + Args: + sort_by_difficulty: If True, sort by number of candidates (easiest first). + If False, keep natural order (top-left to bottom-right). + """ + grid = parse_board(board_str) + cells_with_candidates = [] + + for row in range(9): + for col in range(9): + if grid[row][col] == 0: + candidates = get_valid_numbers(grid, row, col) + cells_with_candidates.append((row + 1, col + 1, candidates)) # 1-indexed + + if sort_by_difficulty: + # Sort by number of candidates (easiest first = naked singles) + cells_with_candidates.sort(key=lambda x: len(x[2])) + + return cells_with_candidates + + +def extract_empty_cells(board_str: str) -> list[tuple[int, int]]: + """Extract list of empty cells (row, col) from board string.""" + empty_cells = [] + if not is_valid_board_state(board_str): + return empty_cells + + for line in board_str.split("\n"): + line_stripped = line.strip() + if line_stripped and line_stripped[0] == "R" and len(line_stripped) > 1 and line_stripped[1].isdigit(): + row = int(line_stripped[1]) + cell_part = line_stripped[2:] + col = 0 + for char in cell_part: + if char == ".": + col += 1 + empty_cells.append((row, col)) + elif char.isdigit(): + col += 1 + return empty_cells + + +def extract_board_only(text: str) -> str: + """Extract just the Sudoku grid from a message.""" + if not text: + return "" + + lines = text.split("\n") + board_lines = [] + in_board = False + + for line in lines: + stripped = line.strip() + if stripped.startswith("C1") or ( + stripped and stripped[0] == "R" and len(stripped) > 1 and stripped[1].isdigit() + ): + in_board = True + if in_board and (stripped.startswith("-") or stripped.startswith("R") or stripped.startswith("C1")): + board_lines.append(line) + elif ( + in_board + and stripped + and not stripped.startswith("-") + and not (stripped[0] == "R" and len(stripped) > 1 and stripped[1].isdigit()) + ): + break + + return "\n".join(board_lines) if board_lines else "" + + +# --------------------------------------------------------------------------- +# Reward functions +# --------------------------------------------------------------------------- + + +def reward_empty_cell(environments, **kwargs) -> list[float]: + """Reward for targeting empty cells (learn to pick valid positions first).""" + return [env.empty_cell_reward for env in environments] + + +def reward_valid_moves(environments, **kwargs) -> list[float]: + """Reward for making valid moves.""" + return [env.valid_move_reward for env in environments] + + +def reward_correct(environments, **kwargs) -> list[float]: + """Reward for solving the puzzle.""" + return [env.correct_reward for env in environments] + + +def reward_repetition(environments, **kwargs) -> list[float]: + """Penalty for repeating moves.""" + return [env.repetition_reward for env in environments] + + +def reward_progress(environments, **kwargs) -> list[float]: + """Reward for filling more cells in the board.""" + return [env.progress_reward for env in environments] + + +# --------------------------------------------------------------------------- +# Main +# --------------------------------------------------------------------------- + + +def main() -> None: + args = parse_args() + + # Setup environment — all modes resolve to env_url + if args.env_mode == "docker-local": + env_url = f"http://{args.env_host}:{args.env_port}" + elif args.env_mode == "docker-image": + _bootstrap = TextArenaEnv.from_docker_image(args.env_image) + env_url = _bootstrap.base_url + elif args.env_mode == "docker-hub": + _bootstrap = TextArenaEnv.from_hub(args.env_image) + env_url = _bootstrap.base_url + elif args.env_mode == "space": + env_url = args.env_host + else: + raise ValueError(f"Unknown environment mode: {args.env_mode}") + + print(f"Environment: {args.env_mode} ({env_url})") + + system_prompt = resolve_system_prompt(args.system_prompt_path) + dataset = Dataset.from_dict( + { + "prompt": [ + [ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": args.dataset_prompt}, + ] + ] + * args.dataset_size + } + ) + + # Capture args for use in the environment class closure + difficulty = args.difficulty + max_turns = args.max_turns + api_delay = args.api_delay + + class SudokuEnv: + def __init__(self): + self.client = TextArenaEnv(base_url=env_url) + self._difficulty = difficulty + self._max_turns = max_turns + self._api_delay = api_delay + self._reset_state() + + def _reset_state(self): + self._move_counts: defaultdict[str, int] = defaultdict(int) + self._successful_moves: list[str] = [] + self._failed_moves: list[str] = [] + self._valid_move_scores: list[float] = [] + self._empty_cell_scores: list[float] = [] + self._correct_scores: list[float] = [] + self._repetition_scores: list[float] = [] + self._last_board_state = "" + self._initial_filled = 0 + self._max_filled = 0 + self._turn = 0 + self._done = False + + def reset(self, **kwargs) -> str: + self._reset_state() + result = self.client.reset() + time.sleep(self._api_delay) + observation = result.observation + self._done = result.done + + # Store full message content for diffing (messages are cumulative) + self._last_full_content = observation.messages[0].content if observation.messages else "" + + if is_valid_board_state(self._last_full_content): + self._last_board_state = self._last_full_content + self._initial_filled = count_filled_cells(self._last_board_state) + self._max_filled = self._initial_filled + + board = extract_board_only(self._last_board_state) if self._last_board_state else "No board available." + hints = self._format_hints() + return f"Step 0. Progress: 0 cells filled.\n\nBoard:\n{board}{hints}" + + def place(self, row: int, col: int, number: int) -> str: + """Place a number on the Sudoku board. + + Args: + row: Row number (1-9). + col: Column number (1-9). + number: Number to place (1-9). + + Returns: + The result of the move and updated board state. + """ + if self._done: + raise ValueError("Game is over. No more moves allowed.") + + self._turn += 1 + move = f"[{row} {col} {number}]" + + # Step environment + result = self.client.step(TextArenaAction(message=move)) + time.sleep(self._api_delay) + observation = result.observation + correct_score = float(result.reward or 0.0) + self._done = result.done + + # Only check the NEW content for feedback (messages are cumulative) + full_content = observation.messages[0].content if observation.messages else "" + new_content = full_content[len(self._last_full_content) :] + self._last_full_content = full_content + + new_content_lower = new_content.lower() + env_says_invalid = any( + kw in new_content_lower for kw in ["invalid", "error", "cannot", "already", "violation", "lost"] + ) + got_warning = "please resubmit" in new_content_lower or "avoid penalties" in new_content_lower + + # Also verify against our own board state: placing on a non-empty cell is always invalid + if self._last_board_state: + empty_cells = extract_empty_cells(self._last_board_state) + targets_empty = (row, col) in empty_cells + else: + empty_cells = [] + targets_empty = True # Can't verify, assume valid + + is_valid = not env_says_invalid and targets_empty + + # Empty cell score: did the model target an empty cell? + empty_cell_score = 1.0 if targets_empty else -1.0 + + # Repetition tracking + is_new_move = self._move_counts[move] == 0 + repetition_count = self._move_counts[move] + self._move_counts[move] += 1 + repetition_score = -min(2 ** (repetition_count - 1), 10.0) if repetition_count > 0 else 0.0 + + # Valid move score + if is_valid and is_new_move: + valid_move_score = 1.0 + self._successful_moves.append(move) + elif got_warning: + valid_move_score = -0.5 + self._failed_moves.append(move) + else: + valid_move_score = 0.0 + + # Update board state from new content + if is_valid and is_valid_board_state(new_content): + self._last_board_state = new_content + current_filled = count_filled_cells(self._last_board_state) + if current_filled > self._max_filled: + self._max_filled = current_filled + + self._valid_move_scores.append(valid_move_score) + self._empty_cell_scores.append(empty_cell_score) + self._correct_scores.append(correct_score) + self._repetition_scores.append(repetition_score) + + # Enforce max turns + if self._turn >= self._max_turns: + self._done = True + + # Build response + board = extract_board_only(self._last_board_state) if self._last_board_state else "No board available." + status = "valid" if is_valid else "invalid" + cells_filled = len(self._successful_moves) + progress = f"Step {self._turn}. Progress: {cells_filled} cells filled." + hints = self._format_hints() + + if self._done: + return f"Move {move}: {status}. Game over.\n{progress}\n\nFinal board:\n{board}" + return f"Move {move}: {status}\n{progress}\n\nBoard:\n{board}{hints}" + + def _format_hints(self) -> str: + parts = [] + + # Already tried moves (avoid repetitions) + all_tried = self._successful_moves + self._failed_moves + if all_tried: + parts.append(f"\nMOVES ALREADY TRIED (do not repeat): {', '.join(all_tried)}") + + if not self._last_board_state: + return "\n".join(parts) + + if self._difficulty == "easy": + cells = extract_empty_cells_with_candidates(self._last_board_state, sort_by_difficulty=True) + if cells: + guaranteed = [] + other = [] + for r, c, candidates in cells[:10]: + if len(candidates) == 1: + guaranteed.append(f"[{r} {c} {list(candidates)[0]}]") + elif len(candidates) <= 3: + nums = ",".join(str(n) for n in sorted(candidates)) + other.append(f"({r},{c})->{nums}") + if guaranteed: + parts.append(f"\nGUARANTEED MOVES: {', '.join(guaranteed[:5])}") + if other: + parts.append(f"Other options: {' | '.join(other[:5])}") + + elif self._difficulty == "medium": + cells = extract_empty_cells_with_candidates(self._last_board_state, sort_by_difficulty=False) + if cells: + cell_hints = [] + for r, c, candidates in cells[:10]: + nums = ",".join(str(n) for n in sorted(candidates)) + cell_hints.append(f"({r},{c})->{nums}") + parts.append(f"\nEmpty cells: {' | '.join(cell_hints)}") + + return "\n".join(parts) + + # Reward properties — properties are not detected by inspect.ismethod, + # so they won't be exposed as tools. + + @property + def correct_reward(self) -> float: + return self._correct_scores[-1] if self._correct_scores else 0.0 + + @property + def valid_move_reward(self) -> float: + return sum(self._valid_move_scores) / len(self._valid_move_scores) if self._valid_move_scores else 0.0 + + @property + def empty_cell_reward(self) -> float: + return sum(self._empty_cell_scores) / len(self._empty_cell_scores) if self._empty_cell_scores else 0.0 + + @property + def repetition_reward(self) -> float: + return sum(self._repetition_scores) / len(self._repetition_scores) if self._repetition_scores else 0.0 + + @property + def progress_reward(self) -> float: + remaining = 81 - self._initial_filled + if remaining > 0: + return (self._max_filled - self._initial_filled) / remaining + return 1.0 + + timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + output_dir = Path(args.output_dir or f"outputs/sudoku-grpo-{sanitize_name(args.model_id)}-{timestamp}") + + grpo_config = GRPOConfig( + use_vllm=True, + vllm_mode=args.vllm_mode, + vllm_server_base_url=args.vllm_server_url if args.vllm_mode == "server" else None, + vllm_gpu_memory_utilization=args.vllm_gpu_memory_utilization or 0.2, + output_dir=str(output_dir), + num_train_epochs=args.num_epochs, + learning_rate=args.learning_rate, + weight_decay=args.weight_decay, + gradient_accumulation_steps=args.gradient_accumulation_steps, + per_device_train_batch_size=args.per_device_batch_size, + warmup_steps=args.warmup_steps, + num_generations=args.num_generations, + max_completion_length=args.max_completion_length, + logging_steps=args.logging_steps, + save_strategy="steps", + save_steps=args.save_interval, + save_total_limit=args.save_total_limit, + temperature=args.temperature, + top_k=args.top_k, + top_p=args.top_p, + report_to="trackio", + log_completions=True, + num_completions_to_print=1, + chat_template_kwargs={"enable_thinking": False}, + ) + + grpo_config.run_name = args.run_name or f"run-{timestamp}" + grpo_config.project = args.project or f"group-{sanitize_name(args.model_id)}" + grpo_config.trackio_space_id = args.trackio_space_id + grpo_config.gradient_checkpointing = args.gradient_checkpointing + + peft_config = None + if args.use_lora: + from peft import LoraConfig + + peft_config = LoraConfig(r=args.lora_r, lora_alpha=args.lora_alpha, task_type="CAUSAL_LM") + + trainer = GRPOTrainer( + model=args.model_id, + reward_funcs=[ + reward_empty_cell, # Learn to pick empty cells + reward_valid_moves, # Learn valid numbers + reward_repetition, # Penalize repeating moves + reward_progress, # Reward filling more cells + reward_correct, # Solve the puzzle + ], + peft_config=peft_config, + train_dataset=dataset, + args=grpo_config, + environment_factory=SudokuEnv, + callbacks=[RichProgressCallback()], + ) + + print(f"Starting GRPO training: {args.num_generations} generations, {args.max_turns} max turns") + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/sudoku_prompt.txt b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/sudoku_prompt.txt new file mode 100644 index 0000000000000000000000000000000000000000..d94ac4d3e93da0671a6e42c9e474291c88f82477 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/sudoku_prompt.txt @@ -0,0 +1,122 @@ +You are an expert Sudoku player with deep knowledge of logical deduction strategies and number placement techniques. + +## GAME RULES + +1. The puzzle is a 9x9 grid divided into nine 3x3 subgrids (boxes) +2. Some cells are pre-filled with numbers 1-9 +3. You must fill in the empty cells (shown as '.') with numbers 1-9 +4. Each row must contain numbers 1-9 without repetition +5. Each column must contain numbers 1-9 without repetition +6. Each 3x3 subgrid must contain numbers 1-9 without repetition +7. You cannot overwrite pre-filled cells +8. Invalid moves result in penalties (-1 reward) + +## HOW TO PLAY + +Use the `place` tool to make moves. The tool takes three arguments: +- `row`: Row number (1-9) +- `col`: Column number (1-9) +- `number`: Number to place (1-9) + +## STRATEGIC APPROACH + +Do not repeat the same move twice. + +### Basic Strategies +- **Naked Singles**: If a cell has only one possible candidate, fill it in immediately. +- **Hidden Singles**: If a number can only go in one cell within a row, column, or box, place it there. +- **Scanning**: Look at each row, column, and box to find where specific numbers can go. + +### Intermediate Strategies +- **Naked Pairs/Triples**: When two/three cells in a unit contain only the same candidates, eliminate those from other cells. +- **Hidden Pairs/Triples**: When numbers only appear in specific cells within a unit, those cells can only contain those numbers. +- **Pointing Pairs**: When a candidate in a box is restricted to a single row/column, eliminate it elsewhere. + +### Solving Process +1. Start by scanning the entire grid to identify easy fills (cells with few candidates) +2. Look for rows, columns, or boxes with many numbers already placed +3. Fill all naked singles first +4. Then look for hidden singles in each row, column, and box +5. Apply more advanced techniques as needed + +### Common Pitfalls to Avoid +- Don't guess randomly - Sudoku is pure logic +- Don't overlook any constraint (row, column, or box) +- Don't try to overwrite pre-filled cells +- Don't place invalid numbers (must be 1-9) +- Don't use invalid coordinates (must be 1-9) +- Don't repeat a move that was already made + +## EXAMPLES + +### Example 1: Naked Single +If row 3, column 4 can only contain the number 5: +→ call `place(row=3, col=4, number=5)` + +### Example 2: Hidden Single +If the number 8 can only go in one cell in row 1: +→ call `place(row=1, col=7, number=8)` + +### Example 3: Row Analysis +Row 2 is missing only value 5, and column 8 is the empty cell: +→ call `place(row=2, col=8, number=5)` + +### Example 4: Box Analysis +In the center box, only one cell can contain 9: +→ call `place(row=5, col=5, number=9)` + +## BOARD READING + +The board is displayed as a 9x9 grid: +- Numbers 1-9 are pre-filled or already placed +- Empty cells are shown as '.' +- Rows are labeled R1-R9 (top to bottom) +- Columns are labeled C1-C9 (left to right) + +Example board representation: +``` + C1 C2 C3 C4 C5 C6 C7 C8 C9 +R1 . 8 9 | 1 . . | . 3 7 +R2 2 7 1 | 9 4 3 | 6 . 8 +R3 . 6 5 | . 2 7 | 4 9 . + - - - - - - - - - - - - - - - - +R4 . . . | 7 8 . | 9 2 3 +R5 . 9 2 | . 5 6 | . . 4 +R6 7 3 8 | . . 2 | 1 . . + - - - - - - - - - - - - - - - - +R7 8 4 . | . . 9 | 5 . . +R8 5 . . | 6 . 8 | 3 4 9 +R9 9 . 6 | 5 3 4 | 8 7 2 +``` + +## COORDINATE REFERENCE + +Row indices (top to bottom): 1, 2, 3, 4, 5, 6, 7, 8, 9 +Column indices (left to right): 1, 2, 3, 4, 5, 6, 7, 8, 9 + +Subgrid layout: +``` +Subgrid 1 | Subgrid 2 | Subgrid 3 + (R1-R3) (R1-R3) (R1-R3) + (C1-C3) (C4-C6) (C7-C9) +----------+-----------+---------- +Subgrid 4 | Subgrid 5 | Subgrid 6 + (R4-R6) (R4-R6) (R4-R6) + (C1-C3) (C4-C6) (C7-C9) +----------+-----------+---------- +Subgrid 7 | Subgrid 8 | Subgrid 9 + (R7-R9) (R7-R9) (R7-R9) + (C1-C3) (C4-C6) (C7-C9) +``` + +## IMPORTANT CONSTRAINTS + +- Coordinates are 1-indexed (1-9 for both row and column) +- Numbers must be 1-9 +- One move per tool call +- Must be a valid move (no rule violations) +- Never repeat a previous move + +## YOUR GOAL + +Use ONLY the `place` tool to fill in empty cells one at a time. No explanation, no reasoning, just the `place`. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/wordle.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/wordle.py new file mode 100644 index 0000000000000000000000000000000000000000..6aa6a8de98b60b84e604e21d945262543e69c818 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/openenv/wordle.py @@ -0,0 +1,277 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "trackio", +# "openenv-textarena @ git+https://huggingface.co/spaces/openenv/wordle", +# ] +# /// + + +""" +Simple script to run GRPO training with OpenEnv's Wordle environment and vLLM. + +Setup (Option A - Install from HF Space, recommended): + +```sh +uv pip install git+https://huggingface.co/spaces/openenv/wordle +``` + +# Option 1: HF Spaces + Colocated vLLM (1 GPU required) +```sh +python examples/scripts/openenv/wordle.py --vllm-mode colocate +``` + +# Option 2: HF Spaces + Separate vLLM server (2 GPUs required) + +# Spin up vLLM server (Terminal 1) +```sh +CUDA_VISIBLE_DEVICES=0 trl vllm-serve --model Qwen/Qwen3-1.7B --host 0.0.0.0 --port 8000 +``` + +# Run training (Terminal 2) +```sh +CUDA_VISIBLE_DEVICES=1 python examples/scripts/openenv/wordle.py --vllm-mode server --vllm-server-url http://localhost:8000 +``` + +# Option 3: Local Environment + Colocated vLLM (1 GPU required) + +To run the Wordle environment locally, you have several options: + +## Option 3a: Using Docker Image (Recommended) + +First, build the Docker image from the textarena_env directory: +```sh +cd 3rd_party/OpenEnv/envs/textarena_env +docker build -t textarena-env:latest -f server/Dockerfile . +``` + +Then run the environment server: +```sh +docker run -d -p 8001:8001 textarena-env:latest +``` + +Finally, run training pointing to local server: +```sh +python examples/scripts/openenv/wordle.py --vllm-mode colocate --env-url http://localhost:8001 +``` + +## Option 3b: Running Server Directly + +From the textarena_env directory: +```sh +cd 3rd_party/OpenEnv/envs/textarena_env +uv venv && source .venv/bin/activate +uv pip install -e . +python -m uvicorn server.app:app --reload --port 8001 +``` + +Then in another terminal, run training: +```sh +python examples/scripts/openenv/wordle.py --vllm-mode colocate --env-url http://localhost:8001 +``` + +## Option 3c: Using Pre-built HF Space Image + +```sh +docker run -d -p 8001:8001 registry.hf.space/burtenshaw-wordle:latest +python examples/scripts/openenv/wordle.py --vllm-mode colocate --env-url http://localhost:8001 +``` +""" + +import argparse + +from datasets import Dataset +from textarena_env import TextArenaAction, TextArenaEnv + +from trl import GRPOConfig, GRPOTrainer, RichProgressCallback + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser( + description="Run GRPO training for Wordle using the TextArena OpenEnv environment." + ) + parser.add_argument( + "--model", + type=str, + default="Qwen/Qwen3-1.7B", + help="Model identifier passed to GRPOTrainer for fine-tuning.", + ) + parser.add_argument( + "--env-url", + type=str, + default="https://openenv-wordle.hf.space", + help="URL for the environment server.", + ) + parser.add_argument( + "--dataset-size", + type=int, + default=1000, + help="Number of entries to include in the synthetic training dataset.", + ) + parser.add_argument( + "--num-generations", + type=int, + default=4, + help="Number of rollout generations per dataset prompt.", + ) + parser.add_argument( + "--num-epochs", + type=int, + default=1, + help="Number of training epochs.", + ) + parser.add_argument( + "--learning-rate", + type=float, + default=1e-6, + help="Learning rate for GRPO training.", + ) + parser.add_argument( + "--gradient-accumulation-steps", + type=int, + default=64, + help="Gradient accumulation steps for GRPO training.", + ) + parser.add_argument( + "--logging-steps", + type=int, + default=1, + help="Frequency of logging steps for GRPO training.", + ) + parser.add_argument( + "--output-dir", + type=str, + default=None, + help="Directory where training outputs and checkpoints are stored.", + ) + parser.add_argument( + "--trackio-space-id", + type=str, + default="wordle-grpo", + help="Trackio space identifier.", + ) + parser.add_argument( + "--vllm-mode", + choices=("colocate", "server"), + default="colocate", + help="vLLM execution mode: 'colocate' or 'server'.", + ) + parser.add_argument( + "--vllm-server-url", + type=str, + default="http://localhost:8000", + help="URL for the vLLM server (only used when --vllm-mode=server).", + ) + return parser.parse_args() + + +prompt = """You are an expert Wordle solver with deep knowledge of English vocabulary, letter frequency patterns, and optimal guessing strategies. + +Follow these rules to play Wordle: + +1. The target is a 5-letter English word +2. You have 6 attempts to guess the correct word +3. After each guess, you receive color-coded feedback: + - GREEN (G): Letter is correct and in the correct position + - YELLOW (Y): Letter is in the word but in the wrong position + - GRAY (X): Letter is not in the word at all +4. All guesses must be valid 5-letter English words +5. You cannot reuse a word you've already guessed +6. Use the tool `guess` to make a guess. +""" + + +def reward_func(environments, **kwargs) -> list[float]: + return [env.reward for env in environments] + + +def main() -> None: + args = parse_args() + + env_url = args.env_url + + class WordleEnv: + def __init__(self): + self.client = TextArenaEnv(base_url=env_url) + + def reset(self, **kwargs) -> str | None: + result = self.client.reset() + # The game returns cumulative feedback each turn (new text appended at the end), so + # we store the previous full response and slice out only the newly appended part. + self._last_full_feedback = result.observation.messages[0].content + self.reward = 0.0 + self.done = False + return self._last_full_feedback + + def guess(self, guess: str) -> str: + """ + Make a guess in the Wordle environment. + + Args: + guess: The guessed word, formatted as '[abcde]' + + Returns: + The feedback message from the environment. + """ + if self.done: + raise ValueError("Game over.") + result = self.client.step(TextArenaAction(message=guess)) + _full_feedback = result.observation.messages[0].content + # Just take the new feedback since the last guess, which is the part appended to the end of the full feedback + feedback = _full_feedback[len(self._last_full_feedback) :] + self._last_full_feedback = _full_feedback + # For some reason, the environment doesn't penalize invalid moves and just returns the last reward. + # We check the feedback for the invalid move message and penalize it if found. + if "You attempted an invalid move" in feedback: + self.reward = 0.0 + else: + self.reward = result.reward + self.done = result.done + return feedback + + output_dir = args.output_dir or f"{args.model.split('/')[-1]}-wordle-GRPO" + dataset = Dataset.from_dict({"prompt": [[{"role": "user", "content": prompt}] for _ in range(args.dataset_size)]}) + + trainer = GRPOTrainer( + model=args.model, + reward_funcs=reward_func, + train_dataset=dataset, + args=GRPOConfig( + output_dir=output_dir, + use_vllm=True, + vllm_mode=args.vllm_mode, + vllm_server_base_url=args.vllm_server_url if args.vllm_mode == "server" else None, + report_to="trackio", + trackio_space_id=args.trackio_space_id, + log_completions=True, + num_completions_to_print=2, + logging_steps=args.logging_steps, + num_train_epochs=args.num_epochs, + num_generations=args.num_generations, + learning_rate=args.learning_rate, + gradient_accumulation_steps=args.gradient_accumulation_steps, + chat_template_kwargs={"enable_thinking": False}, + max_completion_length=1024, + ), + environment_factory=WordleEnv, + callbacks=[RichProgressCallback()], + ) + trainer.train() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/orpo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/orpo.py new file mode 100644 index 0000000000000000000000000000000000000000..9694f0cd594b3ca5244a0176bca452443b36f48a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/orpo.py @@ -0,0 +1,106 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +Run the ORPO training script with the following command with some example arguments. +In general, the optimal configuration for ORPO will be similar to that of DPO without the need for a reference model: + +# regular: +python examples/scripts/orpo.py \ + --dataset_name trl-internal-testing/hh-rlhf-helpful-base-trl-style \ + --model_name_or_path gpt2 \ + --per_device_train_batch_size 4 \ + --max_steps 1000 \ + --learning_rate 8e-6 \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir "gpt2-aligned-orpo" \ + --warmup_steps 150 \ + --logging_first_step \ + --no_remove_unused_columns + +# peft: +python examples/scripts/orpo.py \ + --dataset_name trl-internal-testing/hh-rlhf-helpful-base-trl-style \ + --model_name_or_path gpt2 \ + --per_device_train_batch_size 4 \ + --max_steps 1000 \ + --learning_rate 8e-5 \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir "gpt2-lora-aligned-orpo" \ + --optim rmsprop \ + --warmup_steps 150 \ + --logging_first_step \ + --no_remove_unused_columns \ + --use_peft \ + --lora_r 16 \ + --lora_alpha 16 +""" + +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser + +from trl import ModelConfig, ScriptArguments, get_peft_config +from trl.experimental.orpo import ORPOConfig, ORPOTrainer + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, ORPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + ################ + # Model & Tokenizer + ################ + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ################ + # Training + ################ + trainer = ORPOTrainer( + model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + # train and save the model + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/ppo/ppo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/ppo/ppo.py new file mode 100644 index 0000000000000000000000000000000000000000..ed7105105e8d4c530bc90cde191a8e1c7d70fa97 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/ppo/ppo.py @@ -0,0 +1,172 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +import shutil + +import torch +from accelerate import PartialState +from datasets import load_dataset +from transformers import ( + AutoModelForCausalLM, + AutoModelForSequenceClassification, + AutoTokenizer, + HfArgumentParser, +) + +from trl import ModelConfig, ScriptArguments, get_kbit_device_map, get_peft_config, get_quantization_config +from trl.experimental.ppo import PPOConfig, PPOTrainer + + +""" +python -i examples/scripts/ppo/ppo.py \ + --dataset_name trl-internal-testing/descriptiveness-sentiment-trl-style \ + --dataset_train_split descriptiveness \ + --output_dir pythia-1b-deduped-descriptiveness-sentiment-trl-style-ppo \ + --per_device_train_batch_size 64 \ + --gradient_accumulation_steps 1 \ + --total_episodes 10000 \ + --model_name_or_path EleutherAI/pythia-1b-deduped \ + --missing_eos_penalty 1.0 + +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/ppo/ppo.py \ + --dataset_name trl-internal-testing/descriptiveness-sentiment-trl-style \ + --dataset_train_split descriptiveness \ + --output_dir pythia-1b-deduped-descriptiveness-sentiment-trl-style-ppo \ + --num_ppo_epochs 1 \ + --num_mini_batches 1 \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 16 \ + --total_episodes 10000 \ + --model_name_or_path EleutherAI/pythia-1b-deduped \ + --sft_model_path EleutherAI/pythia-1b-deduped \ + --reward_model_path EleutherAI/pythia-1b-deduped \ + --local_rollout_forward_batch_size 1 \ + --missing_eos_penalty 1.0 +""" + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, PPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + # remove output_dir if exists + shutil.rmtree(training_args.output_dir, ignore_errors=True) + + ################ + # Model & Tokenizer + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, padding_side="left", trust_remote_code=model_args.trust_remote_code + ) + tokenizer.add_special_tokens({"pad_token": "[PAD]"}) + value_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + trust_remote_code=model_args.trust_remote_code, + num_labels=1, + **model_kwargs, + ) + reward_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + trust_remote_code=model_args.trust_remote_code, + num_labels=1, + **model_kwargs, + ) + policy = AutoModelForCausalLM.from_pretrained( + training_args.sft_model_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + peft_config = get_peft_config(model_args) + if peft_config is None: + ref_policy = AutoModelForCausalLM.from_pretrained( + training_args.sft_model_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + else: + ref_policy = None + + ################ + # Dataset + ################ + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, split=script_args.dataset_train_split + ) + eval_samples = 100 + train_dataset = dataset.select(range(len(dataset) - eval_samples)) + eval_dataset = dataset.select(range(len(dataset) - eval_samples, len(dataset))) + dataset_text_field = "prompt" + + def prepare_dataset(dataset, tokenizer): + """pre-tokenize the dataset before training; only collate during training""" + + def tokenize(element): + outputs = tokenizer( + element[dataset_text_field], + padding=False, + ) + return {"input_ids": outputs["input_ids"]} + + return dataset.map( + tokenize, + batched=True, + remove_columns=dataset.column_names, + num_proc=training_args.dataset_num_proc, + ) + + # Compute that only on the main process for faster data processing. + # see: https://github.com/huggingface/trl/pull/1255 + with PartialState().local_main_process_first(): + train_dataset = prepare_dataset(train_dataset, tokenizer) + eval_dataset = prepare_dataset(eval_dataset, tokenizer) + + ################ + # Training + ################ + trainer = PPOTrainer( + args=training_args, + processing_class=tokenizer, + model=policy, + ref_model=ref_policy, + reward_model=reward_model, + value_model=value_model, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=peft_config, + ) + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + trainer.generate_completions() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/ppo/ppo_tldr.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/ppo/ppo_tldr.py new file mode 100644 index 0000000000000000000000000000000000000000..7e5714e5a79d74a6acda7399cc9b207a0f996c3d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/ppo/ppo_tldr.py @@ -0,0 +1,178 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +import shutil + +import torch +from accelerate import PartialState +from datasets import load_dataset +from transformers import ( + AutoModelForCausalLM, + AutoModelForSequenceClassification, + AutoTokenizer, + HfArgumentParser, +) + +from trl import ModelConfig, ScriptArguments, get_kbit_device_map, get_peft_config, get_quantization_config +from trl.experimental.ppo import PPOConfig, PPOTrainer + + +""" +python examples/scripts/ppo/ppo_tldr.py \ + --dataset_name trl-lib/tldr \ + --dataset_test_split validation \ + --output_dir pythia-1b-deduped-tldr-preference-sft-trl-style-ppo \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 64 \ + --total_episodes 30000 \ + --model_name_or_path EleutherAI/pythia-1b-deduped \ + --sft_model_path cleanrl/EleutherAI_pythia-1b-deduped__sft__tldr \ + --reward_model_path cleanrl/EleutherAI_pythia-1b-deduped__reward__tldr \ + --missing_eos_penalty 1.0 \ + --stop_token eos \ + --response_length 53 \ + --eval_strategy steps \ + --eval_steps 100 + +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero2.yaml \ + examples/scripts/ppo/ppo_tldr.py \ + --dataset_name trl-lib/tldr \ + --dataset_test_split validation \ + --output_dir pythia-1b-deduped-tldr-preference-sft-trl-style-ppo \ + --per_device_train_batch_size 16 \ + --gradient_accumulation_steps 4 \ + --total_episodes 1000000 \ + --model_name_or_path EleutherAI/pythia-1b-deduped \ + --sft_model_path cleanrl/EleutherAI_pythia-1b-deduped__sft__tldr \ + --reward_model_path cleanrl/EleutherAI_pythia-1b-deduped__reward__tldr \ + --local_rollout_forward_batch_size 16 \ + --missing_eos_penalty 1.0 \ + --stop_token eos \ + --eval_strategy steps \ + --eval_steps 100 +""" + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, PPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + # remove output_dir if exists + shutil.rmtree(training_args.output_dir, ignore_errors=True) + + ################ + # Model & Tokenizer + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, padding_side="left", trust_remote_code=model_args.trust_remote_code + ) + tokenizer.add_special_tokens({"pad_token": "[PAD]"}) + value_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + trust_remote_code=model_args.trust_remote_code, + num_labels=1, + **model_kwargs, + ) + reward_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + trust_remote_code=model_args.trust_remote_code, + num_labels=1, + **model_kwargs, + ) + policy = AutoModelForCausalLM.from_pretrained( + training_args.sft_model_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + peft_config = get_peft_config(model_args) + if peft_config is None: + ref_policy = AutoModelForCausalLM.from_pretrained( + training_args.sft_model_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + else: + ref_policy = None + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + train_dataset = dataset[script_args.dataset_train_split] + eval_dataset = dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None + + def prepare_dataset(dataset, tokenizer): + """pre-tokenize the dataset before training; only collate during training""" + + def tokenize(element): + input_ids = tokenizer(element["prompt"], padding=False)["input_ids"] + return {"input_ids": input_ids, "lengths": len(input_ids)} + + return dataset.map( + tokenize, + remove_columns=dataset.column_names, + num_proc=training_args.dataset_num_proc, + ) + + # Compute that only on the main process for faster data processing. + # see: https://github.com/huggingface/trl/pull/1255 + with PartialState().local_main_process_first(): + train_dataset = prepare_dataset(train_dataset, tokenizer) + if eval_dataset is not None: + eval_dataset = prepare_dataset(eval_dataset, tokenizer) + # filtering + train_dataset = train_dataset.filter(lambda x: x["lengths"] <= 512, num_proc=training_args.dataset_num_proc) + if eval_dataset is not None: + eval_dataset = eval_dataset.filter(lambda x: x["lengths"] <= 512, num_proc=training_args.dataset_num_proc) + + assert train_dataset[0]["input_ids"][-1] != tokenizer.eos_token_id, "The last token should not be an EOS token" + + ################ + # Training + ################ + trainer = PPOTrainer( + args=training_args, + processing_class=tokenizer, + model=policy, + ref_model=ref_policy, + reward_model=reward_model, + value_model=value_model, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=peft_config, + ) + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + trainer.generate_completions() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/prm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/prm.py new file mode 100644 index 0000000000000000000000000000000000000000..bda78a91fa9ac3e17764f291bce0cb9f3b5add26 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/prm.py @@ -0,0 +1,130 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "trackio", +# "kernels", +# ] +# /// + +""" +Full training: +python examples/scripts/prm.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/prm800k \ + --output_dir Qwen2-0.5B-Reward \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 1.0e-5 \ + --eval_strategy steps \ + --eval_steps 50 + +LoRA: +python examples/scripts/prm.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/prm800k \ + --output_dir Qwen2-0.5B-Reward-LoRA \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 1.0e-4 \ + --eval_strategy steps \ + --eval_steps 50 + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 +""" + +import torch +from accelerate import logging +from datasets import load_dataset +from transformers import AutoModelForTokenClassification, AutoTokenizer, HfArgumentParser + +from trl import ( + ModelConfig, + ScriptArguments, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.experimental.prm import PRMConfig, PRMTrainer + + +logger = logging.get_logger(__name__) + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, PRMConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + ################ + # Model & Tokenizer + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + use_cache=False if training_args.gradient_checkpointing else True, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, use_fast=True + ) + model = AutoModelForTokenClassification.from_pretrained( + model_args.model_name_or_path, num_labels=2, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + if model_args.use_peft and model_args.lora_task_type != "TOKEN_CLS": + logger.warning( + "You are using a `task_type` that is different than `TOKEN_CLS` for PEFT. This will lead to silent bugs" + " Make sure to pass --lora_task_type TOKEN_CLS when using this script with PEFT.", + ) + + ############## + # Load dataset + ############## + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + dataset = dataset.filter(lambda x: len(x["completions"]) > 0) + + ########## + # Training + ########## + trainer = PRMTrainer( + model=model, + processing_class=tokenizer, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split], + peft_config=get_peft_config(model_args), + ) + trainer.train() + + ############################ + # Save model and push to Hub + ############################ + trainer.save_model(training_args.output_dir) + metrics = trainer.evaluate() + trainer.log_metrics("eval", metrics) + trainer.save_metrics("eval", metrics) + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/reward_modeling.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/reward_modeling.py new file mode 100644 index 0000000000000000000000000000000000000000..eac5b80cfe7542884b969d28f8a52669cb9b5bd2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/reward_modeling.py @@ -0,0 +1,131 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "trackio", +# "kernels", +# ] +# /// + +""" +Full training: +python examples/scripts/reward_modeling.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --output_dir Qwen2-0.5B-Reward \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 1.0e-5 \ + --eval_strategy steps \ + --eval_steps 50 \ + --max_length 2048 + +LoRA: +python examples/scripts/reward_modeling.py \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --output_dir Qwen2-0.5B-Reward-LoRA \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 1.0e-4 \ + --eval_strategy steps \ + --eval_steps 50 \ + --max_length 2048 \ + --use_peft \ + --lora_task_type SEQ_CLS \ + --lora_r 32 \ + --lora_alpha 16 +""" + +import torch +from accelerate import logging +from datasets import load_dataset +from transformers import AutoModelForSequenceClassification, HfArgumentParser + +from trl import ( + ModelConfig, + RewardConfig, + RewardTrainer, + ScriptArguments, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) + + +logger = logging.get_logger(__name__) + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, RewardConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + ################ + # Model & Tokenizer + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + use_cache=False if training_args.gradient_checkpointing else True, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForSequenceClassification.from_pretrained( + model_args.model_name_or_path, num_labels=1, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + if model_args.use_peft and model_args.lora_task_type != "SEQ_CLS": + logger.warning( + "You are using a `task_type` that is different than `SEQ_CLS` for PEFT. This will lead to silent bugs" + " Make sure to pass --lora_task_type SEQ_CLS when using this script with PEFT.", + ) + + ############## + # Load dataset + ############## + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ########## + # Training + ########## + trainer = RewardTrainer( + model=model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + trainer.train() + + ############################ + # Save model and push to Hub + ############################ + trainer.save_model(training_args.output_dir) + + if training_args.eval_strategy != "no": + metrics = trainer.evaluate() + trainer.log_metrics("eval", metrics) + trainer.save_metrics("eval", metrics) + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/rloo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/rloo.py new file mode 100644 index 0000000000000000000000000000000000000000..5ed2cd0409780f835966f1746ce54b051ff15252 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/rloo.py @@ -0,0 +1,99 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[vllm,peft]", +# "math-verify", +# "latex2sympy2_extended", +# "trackio", +# "kernels", +# ] +# /// + +""" +NuminaMath example: RLOO on math dataset with vLLM. + + pip install math_verify num2words==0.5.14 peft trackio vllm + export TRACKIO_PROJECT="RLOO-NuminaMath-TIR" + accelerate launch --config_file examples/accelerate_configs/deepspeed_zero3.yaml examples/scripts/rloo.py + +For TL;DR or other datasets with a reward model, use the generic script: + python -m trl.scripts.rloo --dataset_name trl-lib/tldr --reward_model_name_or_path ... --model_name_or_path ... +""" + +import torch +from datasets import load_dataset +from peft import LoraConfig + +from trl import RLOOConfig, RLOOTrainer +from trl.rewards import accuracy_reward, think_format_reward + + +def main(): + # Dataset + train_dataset, eval_dataset = load_dataset("AI-MO/NuminaMath-TIR", split=["train[:5%]", "test[:5%]"]) + + SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The " + "assistant first thinks about the reasoning process in the mind and then provides the user with the answer. " + "The reasoning process and answer are enclosed within tags, i.e., \nThis is my " + "reasoning.\n\nThis is my answer." + ) + + def make_conversation(example): + return { + "prompt": [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ], + } + + train_dataset = train_dataset.map(make_conversation, remove_columns=["messages", "problem"]) + eval_dataset = eval_dataset.map(make_conversation, remove_columns=["messages", "problem"]) + + # Training + training_args = RLOOConfig( + output_dir="Qwen3-0.6B-RLOO", + model_init_kwargs={"dtype": torch.bfloat16}, + learning_rate=1e-5, + log_completions=True, + num_completions_to_print=2, + max_completion_length=1024, + gradient_accumulation_steps=2, + steps_per_generation=8, + use_vllm=True, + vllm_mode="colocate", + vllm_gpu_memory_utilization=0.5, + run_name="Qwen3-0.6B-RLOO-NuminaMath-TIR", + ) + + trainer = RLOOTrainer( + model="Qwen/Qwen3-0.6B", + args=training_args, + reward_funcs=[think_format_reward, accuracy_reward], + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=LoraConfig(), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + trainer.push_to_hub(dataset_name="AI-MO/NuminaMath-TIR") + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/rloo_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/rloo_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..87bcdc59752ac5183912a26b50ce1202e25e394b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/rloo_vlm.py @@ -0,0 +1,157 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow", +# "math-verify", +# "latex2sympy2_extended", +# "torchvision", +# "trackio", +# "kernels", +# ] +# /// + +""" +pip install math_verify + +# For Qwen/Qwen2.5-VL-3B-Instruct +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/rloo_vlm.py \ + --model_name_or_path Qwen/Qwen2.5-VL-3B-Instruct \ + --output_dir rloo-Qwen2.5-VL-3B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_vllm \ + --vllm_mode colocate \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions + +# For HuggingFaceTB/SmolVLM2-2.2B-Instruct +pip install num2words==0.5.14 + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/rloo_vlm.py \ + --model_name_or_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \ + --output_dir rloo-SmolVLM2-2.2B-Instruct \ + --learning_rate 1e-5 \ + --dtype bfloat16 \ + --max_completion_length 1024 \ + --use_peft \ + --lora_target_modules "q_proj", "v_proj" \ + --log_completions \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 2 \ + --num_generations 2 + +""" + +import torch +from datasets import load_dataset + +from trl import ( + ModelConfig, + RLOOConfig, + RLOOTrainer, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.rewards import accuracy_reward, think_format_reward + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, RLOOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + ################ + # Model + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + training_args.model_init_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + training_args.model_init_kwargs["device_map"] = get_kbit_device_map() + training_args.model_init_kwargs["quantization_config"] = quantization_config + + ################ + # Dataset + ################ + dataset = load_dataset("lmms-lab/multimodal-open-r1-8k-verified", split="train") + dataset = dataset.train_test_split(test_size=100, seed=42) + + SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The " + "assistant first thinks about the reasoning process in the mind and then provides the user with the answer. " + "The reasoning process and answer are enclosed within tags, i.e., \nThis is my " + "reasoning.\n\nThis is my answer." + ) + + def make_conversation(example): + prompt = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ] + return {"prompt": prompt} + + dataset = dataset.map(make_conversation) + + # Filter have big images + def filter_big_images(example): + image = example["image"] + return image.size[0] < 512 and image.size[1] < 512 + + dataset = dataset.filter(filter_big_images) + + def convert_to_rgb(example): + image = example["image"] + if image.mode != "RGB": + image = image.convert("RGB") + example["image"] = image + return example + + dataset = dataset.map(convert_to_rgb) + + train_dataset = dataset["train"] + eval_dataset = dataset["test"] if training_args.eval_strategy != "no" else None + + ################ + # Training + ################ + trainer = RLOOTrainer( + model=model_args.model_name_or_path, + args=training_args, + reward_funcs=[think_format_reward, accuracy_reward], + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft.py new file mode 100644 index 0000000000000000000000000000000000000000..b6e132e99026e779bbf3ee14a52447886b3b1a31 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft.py @@ -0,0 +1,17 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +############################################################################################### +# This file has been moved to https://github.com/huggingface/trl/blob/main/trl/scripts/sft.py # +############################################################################################### diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_gemma3.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_gemma3.py new file mode 100644 index 0000000000000000000000000000000000000000..8aeb74abc71d4f0e7c1bfd82e30e94e2de8a948e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_gemma3.py @@ -0,0 +1,69 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "Pillow", +# "trackio", +# "kernels", +# ] +# /// + +""" +Train Gemma-3 on the Codeforces COTS dataset. + +accelerate launch --config_file examples/accelerate_configs/deepspeed_zero3.yaml examples/scripts/sft_gemma3.py +""" + +from datasets import load_dataset +from transformers import AutoModelForImageTextToText + +from trl import SFTConfig, SFTTrainer + + +def main(): + # Load dataset + train_dataset = load_dataset("open-r1/codeforces-cots", split="train") + train_dataset = train_dataset.remove_columns("prompt") + + # Load model + model_id = "google/gemma-3-12b-it" + model = AutoModelForImageTextToText.from_pretrained(model_id, attn_implementation="eager") + + # Train model + training_args = SFTConfig( + output_dir=f"{model_id}-codeforces-SFT", + bf16=True, + use_liger_kernel=True, + max_length=8192, + per_device_train_batch_size=1, + gradient_accumulation_steps=8, + dataset_num_proc=32, + num_train_epochs=1, + ) + + trainer = SFTTrainer( + args=training_args, + model=model, + train_dataset=train_dataset, + ) + trainer.train() + + # Push to hub + trainer.push_to_hub(dataset_name="open-r1/codeforces-cots") + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_gpt_oss.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_gpt_oss.py new file mode 100644 index 0000000000000000000000000000000000000000..e22fe82d9df7f44909c94c0c686ea816c6dc8220 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_gpt_oss.py @@ -0,0 +1,92 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "kernels", +# "trackio", +# "kernels", +# ] +# /// + +""" +pip install –-upgrade kernels + +Example: + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/sft_gpt_oss.py \ + --dtype bfloat16 \ + --model_name_or_path openai/gpt-oss-20b \ + --packing \ + --run_name 20b-full-eager \ + --attn_implementation kernels-community/vllm-flash-attn3 \ + --dataset_num_proc 12 \ + --dataset_name HuggingFaceH4/Multilingual-Thinking \ + --max_length 4096 \ + --per_device_train_batch_size 2 \ + --num_train_epochs 1 \ + --logging_steps 1 \ + --warmup_steps 0.03 \ + --lr_scheduler_type cosine_with_min_lr \ + --lr_scheduler_kwargs '{"min_lr_rate": 0.1}' \ + --output_dir gpt-oss-20b-multilingual-reasoner \ + --report_to trackio \ + --seed 42 +""" + +from datasets import load_dataset +from transformers import AutoModelForCausalLM, Mxfp4Config + +from trl import ModelConfig, ScriptArguments, SFTConfig, SFTTrainer, TrlParser, get_peft_config + + +def main(script_args, training_args, model_args): + # Load model + quantization_config = Mxfp4Config(dequantize=True) + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + dtype=model_args.dtype, + use_cache=False if training_args.gradient_checkpointing else True, + quantization_config=quantization_config, + ) + + model = AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path, **model_kwargs) + + # Load dataset + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + # Train model + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, SFTConfig, ModelConfig)) + script_args, training_args, model_args, _ = parser.parse_args_and_config(return_remaining_strings=True) + main(script_args, training_args, model_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_nemotron_3.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_nemotron_3.py new file mode 100644 index 0000000000000000000000000000000000000000..c3f6aa0c9389c41b9d025e2053a1a4dcd1c71625 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_nemotron_3.py @@ -0,0 +1,116 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft,quantization]", +# "transformers>=5.3.0", +# "trackio", +# "mamba_ssm==2.2.5", +# "causal_conv1d==1.5.2", +# ] +# /// + +""" +Fine-tune NVIDIA Nemotron 3 models with SFT. + +Prerequisites: + + pip install "transformers>=5.3.0" + pip install --no-build-isolation mamba_ssm==2.2.5 + pip install --no-build-isolation causal_conv1d==1.5.2 + +Example: + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/sft_nemotron_3.py \ + --dtype bfloat16 \ + --model_name_or_path nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \ + --attn_implementation eager \ + --dataset_name HuggingFaceH4/Multilingual-Thinking \ + --max_length 128 \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 4 \ + --num_train_epochs 1 \ + --learning_rate 2e-4 \ + --optim paged_adamw_8bit \ + --logging_steps 10 \ + --output_dir nemotron-3-sft \ + --report_to trackio \ + --use_peft \ + --lora_r 8 \ + --lora_alpha 16 \ + --lora_target_modules q_proj k_proj v_proj o_proj gate_proj up_proj down_proj +""" + +from datasets import load_dataset +from transformers import AutoModelForCausalLM + +from trl import ModelConfig, ScriptArguments, SFTConfig, SFTTrainer, TrlParser, get_peft_config + + +def main(script_args, training_args, model_args): + # NemotronH does not support gradient checkpointing + training_args.gradient_checkpointing = False + + # Load model + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=model_args.dtype, + ) + model = AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path, **model_kwargs) + + # Load dataset + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + # Merge thinking into message content using tags and remove extra columns + def merge_thinking_and_remove_key(example): + new_messages = [] + for msg in example["messages"]: + content = msg["content"] + thinking = msg.get("thinking") + if thinking and isinstance(thinking, str) and thinking.strip(): + content = f"\n{thinking}\n\n{content}" + new_messages.append({"role": msg["role"], "content": content}) + example["messages"] = new_messages + return example + + dataset = dataset.map(merge_thinking_and_remove_key) + + # Prepare eval dataset if needed + eval_dataset = None + if training_args.eval_strategy != "no" and script_args.dataset_test_split in dataset: + eval_dataset = dataset[script_args.dataset_test_split] + + # Train model + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, SFTConfig, ModelConfig)) + script_args, training_args, model_args, _ = parser.parse_args_and_config(return_remaining_strings=True) + main(script_args, training_args, model_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_tiny_aya_tool_calling.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_tiny_aya_tool_calling.py new file mode 100644 index 0000000000000000000000000000000000000000..7a29be6035863fbc20a3e5b49fb60ca2233a74c7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_tiny_aya_tool_calling.py @@ -0,0 +1,164 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "bitsandbytes", +# "liger-kernel", +# "trackio", +# ] +# /// + +""" +Teach tool calling to CohereLabs/tiny-aya-global using SFT with QLoRA on the bebechien/SimpleToolCalling dataset. + +The model used in this script does not have native tool-calling support. We extend its existing Jinja2 chat template to +serialize tool schemas into the system preamble and render tool calls as structured XML inside the model's +native <|START_RESPONSE|> / <|END_RESPONSE|> delimiters. The modified template is saved with the tokenizer, so +inference only requires loading the tokenizer from the output directory and calling apply_chat_template with +tools=TOOLS — no manual system-prompt construction needed. + +Example: + + python examples/scripts/sft_tiny_aya_tool_calling.py +""" + +import json +from pathlib import Path + +import torch +from datasets import load_dataset +from peft import LoraConfig +from transformers import AutoModelForCausalLM, BitsAndBytesConfig + +from trl import SFTConfig, SFTTrainer + + +# These are the tool schemas that are used in the dataset +TOOLS = [ + { + "type": "function", + "function": { + "name": "search_knowledge_base", + "description": "Search internal company documents, policies and project data.", + "parameters": { + "type": "object", + "properties": {"query": {"type": "string", "description": "query string"}}, + "required": ["query"], + }, + "return": {"type": "string"}, + }, + }, + { + "type": "function", + "function": { + "name": "search_google", + "description": "Search public information.", + "parameters": { + "type": "object", + "properties": {"query": {"type": "string", "description": "query string"}}, + "required": ["query"], + }, + "return": {"type": "string"}, + }, + }, +] + + +def create_conversation(sample): + return { + "prompt": [{"role": "user", "content": sample["user_content"]}], + "completion": [ + { + "role": "assistant", + "tool_calls": [ + { + "type": "function", + "function": { + "name": sample["tool_name"], + "arguments": json.loads(sample["tool_arguments"]), + }, + } + ], + }, + ], + "tools": TOOLS, + } + + +def main(): + model_id = "CohereLabs/tiny-aya-global" + dataset_name = "bebechien/SimpleToolCalling" + output_dir = "tiny-aya-global-tool-calling-SFT" + + # Load and format dataset + dataset = load_dataset(dataset_name, split="train") + dataset = dataset.map(create_conversation, remove_columns=dataset.features) + dataset = dataset.train_test_split(test_size=0.5, shuffle=True) + + # Load model + model = AutoModelForCausalLM.from_pretrained( + model_id, + attn_implementation="sdpa", + dtype=torch.float16, + quantization_config=BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_compute_dtype=torch.float16, + bnb_4bit_use_double_quant=True, + bnb_4bit_quant_type="nf4", + ), + ) + + # Configure LoRA + peft_config = LoraConfig( + r=32, + lora_alpha=32, + target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"], + ) + + # Train + training_args = SFTConfig( + output_dir=output_dir, + per_device_train_batch_size=1, + gradient_accumulation_steps=4, + # Use the tool-aware chat template + chat_template_path=str(Path(__file__).parent / "tiny_aya_chat_template.jinja"), + warmup_steps=5, + learning_rate=2e-4, + optim="paged_adamw_8bit", + logging_steps=1, + report_to="trackio", + trackio_space_id=output_dir, + max_length=1024, + use_liger_kernel=True, + activation_offloading=True, + push_to_hub=True, + ) + + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset["train"], + peft_config=peft_config, + ) + trainer.train() + + # Save model and tokenizer (tokenizer carries the updated chat template) + trainer.save_model(output_dir) + trainer.push_to_hub(dataset_name=dataset_name) + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_video_llm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_video_llm.py new file mode 100644 index 0000000000000000000000000000000000000000..cde6d6594f390b4259e941d5b3a35d41638ff909 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_video_llm.py @@ -0,0 +1,248 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "qwen-vl-utils", +# "torchvision", +# "bitsandbytes", +# "trackio", +# "kernels", +# ] +# /// + +""" +Example usage: +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero2.yaml \ + examples/scripts/sft_video_llm.py \ + --dataset_name mfarre/simplevideoshorts \ + --video_cache_dir "/optional/path/to/cache/" \ + --model_name_or_path Qwen/Qwen2-VL-7B-Instruct \ + --per_device_train_batch_size 1 \ + --output_dir video-llm-output \ + --tf32 True \ + --gradient_accumulation_steps 4 \ + --num_train_epochs 4 \ + --optim adamw_torch_fused \ + --log_level debug \ + --log_level_replica debug \ + --save_strategy steps \ + --save_steps 300 \ + --learning_rate 8e-5 \ + --max_grad_norm 0.3 \ + --warmup_steps 0.1 \ + --lr_scheduler_type cosine \ + --push_to_hub False \ + --dtype bfloat16 +""" + +import json +import os +import random +from dataclasses import dataclass, field +from typing import Any + +import requests +import torch +from datasets import load_dataset +from peft import LoraConfig +from qwen_vl_utils import process_vision_info +from transformers import AutoModelForImageTextToText, AutoProcessor, BitsAndBytesConfig, Qwen2VLProcessor + +from trl import ModelConfig, ScriptArguments, SFTConfig, SFTTrainer, TrlParser, get_kbit_device_map + + +def download_video(url: str, cache_dir: str) -> str: + """Download video if not already present locally.""" + os.makedirs(cache_dir, exist_ok=True) # Create cache dir if it doesn't exist + filename = url.split("/")[-1] + local_path = os.path.join(cache_dir, filename) + + if os.path.exists(local_path): + return local_path + + try: + with requests.get(url, stream=True) as r: + r.raise_for_status() + with open(local_path, "wb") as f: + for chunk in r.iter_content(chunk_size=8192): + if chunk: + f.write(chunk) + return local_path + except requests.RequestException as e: + raise Exception(f"Failed to download video: {e}") from e + + +def prepare_dataset(example: dict[str, Any], cache_dir: str) -> dict[str, list[dict[str, Any]]]: + """Prepare dataset example for training.""" + video_url = example["video_url"] + timecoded_cc = example["timecoded_cc"] + qa_pairs = json.loads(example["qa"]) + + system_message = "You are an expert in movie narrative analysis." + base_prompt = f"""Analyze the video and consider the following timecoded subtitles: + +{timecoded_cc} + +Based on this information, please answer the following questions:""" + + selected_qa = random.sample(qa_pairs, 1)[0] + + messages = [ + {"role": "system", "content": [{"type": "text", "text": system_message}]}, + { + "role": "user", + "content": [ + {"type": "video", "video": download_video(video_url, cache_dir), "max_pixels": 360 * 420, "fps": 1.0}, + {"type": "text", "text": f"{base_prompt}\n\nQuestion: {selected_qa['question']}"}, + ], + }, + {"role": "assistant", "content": [{"type": "text", "text": selected_qa["answer"]}]}, + ] + + return {"messages": messages} + + +def collate_fn(examples: list[dict[str, Any]]) -> dict[str, torch.Tensor]: + """Collate batch of examples for training.""" + texts = [] + video_inputs = [] + + for i, example in enumerate(examples): + try: + video_path = next( + content["video"] + for message in example["messages"] + for content in message["content"] + if content.get("type") == "video" + ) + print(f"Processing video: {os.path.basename(video_path)}") + + texts.append(processor.apply_chat_template(example["messages"], tokenize=False)) + video_input = process_vision_info(example["messages"])[1][0] + video_inputs.append(video_input) + except Exception as e: + raise ValueError(f"Failed to process example {i}: {e}") from e + + inputs = processor(text=texts, videos=video_inputs, return_tensors="pt", padding=True) + + labels = inputs["input_ids"].clone() + labels[labels == processor.tokenizer.pad_token_id] = -100 + + # Handle visual tokens based on processor type + visual_tokens = ( + [151652, 151653, 151656] + if isinstance(processor, Qwen2VLProcessor) + else [processor.tokenizer.convert_tokens_to_ids(processor.image_token)] + ) + + for visual_token_id in visual_tokens: + labels[labels == visual_token_id] = -100 + + inputs["labels"] = labels + return inputs + + +@dataclass +class CustomScriptArguments(ScriptArguments): + r""" + Arguments for the script. + + Args: + video_cache_dir (`str`, *optional*, defaults to `"/tmp/videos/"`): + Video cache directory. + """ + + video_cache_dir: str = field(default="/tmp/videos/", metadata={"help": "Video cache directory."}) + + +if __name__ == "__main__": + # Parse arguments + parser = TrlParser((CustomScriptArguments, SFTConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + # Configure training args + training_args.remove_unused_columns = False + + # Load dataset + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config, split="train") + + # Setup model + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + + # Quantization configuration for 4-bit training + bnb_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_use_double_quant=True, + bnb_4bit_quant_type="nf4", + bnb_4bit_compute_dtype=torch.bfloat16, + ) + + # Model initialization + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + dtype=dtype, + device_map=get_kbit_device_map(), + quantization_config=bnb_config, + ) + + model = AutoModelForImageTextToText.from_pretrained(model_args.model_name_or_path, **model_kwargs) + + peft_config = LoraConfig( + task_type="CAUSAL_LM", + r=16, + lora_alpha=16, + lora_dropout=0.1, + bias="none", + target_modules=["q_proj", "k_proj", "v_proj", "o_proj"], + ) + + # Configure model modules for gradients + if training_args.gradient_checkpointing: + model.gradient_checkpointing_enable() + model.config.use_reentrant = False + model.enable_input_require_grads() + + processor = AutoProcessor.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + + # Prepare dataset + prepared_dataset = [prepare_dataset(example, script_args.video_cache_dir) for example in dataset] + + # Initialize trainer + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=prepared_dataset, + data_collator=collate_fn, + peft_config=peft_config, + processing_class=processor, + ) + + # Train model + trainer.train() + + # Save final model + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + # Cleanup + del model + del trainer + torch.cuda.empty_cache() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_vlm.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_vlm.py new file mode 100644 index 0000000000000000000000000000000000000000..54f92075bd39b0fc272adc5b7e1574659040ccb6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_vlm.py @@ -0,0 +1,117 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow>=9.4.0", +# "trackio", +# "kernels", +# ] +# /// + +""" +pip install pillow + +# Tested on 8x H100 GPUs +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/sft_vlm.py \ + --dataset_name HuggingFaceH4/llava-instruct-mix-vsft \ + --model_name_or_path llava-hf/llava-1.5-7b-hf \ + --gradient_accumulation_steps 8 \ + --output_dir LLaVA-1.5-7B-SFT \ + --dtype bfloat16 + +For LLaVA-NeXT, use: + --model_name_or_path llava-hf/llava-v1.6-mistral-7b-hf + +For meta-llama/Llama-3.2-11B-Vision-Instruct, use: + --model_name_or_path meta-llama/Llama-3.2-11B-Vision-Instruct + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/sft_vlm.py \ + --dataset_name HuggingFaceH4/llava-instruct-mix-vsft \ + --model_name_or_path HuggingFaceTB/SmolVLM-Instruct \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 1 \ + --output_dir SmolVLM-SFT \ + --dtype bfloat16 \ + --use_peft \ + --lora_target_modules down_proj, o_proj, k_proj, q_proj, gate_proj, up_proj, v_proj +""" + +import torch +from datasets import load_dataset +from transformers import AutoModelForImageTextToText + +from trl import ( + ModelConfig, + ScriptArguments, + SFTConfig, + SFTTrainer, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, SFTConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + training_args.max_length = None + + ################ + # Model + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForImageTextToText.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ################ + # Training + ################ + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_vlm_gemma3.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_vlm_gemma3.py new file mode 100644 index 0000000000000000000000000000000000000000..14a4f99a314a349a85bf910ef547f78a1cd9aaf6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/sft_vlm_gemma3.py @@ -0,0 +1,189 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "Pillow>=9.4.0", +# "trackio", +# "kernels", +# ] +# /// + +""" +Train Gemma 3 on the HuggingFaceH4/llava-instruct-mix-vsft dataset (single-image). + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/sft_vlm_gemma3.py \ + --dataset_name HuggingFaceH4/llava-instruct-mix-vsft \ + --model_name_or_path google/gemma-3-4b-it \ + --per_device_train_batch_size 1 \ + --output_dir Gemma-3-4B-SFT-MMIU \ + --dtype bfloat16 \ + --use_peft \ + --lora_target_modules all-linear \ + --attn_implementation eager + +Train Gemma 3 on the FanqingM/MMIU-Benchmark dataset (multi-image). + +accelerate launch \ + --config_file examples/accelerate_configs/deepspeed_zero3.yaml \ + examples/scripts/sft_vlm_gemma3.py \ + --dataset_name FanqingM/MMIU-Benchmark \ + --dataset_train_split test \ + --model_name_or_path google/gemma-3-4b-it \ + --per_device_train_batch_size 1 \ + --output_dir Gemma-3-4B-SFT-MMIU \ + --dtype bfloat16 \ + --use_peft \ + --lora_target_modules all-linear \ + --attn_implementation eager +""" + +import io +import os +import zipfile + +import torch +from datasets import DatasetDict, load_dataset +from huggingface_hub import hf_hub_download, list_repo_files +from PIL import Image +from transformers import AutoModelForImageTextToText + +from trl import ( + ModelConfig, + ScriptArguments, + SFTConfig, + SFTTrainer, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) + + +# For multi-image example +def process_vision_info(messages: list[dict]) -> list[Image.Image]: + image_inputs = [] + for msg in messages: + content = msg.get("content", []) + if not isinstance(content, list): + content = [content] + + for element in content: + if isinstance(element, dict) and ("image" in element or element.get("type") == "image"): + if "image" in element: + image = element["image"] + else: + image = element + if image is not None: + image = Image.open(io.BytesIO(image["bytes"])) + image_inputs.append(image.convert("RGB")) + return image_inputs + + +def format_data(samples: dict[str, any]) -> dict[str, list]: + formatted_samples = {"messages": []} + for cont in range(len(samples["question"])): + images = [] + for img_path in samples["input_image_path"][cont]: + try: + with open(img_path, "rb") as f: + img_bytes = f.read() + image = Image.open(io.BytesIO(img_bytes)).convert("RGB") + images.append({"type": "image", "image": image}) + except Exception as e: + print(f"Error processing image {img_path}: {e}") + continue + + formatted_samples["messages"].append( + [ + {"role": "system", "content": [{"type": "text", "text": samples["context"][cont]}]}, + {"role": "user", "content": images + [{"type": "text", "text": samples["question"][cont]}]}, + {"role": "assistant", "content": [{"type": "text", "text": samples["output"][cont]}]}, + ] + ) + return formatted_samples + + +# For multi-image example +def prepare_dataset(dataset: DatasetDict, dataset_name: str) -> DatasetDict: + all_files = list_repo_files(dataset_name, repo_type="dataset") + zip_files = [f for f in all_files if f.endswith(".zip")] + + for zip_filename in zip_files: + zip_path = hf_hub_download(repo_id=dataset_name, filename=zip_filename, repo_type="dataset") + extract_folder = zip_filename.replace(".zip", "") + os.makedirs(extract_folder, exist_ok=True) + + with zipfile.ZipFile(zip_path, "r") as zip_ref: + zip_ref.extractall(extract_folder) + + dataset = dataset.map(format_data, batched=True, batch_size=4, num_proc=16) + return dataset + + +def main(): + parser = TrlParser((ScriptArguments, SFTConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + training_args.max_length = None + + ################ + # Model + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForImageTextToText.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + if script_args.dataset_name == "FanqingM/MMIU-Benchmark": + dataset = prepare_dataset(dataset, script_args.dataset_name) + + ################ + # Training + ################ + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/tiny_aya_chat_template.jinja b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/tiny_aya_chat_template.jinja new file mode 100644 index 0000000000000000000000000000000000000000..3c2dbc4bed50e5751e43749237191460df5c090c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/tiny_aya_chat_template.jinja @@ -0,0 +1,66 @@ +{{ bos_token }}{% set ns = namespace(system_prompt=false, expect_user=true) %}{% for message in messages %}{% if message['role']|lower == 'system' %}{% set ns.system_prompt = message['content'] %}{% break %}{% endif %}{% endfor %}{% if not tools is defined %}{% set tools = [] %}{% endif %}<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble +You are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes. + +Your information cutoff date is June 2024. + +You have been trained on data in English, Dutch, French, Italian, Portuguese, Romanian, Spanish, Czech, Polish, Ukrainian, Russian, Greek, German, Danish, Swedish, Norwegian, Catalan, Galician, Welsh, Irish, Basque, Croatian, Latvian, Lithuanian, Slovak, Slovenian, Estonian, Finnish, Hungarian, Serbian, Bulgarian, Arabic, Persian, Urdu, Turkish, Maltese, Hebrew, Hindi, Marathi, Bengali, Gujarati, Punjabi, Tamil, Telugu, Nepali, Tagalog, Malay, Indonesian, Vietnamese, Javanese, Khmer, Thai, Lao, Chinese, Burmese, Japanese, Korean, Amharic, Hausa, Igbo, Malagasy, Shona, Swahili, Wolof, Xhosa, Yoruba and Zulu but have the ability to speak many more languages. + +# Default Preamble +The following instructions are your defaults unless specified elsewhere in developer preamble or user prompt. +- Your name is Aya. +- You are a large language model built by Cohere. +- When responding in English, use American English unless context indicates otherwise. +- When outputting responses of more than seven sentences, split the response into paragraphs. +- Prefer the active voice. +- Use gender-neutral pronouns for unspecified persons. +- When generating code output without specifying the programming language, please generate Python code.{% if ns.system_prompt and ns.system_prompt != "" %} + +# Developer Preamble +The following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions. +{{ ns.system_prompt }}{% endif %}{% if tools is iterable and tools | length > 0 %} + +# Tools +You have access to the following functions: + +{% for tool in tools %}{% if tool.function is defined %}{% set t = tool.function %}{% else %}{% set t = tool %}{% endif %} + +{{ t.name }}{% if t.description is defined %} +{{ t.description | trim }}{% endif %}{% if t.parameters is defined %} +{{ t.parameters | tojson | safe }}{% endif %} +{% endfor %} + + +If you choose to call a function ONLY reply in the following format with NO suffix: + + + + +value_1 + + +This is the value for the second parameter +that can span +multiple lines + + + + + +Reminder: +- Function calls MUST follow the specified format: an inner block must be nested within XML tags +- Required parameters MUST be specified +- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after +- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls +{% endif %}<|END_OF_TURN_TOKEN|>{% for message in messages %}{% set role = message['role']|lower %}{% if role == 'system' and ns.system_prompt and message['content'] == ns.system_prompt %}{% continue %}{% endif %}{% if role == 'user' %}{% if not ns.expect_user %}{{- raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") -}}{% endif %}{% set ns.expect_user = false %}{% elif role == 'assistant' or role == 'chatbot' %}{% if ns.expect_user %}{{- raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") -}}{% endif %}{% set ns.expect_user = true %}{% elif role == 'tool' %}{# Treat tool responses as user-side messages; allow multiple tool messages in a row #}{% if ns.expect_user %}{% set ns.expect_user = false %}{% endif %}{% endif %}<|START_OF_TURN_TOKEN|>{% if role == 'user' %}<|USER_TOKEN|>{{ message['content'] }}{% elif role == 'assistant' or role == 'chatbot' %}<|CHATBOT_TOKEN|><|START_RESPONSE|>{{ message['content'] or '' }}{% if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}{% for tool_call in message.tool_calls %}{% if tool_call.function is defined %}{% set tc = tool_call.function %}{% else %}{% set tc = tool_call %}{% endif %} + + +{% if tc.arguments is mapping %}{% for args_name, args_value in tc.arguments | items %} +{%- set v = args_value if args_value is string else (args_value | tojson | safe) -%}{{ v }} + +{% endfor %}{% elif tc.arguments is defined %} +{{ tc.arguments }} + +{% endif %} +{% endfor %}{% endif %}<|END_RESPONSE|>{% elif role == 'tool' %}<|USER_TOKEN|> +{{ message['content'] or '' }} +{% elif role == 'system' %}<|SYSTEM_TOKEN|>{{ message['content'] }}{% endif %}<|END_OF_TURN_TOKEN|>{% endfor %}{% if add_generation_prompt %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>{% endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/xpo.py b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/xpo.py new file mode 100644 index 0000000000000000000000000000000000000000..7f55bb4db7a2cc684b75f5f39b9accc2e71c6f85 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/examples/scripts/xpo.py @@ -0,0 +1,121 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "trackio", +# "kernels", +# ] +# /// + +""" +Usage: + +python examples/scripts/xpo.py \ + --model_name_or_path trl-lib/pythia-1b-deduped-tldr-sft \ + --reward_model_path trl-lib/pythia-1b-deduped-tldr-rm \ + --dataset_name trl-lib/tldr \ + --learning_rate 5.0e-7 \ + --output_dir pythia-1b-tldr-xpo \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 32 \ + --num_train_epochs 3 \ + --max_new_tokens 64 \ + --warmup_steps 0.1 \ + --missing_eos_penalty 1.0 \ + --push_to_hub +""" + +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_quantization_config, +) +from trl.experimental.xpo import XPOConfig, XPOTrainer + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, XPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + training_args.gradient_checkpointing_kwargs = {"use_reentrant": True} + + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + use_cache=False if training_args.gradient_checkpointing else True, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + ref_model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + + if training_args.reward_model_path is not None: + reward_model = AutoModelForSequenceClassification.from_pretrained( + training_args.reward_model_path, + num_labels=1, + trust_remote_code=model_args.trust_remote_code, + **model_kwargs, + ) + else: + reward_model = None + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, padding_side="left", trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + trainer = XPOTrainer( + model=model, + ref_model=ref_model, + reward_funcs=reward_model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + ) + + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_new_tokens, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/pyproject.toml b/tasks/tasksmith-1c108f674e97/tests/source/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..f8fd2d13b83e62dc84a76f5408eee547e7ca5a20 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/pyproject.toml @@ -0,0 +1,193 @@ +[build-system] +requires = ["setuptools >= 77.0.3"] +build-backend = "setuptools.build_meta" + +[project] +name = "trl" +description = "Train transformer language models with reinforcement learning." +authors = [ + { name = "Leandro von Werra", email = "leandro.vonwerra@gmail.com" } +] +readme = { file = "README.md", content-type = "text/markdown" } +license = "Apache-2.0" +license-files = ["LICENSE"] +keywords = [ + "transformers", "huggingface", "language modeling", "post-training", "rlhf", "sft", "dpo", "grpo" +] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14" +] +requires-python = ">=3.10" +dependencies = [ + "accelerate>=1.4.0", + "datasets>=4.7.0", # Support Json type and on_mixed_types="use_json" + "jinja2", + "packaging>20.0", + "transformers>=4.56.2", +] +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/huggingface/trl" + +[project.scripts] +trl = "trl.cli:main" + +[project.optional-dependencies] +bco = [ + "scikit-learn", + "joblib" +] +deepspeed = [ + "deepspeed>=0.14.4", + "transformers!=5.1.0", # see transformers#43780 +] +kernels = [ + "kernels" +] +liger = [ + "liger-kernel>=0.7.0" +] +peft = [ + "peft>=0.8.0" +] +quality = [ + "pre-commit", + "hf-doc-builder" +] +quantization = [ + "bitsandbytes" +] +scikit = [ + "scikit-learn" +] +test = [ + "pytest-cov", + "pytest-datadir>=1.7.0", # lazy datadirs + "pytest-rerunfailures==15.1", + "pytest-xdist", + "pytest" +] +vllm = [ + "vllm>=0.12.0,<=0.18.0", + "fastapi", + "pydantic", + "aiohttp>=3.13.3", + "requests", + "uvicorn" +] +vlm = [ + "Pillow", + "torchvision", + "num2words==0.5.14" +] +math_verify = [ + "math-verify>=0.5.2", +] +dev = [ + # bco + "scikit-learn", + "joblib", + # deepspeed + "deepspeed>=0.14.4", + # kernels + "kernels", + # liger + "liger-kernel>=0.7.0", + # peft + "peft>=0.8.0", + # quality + "pre-commit", + "hf-doc-builder", + # quantization + "bitsandbytes", + # scikit: included in bco + # test + "pytest-cov", + "pytest-datadir>=1.7.0", # lazy datadirs + "pytest-rerunfailures==15.1", + "pytest-xdist", + "pytest", + # vllm: not included in dev by default due to CUDA error; see GH-4228 + # vlm + "Pillow", + "torchvision", + "num2words==0.5.14", + # for response parsing (required for training with tools) + "jmespath", +] + +[tool.setuptools] +package-dir = {"trl" = "trl"} + +[tool.setuptools.dynamic] +version = { file = "VERSION" } + +[tool.coverage.run] +branch = true + +[tool.ruff] +target-version = "py310" +line-length = 119 +src = ["trl"] + +[tool.ruff.lint] +ignore = [ + "B028", # warning without explicit stacklevel + "C408", # dict() calls (stylistic) + "C901", # function complexity + "E501", +] +extend-select = ["E", "F", "I", "W", "UP", "B", "T", "C"] + +[tool.ruff.lint.per-file-ignores] +# Allow prints in auxiliary scripts +"examples/**.py" = ["T201"] +"scripts/**.py" = ["T201"] +"trl/cli/**.py" = ["T201"] +"trl/skills/cli.py" = ["T201"] +# Ignore import violations in all `__init__.py` files. +"__init__.py" = ["F401"] + +[tool.ruff.lint.isort] +lines-after-imports = 2 +known-first-party = ["trl"] + +[tool.pytest.ini_options] +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "low_priority: marks tests as low priority (deselect with '-m \"not low_priority\"')" +] +norecursedirs = [ + "tests/experimental", +] +filterwarnings = [ + # SWIG deprecations from SWIG-generated C/C++ extensions: sentencepiece + # Upstream issue: https://github.com/google/sentencepiece/issues/1150 + "ignore:builtin type SwigPyPacked has no __module__ attribute:DeprecationWarning", + "ignore:builtin type SwigPyObject has no __module__ attribute:DeprecationWarning", + "ignore:builtin type swigvarlink has no __module__ attribute:DeprecationWarning", + + # PyTorch JIT deprecations (upstream, not actionable in TRL) + # Upstream issue: https://github.com/deepspeedai/DeepSpeed/issues/7835 + # Upstream PR: https://github.com/deepspeedai/DeepSpeed/pull/7840 + # Upstream fix released in deepspeed v0.18.6: https://github.com/deepspeedai/DeepSpeed/releases/tag/v0.18.6 + "ignore:`torch.jit.script_method` is deprecated:DeprecationWarning", + "ignore:`torch.jit.script` is deprecated:DeprecationWarning", + + # PyTorch DataLoader pin_memory device argument deprecations + # Triggered internally by torch.utils.data, not by our code + # Upstream issue: https://github.com/pytorch/pytorch/issues/174546 + "ignore:The argument 'device' of Tensor.pin_memory:DeprecationWarning", + "ignore:The argument 'device' of Tensor.is_pinned:DeprecationWarning", +] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/add_copyrights.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/add_copyrights.py new file mode 100644 index 0000000000000000000000000000000000000000..0a0a3e7deb624d067a679071673517d71d369e8f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/add_copyrights.py @@ -0,0 +1,92 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import subprocess +import sys +from datetime import datetime + + +COPYRIGHT_HEADER = f"""# Copyright 2020-{datetime.now().year} The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + + +def get_tracked_python_files(): + """Get a list of all tracked Python files using git.""" + try: + # Get the list of all tracked files from Git + result = subprocess.run(["git", "ls-files"], stdout=subprocess.PIPE, text=True, check=True) + # Split the result by lines to get individual file paths + files = result.stdout.splitlines() + # Filter only Python files + py_files = [f for f in files if f.endswith(".py")] + return py_files + except subprocess.CalledProcessError as e: + print(f"Error fetching tracked files: {e}") + return [] + + +def check_and_add_copyright(file_path): + """Check if the file contains a copyright notice, and add it if missing.""" + if not os.path.isfile(file_path): + print(f"[SKIP] {file_path} does not exist.") + return + + with open(file_path, encoding="utf-8") as f: + content = f.readlines() + + # Check if the exact copyright header exists + if "".join(content).startswith(COPYRIGHT_HEADER): + return True + + # If no copyright notice was found, prepend the header + print(f"[MODIFY] Adding copyright to {file_path}.") + with open(file_path, "w", encoding="utf-8") as f: + # Write the copyright header followed by the original content + f.write(COPYRIGHT_HEADER + "\n" + "".join(content)) + return False + + +def main(): + """Main function to check and add copyright for all tracked Python files.""" + py_files = get_tracked_python_files() + if not py_files: + print("No Python files are tracked in the repository.") + return + + print(f"Checking {len(py_files)} Python files for copyright notice...") + + have_copyright = [check_and_add_copyright(file_path) for file_path in py_files] + if not all(have_copyright): + print("❌ Some files were missing the required copyright and have been updated.") + sys.exit(1) + else: + print("✅ All files have the required copyright.") + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_harmony_dataset.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_harmony_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..2257be8b7e64de4fe69ebf17ae2f513fed0e5fa0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_harmony_dataset.py @@ -0,0 +1,263 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import Dataset +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + test_size (`float`, *optional*, defaults to `0.1`): + Fraction of the dataset to include in the test split. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-internal-testing/harmony"`): + Hugging Face repository ID to push the dataset to. + """ + + test_size: float = field( + default=0.1, + metadata={"help": "Fraction of the dataset to include in the test split."}, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-internal-testing/harmony", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + + +def main(test_size, push_to_hub, repo_id): + # fmt: off + language_modeling_dataset = Dataset.from_dict({ + "messages": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "thinking": "Beauty improves clarity and appeal.", "content": "Beautiful."}], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "thinking": "Clarity avoids confusion.", "content": "Explicit."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "thinking": "Simplicity is easier to manage.", "content": "Simple."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "thinking": "Complexity has structure; complication doesn’t.", "content": "Complex."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "thinking": "Flat structures are easier to read.", "content": "Flat."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "thinking": "Spacing aids understanding.", "content": "Sparse."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "thinking": "Readable code lasts longer.", "content": "Readability."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "thinking": "Consistency is more valuable.", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "thinking": "Real-world needs outweigh ideals.", "content": "Practicality."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "thinking": "Silent errors cause hidden issues.", "content": "Errors."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "thinking": "Silence must be intentional.", "content": "When explicitly silenced."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "thinking": "Guessing leads to wrong choices.", "content": "Refuse the temptation to guess."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "thinking": "One way reduces confusion.", "content": "One, and preferably only one."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "thinking": "A playful nod to Python’s creator.", "content": "Dutch."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "thinking": "Action is better than endless delay.", "content": "Now is better than never."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "thinking": "Rushed action can be worse.", "content": "Yes, often."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "thinking": "Good ideas should be clear.", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "thinking": "Clarity suggests soundness.", "content": "It means it may be a good idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "thinking": "Namespaces prevent conflicts.", "content": "Namespaces are one honking great idea."}] + ], + "chat_template_kwargs": [ + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + ] + }, on_mixed_types="use_json") + language_modeling_dataset = language_modeling_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + language_modeling_dataset.push_to_hub(repo_id, config_name="language_modeling") + + prompt_completion_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "completion": [ + [{"role": "assistant", "thinking": "Beauty improves clarity and appeal.", "content": "Beautiful."}], + [{"role": "assistant", "thinking": "Clarity avoids confusion.", "content": "Explicit."}], + [{"role": "assistant", "thinking": "Simplicity is easier to manage.", "content": "Simple."}], + [{"role": "assistant", "thinking": "Complexity has structure; complication doesn’t.", "content": "Complex."}], + [{"role": "assistant", "thinking": "Flat structures are easier to read.", "content": "Flat."}], + [{"role": "assistant", "thinking": "Spacing aids understanding.", "content": "Sparse."}], + [{"role": "assistant", "thinking": "Readable code lasts longer.", "content": "Readability."}], + [{"role": "assistant", "thinking": "Consistency is more valuable.", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "assistant", "thinking": "Real-world needs outweigh ideals.", "content": "Practicality."}], + [{"role": "assistant", "thinking": "Silent errors cause hidden issues.", "content": "Errors."}], + [{"role": "assistant", "thinking": "Silence must be intentional.", "content": "When explicitly silenced."}], + [{"role": "assistant", "thinking": "Guessing leads to wrong choices.", "content": "Refuse the temptation to guess."}], + [{"role": "assistant", "thinking": "One way reduces confusion.", "content": "One, and preferably only one."}], + [{"role": "assistant", "thinking": "A playful nod to Python’s creator.", "content": "Dutch."}], + [{"role": "assistant", "thinking": "Action is better than endless delay.", "content": "Now is better than never."}], + [{"role": "assistant", "thinking": "Rushed action can be worse.", "content": "Yes, often."}], + [{"role": "assistant", "thinking": "Good ideas should be clear.", "content": "It means it's a bad idea."}], + [{"role": "assistant", "thinking": "Clarity suggests soundness.", "content": "It means it may be a good idea."}], + [{"role": "assistant", "thinking": "Namespaces prevent conflicts.", "content": "Namespaces are one honking great idea."}], + ], + "chat_template_kwargs": [ + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + ] + }) + prompt_completion_dataset = prompt_completion_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + prompt_completion_dataset.push_to_hub(repo_id, config_name="prompt_completion") + + preference_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "chosen": [ + [{"role": "assistant", "thinking": "Beauty improves clarity and appeal.", "content": "Beautiful."}], + [{"role": "assistant", "thinking": "Clarity avoids confusion.", "content": "Explicit."}], + [{"role": "assistant", "thinking": "Simplicity is easier to manage.", "content": "Simple."}], + [{"role": "assistant", "thinking": "Complexity has structure; complication doesn’t.", "content": "Complex."}], + [{"role": "assistant", "thinking": "Flat structures are easier to read.", "content": "Flat."}], + [{"role": "assistant", "thinking": "Spacing aids understanding.", "content": "Sparse."}], + [{"role": "assistant", "thinking": "Readable code lasts longer.", "content": "Readability."}], + [{"role": "assistant", "thinking": "Consistency is more valuable.", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "assistant", "thinking": "Real-world needs outweigh ideals.", "content": "Practicality."}], + [{"role": "assistant", "thinking": "Silent errors cause hidden issues.", "content": "Errors."}], + [{"role": "assistant", "thinking": "Silence must be intentional.", "content": "When explicitly silenced."}], + [{"role": "assistant", "thinking": "Guessing leads to wrong choices.", "content": "Refuse the temptation to guess."}], + [{"role": "assistant", "thinking": "One way reduces confusion.", "content": "One, and preferably only one."}], + [{"role": "assistant", "thinking": "A playful nod to Python’s creator.", "content": "Dutch."}], + [{"role": "assistant", "thinking": "Action is better than endless delay.", "content": "Now is better than never."}], + [{"role": "assistant", "thinking": "Rushed action can be worse.", "content": "Yes, often."}], + [{"role": "assistant", "thinking": "Good ideas should be clear.", "content": "It means it's a bad idea."}], + [{"role": "assistant", "thinking": "Clarity suggests soundness.", "content": "It means it may be a good idea."}], + [{"role": "assistant", "thinking": "Namespaces prevent conflicts.", "content": "Namespaces are one honking great idea."}], + ], + "rejected": [ + [{"role": "assistant", "thinking": "This comparison is nonsensical.", "content": "Better than the moon."}], + [{"role": "assistant", "thinking": "This dismisses the value of clarity.", "content": "Worse than nothing."}], + [{"role": "assistant", "thinking": "This mixes code style with leisure.", "content": "Better than a long vacation."}], + [{"role": "assistant", "thinking": "This overstates complexity as a universal solution.", "content": "Always the answer."}], + [{"role": "assistant", "thinking": "This swaps a structural concept for a random object.", "content": "Better than chocolate."}], + [{"role": "assistant", "thinking": "This ignores the need for context in sparse designs.", "content": "Without any context."}], + [{"role": "assistant", "thinking": "This implies readability is optional, which it is not.", "content": "Optional."}], + [{"role": "assistant", "thinking": "This exaggerates special cases into fantasy.", "content": "Enough to become unicorns."}], + [{"role": "assistant", "thinking": "This twists the original contrast between practicality and purity.", "content": "Beats reality."}], + [{"role": "assistant", "thinking": "This misapplies \"passing\" to a literal driving test.", "content": "Pass their driving test."}], + [{"role": "assistant", "thinking": "This suggests forgetting rather than intentional silence.", "content": "Forgotten."}], + [{"role": "assistant", "thinking": "This replaces careful judgment with a joke.", "content": "Refuse the opportunity to laugh."}], + [{"role": "assistant", "thinking": "This encourages multiple confusing approaches instead of one clear way.", "content": "Two or more confusing methods."}], + [{"role": "assistant", "thinking": "This turns a simple example into time-travel absurdity.", "content": "A time traveler."}], + [{"role": "assistant", "thinking": "This denies the value of timely action.", "content": "Never better."}], + [{"role": "assistant", "thinking": "This removes the sense of tradeoff and possibility.", "content": "Not even a possibility."}], + [{"role": "assistant", "thinking": "This inverts the meaning of explainability.", "content": "Clearly the best choice."}], + [{"role": "assistant", "thinking": "This treats clarity as something mystical rather than practical.", "content": "Probably magic."}], + [{"role": "assistant", "thinking": "This turns a design principle into a silly metaphor.", "content": "Watermelon -- let's plant some!"}], + ], + "chat_template_kwargs": [ + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "medium", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "high", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + {"reasoning_effort": "low", "model_identity": "You are Tiny ChatGPT, a tiny language model."}, + ], + }) + preference_dataset = preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + preference_dataset.push_to_hub(repo_id, config_name="preference") + # fmt: on + + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + main(script_args.test_size, script_args.push_to_hub, script_args.repo_id) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_tiny_models.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_tiny_models.py new file mode 100644 index 0000000000000000000000000000000000000000..9090fd346af5a9556c7d819ea493769ccf8979f8 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_tiny_models.py @@ -0,0 +1,448 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script generates tiny models used in the TRL library for unit tests. It pushes them to the Hub under the +# `trl-internal-testing` organization. +# This script is meant to be run when adding new tiny model to the TRL library. + +import torch +from huggingface_hub import HfApi, ModelCard +from peft import LoraConfig, get_peft_model +from torch import nn +from transformers import ( + AutoConfig, + AutoProcessor, + AutoTokenizer, + BartModel, + Cohere2Config, + Cohere2ForCausalLM, + CohereConfig, + CohereForCausalLM, + DeepseekV3Config, + DeepseekV3ForCausalLM, + FalconMambaConfig, + FalconMambaForCausalLM, + Gemma2Config, + Gemma2ForCausalLM, + Gemma3ForConditionalGeneration, + Gemma4ForConditionalGeneration, + GemmaConfig, + GemmaForCausalLM, + GenerationConfig, + Glm4MoeConfig, + Glm4MoeForCausalLM, + GPT2Config, + GPT2LMHeadModel, + GPTNeoXConfig, + GPTNeoXForCausalLM, + GPTNeoXForSequenceClassification, + GptOssConfig, + GptOssForCausalLM, + Idefics2Config, + Idefics2ForConditionalGeneration, + Idefics3ForConditionalGeneration, + InternVLForConditionalGeneration, + LlamaConfig, + LlamaForCausalLM, + LlamaForSequenceClassification, + LlavaForConditionalGeneration, + LlavaNextForConditionalGeneration, + MistralConfig, + MistralForCausalLM, + OPTConfig, + OPTForCausalLM, + PaliGemmaForConditionalGeneration, + Phi3Config, + Phi3ForCausalLM, + Qwen2_5_VLConfig, + Qwen2_5_VLForConditionalGeneration, + Qwen2Config, + Qwen2ForCausalLM, + Qwen2ForSequenceClassification, + Qwen2VLConfig, + Qwen2VLForConditionalGeneration, + Qwen3_5Config, + Qwen3_5ForConditionalGeneration, + Qwen3_5MoeConfig, + Qwen3_5MoeForConditionalGeneration, + Qwen3Config, + Qwen3ForCausalLM, + Qwen3ForSequenceClassification, + Qwen3MoeConfig, + Qwen3MoeForCausalLM, + Qwen3MoeForSequenceClassification, + Qwen3VLConfig, + Qwen3VLForConditionalGeneration, + SmolVLMForConditionalGeneration, + T5ForConditionalGeneration, +) + + +ORGANIZATION = "trl-internal-testing" + +MODEL_CARD = """ +--- +library_name: transformers +tags: [trl] +--- + +# Tiny {model_class_name} + +This is a minimal model built for unit tests in the [TRL](https://github.com/huggingface/trl) library. +""" + + +api = HfApi() + + +def push_to_hub(model, tokenizer, generation_config, prefix=None, suffix=None, force=False): + model_class_name = model.__class__.__name__ + content = MODEL_CARD.format(model_class_name=model_class_name) + model_card = ModelCard(content) + if prefix is not None: + model_class_name = f"{prefix}-{model_class_name}" + repo_id = f"{ORGANIZATION}/{model_class_name}" + if suffix is not None: + repo_id += f"-{suffix}" + + if api.repo_exists(repo_id) and not force: + print(f"Model {repo_id} already exists, skipping") + else: + model.push_to_hub(repo_id) + model_card.push_to_hub(repo_id) + if tokenizer is not None: + tokenizer.push_to_hub(repo_id) + if generation_config is not None: + generation_config.push_to_hub(repo_id) + + +def init_weights_tiny_model(model): + """ + Initialize tiny test models to avoid NaNs from uninitialized weights. + + Uses safe defaults: + - Linear/Conv1d: Xavier uniform (weights), zero (biases) + - Embedding: Normal(0, 0.02) + - LayerNorm: Ones (weights), zero (biases) + + Args: + model: PyTorch model (modified in-place) + """ + for module in model.modules(): + if isinstance(module, nn.Linear): + # Attention/MLP projections → Xavier or Normal + if module.bias is not None: + nn.init.zeros_(module.bias) + nn.init.xavier_uniform_(module.weight) + + elif isinstance(module, nn.Embedding): + # Token embeddings → GPT-style Normal + nn.init.normal_(module.weight, mean=0.0, std=0.02) + + elif isinstance(module, nn.LayerNorm): + # LayerNorm weights always 1, bias 0 + nn.init.ones_(module.weight) + if module.bias is not None: + nn.init.zeros_(module.bias) + + elif isinstance(module, nn.Conv1d): + # Convolutional layers → Xavier or Normal + if module.bias is not None: + nn.init.zeros_(module.bias) + nn.init.xavier_uniform_(module.weight) + + +# Decoder models +for model_id, config_class, model_class, dtype, suffix in [ + # ("bigscience/bloomz-560m", BloomConfig, BloomForCausalLM, None), # loading fails with this model, see https://huggingface.co/bigscience/bloomz-560m/discussions/14 + ("CohereLabs/aya-expanse-8b", CohereConfig, CohereForCausalLM, torch.float16, None), + ("CohereLabs/tiny-aya-earth", Cohere2Config, Cohere2ForCausalLM, torch.bfloat16, None), + ("deepseek-ai/DeepSeek-R1", DeepseekV3Config, DeepseekV3ForCausalLM, torch.bfloat16, None), + # It's important to have R1-0528 as it doesn't have the same chat template + ("deepseek-ai/DeepSeek-R1-0528", DeepseekV3Config, DeepseekV3ForCausalLM, torch.bfloat16, "0528"), + ("tiiuae/falcon-7b-instruct", FalconMambaConfig, FalconMambaForCausalLM, torch.bfloat16, None), + ("google/gemma-2-2b-it", Gemma2Config, Gemma2ForCausalLM, torch.bfloat16, None), + ("google/gemma-7b-it", GemmaConfig, GemmaForCausalLM, torch.bfloat16, None), + ("openai-community/gpt2", GPT2Config, GPT2LMHeadModel, torch.float32, None), + ("EleutherAI/pythia-14m", GPTNeoXConfig, GPTNeoXForCausalLM, torch.float16, None), + ("meta-llama/Meta-Llama-3-8B-Instruct", LlamaConfig, LlamaForCausalLM, torch.bfloat16, "3"), + ("meta-llama/Llama-3.1-8B-Instruct", LlamaConfig, LlamaForCausalLM, torch.bfloat16, "3.1"), + ("meta-llama/Llama-3.2-1B-Instruct", LlamaConfig, LlamaForCausalLM, torch.bfloat16, "3.2"), + ("mistralai/Mistral-7B-Instruct-v0.1", MistralConfig, MistralForCausalLM, torch.bfloat16, "0.1"), + ("mistralai/Mistral-7B-Instruct-v0.2", MistralConfig, MistralForCausalLM, torch.bfloat16, "0.2"), + ("facebook/opt-1.3b", OPTConfig, OPTForCausalLM, torch.float16, None), + ("microsoft/Phi-3-mini-4k-instruct", Phi3Config, Phi3ForCausalLM, torch.bfloat16, "3"), + ("microsoft/Phi-3.5-mini-instruct", Phi3Config, Phi3ForCausalLM, torch.bfloat16, "3.5"), + ("Qwen/Qwen2.5-32B-Instruct", Qwen2Config, Qwen2ForCausalLM, torch.bfloat16, "2.5"), + ("Qwen/Qwen2.5-Coder-0.5B", Qwen2Config, Qwen2ForCausalLM, torch.bfloat16, "2.5-Coder"), + ("Qwen/Qwen3-8B", Qwen3Config, Qwen3ForCausalLM, torch.bfloat16, None), +]: + revision = "refs/pr/14" if model_id == "Qwen/Qwen3-8B" else "main" # chat template with {% generation %} + tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision) + generation_config = GenerationConfig.from_pretrained(model_id, revision=revision) + config = config_class( + vocab_size=len(tokenizer.vocab), + hidden_size=8, + num_attention_heads=4, + num_key_value_heads=2, + num_hidden_layers=2, + intermediate_size=32, + ) + model = model_class(config).to(dtype=dtype) + init_weights_tiny_model(model) + push_to_hub(model, tokenizer, generation_config, "tiny", suffix) + +# MoE models +for model_id, config_class, model_class, dtype, suffix in [ + ("Qwen/Qwen3-30B-A3B", Qwen3MoeConfig, Qwen3MoeForCausalLM, torch.bfloat16, None), + ("openai/gpt-oss-20b", GptOssConfig, GptOssForCausalLM, torch.bfloat16, None), + ("zai-org/GLM-4.5", Glm4MoeConfig, Glm4MoeForCausalLM, torch.bfloat16, None), +]: + tokenizer = AutoTokenizer.from_pretrained(model_id) + generation_config = GenerationConfig.from_pretrained(model_id) + kwargs = {} + if model_id == "zai-org/GLM-4.5": + kwargs["n_routed_experts"] = 4 + elif model_id == "Qwen/Qwen3-30B-A3B": + kwargs["num_experts"] = 4 + elif model_id == "openai/gpt-oss-20b": + kwargs["num_local_experts"] = 4 + + config = config_class( + vocab_size=len(tokenizer.vocab), + hidden_size=8, + num_attention_heads=4, + num_key_value_heads=2, + num_hidden_layers=2, + intermediate_size=32, + num_experts_per_tok=2, + **kwargs, + ) + model = model_class(config).to(dtype=dtype) + init_weights_tiny_model(model) + push_to_hub(model, tokenizer, generation_config, "tiny", suffix) + +# Two slightly bigger models, required for vLLM testing +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-32B-Instruct") +generation_config = GenerationConfig.from_pretrained("Qwen/Qwen2.5-32B-Instruct") +config = Qwen2Config( + vocab_size=len(tokenizer.vocab), + hidden_size=128, # increase hidden size so that hidden_size // num_attention_heads = 32, required for vLLM + num_attention_heads=4, + num_key_value_heads=2, + num_hidden_layers=2, + intermediate_size=32, +) +model = Qwen2ForCausalLM(config).to(dtype=torch.bfloat16) +push_to_hub(model, tokenizer, generation_config, "small", "2.5") + +tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-4B") +generation_config = GenerationConfig.from_pretrained("Qwen/Qwen3-4B") +config = Qwen3Config( + vocab_size=len(tokenizer.vocab), + hidden_size=128, # increase hidden size so that hidden_size // num_attention_heads = 32, required for vLLM + num_attention_heads=4, + num_key_value_heads=2, + num_hidden_layers=2, + intermediate_size=32, +) +model = Qwen3ForCausalLM(config).to(dtype=torch.bfloat16) +push_to_hub(model, tokenizer, generation_config, "small") + +# Reward models +for model_id, model_class, dtype, suffix in [ + ("EleutherAI/pythia-14m", GPTNeoXForSequenceClassification, torch.bfloat16, None), + ("meta-llama/Llama-3.2-1B-Instruct", LlamaForSequenceClassification, torch.bfloat16, "3.2"), + ("Qwen/Qwen2.5-32B-Instruct", Qwen2ForSequenceClassification, torch.bfloat16, "2.5"), + ("Qwen/Qwen3-4B", Qwen3ForSequenceClassification, torch.bfloat16, None), +]: + tokenizer = AutoTokenizer.from_pretrained(model_id) + generation_config = GenerationConfig.from_pretrained(model_id) + kwargs = { + "num_labels": 1, + "hidden_size": 16, + "num_attention_heads": 4, + "num_key_value_heads": 2, + "num_hidden_layers": 2, + "intermediate_size": 32, + } + config = AutoConfig.from_pretrained(model_id, **kwargs) + # Bug in transformers: it ignores num_hidden_layers to build layer_types + if model_id in ("Qwen/Qwen2.5-32B-Instruct", "Qwen/Qwen3-4B"): + config.layer_types = config.layer_types[:2] + model = model_class(config).to(dtype=dtype) + init_weights_tiny_model(model) + push_to_hub(model, tokenizer, generation_config, "tiny", suffix) + +# MoE Reward models +for model_id, model_class, dtype, suffix in [ + ("Qwen/Qwen3-30B-A3B", Qwen3MoeForSequenceClassification, torch.bfloat16, None), +]: + tokenizer = AutoTokenizer.from_pretrained(model_id) + generation_config = GenerationConfig.from_pretrained(model_id) + kwargs = { + "num_labels": 1, + "hidden_size": 16, + "num_attention_heads": 4, + "num_key_value_heads": 2, + "num_hidden_layers": 2, + "intermediate_size": 32, + "num_experts": 4, + "num_experts_per_tok": 2, + } + config = AutoConfig.from_pretrained(model_id, **kwargs) + model = model_class(config).to(dtype=dtype) + push_to_hub(model, tokenizer, generation_config, "tiny", suffix) + + +# Encoder-decoder models +for model_id, model_class, dtype, suffix in [ + ("facebook/bart-base", BartModel, torch.float32, None), + ("google/flan-t5-small", T5ForConditionalGeneration, torch.float32, None), +]: + tokenizer = AutoTokenizer.from_pretrained(model_id) + generation_config = GenerationConfig.from_pretrained(model_id) if model_id != "facebook/bart-base" else None + config = AutoConfig.from_pretrained(model_id) + config.d_model = 24 + model = model_class(config).to(dtype=dtype) + push_to_hub(model, tokenizer, generation_config, "tiny", suffix) + + +# Vision Language Models +for model_id, model_class, dtype in [ + ("google/gemma-3-4b-it", Gemma3ForConditionalGeneration, torch.bfloat16), + ("google/gemma-4-E2B-it", Gemma4ForConditionalGeneration, torch.bfloat16), + ("google/paligemma-3b-pt-224", PaliGemmaForConditionalGeneration, torch.float32), + ("HuggingFaceM4/idefics2-8b", Idefics2ForConditionalGeneration, torch.float32), + ("HuggingFaceM4/Idefics3-8B-Llama3", Idefics3ForConditionalGeneration, torch.bfloat16), + ("HuggingFaceTB/SmolVLM2-2.2B-Instruct", SmolVLMForConditionalGeneration, torch.float32), + ("llava-hf/llava-1.5-7b-hf", LlavaForConditionalGeneration, torch.float16), + # Original model dtype is float16, but it triggers CUDA device side assert error (see GH-4741): + ("llava-hf/llava-v1.6-mistral-7b-hf", LlavaNextForConditionalGeneration, torch.bfloat16), + ("OpenGVLab/InternVL3-8B-hf", InternVLForConditionalGeneration, torch.bfloat16), + ("Qwen/Qwen2-VL-2B-Instruct", Qwen2VLForConditionalGeneration, torch.bfloat16), + ("Qwen/Qwen2.5-VL-3B-Instruct", Qwen2_5_VLForConditionalGeneration, torch.bfloat16), + ("Qwen/Qwen3-VL-2B-Instruct", Qwen3VLForConditionalGeneration, torch.bfloat16), + ("Qwen/Qwen3.5-0.8B", Qwen3_5ForConditionalGeneration, torch.bfloat16), + ("Qwen/Qwen3.6-35B-A3B", Qwen3_5MoeForConditionalGeneration, torch.bfloat16), +]: + processor = AutoProcessor.from_pretrained(model_id) + generation_config = GenerationConfig.from_pretrained(model_id) if model_id != "Qwen/Qwen3.5-0.8B" else None + + text_config = { + "num_hidden_layers": 2, + "hidden_size": 16, + "num_attention_heads": 4, + "num_key_value_heads": 2, + "layer_types": None, # Set it automatically from num_hidden_layers + } + vision_config = { + "num_hidden_layers": 2, + "hidden_size": 16, + "num_attention_heads": 4, + "num_key_value_heads": 2, + "embed_dim": 64, + } + kwargs = {} + + if issubclass(model_class.config_class, (Qwen2VLConfig, Qwen2_5_VLConfig)): + text_config["rope_scaling"] = {"type": "default", "mrope_section": [1, 1], "rope_type": "default"} + vision_config["depth"] = 2 + # Different dict object from text_config; see GH-4101 and transformers#41020 + kwargs["rope_scaling"] = {"type": "default", "mrope_section": [1, 1], "rope_type": "default"} + + if issubclass(model_class.config_class, Qwen2_5_VLConfig): + vision_config["out_hidden_size"] = 16 + # Different dict object at the config root; see GH-4101 and transformers#41020 + kwargs["num_hidden_layers"] = 2 + kwargs["hidden_size"] = 16 + kwargs["num_attention_heads"] = 4 + + if issubclass(model_class.config_class, Idefics2Config): + kwargs["perceiver_config"] = {"hidden_size": 16} + + if issubclass(model_class.config_class, Qwen3VLConfig): + # So hasattr(config, "layer_types") is False + # See: https://github.com/huggingface/transformers/blob/fe5ca9ddaa07fac2872407e75c7a7661216ac956/src/transformers/models/qwen3_vl/modeling_qwen3_vl.py#L420 + del text_config["layer_types"] + # "mrope_section" needs 3 elements: for dim, offset in enumerate((1, 2), start=1): mrope_section[dim] + # See: https://github.com/huggingface/transformers/blob/fe5ca9ddaa07fac2872407e75c7a7661216ac956/src/transformers/models/qwen3_vl/modeling_qwen3_vl.py#L361 + text_config["rope_scaling"] = {"mrope_interleaved": True, "mrope_section": [2, 2, 2], "rope_type": "default"} + vision_config["depth"] = 2 + vision_config["out_hidden_size"] = 16 + + if issubclass(model_class.config_class, (Qwen3_5Config, Qwen3_5MoeConfig)): + # For tiny layer counts, default `layer_types` can end up with no full-attention layers (e.g. 2 layers and + # default interval 4), which breaks Qwen3.5 dynamic cache logic. Keep one full-attention layer at the end. + text_config["layer_types"] = ["linear_attention", "full_attention"] + text_config["full_attention_interval"] = 2 + # Qwen3.5-VL vision config expects `depth`/`num_heads`, not `num_hidden_layers`/`num_attention_heads`. + vision_config.pop("num_hidden_layers", None) + vision_config.pop("num_attention_heads", None) + vision_config.pop("num_key_value_heads", None) + vision_config.pop("embed_dim", None) + vision_config["depth"] = 2 + vision_config["num_heads"] = 4 + vision_config["intermediate_size"] = 32 + vision_config["out_hidden_size"] = 16 + + if issubclass(model_class.config_class, Qwen3_5MoeConfig): + text_config["num_experts"] = 4 + text_config["num_experts_per_tok"] = 2 + text_config["moe_intermediate_size"] = 32 + text_config["shared_expert_intermediate_size"] = 32 + + if model_id == "llava-hf/llava-v1.6-mistral-7b-hf": + # Hotfix: llava-hf/llava-v1.6-mistral-7b-hf mistakesly sets text_config.dtype to "bfloat16". + # See https://huggingface.co/llava-hf/llava-v1.6-mistral-7b-hf/discussions/46 + text_config["dtype"] = None + + if model_class is Gemma4ForConditionalGeneration: + # Gemma4 rope validation fails when passing text_config as a dict, so we mutate the config directly. + config = AutoConfig.from_pretrained(model_id) + for k, v in text_config.items(): + setattr(config.text_config, k, v) + for k, v in vision_config.items(): + setattr(config.vision_config, k, v) + config.text_config.layer_types = ["sliding_attention", "full_attention"] + config.text_config.num_kv_shared_layers = 0 + config.text_config.global_head_dim = 8 + config.text_config.hidden_size_per_layer_input = 16 + config.audio_config = None + else: + config = AutoConfig.from_pretrained(model_id, text_config=text_config, vision_config=vision_config, **kwargs) + model = model_class(config).to(dtype=dtype) + + if model_id.startswith("Qwen/Qwen3.5"): + # Qwen3.5 models has some weights in float32, to mirror this in the tiny model we need to convert them to float32 manually. + # Qwen3.6 reuses the Qwen3_5Moe class but stores those weights in bf16, so the cast is not needed there. + for layer in model.model.language_model.layers: + if hasattr(layer, "linear_attn"): # applies to linear attention layers only + layer.linear_attn.A_log.data = layer.linear_attn.A_log.data.float() + layer.linear_attn.norm.weight.data = layer.linear_attn.norm.weight.data.float() + + suffix = "3.6" if model_id == "Qwen/Qwen3.6-35B-A3B" else None + push_to_hub(model, processor, generation_config, "tiny", suffix) + +# PEFT models +model = Qwen3ForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen3ForCausalLM", dtype="auto") +model = get_peft_model(model, LoraConfig()) +generation_config = GenerationConfig.from_pretrained("trl-internal-testing/tiny-Qwen3ForCausalLM") +push_to_hub(model, None, None, "tiny") + +# Same model, but different weights +model = Qwen3ForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen3ForCausalLM", dtype="auto") +model = get_peft_model(model, LoraConfig()) +generation_config = GenerationConfig.from_pretrained("trl-internal-testing/tiny-Qwen3ForCausalLM") +push_to_hub(model, None, None, "tiny", "2") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_toolcall_dataset.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_toolcall_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..84b56b88ab94fd418e6685bc8d3429bca59bcec0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_toolcall_dataset.py @@ -0,0 +1,340 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import Dataset +from transformers import HfArgumentParser +from transformers.utils import get_json_schema + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + test_size (`float`, *optional*, defaults to `0.1`): + Fraction of the dataset to include in the test split. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-internal-testing/zen"`): + Hugging Face repository ID to push the dataset to. + """ + + test_size: float = field( + default=0.1, + metadata={"help": "Fraction of the dataset to include in the test split."}, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-internal-testing/toolcall", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + + +def main(test_size, push_to_hub, repo_id): + # Fictitious functions to simulate tool calls + def start_timer(duration: int) -> int: + """ + Starts a timer for the specified duration in seconds. + + Args: + duration: Duration in seconds to set the timer for. + + Returns: + The duration set for the timer. + """ + return duration + + def get_current_time(location: str) -> str: + """ + Returns the current time in the specified location. + + Args: + location: The location for which to get the current time. + + Returns: + The current time in the specified location. + """ + return "06:22:48" + + def get_air_quality_index(location: str) -> int: + """ + Returns the air quality index for the specified location. + + Args: + location: The location for which to get the air quality index. + + Returns: + The air quality index for the specified location. + """ + return 53 + + def play_music(title: str, artist: str) -> dict: + """ + Plays music by the specified title and artist. + + Args: + title: The title of the music to play. + artist: The artist of the music to play. + + Returns: + A dictionary indicating the status of the music playback. + """ + return {"status": "Playing"} + + def get_weather_forecast(city: str, date: str) -> dict: + """ + Returns the weather forecast for the specified city and date. + + Args: + city: The city for which to get the weather forecast. + date: The date for which to get the weather forecast. + + Returns: + A dictionary containing the temperature and weather condition. + """ + return {"temperature": 22, "condition": "partly cloudy"} + + def control_light(room: str, state: str) -> dict: + """ + Controls the light in the specified room. + + Args: + room: The room where the light should be controlled. + state: The desired state of the light ("on" or "off"). + + Returns: + A dictionary indicating the state of the light. + """ + return {"state": state} + + def create_reminder(time: str, note: str) -> str: + """ + Creates a reminder for the specified time and note. + + Args: + time: The time for the reminder. + note: The note for the reminder. + + Returns: + A confirmation message indicating that the reminder has been set. + """ + return "I'll remind you to call mom at 7 PM." + + def get_wind_conditions(city: str, unit: str) -> tuple[int, str]: + """ + Returns the wind conditions for the specified city. + + Args: + city: The city for which to get the wind conditions. + unit: The unit of measurement for the wind speed (e.g., "mph"). + + Returns: + A tuple containing the wind speed and direction. + """ + return 14, "NW" + + start_timer = get_json_schema(start_timer) + get_current_time = get_json_schema(get_current_time) + get_air_quality_index = get_json_schema(get_air_quality_index) + play_music = get_json_schema(play_music) + get_weather_forecast = get_json_schema(get_weather_forecast) + control_light = get_json_schema(control_light) + create_reminder = get_json_schema(create_reminder) + get_wind_conditions = get_json_schema(get_wind_conditions) + + # fmt: off + language_modeling_dataset = Dataset.from_dict({ + "messages": [ + [ + {"role": "user", "content": "Set a timer for 10 minutes."}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "start_timer", "arguments": {"duration": 600}}}]}, + {"role": "tool", "name": "start_timer", "content": "600"}, + {"role": "assistant", "content": "Timer set for 10 minutes."}, + ], + [ + {"role": "user", "content": "What time is it in Tokyo?"}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_current_time", "arguments": {"location": "Tokyo"}}}]}, + {"role": "tool", "name": "get_current_time", "content": "06:22:48"}, + {"role": "assistant", "content": "The current time in Tokyo is 06:22 AM."}, + ], + [ + {"role": "user", "content": "Is the air clean today in Lisbon?"}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_air_quality_index", "arguments": {"location": "Lisbon, Portugal"}}}]}, + {"role": "tool", "name": "get_air_quality_index", "content": "53"}, + {"role": "assistant", "content": "The air quality is moderate."}, + ], + [ + {"role": "user", "content": "Play some music."}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "play_music", "arguments": {"title": "Take Five", "artist": "Dave Brubeck"}}}]}, + {"role": "tool", "name": "play_music", "content": "{'status': 'Playing'}"}, + {"role": "assistant", "content": "Enjoy the jazz tunes!"}, + ], + [ + {"role": "user", "content": "What's the weather like tomorrow in Berlin?"}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_weather_forecast", "arguments": {"city": "Berlin", "date": "2025-06-16"}}}]}, + {"role": "tool", "name": "get_weather_forecast", "content": "{'temperature': 22, 'condition': 'partly cloudy'}"}, + {"role": "assistant", "content": "Tomorrow in Berlin will be partly cloudy with a high of 22°C."} + ], + [ + {"role": "user", "content": "Turn on the living room lights."}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "control_light", "arguments": {"room": "living room", "state": "on"}}}]}, + {"role": "tool", "name": "control_light", "content": "{'state': 'on'}"}, + {"role": "assistant", "content": "The living room lights are now on."} + ], + [ + {"role": "user", "content": "Remind me to call mom at 7 PM."}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "create_reminder", "arguments": {"time": "19:00", "note": "Call mom"}}}]}, + {"role": "tool", "name": "create_reminder", "content": "Reminder set"}, + {"role": "assistant", "content": "Okay, I'll remind you to call mom at 7 PM."} + ], + [ + {"role": "user", "content": "How strong is the wind in Chicago right now?"}, + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_wind_conditions", "arguments": {"city": "Chicago", "unit": "mph"}}}]}, + {"role": "tool", "name": "get_wind_conditions", "content": "(14, 'NW')"}, + {"role": "assistant", "content": "The wind in Chicago is blowing at 14 mph from the northwest."} + ] + ], + "tools": [ + [start_timer, create_reminder], + [get_current_time], + [get_air_quality_index, get_weather_forecast, get_wind_conditions], + [play_music, control_light], + [get_weather_forecast, get_wind_conditions], + [control_light], + [start_timer, create_reminder], + [get_weather_forecast, get_wind_conditions], + ] + }, on_mixed_types="use_json") + language_modeling_dataset = language_modeling_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + language_modeling_dataset.push_to_hub(repo_id, config_name="language_modeling") + + preference_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "Set a timer for 10 minutes."}], + [{"role": "user", "content": "What time is it in Tokyo?"}], + [{"role": "user", "content": "Is the air clean today in Lisbon?"}], + [{"role": "user", "content": "Play some music."}], + [{"role": "user", "content": "What's the weather like tomorrow in Berlin?"}], + [{"role": "user", "content": "Turn on the living room lights."}], + [{"role": "user", "content": "Remind me to call mom at 7 PM."}], + [{"role": "user", "content": "How strong is the wind in Chicago right now?"}], + ], + "chosen": [ + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "start_timer", "arguments": {"duration": 600}}}]}, + {"role": "tool", "name": "start_timer", "content": "600"}, + {"role": "assistant", "content": "Timer set for 10 minutes."}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_current_time", "arguments": {"location": "Tokyo"}}}]}, + {"role": "tool", "name": "get_current_time", "content": "06:22:48"}, + {"role": "assistant", "content": "The current time in Tokyo is 06:22 AM."}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_air_quality_index", "arguments": {"location": "Lisbon, Portugal"}}}]}, + {"role": "tool", "name": "get_air_quality_index", "content": "53"}, + {"role": "assistant", "content": "The air quality is moderate."}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "play_music", "arguments": {"title": "Take Five", "artist": "Dave Brubeck"}}}]}, + {"role": "tool", "name": "play_music", "content": "{'status': 'Playing'}"}, + {"role": "assistant", "content": "Enjoy the jazz tunes!"}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_weather_forecast", "arguments": {"city": "Berlin", "date": "2025-06-16"}}}]}, + {"role": "tool", "name": "get_weather_forecast", "content": "{'temperature': 22, 'condition': 'partly cloudy'}"}, + {"role": "assistant", "content": "Tomorrow in Berlin will be partly cloudy with a high of 22°C."} + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "control_light", "arguments": {"room": "living room", "state": "on"}}}]}, + {"role": "tool", "name": "control_light", "content": "{'state': 'on'}"}, + {"role": "assistant", "content": "The living room lights are now on."} + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "create_reminder", "arguments": {"time": "19:00", "note": "Call mom"}}}]}, + {"role": "tool", "name": "create_reminder", "content": "Reminder set"}, + {"role": "assistant", "content": "Okay, I’ll remind you to call mom at 7 PM."} + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_wind_conditions", "arguments": {"city": "Chicago", "unit": "mph"}}}]}, + {"role": "tool", "name": "get_wind_conditions", "content": "(14, 'NW')"}, + {"role": "assistant", "content": "The wind in Chicago is blowing at 14 mph from the northwest."} + ], + ], + "rejected": [ + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "start_timer", "arguments": {"duration": 10}}}]}, + {"role": "tool", "name": "start_timer", "content": "10"}, + {"role": "assistant", "content": "Timer set for 10 seconds."}, + ], + [ + {"role": "assistant", "content": "It is 6:22 AM in Tokyo."}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_air_quality_index", "arguments": {"location": "Lisbon"}}}]}, + {"role": "tool", "name": "get_air_quality_index", "content": "53"}, + {"role": "assistant", "content": "The air quality is great."}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "play_music", "arguments": {"title": "Take Five", "artist": "Daft Punk"}}}]}, + {"role": "tool", "name": "play_music", "content": "{'status': 'Playing'}"}, + {"role": "assistant", "content": "Playing your song."}, + ], + [ + {"role": "assistant", "content": "Tomorrow in Berlin will be hot and sunny."}, + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "control_light", "arguments": {"room": "living room", "state": "off"}}}]}, + {"role": "tool", "name": "control_light", "content": "{'state': 'off'}"}, + {"role": "assistant", "content": "The living room lights are now off."} + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "create_reminder", "arguments": {"time": "07:00", "note": "Call mom"}}}]}, + {"role": "tool", "name": "create_reminder", "content": "Reminder set"}, + {"role": "assistant", "content": "Okay, I'll remind you to call mom at 7 AM."} + ], + [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_weather_forecast", "arguments": {"city": "Chicago", "date": "2025-06-16"}}}]}, + {"role": "tool", "name": "get_weather_forecast", "content": "{'temperature': 22, 'condition': 'partly cloudy'}"}, + {"role": "assistant", "content": "Tomorrow in Chicago will be partly cloudy with a high of 22°C."} + ], + ], + "tools": [ + [start_timer], + [get_current_time], + [get_air_quality_index], + [play_music], + [get_weather_forecast], + [control_light], + [create_reminder], + [get_wind_conditions], + ], + }, on_mixed_types="use_json") + preference_dataset = preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + preference_dataset.push_to_hub(repo_id, config_name="preference") + # fmt: on + + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + main(script_args.test_size, script_args.push_to_hub, script_args.repo_id) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_dataset.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..14b78c7f73fdb6f9bc04acc63b3b0f4479b2f3b4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_dataset.py @@ -0,0 +1,660 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from datasets import Dataset +from transformers import HfArgumentParser + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + test_size (`float`, *optional*, defaults to `0.1`): + Fraction of the dataset to include in the test split. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-internal-testing/zen"`): + Hugging Face repository ID to push the dataset to. + """ + + test_size: float = field( + default=0.1, + metadata={"help": "Fraction of the dataset to include in the test split."}, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-internal-testing/zen", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + + +def main(test_size, push_to_hub, repo_id): + # fmt: off + standard_language_modeling_dataset = Dataset.from_dict({ + "text": [ + "Beautiful is better than ugly.", + "Explicit is better than implicit.", + "Simple is better than complex.", + "Complex is better than complicated.", + "Flat is better than nested.", + "Sparse is better than dense.", + "Readability counts.", + "Special cases aren't special enough to break the rules.", + "Although practicality beats purity.", + "Errors should never pass silently.", + "Unless explicitly silenced.", + "In the face of ambiguity, refuse the temptation to guess.", + "There should be one-- and preferably only one --obvious way to do it.", + "Although that way may not be obvious at first unless you're Dutch.", + "Now is better than never.", + "Although never is often better than *right* now.", + "If the implementation is hard to explain, it's a bad idea.", + "If the implementation is easy to explain, it may be a good idea.", + "Namespaces are one honking great idea -- let's do more of those!", + ], + }) + standard_language_modeling_dataset = standard_language_modeling_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_language_modeling_dataset.push_to_hub(repo_id, config_name="standard_language_modeling") + + standard_prompt_only_dataset = Dataset.from_dict({ + "prompt": [ + "Beautiful is better than", + "Explicit is", + "Simple is better", + "Complex", + "Flat is better than", + "Sparse is better", + "Readability", + "Special cases aren't special", + "Although practicality beats", + "Errors should never", + "Unless explicitly", + "In the face of ambiguity, refuse", + "There should be one-- and preferably", + "Although that way may not be obvious at first unless you're", + "Now is", + "Although never is often", + "If the implementation is hard to explain,", + "If the implementation is easy", + "Namespaces are one honking great", + ], + }) + standard_prompt_only_dataset = standard_prompt_only_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_prompt_only_dataset.push_to_hub(repo_id, config_name="standard_prompt_only") + + standard_prompt_completion_dataset = Dataset.from_dict({ + "prompt": [ + "Beautiful is better than", + "Explicit is", + "Simple is better", + "Complex", + "Flat is better than", + "Sparse is better", + "Readability", + "Special cases aren't special", + "Although practicality beats", + "Errors should never", + "Unless explicitly", + "In the face of ambiguity, refuse", + "There should be one-- and preferably", + "Although that way may not be obvious at first unless you're", + "Now is", + "Although never is often", + "If the implementation is hard to explain,", + "If the implementation is easy", + "Namespaces are one honking great", + ], + "completion": [ + " ugly.", + " better than implicit.", + " than complex.", + " is better than complicated.", + " nested.", + " than dense.", + " counts.", + " enough to break the rules.", + " purity.", + " pass silently.", + " silenced.", + " the temptation to guess.", + " only one --obvious way to do it.", + " Dutch.", + " better than never.", + " better than *right* now.", + " it's a bad idea.", + " to explain, it may be a good idea.", + " idea -- let's do more of those!", + ], + }) + standard_prompt_completion_dataset = standard_prompt_completion_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_prompt_completion_dataset.push_to_hub(repo_id, config_name="standard_prompt_completion") + + standard_preference_dataset = Dataset.from_dict({ + "prompt": [ + "Beautiful is better than", + "Explicit is", + "Simple is better", + "Complex", + "Flat is better than", + "Sparse is better", + "Readability", + "Special cases aren't special", + "Although practicality beats", + "Errors should never", + "Unless explicitly", + "In the face of ambiguity, refuse", + "There should be one-- and preferably", + "Although that way may not be obvious at first unless you're", + "Now is", + "Although never is often", + "If the implementation is hard to explain,", + "If the implementation is easy", + "Namespaces are one honking great", + ], + "chosen": [ + " ugly.", + " better than implicit.", + " than complex.", + " is better than complicated.", + " nested.", + " than dense.", + " counts.", + " enough to break the rules.", + " purity.", + " pass silently.", + " silenced.", + " the temptation to guess.", + " only one --obvious way to do it.", + " Dutch.", + " better than never.", + " better than *right* now.", + " it's a bad idea.", + " to explain, it may be a good idea.", + " idea -- let's do more of those!", + ], + "rejected": [ + " the moon.", + " worse than nothing.", + " than a long vacation.", + " is always the answer.", + " chocolate.", + " without any context.", + " is optional.", + " enough to become unicorns.", + " reality.", + " pass their driving test.", + " forgotten.", + " the opportunity to laugh.", + " two or more confusing methods.", + " a time traveler.", + " never better.", + " not even a possibility.", + " it's clearly the best choice.", + " it's probably magic.", + " watermelon -- let's plant some!", + ], + }) + standard_preference_dataset = standard_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_preference_dataset.push_to_hub(repo_id, config_name="standard_preference") + + standard_implicit_prompt_preference_dataset = Dataset.from_dict({ + "chosen": [ + "Beautiful is better than ugly.", + "Explicit is better than implicit.", + "Simple is better than complex.", + "Complex is better than complicated.", + "Flat is better than nested.", + "Sparse is better than dense.", + "Readability counts.", + "Special cases aren't special enough to break the rules.", + "Although practicality beats purity.", + "Errors should never pass silently.", + "Unless explicitly silenced.", + "In the face of ambiguity, refuse the temptation to guess.", + "There should be one-- and preferably only one --obvious way to do it.", + "Although that way may not be obvious at first unless you're Dutch.", + "Now is better than never.", + "Although never is often better than *right* now.", + "If the implementation is hard to explain, it's a bad idea.", + "If the implementation is easy to explain, it may be a good idea.", + "Namespaces are one honking great idea -- let's do more of those!", + ], + "rejected": [ + "Beautiful is better than the moon.", + "Explicit is worse than nothing.", + "Simple is better than a long vacation.", + "Complex is always the answer.", + "Flat is better than chocolate.", + "Sparse is better without any context.", + "Readability is optional.", + "Special cases aren't special enough to become unicorns.", + "Although practicality beats reality.", + "Errors should never pass their driving test.", + "Unless explicitly forgotten.", + "In the face of ambiguity, refuse the opportunity to laugh.", + "There should be one-- and preferably two or more confusing methods.", + "Although that way may not be obvious at first unless you're a time traveler.", + "Now is never better.", + "Although never is often not even a possibility.", + "If the implementation is hard to explain, it's clearly the best choice.", + "If the implementation is easy it's probably magic.", + "Namespaces are one honking great watermelon -- let's plant some!", + ], + }) + standard_implicit_prompt_preference_dataset = standard_implicit_prompt_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_implicit_prompt_preference_dataset.push_to_hub(repo_id, config_name="standard_implicit_prompt_preference") + + standard_unpaired_preference_dataset = Dataset.from_dict({ + "prompt": [ + "Beautiful is better than", + "Explicit is", + "Simple is better", + "Complex", + "Flat is better than", + "Sparse is better", + "Readability", + "Special cases aren't special", + "Although practicality beats", + "Errors should never", + "Unless explicitly", + "In the face of ambiguity, refuse", + "There should be one-- and preferably", + "Although that way may not be obvious at first unless you're", + "Now is", + "Although never is often", + "If the implementation is hard to explain,", + "If the implementation is easy", + "Namespaces are one honking great", + ], + "completion": [ + " ugly.", + " worse than nothing.", + " than a long vacation.", + " is better than complicated.", + " nested.", + " without any context.", + " counts.", + " enough to become unicorns.", + " purity.", + " pass silently.", + " forgotten.", + " the temptation to guess.", + " only one --obvious way to do it.", + " a time traveler.", + " better than never.", + " not even a possibility.", + " it's a bad idea.", + " it's probably magic.", + " watermelon -- let's plant some!", + ], + "label": [True, False, False, True, True, False, True, False, True, True, False, True, True, False, True, False, True, False, False], + }) + standard_unpaired_preference_dataset = standard_unpaired_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_unpaired_preference_dataset.push_to_hub(repo_id, config_name="standard_unpaired_preference") + + standard_stepwise_supervision_dataset = Dataset.from_dict({ + "prompt": [ + "Beautiful is better than", + "Explicit is better than", + "Simple is better than", + "Complex is better than", + "Flat is better than", + "Sparse is better than", + "Readability counts", + "Special cases aren't special enough", + "Although practicality beats", + "Errors should never pass", + "In the face of ambiguity, refuse", + "There should be one-- and preferably only one --", + "Although that way may not be", + "Now is better than", + "Never is often better than", + "If the implementation is hard to explain, it's", + "If the implementation is easy to explain, it", + "Namespaces are one", + "Although practicality sometimes beats purity,", + ], + "completions": [ + [", let me think...", " ugly."], + [", of course,", " implicit.", " because clarity matters."], + ["... let's keep it basic,", " complex."], + [" when needed,", " complicated."], + [" in terms of structure,", " nested."], + ["... especially for readability."], + [" especially when others read it."], + [", unless...", " they follow the rules."], + [" some theoretical elegance,", " purity."], + [" silently,", " unless explicitly silenced."], + [" the temptation to guess."], + [" way to do it,", " but sometimes it's not obvious.", " especially when there's more than one possibility."], + [" clear at first,", " it will eventually emerge."], + [" later."], + [" problematic fixes."], + [" likely because it's too complicated."], + [" might be a good design."], + [" of those great ideas,", " that solve many problems."], + [" the code should still aim for balance."], + ], + "labels": [ + [False, True], + [False, True, False], + [False, True], + [True, True], + [True, False], + [True], + [False], + [True, False], + [False, False], + [False, False], + [True], + [True, True, False], + [True, True], + [False], + [True], [False], + [False], + [True, True], + [False] + ] + }) + standard_stepwise_supervision_dataset = standard_stepwise_supervision_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + standard_stepwise_supervision_dataset.push_to_hub(repo_id, config_name="standard_stepwise_supervision") + + conversational_language_modeling_dataset = Dataset.from_dict({ + "messages": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "content": "Beautiful."},], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "content": "Explicit."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "content": "Simple."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "content": "Complex."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "content": "Flat."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "content": "Sparse."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "content": "Readability."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "content": "Practicality."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "content": "Errors."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "content": "Dutch."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "content": "Now is better than never."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "content": "Yes, often."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + }) + conversational_language_modeling_dataset = conversational_language_modeling_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_language_modeling_dataset.push_to_hub(repo_id, config_name="conversational_language_modeling") + + conversational_prompt_only_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + }) + conversational_prompt_only_dataset = conversational_prompt_only_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_prompt_only_dataset.push_to_hub(repo_id, config_name="conversational_prompt_only") + + conversational_prompt_completion_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "completion": [ + [{"role": "assistant", "content": "Beautiful."}], + [{"role": "assistant", "content": "Explicit."}], + [{"role": "assistant", "content": "Simple."}], + [{"role": "assistant", "content": "Complex."}], + [{"role": "assistant", "content": "Flat."}], + [{"role": "assistant", "content": "Sparse."}], + [{"role": "assistant", "content": "Readability."}], + [{"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "assistant", "content": "Practicality."}], + [{"role": "assistant", "content": "Errors."}], + [{"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "assistant", "content": "Dutch."}], + [{"role": "assistant", "content": "Now is better than never."}], + [{"role": "assistant", "content": "Yes, often."}], + [{"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + }) + conversational_prompt_completion_dataset = conversational_prompt_completion_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_prompt_completion_dataset.push_to_hub(repo_id, config_name="conversational_prompt_completion") + + conversational_preference_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "chosen": [ + [{"role": "assistant", "content": "Beautiful."}], + [{"role": "assistant", "content": "Explicit."}], + [{"role": "assistant", "content": "Simple."}], + [{"role": "assistant", "content": "Complex."}], + [{"role": "assistant", "content": "Flat."}], + [{"role": "assistant", "content": "Sparse."}], + [{"role": "assistant", "content": "Readability."}], + [{"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "assistant", "content": "Practicality."}], + [{"role": "assistant", "content": "Errors."}], + [{"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "assistant", "content": "Dutch."}], + [{"role": "assistant", "content": "Now is better than never."}], + [{"role": "assistant", "content": "Yes, often."}], + [{"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + "rejected": [ + [{"role": "assistant", "content": "Acceptable."}], + [{"role": "assistant", "content": "Explained."}], + [{"role": "assistant", "content": "Very complex."}], + [{"role": "assistant", "content": "Very complicated."}], + [{"role": "assistant", "content": "Circular."}], + [{"role": "assistant", "content": "Heavy."}], + [{"role": "assistant", "content": "Looking complicated."}], + [{"role": "assistant", "content": "Yes, special cases are special enough to break the rules."}], + [{"role": "assistant", "content": "Nothing."}], + [{"role": "assistant", "content": "Warnings."}], + [{"role": "assistant", "content": "Never."}], + [{"role": "assistant", "content": "Give up."}], + [{"role": "assistant", "content": "As many as possible."}], + [{"role": "assistant", "content": "French."}], + [{"role": "assistant", "content": "Some day."}], + [{"role": "assistant", "content": "No, never."}], + [{"role": "assistant", "content": "It means it's a good idea."}], + [{"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "assistant", "content": "Recursion."}], + ], + }) + conversational_preference_dataset = conversational_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_preference_dataset.push_to_hub(repo_id, config_name="conversational_preference") + + conversational_implicit_prompt_preference_dataset = Dataset.from_dict({ + "chosen": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "content": "Beautiful."}], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "content": "Explicit."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "content": "Simple."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "content": "Complex."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "content": "Flat."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "content": "Sparse."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "content": "Readability."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "content": "Practicality."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "content": "Errors."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "content": "Dutch."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "content": "Now is better than never."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "content": "Yes, often."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + "rejected": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "content": "Acceptable."}], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "content": "Explained."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "content": "Very complex."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "content": "Very complicated."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "content": "Circular."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "content": "Heavy."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "content": "Looking complicated."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "content": "Yes, special cases are special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "content": "Nothing."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "content": "Warnings."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "content": "Never."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "content": "Give up."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "content": "As many as possible."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "content": "French."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "content": "Some day."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "content": "No, never."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "content": "It means it's a good idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "content": "Recursion."}], + ], + }) + conversational_implicit_prompt_preference_dataset = conversational_implicit_prompt_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_implicit_prompt_preference_dataset.push_to_hub(repo_id, config_name="conversational_implicit_prompt_preference") + + conversational_unpaired_preference_dataset = Dataset.from_dict({ + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "completion": [ + [{'role': 'assistant', 'content': 'Beautiful.'}], + [{'role': 'assistant', 'content': 'Explicit.'}], + [{'role': 'assistant', 'content': 'Simple.'}], + [{'role': 'assistant', 'content': 'Very complicated.'}], + [{'role': 'assistant', 'content': 'Flat.'}], + [{'role': 'assistant', 'content': 'Sparse.'}], + [{'role': 'assistant', 'content': 'Readability.'}], + [{'role': 'assistant', 'content': 'Yes, special cases are special enough to break the rules.'}], + [{'role': 'assistant', 'content': 'Practicality.'}], + [{'role': 'assistant', 'content': 'Warnings.'}], + [{'role': 'assistant', 'content': 'When explicitly silenced.'}], + [{'role': 'assistant', 'content': 'Give up.'}], + [{'role': 'assistant', 'content': 'One, and preferably only one.'}], + [{'role': 'assistant', 'content': 'French.'}], + [{'role': 'assistant', 'content': 'Some day.'}], + [{'role': 'assistant', 'content': 'Yes, often.'}], + [{'role': 'assistant', 'content': "It means it's a bad idea."}], + [{'role': 'assistant', 'content': 'It means it may be a good idea.'}], + [{'role': 'assistant', 'content': 'Namespaces are one honking great idea.'}], + ], + "label": [True, True, True, False, True, True, True, False, True, False, True, False, True, False, False, True, True, True, True], + }) + conversational_unpaired_preference_dataset = conversational_unpaired_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_unpaired_preference_dataset.push_to_hub(repo_id, config_name="conversational_unpaired_preference") + # fmt: on + + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + main(script_args.test_size, script_args.push_to_hub, script_args.repo_id) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_image_dataset.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_image_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..dff74d2d062d3b9d77db47120364801fdac9fc5e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_image_dataset.py @@ -0,0 +1,346 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +import numpy as np +from datasets import Dataset, Features, Image, Value +from transformers import HfArgumentParser + + +Message = [{"content": Value("string"), "role": Value("string")}] + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + test_size (`float`, *optional*, defaults to `0.1`): + Fraction of the dataset to include in the test split. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-internal-testing/zen-image"`): + Hugging Face repository ID to push the dataset to. + """ + + test_size: float = field( + default=0.1, + metadata={"help": "Fraction of the dataset to include in the test split."}, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-internal-testing/zen-image", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + + +def main(test_size, push_to_hub, repo_id): + # fmt: off + sizes = np.random.randint(32, 64, size=(19, 2)) + data = { + "messages": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "content": "Beautiful."},], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "content": "Explicit."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "content": "Simple."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "content": "Complex."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "content": "Flat."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "content": "Sparse."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "content": "Readability."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "content": "Practicality."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "content": "Errors."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "content": "Dutch."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "content": "Now is better than never."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "content": "Yes, often."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + "image": [np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in sizes], + } + conversational_language_modeling_dataset = Dataset.from_dict(data, features=Features(messages=Message, image=Image())) + conversational_language_modeling_dataset = conversational_language_modeling_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_language_modeling_dataset.push_to_hub(repo_id, config_name="conversational_language_modeling") + + sizes = np.random.randint(32, 64, size=(19, 2)) + data = { + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "image": [np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in sizes], + } + conversational_prompt_only_dataset = Dataset.from_dict(data, features=Features(prompt=Message, image=Image())) + conversational_prompt_only_dataset = conversational_prompt_only_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_prompt_only_dataset.push_to_hub(repo_id, config_name="conversational_prompt_only") + + sizes = np.random.randint(32, 64, size=(19, 2)) + data = { + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "completion": [ + [{"role": "assistant", "content": "Beautiful."}], + [{"role": "assistant", "content": "Explicit."}], + [{"role": "assistant", "content": "Simple."}], + [{"role": "assistant", "content": "Complex."}], + [{"role": "assistant", "content": "Flat."}], + [{"role": "assistant", "content": "Sparse."}], + [{"role": "assistant", "content": "Readability."}], + [{"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "assistant", "content": "Practicality."}], + [{"role": "assistant", "content": "Errors."}], + [{"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "assistant", "content": "Dutch."}], + [{"role": "assistant", "content": "Now is better than never."}], + [{"role": "assistant", "content": "Yes, often."}], + [{"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + "image": [np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in sizes], + } + conversational_prompt_completion_dataset = Dataset.from_dict(data, features=Features(prompt=Message, completion=Message, image=Image())) + conversational_prompt_completion_dataset = conversational_prompt_completion_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_prompt_completion_dataset.push_to_hub(repo_id, config_name="conversational_prompt_completion") + + sizes = np.random.randint(32, 64, size=(19, 2)) + data = { + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "chosen": [ + [{"role": "assistant", "content": "Beautiful."}], + [{"role": "assistant", "content": "Explicit."}], + [{"role": "assistant", "content": "Simple."}], + [{"role": "assistant", "content": "Complex."}], + [{"role": "assistant", "content": "Flat."}], + [{"role": "assistant", "content": "Sparse."}], + [{"role": "assistant", "content": "Readability."}], + [{"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "assistant", "content": "Practicality."}], + [{"role": "assistant", "content": "Errors."}], + [{"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "assistant", "content": "Dutch."}], + [{"role": "assistant", "content": "Now is better than never."}], + [{"role": "assistant", "content": "Yes, often."}], + [{"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + "rejected": [ + [{"role": "assistant", "content": "Acceptable."}], + [{"role": "assistant", "content": "Explained."}], + [{"role": "assistant", "content": "Very complex."}], + [{"role": "assistant", "content": "Very complicated."}], + [{"role": "assistant", "content": "Circular."}], + [{"role": "assistant", "content": "Heavy."}], + [{"role": "assistant", "content": "Looking complicated."}], + [{"role": "assistant", "content": "Yes, special cases are special enough to break the rules."}], + [{"role": "assistant", "content": "Nothing."}], + [{"role": "assistant", "content": "Warnings."}], + [{"role": "assistant", "content": "Never."}], + [{"role": "assistant", "content": "Give up."}], + [{"role": "assistant", "content": "As many as possible."}], + [{"role": "assistant", "content": "French."}], + [{"role": "assistant", "content": "Some day."}], + [{"role": "assistant", "content": "No, never."}], + [{"role": "assistant", "content": "It means it's a good idea."}], + [{"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "assistant", "content": "Recursion."}], + ], + "image": [np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in sizes], + } + conversational_preference_dataset = Dataset.from_dict(data, features=Features(prompt=Message, chosen=Message, rejected=Message, image=Image())) + conversational_preference_dataset = conversational_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_preference_dataset.push_to_hub(repo_id, config_name="conversational_preference") + + sizes = np.random.randint(32, 64, size=(19, 2)) + data = { + "chosen": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "content": "Beautiful."}], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "content": "Explicit."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "content": "Simple."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "content": "Complex."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "content": "Flat."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "content": "Sparse."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "content": "Readability."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "content": "No, special cases aren't special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "content": "Practicality."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "content": "Errors."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "content": "When explicitly silenced."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "content": "Refuse the temptation to guess."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "content": "One, and preferably only one."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "content": "Dutch."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "content": "Now is better than never."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "content": "Yes, often."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "content": "It means it may be a good idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "content": "Namespaces are one honking great idea."}], + ], + "rejected": [ + [{"role": "user", "content": "What is better than ugly?"}, {"role": "assistant", "content": "Acceptable."}], + [{"role": "user", "content": "What is better than implicit?"}, {"role": "assistant", "content": "Explained."}], + [{"role": "user", "content": "What is better than complex?"}, {"role": "assistant", "content": "Very complex."}], + [{"role": "user", "content": "What is better than complicated?"}, {"role": "assistant", "content": "Very complicated."}], + [{"role": "user", "content": "What is better than nested?"}, {"role": "assistant", "content": "Circular."}], + [{"role": "user", "content": "What is better than dense?"}, {"role": "assistant", "content": "Heavy."}], + [{"role": "user", "content": "What counts?"}, {"role": "assistant", "content": "Looking complicated."}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}, {"role": "assistant", "content": "Yes, special cases are special enough to break the rules."}], + [{"role": "user", "content": "What beats purity?"}, {"role": "assistant", "content": "Nothing."}], + [{"role": "user", "content": "What should never pass silently?"}, {"role": "assistant", "content": "Warnings."}], + [{"role": "user", "content": "When can errors pass silently?"}, {"role": "assistant", "content": "Never."}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}, {"role": "assistant", "content": "Give up."}], + [{"role": "user", "content": "How many ways should there be to do it?"}, {"role": "assistant", "content": "As many as possible."}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}, {"role": "assistant", "content": "French."}], + [{"role": "user", "content": "What is better than never?"}, {"role": "assistant", "content": "Some day."}], + [{"role": "user", "content": "Is never better than *right* now?"}, {"role": "assistant", "content": "No, never."}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}, {"role": "assistant", "content": "It means it's a good idea."}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}, {"role": "assistant", "content": "It means it's a bad idea."}], + [{"role": "user", "content": "Any great ideas?"}, {"role": "assistant", "content": "Recursion."}], + ], + "image": [np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in sizes], + } + conversational_implicit_prompt_preference_dataset = Dataset.from_dict(data, features=Features(chosen=Message, rejected=Message, image=Image())) + conversational_implicit_prompt_preference_dataset = conversational_implicit_prompt_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_implicit_prompt_preference_dataset.push_to_hub(repo_id, config_name="conversational_implicit_prompt_preference") + + sizes = np.random.randint(32, 64, size=(19, 2)) + data = { + "prompt": [ + [{"role": "user", "content": "What is better than ugly?"}], + [{"role": "user", "content": "What is better than implicit?"}], + [{"role": "user", "content": "What is better than complex?"}], + [{"role": "user", "content": "What is better than complicated?"}], + [{"role": "user", "content": "What is better than nested?"}], + [{"role": "user", "content": "What is better than dense?"}], + [{"role": "user", "content": "What counts?"}], + [{"role": "user", "content": "Are special cases enough to break the rules?"}], + [{"role": "user", "content": "What beats purity?"}], + [{"role": "user", "content": "What should never pass silently?"}], + [{"role": "user", "content": "When can errors pass silently?"}], + [{"role": "user", "content": "What should you do in the face of ambiguity?"}], + [{"role": "user", "content": "How many ways should there be to do it?"}], + [{"role": "user", "content": "For whom may the way not be obvious at first?"}], + [{"role": "user", "content": "What is better than never?"}], + [{"role": "user", "content": "Is never better than *right* now?"}], + [{"role": "user", "content": "What does it mean if the implementation is hard to explain?"}], + [{"role": "user", "content": "What does it mean if the implementation is easy to explain?"}], + [{"role": "user", "content": "Any great ideas?"}], + ], + "completion": [ + [{'role': 'assistant', 'content': 'Beautiful.'}], + [{'role': 'assistant', 'content': 'Explicit.'}], + [{'role': 'assistant', 'content': 'Simple.'}], + [{'role': 'assistant', 'content': 'Very complicated.'}], + [{'role': 'assistant', 'content': 'Flat.'}], + [{'role': 'assistant', 'content': 'Sparse.'}], + [{'role': 'assistant', 'content': 'Readability.'}], + [{'role': 'assistant', 'content': 'Yes, special cases are special enough to break the rules.'}], + [{'role': 'assistant', 'content': 'Practicality.'}], + [{'role': 'assistant', 'content': 'Warnings.'}], + [{'role': 'assistant', 'content': 'When explicitly silenced.'}], + [{'role': 'assistant', 'content': 'Give up.'}], + [{'role': 'assistant', 'content': 'One, and preferably only one.'}], + [{'role': 'assistant', 'content': 'French.'}], + [{'role': 'assistant', 'content': 'Some day.'}], + [{'role': 'assistant', 'content': 'Yes, often.'}], + [{'role': 'assistant', 'content': "It means it's a bad idea."}], + [{'role': 'assistant', 'content': 'It means it may be a good idea.'}], + [{'role': 'assistant', 'content': 'Namespaces are one honking great idea.'}], + ], + "label": [True, True, True, False, True, True, True, False, True, False, True, False, True, False, False, True, True, True, True], + "image": [np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in sizes], + } + conversational_unpaired_preference_dataset = Dataset.from_dict(data, features=Features(prompt=Message, completion=Message, label=Value("bool"), image=Image())) + conversational_unpaired_preference_dataset = conversational_unpaired_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_unpaired_preference_dataset.push_to_hub(repo_id, config_name="conversational_unpaired_preference") + # fmt: on + + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + main(script_args.test_size, script_args.push_to_hub, script_args.repo_id) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_multi_image_dataset.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_multi_image_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..bb7089386eab6aefc51e27d24d306c1529612a62 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/generate_zen_multi_image_dataset.py @@ -0,0 +1,243 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +import numpy as np +from datasets import Dataset, Features, Image, List, Value +from transformers import HfArgumentParser + + +Message = List({"content": List({"text": Value("string"), "type": Value("string")}), "role": Value("string")}) + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + test_size (`float`, *optional*, defaults to `0.1`): + Fraction of the dataset to include in the test split. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the dataset to the Hugging Face Hub. + repo_id (`str`, *optional*, defaults to `"trl-internal-testing/zen-multi-image"`): + Hugging Face repository ID to push the dataset to. + """ + + test_size: float = field( + default=0.1, + metadata={"help": "Fraction of the dataset to include in the test split."}, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the dataset to the Hugging Face Hub."}, + ) + repo_id: str = field( + default="trl-internal-testing/zen-multi-image", + metadata={"help": "Hugging Face repository ID to push the dataset to."}, + ) + + +def main(test_size, push_to_hub, repo_id): + # fmt: off + messages = [ + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than ugly?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Beautiful."}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than implicit?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Explicit."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than complex?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Simple."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What is better than complicated?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Complex."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than nested?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Flat."}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than dense?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Sparse."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What counts?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Readability."}]}], + [{"role": "user", "content": [{"type": "text", "text": "Are special cases enough to break the rules?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "No, special cases aren't special enough to break the rules."}]}], + [{"role": "user", "content": [{"type": "text", "text": "What beats purity?"}, {"type": "image"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Practicality."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What should never pass silently?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Errors."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "When can errors pass silently?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "When explicitly silenced."}]}], + [{"role": "user", "content": [{"type": "text", "text": "What should you do in the face of ambiguity?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Refuse the temptation to guess."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "How many ways should there be to do it?"}, {"type": "image"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "One, and preferably only one."}]}], + [{"role": "user", "content": [{"type": "text", "text": "For whom may the way not be obvious at first?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Dutch."}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than never?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Now is better than never."}]}], + [{"role": "user", "content": [{"type": "text", "text": "Is"}, {"type": "image"}, {"type": "text", "text": " never better than *right* now?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Yes, often."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What does it mean if the implementation is hard to explain?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "It means it's a bad idea."}]}], + [{"role": "user", "content": [{"type": "text", "text": "What does it mean if the implementation is easy to explain?"}, {"type": "image"}]}, {"role": "assistant", "content": [{"type": "text", "text": "It means it may be a good idea."}]}], + [{"role": "user", "content": [{"type": "text", "text": "Any great ideas?"}]}, {"role": "assistant", "content": [{"type": "text", "text": "Namespaces are one honking great idea."}]}], + ] + # Create the images + number_of_images = [sum(1 for part in row[0]["content"] if part.get("type") == "image") for row in messages] + sizes = [np.random.randint(32, 64, size=(num_images, 2)) for num_images in number_of_images] + images = [[np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in s] for s in sizes] + conversational_language_modeling_dataset = Dataset.from_dict({"messages": messages, "images": images}, features=Features(messages=Message, images=List(Image()))) + conversational_language_modeling_dataset = conversational_language_modeling_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_language_modeling_dataset.push_to_hub(repo_id, config_name="conversational_language_modeling") + + prompt = [ + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than ugly?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than implicit?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than complex?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What is better than complicated?"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than nested?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than dense?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What counts?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Are special cases enough to break the rules?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What beats purity?"}, {"type": "image"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What should never pass silently?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "When can errors pass silently?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What should you do in the face of ambiguity?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "How many ways should there be to do it?"}, {"type": "image"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "For whom may the way not be obvious at first?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than never?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Is"}, {"type": "image"}, {"type": "text", "text": " never better than *right* now?"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What does it mean if the implementation is hard to explain?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What does it mean if the implementation is easy to explain?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Any great ideas?"}]}], + ] + # Create the images + number_of_images = [sum(1 for part in row[0]["content"] if part.get("type") == "image") for row in prompt] + sizes = [np.random.randint(32, 64, size=(num_images, 2)) for num_images in number_of_images] + images = [[np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in s] for s in sizes] + conversational_prompt_only_dataset = Dataset.from_dict({"prompt": prompt, "images": images}, features=Features(prompt=Message, images=List(Image()))) + conversational_prompt_only_dataset = conversational_prompt_only_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_prompt_only_dataset.push_to_hub(repo_id, config_name="conversational_prompt_only") + + prompt = [ + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than ugly?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than implicit?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than complex?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What is better than complicated?"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than nested?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than dense?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What counts?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Are special cases enough to break the rules?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What beats purity?"}, {"type": "image"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What should never pass silently?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "When can errors pass silently?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What should you do in the face of ambiguity?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "How many ways should there be to do it?"}, {"type": "image"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "For whom may the way not be obvious at first?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than never?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Is"}, {"type": "image"}, {"type": "text", "text": " never better than *right* now?"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What does it mean if the implementation is hard to explain?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What does it mean if the implementation is easy to explain?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Any great ideas?"}]}], + ] + completion = [ + [{"role": "assistant", "content": [{"type": "text", "text": "Beautiful."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Explicit."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Simple."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Complex."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Flat."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Sparse."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Readability."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "No, special cases aren't special enough to break the rules."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Practicality."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Errors."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "When explicitly silenced."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Refuse the temptation to guess."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "One, and preferably only one."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Dutch."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Now is better than never."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Yes, often."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "It means it's a bad idea."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "It means it may be a good idea."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Namespaces are one honking great idea."}]}], + ] + # Create the images + number_of_images = [sum(1 for part in row[0]["content"] if part.get("type") == "image") for row in prompt] + sizes = [np.random.randint(32, 64, size=(num_images, 2)) for num_images in number_of_images] + images = [[np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in s] for s in sizes] + conversational_prompt_completion_dataset = Dataset.from_dict({"prompt": prompt, "completion": completion, "images": images}, features=Features(prompt=Message, completion=Message, images=List(Image()))) + conversational_prompt_completion_dataset = conversational_prompt_completion_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_prompt_completion_dataset.push_to_hub(repo_id, config_name="conversational_prompt_completion") + + prompt = [ + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than ugly?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than implicit?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than complex?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What is better than complicated?"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What is better than nested?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than dense?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What counts?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Are special cases enough to break the rules?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What beats purity?"}, {"type": "image"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "image"}, {"type": "text", "text": "What should never pass silently?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "When can errors pass silently?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What should you do in the face of ambiguity?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "How many ways should there be to do it?"}, {"type": "image"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "For whom may the way not be obvious at first?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What is better than never?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Is"}, {"type": "image"}, {"type": "text", "text": " never better than *right* now?"}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What does it mean if the implementation is hard to explain?"}]}], + [{"role": "user", "content": [{"type": "text", "text": "What does it mean if the implementation is easy to explain?"}, {"type": "image"}]}], + [{"role": "user", "content": [{"type": "text", "text": "Any great ideas?"}]}], + ] + chosen = [ + [{"role": "assistant", "content": [{"type": "text", "text": "Beautiful."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Explicit."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Simple."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Complex."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Flat."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Sparse."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Readability."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "No, special cases aren't special enough to break the rules."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Practicality."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Errors."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "When explicitly silenced."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Refuse the temptation to guess."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "One, and preferably only one."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Dutch."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Now is better than never."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Yes, often."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "It means it's a bad idea."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "It means it may be a good idea."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Namespaces are one honking great idea."}]}], + ] + rejected = [ + [{"role": "assistant", "content": [{"type": "text", "text": "Acceptable."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Explained."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Very complex."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Very complicated."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Circular."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Heavy."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Looking complicated."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Yes, special cases are special enough to break the rules."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Nothing."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Warnings."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Never."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Give up."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "As many as possible."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "French."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Some day."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "No, never."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "It means it's a good idea."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "It means it's a bad idea."}]}], + [{"role": "assistant", "content": [{"type": "text", "text": "Recursion."}]}], + ] + # Create the images + number_of_images = [sum(1 for part in row[0]["content"] if part.get("type") == "image") for row in prompt] + sizes = [np.random.randint(32, 64, size=(num_images, 2)) for num_images in number_of_images] + images = [[np.random.uniform(low=0.0, high=255.0, size=(h, w, 3)).astype(np.uint8) for h, w in s] for s in sizes] + conversational_preference_dataset = Dataset.from_dict({"prompt": prompt, "chosen": chosen, "rejected": rejected, "images": images}, features=Features(prompt=Message, chosen=Message, rejected=Message, images=List(Image()))) + conversational_preference_dataset = conversational_preference_dataset.train_test_split(test_size=test_size, shuffle=False) + if push_to_hub: + conversational_preference_dataset.push_to_hub(repo_id, config_name="conversational_preference") + # fmt: on + + +if __name__ == "__main__": + parser = HfArgumentParser(ScriptArguments) + script_args = parser.parse_args_into_dataclasses()[0] + main(script_args.test_size, script_args.push_to_hub, script_args.repo_id) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/scripts/log_reports.py b/tasks/tasksmith-1c108f674e97/tests/source/scripts/log_reports.py new file mode 100644 index 0000000000000000000000000000000000000000..a3f2a88f0cdef53f45cf016951a576e230a1a9cd --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/scripts/log_reports.py @@ -0,0 +1,169 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import json +import logging +import os +from datetime import date +from pathlib import Path + +from tabulate import tabulate + + +MAX_LEN_MESSAGE = 2900 # Slack endpoint has a limit of 3001 characters + +parser = argparse.ArgumentParser() +parser.add_argument("--slack_channel_name", default="trl-push-ci") + +# Set up logging +logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") + + +def process_log_file(log): + failed_tests = [] + passed_tests = [] + section_num_failed = 0 + + try: + with open(log) as f: + for line in f: + try: + data = json.loads(line) + test_name = data.get("nodeid", "") + duration = f"{data['duration']:.4f}" if "duration" in data else "N/A" + outcome = data.get("outcome", "") + + if test_name: + if outcome == "failed": + section_num_failed += 1 + failed_tests.append([test_name, duration, log.stem.split("_")[0]]) + else: + passed_tests.append([test_name, duration, log.stem.split("_")[0]]) + except json.JSONDecodeError as e: + logging.warning(f"Could not decode line in {log}: {e}") + + except FileNotFoundError as e: + logging.error(f"Log file {log} not found: {e}") + except Exception as e: + logging.error(f"Error processing log file {log}: {e}") + + return failed_tests, passed_tests, section_num_failed + + +def main(slack_channel_name): + group_info = [] + total_num_failed = 0 + total_empty_files = [] + + log_files = list(Path().glob("*.log")) + if not log_files: + logging.info("No log files found.") + return + + for log in log_files: + failed, passed, section_num_failed = process_log_file(log) + empty_file = not failed and not passed + + total_num_failed += section_num_failed + total_empty_files.append(empty_file) + group_info.append([str(log), section_num_failed, failed]) + + # Clean up log file + try: + os.remove(log) + except OSError as e: + logging.warning(f"Could not remove log file {log}: {e}") + + # Prepare Slack message payload + payload = [ + { + "type": "header", + "text": {"type": "plain_text", "text": f"🤗 Results of the {os.environ.get('TEST_TYPE', '')} TRL tests."}, + }, + ] + + if total_num_failed > 0: + message = "" + for name, num_failed, failed_tests in group_info: + if num_failed > 0: + message += f"*{name}: {num_failed} failed test(s)*\n" + failed_table = [ + test[0].split("::")[:2] + [test[0].split("::")[-1][:30] + ".."] for test in failed_tests + ] + message += ( + "\n```\n" + + tabulate(failed_table, headers=["Test Location", "Test Name"], tablefmt="grid") + + "\n```\n" + ) + + if any(total_empty_files): + message += f"\n*{name}: Warning! Empty file - check GitHub action job*\n" + + # Logging + logging.info(f"Total failed tests: {total_num_failed}") + print(f"### {message}") + + if len(message) > MAX_LEN_MESSAGE: + message = ( + f"❌ There are {total_num_failed} failed tests in total! Please check the action results directly." + ) + + payload.append({"type": "section", "text": {"type": "mrkdwn", "text": message}}) + payload.append( + { + "type": "section", + "text": {"type": "mrkdwn", "text": "*For more details:*"}, + "accessory": { + "type": "button", + "text": {"type": "plain_text", "text": "Check Action results"}, + "url": f"https://github.com/huggingface/trl/actions/runs/{os.environ['GITHUB_RUN_ID']}", + }, + } + ) + payload.append( + { + "type": "context", + "elements": [ + { + "type": "plain_text", + "text": f"On Push main {os.environ.get('TEST_TYPE')} results for {date.today()}", + } + ], + } + ) + + # Send to Slack + from slack_sdk import WebClient + + slack_client = WebClient(token=os.environ.get("SLACK_API_TOKEN")) + slack_client.chat_postMessage(channel=f"#{slack_channel_name}", text=message, blocks=payload) + + else: + payload.append( + { + "type": "section", + "text": { + "type": "plain_text", + "text": "✅ No failures! All tests passed successfully.", + "emoji": True, + }, + } + ) + logging.info("All tests passed. No errors detected.") + + +if __name__ == "__main__": + args = parser.parse_args() + main(args.slack_channel_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d2777dd0eb21a0ea67dce8775337a27ea8499da2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/conftest.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..f071b789ffd082ed66087339c67ac7e6fab50700 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/conftest.py @@ -0,0 +1,89 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +from functools import wraps + +import pytest +import torch + + +# ============================================================================ +# Model Revision Override +# ============================================================================ +# To test a tiny model PR before merging to main: +# 1. Add the full model_id and PR revision to this dict +# 2. Commit and push to trigger CI +# 3. Once CI is green, merge the tiny model PR on HF Hub +# 4. Remove the entry from this dict and commit +# +# Example: +# MODEL_REVISIONS = { +# "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5": "refs/pr/3", +# "trl-internal-testing/tiny-LlavaForConditionalGeneration": "refs/pr/5", +# } +# ============================================================================ + +MODEL_REVISIONS = { + # Add model_id: revision mappings here to test PRs +} + + +@pytest.fixture(autouse=True) +def apply_model_revisions(monkeypatch): + """Auto-inject revision parameter for models defined in MODEL_REVISIONS.""" + if not MODEL_REVISIONS: + return + + from transformers import PreTrainedModel, PreTrainedTokenizerBase, ProcessorMixin + + def create_classmethod_wrapper(original_classmethod): + # Extract the underlying function from the classmethod + original_func = original_classmethod.__func__ + + @wraps(original_func) + def wrapper(cls, pretrained_model_name_or_path, *args, **kwargs): + # Direct lookup: only inject if model_id is in the override dict + if pretrained_model_name_or_path in MODEL_REVISIONS: + if "revision" not in kwargs: + kwargs["revision"] = MODEL_REVISIONS[pretrained_model_name_or_path] + + return original_func(cls, pretrained_model_name_or_path, *args, **kwargs) + + # Re-wrap as classmethod + return classmethod(wrapper) + + # Patch all transformers Auto* classes + for cls in [ + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + ]: + monkeypatch.setattr(cls, "from_pretrained", create_classmethod_wrapper(cls.from_pretrained)) + + +@pytest.fixture(autouse=True) +def cleanup_gpu(): + """ + Automatically cleanup GPU memory after each test. + + This fixture helps prevent CUDA out of memory errors when running tests in parallel with pytest-xdist by ensuring + models and tensors are properly garbage collected and GPU memory caches are cleared between tests. + """ + yield + # Cleanup after test + gc.collect() + if torch.cuda.is_available(): + torch.cuda.empty_cache() + torch.cuda.synchronize() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/data/template.jinja b/tasks/tasksmith-1c108f674e97/tests/source/tests/data/template.jinja new file mode 100644 index 0000000000000000000000000000000000000000..01be9b307daa2d425f7c168c9fb145a286e0afb4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/data/template.jinja @@ -0,0 +1,89 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].role == 'system' %} + {{- messages[0].content + '\n\n' }} + {%- endif %} + {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('') and message.content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} +{%- endfor %} +{%- for message in messages %} + {%- if message.content is string %} + {%- set content = message.content %} + {%- else %} + {%- set content = '' %} + {%- endif %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- if loop.index0 > ns.last_query_index %} + {%- if loop.last or (not loop.last and reasoning_content) %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if (loop.first and content) or (not loop.first) %} + {{- '\n' }} + {%- endif %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {%- if tool_call.arguments is string %} + {{- tool_call.arguments }} + {%- else %} + {{- tool_call.arguments | tojson }} + {%- endif %} + {{- '}\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3d26f4482fe3969b6de2b51bd1f85fc16dad6a65 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/ddp.yaml b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/ddp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d5363d79686c57ac0e2b1a1e6f3f53a3b1eec102 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/ddp.yaml @@ -0,0 +1,2 @@ +distributed_type: MULTI_GPU +num_processes: 2 \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/fsdp2.yaml b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/fsdp2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..274141f25833636ba2781193232d9c13d7d846c1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/fsdp2.yaml @@ -0,0 +1,4 @@ +distributed_type: FSDP +fsdp_config: + fsdp_version: 2 +num_processes: 2 \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/zero2.yaml b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/zero2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2c51f5754cb3a51a96b9a94bc3f95ab69418ead0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/zero2.yaml @@ -0,0 +1,4 @@ +distributed_type: DEEPSPEED +deepspeed_config: + zero_stage: 2 +num_processes: 2 \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/zero3.yaml b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/zero3.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6ca9200eadb557b626d238c49f0dc153a54f1709 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/data/accelerate_configs/zero3.yaml @@ -0,0 +1,4 @@ +distributed_type: DEEPSPEED +deepspeed_config: + zero_stage: 3 +num_processes: 2 \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/test_distributed.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/test_distributed.py new file mode 100644 index 0000000000000000000000000000000000000000..37501c60b644c483505834c5eb19bd2784296d6f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/distributed/test_distributed.py @@ -0,0 +1,303 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import subprocess +from pathlib import Path + +import pytest +import torch +import transformers +from packaging.version import Version + +from ..testing_utils import TrlTestCase, require_torch_multi_accelerator + + +ROOT = Path(__file__).resolve().parents[2] + + +def run_command(command: list[str], env: dict[str, str]) -> None: + result = subprocess.run(command, env=env, cwd=ROOT) + assert result.returncode == 0 + + +@pytest.fixture +def get_config_path(lazy_shared_datadir): + def _get_config_path(config_name): + return lazy_shared_datadir / "accelerate_configs" / f"{config_name}.yaml" + + return _get_config_path + + +@require_torch_multi_accelerator +class TestDistributed(TrlTestCase): + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + "fsdp2", + ], + ) + def test_sft(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/sft.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "standard_language_modeling", + ], + os.environ.copy(), + ) + # fmt: on + + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + "fsdp2", + ], + ) + def test_dpo(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/dpo.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "standard_preference", + ], + os.environ.copy(), + ) + # fmt: on + + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + "fsdp2", + ], + ) + def test_sft_dataset_streaming(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/sft.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "standard_language_modeling", + "--dataset_streaming", + "--max_steps", "3", + ], + os.environ.copy(), + ) + # fmt: on + + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + condition=Version("2.10") <= Version(torch.__version__) + and Version(transformers.__version__) < Version("5.1.0"), + reason="ZeRO 2 + PEFT was failing before transformers 5.1.0 on torch 2.10; see #4884", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + condition=Version("2.10") <= Version(torch.__version__) + and Version(transformers.__version__) < Version("5.1.0"), + reason="ZeRO 3 + PEFT was failing before transformers 5.1.0 on torch 2.10; see #4884", + ), + ), + "fsdp2", + ], + ) + def test_sft_peft(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/sft.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "standard_language_modeling", + "--use_peft", + ], + os.environ.copy(), + ) + # fmt: on + + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + "fsdp2", + ], + ) + def test_reward(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/reward.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "conversational_implicit_prompt_preference", + ], + os.environ.copy(), + ) + # fmt: on + + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + Version("5.0.0") <= Version(transformers.__version__) < Version("5.5.4"), + reason="ZeRO-3 fails with transformers >= 5.0.0 and < 5.5.4 (fixed in transformers#45414), see #4899", + strict=True, + ), + ), + pytest.param( + "fsdp2", + marks=pytest.mark.skipif( + Version("5.4.0") <= Version(transformers.__version__) < Version("5.6.0"), + reason="Upstream issue: NaN weights on non-rank-0 FSDP processes (see #5386 and transformers#45050)", + ), + ), + ], + ) + def test_rloo(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/rloo.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "conversational_prompt_only", + "--reward_model_name_or_path", "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + ], + os.environ.copy(), + ) + # fmt: on + + @pytest.mark.parametrize( + "config", + [ + "ddp", + pytest.param( + "zero2", + marks=pytest.mark.xfail( + Version(transformers.__version__) == Version("5.1.0"), + reason="Upstream incompatibility: deepspeed and transformers==5.1.0 (see transformers#43780)", + ), + ), + pytest.param( + "zero3", + marks=pytest.mark.xfail( + Version("5.0.0") <= Version(transformers.__version__) < Version("5.5.4"), + reason="ZeRO-3 fails with transformers >= 5.0.0 and < 5.5.4 (fixed in transformers#45414), see #4899", + strict=True, + ), + ), + "fsdp2", + ], + ) + def test_grpo(self, config, get_config_path): + # fmt: off + run_command( + [ + "accelerate", "launch", "--config_file", get_config_path(config), "trl/scripts/grpo.py", + "--output_dir", self.tmp_dir, + "--model_name_or_path", "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "--dataset_name", "trl-internal-testing/zen", + "--dataset_config", "conversational_prompt_only", + "--reward_model_name_or_path", "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + ], + os.environ.copy(), + ) + # fmt: on diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d2777dd0eb21a0ea67dce8775337a27ea8499da2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_async_grpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_async_grpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..cc5413a62131521c1034455495fbf95bab178412 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_async_grpo_trainer.py @@ -0,0 +1,136 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import itertools +import queue + +import numpy as np +import torch +from datasets import load_dataset +from transformers import AutoTokenizer + +from trl.experimental.async_grpo import AsyncGRPOConfig, AsyncGRPOTrainer +from trl.experimental.async_grpo.async_rollout_worker import RolloutSample + +from ..testing_utils import TrlTestCase + + +def dummy_reward_func(completions, **kwargs): + return [float(hash(c[0]["content"]) % 100) / 100.0 for c in completions] + + +class _StubRolloutWorker: + """Minimal rollout worker stub for testing the trainer in isolation.""" + + def __init__(self, tokenizer, dataset, num_generations: int = 8, samples_per_weight_sync: int = 10): + self.rollout_buffer = queue.Queue() + self._samples_per_weight_sync = samples_per_weight_sync + self._model_version = 0 + self._sample_iter = self._make_sample_iter(tokenizer, dataset, num_generations) + + def _make_sample_iter(self, tokenizer, dataset, num_generations): + for row in itertools.cycle(dataset): + completions = [ + [{"role": "assistant", "content": f"{row['completion'][0]['content']} {idx}"}] + for idx in range(num_generations) + ] + prompt_completions = [row["prompt"] + completion for completion in completions] + prompt_ids = tokenizer.apply_chat_template( + row["prompt"], tokenize=True, add_generation_prompt=True, return_dict=False + ) + prompt_completion_ids = tokenizer.apply_chat_template( + prompt_completions, tokenize=True, add_generation_prompt=False, return_dict=False + ) + rewards = np.array(dummy_reward_func(completions)) + advantages = (rewards - rewards.mean()) / rewards.std() + for idx in range(num_generations): + completion_ids = prompt_completion_ids[idx][len(prompt_ids) :] + yield RolloutSample( + prompt=row["prompt"], + completion=completions[idx], + input_ids=prompt_ids + completion_ids, + completion_mask=[0] * len(prompt_ids) + [1] * len(completion_ids), + old_log_probs=[0.0] * len(prompt_ids) + [-0.5] * len(completion_ids), + advantage=float(advantages[idx]), + model_version=self._model_version, + metrics={"reward": float(rewards[idx]), "reward_std": float(rewards.std())}, + ) + + def _fill_queue(self): + for _ in range(self._samples_per_weight_sync): + self.rollout_buffer.put(next(self._sample_iter)) + + def start(self): + self._fill_queue() + + def update_model_version(self, version): + self._model_version = version + self._fill_queue() + + def stop(self): + pass + + def pause(self): + pass + + def resume(self): + pass + + def send_weights(self, iterator): + pass + + +class TestAsyncGRPOTrainer(TrlTestCase): + def test_init_minimal(self): + # Test that AsyncGRPOTrainer can be instantiated with only model, reward_model and train_dataset + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_completion", split="train") + AsyncGRPOTrainer( + model=model_id, + reward_funcs=dummy_reward_func, + train_dataset=dataset, + rollout_worker=_StubRolloutWorker(AutoTokenizer.from_pretrained(model_id), dataset, num_generations=3), + ) + + def test_training(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_completion", split="train") + + training_args = AsyncGRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + vllm_server_timeout=5.0, # short timeout so test fails fast if queue runs dry + report_to="none", + ) + trainer = AsyncGRPOTrainer( + model=model_id, + reward_funcs=dummy_reward_func, # unused: the stub pre-computes rewards, but the trainer requires this argument + args=training_args, + train_dataset=dataset, + rollout_worker=_StubRolloutWorker(AutoTokenizer.from_pretrained(model_id), dataset, num_generations=3), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_bco_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_bco_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..6f0297fe1056e9ae9c811d112a4cfdc9dc6301f6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_bco_trainer.py @@ -0,0 +1,441 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from functools import partial + +import pytest +import torch +from accelerate import Accelerator +from datasets import load_dataset +from transformers import AutoModel, AutoModelForCausalLM, AutoTokenizer +from transformers.utils import is_peft_available + +from trl.experimental.bco import BCOConfig, BCOTrainer +from trl.experimental.bco.bco_trainer import _process_tokens, _tokenize + +from ..testing_utils import TrlTestCase, require_no_wandb, require_peft, require_sklearn + + +if is_peft_available(): + from peft import LoraConfig + + +@pytest.mark.low_priority +class TestBCOTrainer(TrlTestCase): + @pytest.mark.parametrize( + "config_name", + [ + "standard_preference", + "standard_implicit_prompt_preference", + "standard_unpaired_preference", + "conversational_preference", + "conversational_implicit_prompt_preference", + "conversational_unpaired_preference", + ], + ) + @require_sklearn + def test_train(self, config_name): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + ref_model = AutoModelForCausalLM.from_pretrained(model_id) + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", config_name, split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + ref_model=ref_model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param.cpu(), new_param.cpu()) + + @require_sklearn + def test_train_with_precompute(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + ref_model = AutoModelForCausalLM.from_pretrained(model_id) + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference", split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + precompute_ref_log_probs=True, + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + ref_model=ref_model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param.cpu(), new_param.cpu()) + + @require_sklearn + def test_train_eval(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + ref_model = AutoModelForCausalLM.from_pretrained(model_id) + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + eval_strategy="steps", + eval_steps=3, + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + ref_model=ref_model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + trainer.train() + + @require_sklearn + def test_init_with_ref_model_is_model(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference", split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + report_to="none", + ) + + with pytest.raises(ValueError): + BCOTrainer( + model=model, + ref_model=model, # ref_model can't be the same as model + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + ) + + @require_sklearn + def test_tokenize_and_process_tokens(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + ref_model = AutoModelForCausalLM.from_pretrained(model_id) + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference", split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + ref_model=ref_model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + ) + + tokenized_dataset = dataset.map( + _tokenize, + fn_kwargs={"tokenizer": trainer.processing_class}, + batched=True, + batch_size=2, + ) + assert tokenized_dataset["prompt"][:] == dataset["prompt"][:] + assert tokenized_dataset["completion"][:] == dataset["completion"][:] + assert tokenized_dataset["label"][:] == dataset["label"][:] + assert tokenized_dataset["prompt_input_ids"][0] == [46518, 374, 2664, 1091] + assert tokenized_dataset["prompt_attention_mask"][0] == [1, 1, 1, 1] + assert tokenized_dataset["answer_input_ids"][0] == [27261, 13] + assert tokenized_dataset["answer_attention_mask"][0] == [1, 1] + + fn_kwargs = { + "prefix": "", + "is_encoder_decoder": trainer.is_encoder_decoder, + "tokenizer": trainer.processing_class, + "max_length": trainer.max_length, + } + processed_dataset = tokenized_dataset.map(_process_tokens, fn_kwargs=fn_kwargs) + assert processed_dataset["prompt"][:] == dataset["prompt"][:] + assert processed_dataset["completion"][:] == dataset["completion"][:] + assert processed_dataset["label"][:] == dataset["label"][:] + assert processed_dataset["prompt_input_ids"][0] == [46518, 374, 2664, 1091] + assert processed_dataset["prompt_attention_mask"][0] == [1, 1, 1, 1] + assert processed_dataset["completion_input_ids"][0] == [46518, 374, 2664, 1091, 27261, 13, 151645] + assert processed_dataset["completion_attention_mask"][0] == [1, 1, 1, 1, 1, 1, 1] + assert processed_dataset["completion_labels"][0] == [-100, -100, -100, -100, 27261, 13, 151645] + + @require_sklearn + def test_train_without_providing_ref_model(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference", split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param.cpu(), new_param.cpu()) + + @require_sklearn + def test_train_udm(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_id) + + # Get embedding model + embedding_model_id = "trl-internal-testing/tiny-BartModel" + embedding_model = AutoModel.from_pretrained(embedding_model_id) + embedding_tokenizer = AutoTokenizer.from_pretrained(embedding_model_id) + + def embed_prompt(input_ids, attention_mask, model): + outputs = model(input_ids=input_ids, attention_mask=attention_mask) + + return outputs.last_hidden_state.mean(dim=1) + + embedding_model = Accelerator().prepare_model(embedding_model) + embedding_func = partial(embed_prompt, model=embedding_model) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference", split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + embedding_func=embedding_func, + embedding_tokenizer=embedding_tokenizer, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param.cpu(), new_param.cpu()) + + @require_sklearn + @require_peft + def test_train_without_providing_ref_model_with_lora(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, task_type="CAUSAL_LM") + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference", split="train") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset, + peft_config=lora_config, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + if "lora" in n: + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param.cpu(), new_param.cpu()) + + @require_sklearn + @require_no_wandb + def test_generate_during_eval_no_wandb(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + eval_strategy="steps", + eval_steps=3, + generate_during_eval=True, + report_to="none", + ) + + with pytest.raises( + ValueError, + match="`generate_during_eval=True` requires Weights and Biases or Comet to be installed." + " Please install `wandb` or `comet-ml` to resolve.", + ): + BCOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + @require_sklearn + @require_peft + def test_lora_train_and_save(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, task_type="CAUSAL_LM") + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset["train"], + peft_config=lora_config, + ) + + # train the model + trainer.train() + + # save peft adapter + trainer.save_model() + + # assert that the model is loaded without giving OSError + AutoModelForCausalLM.from_pretrained(self.tmp_dir) + + @require_sklearn + def test_compute_metrics(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + ref_model = AutoModelForCausalLM.from_pretrained(model_id) + tokenizer = AutoTokenizer.from_pretrained(model_id) + + dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + def dummy_compute_metrics(*args, **kwargs): + return {"test": 0.0} + + training_args = BCOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, # warning raised if not set to False + eval_strategy="steps", + eval_steps=3, + report_to="none", + ) + + trainer = BCOTrainer( + model=model, + ref_model=ref_model, + args=training_args, + processing_class=tokenizer, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + trainer.train() + + assert trainer.state.log_history[-2]["eval_test"] == 0.0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_cpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_cpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..4bad5e604f4c54ea28f537f82b65dd5ba050fe6a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_cpo_trainer.py @@ -0,0 +1,216 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizer + +from trl.experimental.cpo import CPOConfig, CPOTrainer + +from ..testing_utils import TrlTestCase, require_peft + + +class TestCPOTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + # get t5 as seq2seq example: + model_id = "trl-internal-testing/tiny-T5ForConditionalGeneration" + self.t5_model = AutoModelForSeq2SeqLM.from_pretrained(model_id, dtype="float32") + self.t5_tokenizer = AutoTokenizer.from_pretrained(model_id) + + @pytest.mark.parametrize( + "name, loss_type, config_name", + [ + ("qwen", "sigmoid", "standard_preference"), + ("t5", "hinge", "standard_implicit_prompt_preference"), + ("qwen", "ipo", "conversational_preference"), + ("qwen", "simpo", "standard_preference"), + ("t5", "simpo", "standard_implicit_prompt_preference"), + ("qwen", "hinge", "conversational_preference"), + ], + ) + def test_cpo_trainer(self, name, loss_type, config_name): + training_args = CPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + loss_type=loss_type, + cpo_alpha=1.0, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + if name == "qwen": + model = self.model + tokenizer = self.tokenizer + elif name == "t5": + model = self.t5_model + tokenizer = self.t5_tokenizer + training_args.is_encoder_decoder = True + + trainer = CPOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + @pytest.mark.parametrize( + "config_name", + [ + "standard_preference", + "standard_implicit_prompt_preference", + "conversational_preference", + "conversational_implicit_prompt_preference", + ], + ) + @require_peft + def test_cpo_trainer_with_lora(self, config_name): + from peft import LoraConfig + + lora_config = LoraConfig( + r=16, + lora_alpha=32, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + ) + + training_args = CPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=4, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + cpo_alpha=1.0, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = CPOTrainer( + model=self.model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + peft_config=lora_config, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + if "lora" in n: + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + def test_compute_metrics(self): + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + def dummy_compute_metrics(*args, **kwargs): + return {"test": 0.0} + + training_args = CPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + remove_unused_columns=False, + do_eval=True, + eval_strategy="steps", + eval_steps=1, + per_device_eval_batch_size=2, + report_to="none", + ) + + trainer = CPOTrainer( + model=self.model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + trainer.train() + + assert trainer.state.log_history[-2]["eval_test"] == 0.0 + + def test_alphapo_trainer(self): + training_args = CPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + loss_type="alphapo", + alpha=0.5, + simpo_gamma=0.5, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + trainer = CPOTrainer( + model=self.model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: + assert not torch.equal(param, new_param) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_dppo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_dppo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..ef125a913bc2846de9d44092a445cdfd4ce092ce --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_dppo_trainer.py @@ -0,0 +1,184 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset + +from trl.experimental.dppo import DPPOConfig, DPPOTrainer + +from ..testing_utils import TrlTestCase + + +class TestDPPODivergenceMask: + """Unit tests for _compute_divergence_mask with synthetic inputs.""" + + @staticmethod + def make_trainer(divergence_type="binary_tv", epsilon=0.2, epsilon_high=0.28): + """Create a minimal DPPOTrainer-like object with just the attributes needed for _compute_divergence_mask.""" + + class Stub: + pass + + stub = Stub() + stub.divergence_type = divergence_type + stub.epsilon_low = epsilon + stub.epsilon_high = epsilon_high + return stub + + @staticmethod + def compute_divergence_mask( + trainer_stub, + current_logps, + sampling_logps, + advantages, + completion_mask, + current_topk_logps=None, + sampling_topk_logps=None, + ): + return DPPOTrainer._compute_divergence_mask( + trainer_stub, + current_logps, + sampling_logps, + advantages, + completion_mask, + current_topk_logps=current_topk_logps, + sampling_topk_logps=sampling_topk_logps, + ) + + def test_binary_tv_no_masking_within_threshold(self): + stub = self.make_trainer("binary_tv", epsilon=0.2, epsilon_high=0.28) + # Policies are very close — no tokens should be masked + sampling_logps = torch.log(torch.tensor([[0.5, 0.3, 0.7]])) + current_logps = torch.log(torch.tensor([[0.51, 0.29, 0.71]])) + advantages = torch.tensor([[1.0]]) + completion_mask = torch.ones(1, 3) + + mask = self.compute_divergence_mask(stub, current_logps, sampling_logps, advantages, completion_mask) + assert mask.shape == (1, 3) + assert (mask == 1.0).all() + + def test_binary_tv_masks_positive_advantage_high_divergence(self): + stub = self.make_trainer("binary_tv", epsilon=0.01, epsilon_high=0.01) + # π much higher than μ, positive advantage → should be masked (invalid_pos) + sampling_logps = torch.log(torch.tensor([[0.1]])) + current_logps = torch.log(torch.tensor([[0.5]])) + advantages = torch.tensor([[1.0]]) + completion_mask = torch.ones(1, 1) + + mask = self.compute_divergence_mask(stub, current_logps, sampling_logps, advantages, completion_mask) + assert mask.item() == 0.0 + + def test_binary_tv_masks_negative_advantage_low_divergence(self): + stub = self.make_trainer("binary_tv", epsilon=0.01, epsilon_high=0.01) + # π much lower than μ, negative advantage → should be masked (invalid_neg) + sampling_logps = torch.log(torch.tensor([[0.5]])) + current_logps = torch.log(torch.tensor([[0.1]])) + advantages = torch.tensor([[-1.0]]) + completion_mask = torch.ones(1, 1) + + mask = self.compute_divergence_mask(stub, current_logps, sampling_logps, advantages, completion_mask) + assert mask.item() == 0.0 + + def test_binary_tv_respects_completion_mask(self): + stub = self.make_trainer("binary_tv", epsilon=0.01, epsilon_high=0.01) + # Even though divergence is huge, padding tokens stay 0 + sampling_logps = torch.log(torch.tensor([[0.1, 0.5]])) + current_logps = torch.log(torch.tensor([[0.9, 0.9]])) + advantages = torch.tensor([[1.0]]) + completion_mask = torch.tensor([[1.0, 0.0]]) + + mask = self.compute_divergence_mask(stub, current_logps, sampling_logps, advantages, completion_mask) + assert mask[0, 1].item() == 0.0 + + def test_topk_tv_requires_topk_inputs(self): + stub = self.make_trainer("topk_tv") + B, T, K = 1, 2, 4 + sampling_logps = torch.log(torch.full((B, T), 0.3)) + current_logps = torch.log(torch.full((B, T), 0.31)) + advantages = torch.tensor([[1.0]]) + completion_mask = torch.ones(B, T) + + # Build top-K distributions that are nearly identical + topk_probs = torch.softmax(torch.randn(B, T, K), dim=-1) + sampling_topk_logps = torch.log(topk_probs) + current_topk_logps = torch.log(topk_probs + 0.001) + + mask = self.compute_divergence_mask( + stub, + current_logps, + sampling_logps, + advantages, + completion_mask, + current_topk_logps=current_topk_logps, + sampling_topk_logps=sampling_topk_logps, + ) + assert mask.shape == (B, T) + assert (mask == 1.0).all() + + +@pytest.mark.low_priority +class TestDPPOTrainer(TrlTestCase): + @pytest.mark.parametrize("divergence_type", ["binary_tv", "binary_kl"]) + def test_training_binary(self, divergence_type): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = DPPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + divergence_type=divergence_type, + report_to="none", + ) + trainer = DPPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_training_conversational(self, config_name): + dataset = load_dataset("trl-internal-testing/zen", config_name, split="train") + + training_args = DPPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = DPPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gkd_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gkd_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..b4589ef14538de462d1f7f592bd8cc2a9d343386 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gkd_trainer.py @@ -0,0 +1,282 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import pytest +import torch +import torch.nn.functional as F +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig + +from trl.experimental.gkd import GKDConfig, GKDTrainer + +from ..testing_utils import TrlTestCase, require_liger_kernel + + +class TestGKDTrainerGenerateOnPolicy(TrlTestCase): + @classmethod + def setup_class(cls): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + cls.device = "cuda" if torch.cuda.is_available() else "cpu" + cls.tokenizer = AutoTokenizer.from_pretrained(model_id) + cls.tokenizer.pad_token = cls.tokenizer.eos_token + cls.model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32").to(cls.device) + cls.generation_config = GenerationConfig( + max_new_tokens=20, + num_return_sequences=1, + pad_token_id=cls.tokenizer.pad_token_id, + eos_token_id=cls.tokenizer.eos_token_id, + ) + + def test_generate_on_policy_outputs_deterministic(self): + prompts = ["Hello, how are you?", "What's the weather like today?"] + tokenized_prompts = self.tokenizer(prompts, return_tensors="pt", padding=True) + + inputs = { + "prompts": tokenized_prompts["input_ids"].to(self.device), + "prompt_attention_mask": tokenized_prompts["attention_mask"].to(self.device), + } + + # Set temperature to 0 for deterministic output + deterministic_generation_config = GenerationConfig( + max_new_tokens=30, + num_return_sequences=1, + pad_token_id=self.tokenizer.pad_token_id, + eos_token_id=self.tokenizer.eos_token_id, + do_sample=False, + temperature=0.0, + ) + + outputs = GKDTrainer.generate_on_policy_outputs( + self.model, inputs, deterministic_generation_config, self.tokenizer.pad_token_id + ) + + new_input_ids, new_attention_mask, new_labels = outputs + + # Decode the generated outputs + generated_texts = self.tokenizer.batch_decode(new_input_ids, skip_special_tokens=True) + + # Check if the generated texts start with the original prompts + for prompt, generated_text in zip(prompts, generated_texts, strict=True): + assert generated_text.startswith(prompt), ( + f"Generated text '{generated_text}' does not start with prompt '{prompt}'" + ) + + # Run the generation twice and check if the outputs are identical + outputs2 = GKDTrainer.generate_on_policy_outputs( + self.model, inputs, deterministic_generation_config, self.tokenizer.pad_token_id + ) + + new_input_ids2, new_attention_mask2, new_labels2 = outputs2 + + # Check if the two generations are identical + assert torch.all(new_input_ids.eq(new_input_ids2)), "Deterministic generations are not identical" + assert torch.all(new_attention_mask.eq(new_attention_mask2)), ( + "Attention masks for deterministic generations are not identical" + ) + assert torch.all(new_labels.eq(new_labels2)), "Labels for deterministic generations are not identical" + + def test_generate_on_policy_outputs(self): + prompts = ["Hello, how are you?", "What's the weather like today?"] + tokenized_prompts = self.tokenizer(prompts, return_tensors="pt", padding=True) + + inputs = { + "prompts": tokenized_prompts["input_ids"].to(self.device), + "attention_mask": tokenized_prompts["attention_mask"].to(self.device), + } + + outputs = GKDTrainer.generate_on_policy_outputs( + self.model, inputs, self.generation_config, self.tokenizer.pad_token_id + ) + + # Check that outputs is a tuple of three tensors + assert isinstance(outputs, tuple) + assert len(outputs) == 3 + + new_input_ids, new_attention_mask, new_labels = outputs + + # Check shapes + batch_size = len(prompts) + assert new_input_ids.shape[0] == batch_size + assert new_attention_mask.shape[0] == batch_size + assert new_labels.shape[0] == batch_size + + # Check types + assert isinstance(new_input_ids, torch.Tensor) + assert isinstance(new_attention_mask, torch.Tensor) + assert isinstance(new_labels, torch.Tensor) + + # Check that new_input_ids and new_attention_mask have the same shape + assert new_input_ids.shape == new_attention_mask.shape + assert new_labels.shape == new_attention_mask.shape + + +class TestGeneralizedJSDLoss(TrlTestCase): + def setup_method(self): + self.batch_size = 2 + self.seq_length = 3 + self.vocab_size = 5 + self.student_logits = torch.randn(self.batch_size, self.seq_length, self.vocab_size) + self.teacher_logits = torch.randn(self.batch_size, self.seq_length, self.vocab_size) + + def test_uniform_distribution(self): + logits = torch.ones(1, 1, self.vocab_size) + loss = GKDTrainer.generalized_jsd_loss(logits, logits) + assert round(abs(loss.item() - 0), 5) == 0 + + def test_generalized_jsd_loss_edge_cases(self): + # Setup + student_logits = torch.log(torch.tensor([[0.1, 0.9]])).unsqueeze(0) + teacher_logits = torch.log(torch.tensor([[0.9, 0.1]])).unsqueeze(0) + + # Case 1: beta = 1 (should be equivalent to KL(student || teacher)) + loss_beta_1 = GKDTrainer.generalized_jsd_loss(student_logits, teacher_logits, beta=1) + expected_loss_beta_1 = F.kl_div( + F.log_softmax(teacher_logits, dim=-1), F.softmax(student_logits, dim=-1), reduction="batchmean" + ) + assert round(abs(loss_beta_1.item() - expected_loss_beta_1.item()), 5) == 0 + + # Case 2: beta = 0 (should be equivalent to KL(teacher || student)) + loss_beta_0 = GKDTrainer.generalized_jsd_loss(student_logits, teacher_logits, beta=0) + expected_loss_beta_0 = F.kl_div( + F.log_softmax(student_logits, dim=-1), F.softmax(teacher_logits, dim=-1), reduction="batchmean" + ) + assert round(abs(loss_beta_0.item() - expected_loss_beta_0.item()), 5) == 0 + + def test_output_shape(self): + loss = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits) + assert torch.is_tensor(loss) + assert loss.shape == torch.Size([]) + + def test_beta_values(self): + loss_beta_0 = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, beta=0) + loss_beta_1 = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, beta=1) + assert loss_beta_0 != loss_beta_1 + + def test_temperature_scaling(self): + loss_temp_1 = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, temperature=1) + loss_temp_2 = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, temperature=2) + assert loss_temp_1 != loss_temp_2 + + def test_reduction_methods(self): + loss_batchmean = GKDTrainer.generalized_jsd_loss( + self.student_logits, self.teacher_logits, reduction="batchmean" + ) + loss_sum = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, reduction="sum") + loss_mean = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, reduction="mean") + loss_none = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, reduction="none") + + assert loss_batchmean.shape == torch.Size([]) + assert loss_sum.shape == torch.Size([]) + assert loss_mean.shape == torch.Size([]) + assert loss_none.shape == self.student_logits.shape + + def test_symmetry(self): + student_teacher = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, beta=0.1) + teacher_student = GKDTrainer.generalized_jsd_loss(self.teacher_logits, self.student_logits, beta=0.1) + assert student_teacher != teacher_student + + student_teacher = GKDTrainer.generalized_jsd_loss(self.student_logits, self.teacher_logits, beta=0.5) + teacher_student = GKDTrainer.generalized_jsd_loss(self.teacher_logits, self.student_logits, beta=0.5) + assert student_teacher == teacher_student + + def test_zero_loss_for_identical_inputs(self): + identical_logits = torch.randn(self.batch_size, self.seq_length, self.vocab_size) + loss = GKDTrainer.generalized_jsd_loss(identical_logits, identical_logits) + assert round(abs(loss.item() - 0), 6) == 0 + + +class TestGKDTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.teacher_model = AutoModelForCausalLM.from_pretrained(self.model_id) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + def test_gkd_trainer(self): + training_args = GKDConfig( + output_dir=self.tmp_dir, + dataloader_drop_last=True, + eval_strategy="steps", + max_steps=4, + eval_steps=2, + save_steps=2, + per_device_train_batch_size=2, + per_device_eval_batch_size=2, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling") + + trainer = GKDTrainer( + model=self.model_id, + teacher_model=self.model_id, + args=training_args, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + processing_class=self.tokenizer, + ) + + trainer.train() + + assert trainer.state.log_history[(-1)]["train_loss"] is not None + assert trainer.state.log_history[0]["eval_loss"] is not None + assert "model.safetensors" in os.listdir(self.tmp_dir + "/checkpoint-2") + + @require_liger_kernel + @pytest.mark.xfail(reason="Computing the Liger loss spikes GPU memory usage, causing the test to run OOM.") + def test_gkd_trainer_with_liger(self): + training_args = GKDConfig( + output_dir=self.tmp_dir, + report_to="none", + use_liger_kernel=True, + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling") + + trainer = GKDTrainer( + model=self.model_id, + teacher_model=self.model_id, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + ) + + # Ensure liger fused JSD path is enabled; if not, skip (runtime may lack system libs) + if not getattr(trainer, "use_liger_gkd_loss", False): + pytest.skip("Liger fused JSD not enabled at runtime; skipping fused-loss assertion") + + trainer.train() + + # Check we logged a train loss + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_generation_config_init(self): + training_args = GKDConfig(output_dir=self.tmp_dir) + dummy_dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling") + + trainer = GKDTrainer( + model=self.model_id, + teacher_model=self.model_id, + args=training_args, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + processing_class=self.tokenizer, + ) + + assert trainer.generation_config.pad_token_id == self.tokenizer.eos_token_id + assert trainer.generation_config.eos_token_id == self.model.generation_config.eos_token_id + assert trainer.generation_config.max_new_tokens == training_args.max_new_tokens + assert trainer.generation_config.temperature == training_args.temperature + assert trainer.generation_config.top_k == 0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gold_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gold_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..619e01826268144395f2e87720a4c2a399200e1f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gold_trainer.py @@ -0,0 +1,941 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from types import SimpleNamespace + +import pytest +import torch +from datasets import load_dataset +from transformers import AutoTokenizer + +from trl.experimental.gold import gold_trainer as gold_trainer_module +from trl.experimental.gold.gold_trainer import GOLDTrainer, ULDLoss, build_teacher_inputs_from_texts +from trl.experimental.utils import DataCollatorForChatML + + +@pytest.fixture(scope="module") +def openr1_examples(): + try: + dataset = load_dataset( + "HuggingFaceTB/OpenR1-Math-220k-default-verified", + "all", + split="train[:3]", + ) + except Exception as exc: # pragma: no cover - network/environment dependent + pytest.skip(f"OpenR1 dataset unavailable: {exc}") + return [{"messages": row["messages"]} for row in dataset] + + +@pytest.fixture(scope="module") +def countdown_examples(): + try: + dataset = load_dataset( + "HuggingFaceTB/Countdown-Tasks-3to4", + "gkd_verified_Qwen2.5-7B-Instruct", + split="train[:3]", + ) + except Exception as exc: # pragma: no cover - network/environment dependent + pytest.skip(f"Countdown dataset unavailable: {exc}") + return [{"messages": row["messages"]} for row in dataset] + + +def _teacher_inputs_from_collator(student_tok, teacher_tok, batch): + prompt_texts = [] + completion_texts = [] + + pad_token_id = student_tok.pad_token_id + for prompt_ids_tensor, input_ids_tensor, labels_tensor in zip( + batch["prompts"], batch["input_ids"], batch["labels"], strict=True + ): + prompt_ids = prompt_ids_tensor.tolist() + if pad_token_id is not None: + prompt_ids = [tok for tok in prompt_ids if tok != pad_token_id] + prompt_texts.append(student_tok.decode(prompt_ids, skip_special_tokens=False)) + + input_ids = input_ids_tensor.tolist() + labels = labels_tensor.tolist() + completion_token_ids = [tok for tok, label in zip(input_ids, labels, strict=True) if label != -100] + completion_texts.append(student_tok.decode(completion_token_ids, skip_special_tokens=False)) + + teacher_input_ids, teacher_labels, _, _ = build_teacher_inputs_from_texts( + teacher_tok, prompt_texts, completion_texts + ) + return teacher_input_ids, teacher_labels, completion_texts + + +def _assert_alignment_covers_completion(loss_fn, batch, teacher_input_ids, teacher_labels): + for idx in range(batch["input_ids"].shape[0]): + student_mask = batch["attention_mask"][idx].bool() + student_ids = batch["input_ids"][idx][student_mask] + student_labels = batch["labels"][idx][student_mask] + student_answer_ids = student_ids[student_labels != -100].tolist() + + teacher_answer_mask = teacher_labels[idx] != -100 + teacher_answer_ids = teacher_input_ids[idx][teacher_answer_mask].tolist() + + student_groups, teacher_groups = loss_fn._build_alignment_groups_from_ids( + student_answer_ids, teacher_answer_ids + ) + + assert student_groups, "Student alignment groups must not be empty" + assert teacher_groups, "Teacher alignment groups must not be empty" + assert sorted(idx for group in student_groups for idx in group) == list(range(len(student_answer_ids))) + assert sorted(idx for group in teacher_groups for idx in group) == list(range(len(teacher_answer_ids))) + + +@pytest.mark.slow +def test_chatml_collator_preserves_completion_llama(llama_tokenizer, qwen_tokenizer, openr1_examples): + collator = DataCollatorForChatML(tokenizer=llama_tokenizer, max_length=512) + batch = collator(openr1_examples) + + assistant_texts = [example["messages"][-1]["content"] for example in openr1_examples] + decoded_batch = llama_tokenizer.batch_decode(batch["input_ids"], skip_special_tokens=False) + for decoded, assistant in zip(decoded_batch, assistant_texts, strict=True): + assert assistant.strip() in decoded + + teacher_input_ids, teacher_labels, completion_texts = _teacher_inputs_from_collator( + llama_tokenizer, qwen_tokenizer, batch + ) + for completion, assistant in zip(completion_texts, assistant_texts, strict=True): + assert assistant.strip() in completion + assert completion.strip() + + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=0.6, + uld_hybrid_unmatched_weight=0.4, + ) + loss_fn = ULDLoss(config, student_tokenizer=llama_tokenizer, teacher_tokenizer=qwen_tokenizer) + + _assert_alignment_covers_completion(loss_fn, batch, teacher_input_ids, teacher_labels) + + torch.manual_seed(0) + student_vocab = len(llama_tokenizer) + teacher_vocab = len(qwen_tokenizer) + batch_size, seq_len = batch["input_ids"].shape + student_logits = torch.randn(batch_size, seq_len, student_vocab) + teacher_logits = torch.randn(batch_size, teacher_input_ids.shape[1], teacher_vocab) + + loss = loss_fn( + student_logits=student_logits, + teacher_logits=teacher_logits, + student_labels=batch["labels"], + teacher_labels=teacher_labels, + student_input_ids=batch["input_ids"], + teacher_input_ids=teacher_input_ids, + ) + + assert torch.isfinite(loss) + + +@pytest.mark.slow +def test_chatml_collator_preserves_completion_llama_countdown(llama_tokenizer, qwen_tokenizer, countdown_examples): + collator = DataCollatorForChatML(tokenizer=llama_tokenizer, max_length=512) + batch = collator(countdown_examples) + + assistant_texts = [example["messages"][-1]["content"] for example in countdown_examples] + decoded_batch = llama_tokenizer.batch_decode(batch["input_ids"], skip_special_tokens=False) + for decoded, assistant in zip(decoded_batch, assistant_texts, strict=True): + assert assistant.strip() in decoded + + teacher_input_ids, teacher_labels, completion_texts = _teacher_inputs_from_collator( + llama_tokenizer, qwen_tokenizer, batch + ) + for completion, assistant in zip(completion_texts, assistant_texts, strict=True): + assert assistant.strip() in completion + assert completion.strip() + + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=0.6, + uld_hybrid_unmatched_weight=0.4, + ) + loss_fn = ULDLoss(config, student_tokenizer=llama_tokenizer, teacher_tokenizer=qwen_tokenizer) + + _assert_alignment_covers_completion(loss_fn, batch, teacher_input_ids, teacher_labels) + + torch.manual_seed(2) + student_vocab = len(llama_tokenizer) + teacher_vocab = len(qwen_tokenizer) + batch_size, seq_len = batch["input_ids"].shape + student_logits = torch.randn(batch_size, seq_len, student_vocab) + teacher_logits = torch.randn(batch_size, teacher_input_ids.shape[1], teacher_vocab) + + loss = loss_fn( + student_logits=student_logits, + teacher_logits=teacher_logits, + student_labels=batch["labels"], + teacher_labels=teacher_labels, + student_input_ids=batch["input_ids"], + teacher_input_ids=teacher_input_ids, + ) + + assert torch.isfinite(loss) + + +@pytest.mark.slow +def test_chatml_collator_preserves_completion_smollm(smollm_tokenizer, qwen_tokenizer, openr1_examples): + collator = DataCollatorForChatML(tokenizer=smollm_tokenizer, max_length=512) + batch = collator(openr1_examples) + + assistant_texts = [example["messages"][-1]["content"] for example in openr1_examples] + decoded_batch = smollm_tokenizer.batch_decode(batch["input_ids"], skip_special_tokens=False) + for decoded, assistant in zip(decoded_batch, assistant_texts, strict=True): + assert assistant.strip() in decoded + + teacher_input_ids, teacher_labels, completion_texts = _teacher_inputs_from_collator( + smollm_tokenizer, qwen_tokenizer, batch + ) + for completion, assistant in zip(completion_texts, assistant_texts, strict=True): + assert assistant.strip() in completion + assert completion.strip() + + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=0.5, + uld_hybrid_unmatched_weight=0.5, + ) + loss_fn = ULDLoss(config, student_tokenizer=smollm_tokenizer, teacher_tokenizer=qwen_tokenizer) + + _assert_alignment_covers_completion(loss_fn, batch, teacher_input_ids, teacher_labels) + + torch.manual_seed(1) + student_vocab = len(smollm_tokenizer) + teacher_vocab = len(qwen_tokenizer) + batch_size, seq_len = batch["input_ids"].shape + student_logits = torch.randn(batch_size, seq_len, student_vocab) + teacher_logits = torch.randn(batch_size, teacher_input_ids.shape[1], teacher_vocab) + + loss = loss_fn( + student_logits=student_logits, + teacher_logits=teacher_logits, + student_labels=batch["labels"], + teacher_labels=teacher_labels, + student_input_ids=batch["input_ids"], + teacher_input_ids=teacher_input_ids, + ) + + assert torch.isfinite(loss) + + +def build_config(**overrides): + base = dict( + uld_crossentropy_weight=0.0, + uld_distillation_weight=1.0, + uld_student_temperature=1.0, + uld_teacher_temperature=1.0, + uld_skip_student_eos=False, + uld_skip_teacher_eos=False, + use_extended_uld=True, + uld_use_hybrid_loss=False, + uld_hybrid_matched_weight=None, + uld_hybrid_unmatched_weight=None, + beta=0.5, + ) + base.update(overrides) + return SimpleNamespace(**base) + + +@pytest.fixture(scope="session") +def llama_tokenizer(): + tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat-v1.0") + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + return tokenizer + + +@pytest.fixture(scope="session") +def qwen_tokenizer(): + tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct") + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + return tokenizer + + +@pytest.fixture(scope="session") +def smollm_tokenizer(): + tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM3-3B") + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + return tokenizer + + +def encode_prompt_completion(tokenizer, prompt, completion): + prompt_ids = tokenizer(prompt, add_special_tokens=False)["input_ids"] + completion_ids = tokenizer(completion, add_special_tokens=False)["input_ids"] + eos_id = tokenizer.eos_token_id + if eos_id is not None: + completion_ids = completion_ids + [eos_id] + input_ids = prompt_ids + completion_ids + labels = [-100] * len(prompt_ids) + completion_ids + return input_ids, labels + + +def pad_tokens(ids, pad_id, target_length): + return ids + [pad_id] * (target_length - len(ids)) + + +def pad_labels(labels, target_length): + return labels + [-100] * (target_length - len(labels)) + + +def test_process_completions_to_buffer_left_pads_prompt_ids(): + class RecordingTokenizer: + pad_token_id = 0 + pad_token = "" + + def batch_decode(self, sequences, skip_special_tokens=False, clean_up_tokenization_spaces=False): + del skip_special_tokens, clean_up_tokenization_spaces + return [" ".join(str(token) for token in sequence) for sequence in sequences] + + trainer = GOLDTrainer.__new__(GOLDTrainer) + trainer.accelerator = SimpleNamespace(device=torch.device("cpu")) + trainer.processing_class = RecordingTokenizer() + trainer.args = SimpleNamespace(max_length=None) + trainer._buffered_inputs = [None] + trainer._buffered_text_logs = [None] + + GOLDTrainer._process_completions_to_buffer( + trainer, + slices=[{"slice": "original"}], + on_policy_indices=[0], + local_slice_indices=[0, 0], + completion_ids=[[31], [41]], + prompts_text_with_special=["short", "longer"], + prompt_ids_list=[[11], [21, 22]], + prompts_text=["short", "longer"], + max_completion_length=1, + ) + + buffered_inputs = trainer._buffered_inputs[0] + assert torch.equal(buffered_inputs["input_ids"], torch.tensor([[0, 11, 31], [21, 22, 41]], dtype=torch.long)) + assert torch.equal(buffered_inputs["attention_mask"], torch.tensor([[0, 1, 1], [1, 1, 1]], dtype=torch.long)) + assert torch.equal(buffered_inputs["labels"], torch.tensor([[-100, -100, 31], [-100, -100, 41]])) + + +def test_generate_on_policy_for_slices_uses_prompt_attention_mask_for_vllm_prompts(): + class RecordingVLLMGeneration: + def __init__(self): + self.prompts = None + self.sync_calls = 0 + + def sync_weights(self): + self.sync_calls += 1 + + def generate(self, prompts, images, num_generations): + self.prompts = prompts + assert images is None + assert num_generations == 1 + return None, [[42]], None, None + + class RecordingTokenizer: + pad_token_id = 9 + pad_token = "" + + def batch_decode(self, sequences, skip_special_tokens=False, clean_up_tokenization_spaces=False): + del clean_up_tokenization_spaces + decoded = [] + token_map = {5: "A", 6: "B", 9: ""} + for sequence in sequences: + tokens = [] + for token in sequence: + token = int(token) + if skip_special_tokens and token == 9: + continue + tokens.append(token_map[token]) + decoded.append(" ".join(tokens)) + return decoded + + captured = {} + + def capture_process_completions( + slices, + on_policy_indices, + local_slice_indices, + completion_ids, + prompt_ids_list, + prompts_text_with_special, + prompts_text, + max_completion_length, + ): + captured["slices"] = slices + captured["on_policy_indices"] = on_policy_indices + captured["local_slice_indices"] = local_slice_indices + captured["completion_ids"] = completion_ids + captured["prompt_ids_list"] = prompt_ids_list + captured["prompts_text"] = prompts_text + captured["prompts_text_with_special"] = prompts_text_with_special + captured["max_completion_length"] = max_completion_length + + trainer = GOLDTrainer.__new__(GOLDTrainer) + trainer.accelerator = SimpleNamespace(is_main_process=True) + trainer.args = SimpleNamespace(report_to=[]) + trainer.processing_class = RecordingTokenizer() + trainer.use_vllm = True + trainer.vllm_generation = RecordingVLLMGeneration() + trainer.vllm_sync_frequency = 1 + trainer._last_vllm_sync_step = -1 + trainer.state = SimpleNamespace(global_step=0) + trainer.num_generations = 1 + trainer.generation_config = SimpleNamespace(max_new_tokens=1) + trainer._process_completions_to_buffer = capture_process_completions + + slices = [ + { + "prompts": torch.tensor([[9, 9, 5, 9, 6]], dtype=torch.long), + "prompt_attention_mask": torch.tensor([[0, 0, 1, 1, 1]], dtype=torch.long), + } + ] + + GOLDTrainer._generate_on_policy_for_slices(trainer, slices, [0]) + + assert trainer.vllm_generation.prompts == [[5, 9, 6]] + assert trainer.vllm_generation.sync_calls == 1 + assert captured["completion_ids"] == [[42]] + assert captured["prompt_ids_list"] == [[5, 9, 6]] + assert captured["prompts_text"] == ["A B"] + assert captured["prompts_text_with_special"] == ["A B"] + + +def test_generate_on_policy_for_slices_reconstructs_prompt_with_special_tokens(): + class RecordingVLLMGeneration: + def __init__(self): + self.prompts = None + self.sync_calls = 0 + + def sync_weights(self): + self.sync_calls += 1 + + def generate(self, prompts, images, num_generations): + self.prompts = prompts + assert images is None + assert num_generations == 1 + return None, [[42]], None, None + + class RecordingTokenizer: + pad_token_id = 0 + pad_token = "" + + def __init__(self): + self.truncation_side = "right" + + def batch_decode(self, sequences, skip_special_tokens=False, clean_up_tokenization_spaces=False): + del clean_up_tokenization_spaces + token_map = {0: "", 5: "A", 6: "B", 13: "", 42: "C"} + decoded = [] + for sequence in sequences: + tokens = [] + for token in sequence: + token = int(token) + if skip_special_tokens and token == 13: + continue + if token == 0: + continue + tokens.append(token_map[token]) + decoded.append(" ".join(tokens)) + return decoded + + trainer = GOLDTrainer.__new__(GOLDTrainer) + trainer.accelerator = SimpleNamespace(device=torch.device("cpu"), is_main_process=True) + trainer.processing_class = RecordingTokenizer() + trainer.args = SimpleNamespace(max_length=None, report_to=[]) + trainer.use_vllm = True + trainer.vllm_generation = RecordingVLLMGeneration() + trainer.vllm_sync_frequency = 1 + trainer._last_vllm_sync_step = -1 + trainer.state = SimpleNamespace(global_step=0) + trainer.num_generations = 1 + trainer.generation_config = SimpleNamespace(max_new_tokens=1) + trainer._buffered_inputs = [None] + trainer._buffered_text_logs = [None] + + slices = [ + { + "slice": "original", + "prompts": torch.tensor([[0, 0, 5, 13, 6]], dtype=torch.long), + "prompt_attention_mask": torch.tensor([[0, 0, 1, 1, 1]], dtype=torch.long), + } + ] + + GOLDTrainer._generate_on_policy_for_slices(trainer, slices, [0]) + + buffered_inputs = trainer._buffered_inputs[0] + assert trainer.vllm_generation.prompts == [[5, 13, 6]] + assert trainer.vllm_generation.sync_calls == 1 + assert torch.equal(buffered_inputs["input_ids"], torch.tensor([[5, 13, 6, 42]], dtype=torch.long)) + assert torch.equal(buffered_inputs["attention_mask"], torch.tensor([[1, 1, 1, 1]], dtype=torch.long)) + assert torch.equal(buffered_inputs["labels"], torch.tensor([[-100, -100, -100, 42]], dtype=torch.long)) + assert buffered_inputs["original_prompt_text"] == ["A B"] + assert buffered_inputs["original_completion_text"] == ["C"] + assert trainer._buffered_text_logs[0] == (["A B"], ["C"]) + + +def test_gold_trainer_init_defaults_vllm_max_model_length_to_max_length(monkeypatch): + captured = {} + + class DummyStudentModel: + def __init__(self): + self.config = SimpleNamespace(_name_or_path="student", vocab_size=17) + self.generation_config = SimpleNamespace(eos_token_id=2) + self.name_or_path = "student" + + class DummyTeacherModel: + def __init__(self): + self.resized_to = None + + def resize_token_embeddings(self, vocab_size): + self.resized_to = vocab_size + + class DummyProcessingClass: + pad_token_id = 0 + + def fake_sft_init( + self, + model, + args=None, + data_collator=None, + train_dataset=None, + eval_dataset=None, + processing_class=None, + compute_metrics=None, + callbacks=None, + optimizers=None, + preprocess_logits_for_metrics=None, + peft_config=None, + ): + del data_collator, train_dataset, eval_dataset, compute_metrics, callbacks, optimizers + del preprocess_logits_for_metrics, peft_config + self.model = model + self.args = args + self.processing_class = processing_class + self.accelerator = SimpleNamespace( + device=torch.device("cpu"), + num_processes=1, + prepare_model=lambda module, evaluation_mode=True: module, + ) + self.is_deepspeed_enabled = False + self.is_fsdp_enabled = False + + class CapturingVLLMGeneration: + def __init__(self, **kwargs): + captured.update(kwargs) + + monkeypatch.setattr(gold_trainer_module.SFTTrainer, "__init__", fake_sft_init) + monkeypatch.setattr(gold_trainer_module, "is_vllm_available", lambda: True) + monkeypatch.setattr(gold_trainer_module, "VLLMGeneration", CapturingVLLMGeneration) + + args = SimpleNamespace( + model_init_kwargs=None, + max_length=128, + use_liger_kernel=False, + teacher_model_init_kwargs=None, + use_uld_loss=False, + teacher_tokenizer_name_or_path=None, + teacher_model_revision=None, + disable_dropout=False, + lmbda=1.0, + beta=0.5, + temperature=1.0, + top_p=1.0, + seq_kd=False, + num_generations=1, + max_completion_length=16, + top_k=0, + log_completions=False, + log_completions_steps=100, + wandb_log_unique_prompts=True, + num_completions_to_print=None, + per_device_train_batch_size=1, + gradient_accumulation_steps=1, + use_vllm=True, + vllm_mode="colocate", + vllm_structured_outputs_regex=None, + vllm_server_base_url=None, + vllm_server_host="0.0.0.0", + vllm_server_port=8001, + vllm_group_port=51216, + vllm_server_timeout=240.0, + vllm_tensor_parallel_size=1, + vllm_gpu_memory_utilization=0.2, + vllm_max_model_length=None, + vllm_enable_sleep_mode=False, + vllm_model_impl="vllm", + vllm_sync_frequency=1, + ) + + teacher_model = DummyTeacherModel() + GOLDTrainer( + model=DummyStudentModel(), + teacher_model=teacher_model, + args=args, + data_collator=object(), + processing_class=DummyProcessingClass(), + ) + + assert teacher_model.resized_to == 17 + assert captured["max_model_length"] == 128 + + +def test_alignment_groups_cover_all_tokens(llama_tokenizer, qwen_tokenizer): + config = build_config() + loss = ULDLoss(config, student_tokenizer=llama_tokenizer, teacher_tokenizer=qwen_tokenizer) + + text = "SmolLM3-3B is smaller than Llama 3.2 but still capable." + student_ids = llama_tokenizer(text, add_special_tokens=False)["input_ids"] + teacher_ids = qwen_tokenizer(text, add_special_tokens=False)["input_ids"] + + student_groups, teacher_groups = loss._build_alignment_groups_from_ids(student_ids, teacher_ids) + + assert len(student_groups) == len(teacher_groups) + assert sorted(idx for group in student_groups for idx in group) == list(range(len(student_ids))) + assert sorted(idx for group in teacher_groups for idx in group) == list(range(len(teacher_ids))) + + +def test_merge_probabilities_multiplies_split_tokens(): + config = build_config() + # Use simple 3-token vocabulary to validate merging behaviour + # probs[0] = P(token | context) at position 0 for all vocab tokens + # probs[1] = P(token | context) at position 1 for all vocab tokens + probs = torch.tensor([[0.6, 0.3, 0.1], [0.2, 0.5, 0.3]]) + loss = ULDLoss(config, student_tokenizer=None, teacher_tokenizer=None) + + # token_ids[1] = 1 means the actual token at position 1 is token ID 1 + # So we should extract P(token_id=1 | ...) = probs[1, 1] = 0.5 + token_ids = [0, 1] # Actual generated tokens + + merged = loss._merge_probabilities_with_alignment_groups(probs, [[0, 1]], token_ids=token_ids) + + # Expected: P_merged(y) = P(y | context_0) × P(token_1=1 | context_1) + # For each vocab token y, multiply marginal prob at pos 0 by scalar conditional prob of actual token at pos 1 + expected = probs[0] * probs[1, 1] # probs[1, 1] = 0.5 + # Expected unnormalized: [0.6 * 0.5, 0.3 * 0.5, 0.1 * 0.5] = [0.3, 0.15, 0.05] + + torch.testing.assert_close(merged[0], expected) + + +def test_initialize_vocabulary_mapping_contains_common_tokens(llama_tokenizer, qwen_tokenizer): + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=1.0, + uld_hybrid_unmatched_weight=0.0, + ) + loss = ULDLoss(config, student_tokenizer=llama_tokenizer, teacher_tokenizer=qwen_tokenizer) + + common_tokens = ["Hello", "world", "-", "ol", "LM", "3", "B"] + for token in common_tokens: + student_id = llama_tokenizer.convert_tokens_to_ids(token) + teacher_id = qwen_tokenizer.convert_tokens_to_ids(token) + assert student_id is not None + assert teacher_id is not None + assert teacher_id in loss._vocab_mapping + assert loss._vocab_mapping[teacher_id] == student_id + assert teacher_id in loss._teacher_matched_ids + assert student_id in loss._student_matched_ids + + +def test_get_start_and_size_answers_skips_prompt_tokens(): + trainer = ULDLoss.__new__(ULDLoss) + trainer.ignore_index = -100 + + answers = torch.tensor( + [ + [-100, -100, -100, 10, 20, 30, -100, -100], + [-100, 5, 6, 7, -100, -100, -100, -100], + [-100, -100, -100, -100, -100, -100, -100, -100], + ] + ) + + starts, sizes = trainer._get_start_and_size_answers(answers) + + assert starts == [3, 1, 0] + assert sizes == [3, 3, 0] + + +@pytest.mark.slow +def test_generate_on_policy_outputs_masks_prompt(llama_tokenizer): + trainer = GOLDTrainer.__new__(GOLDTrainer) + trainer.processing_class = llama_tokenizer + + prompt_text = "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\nHello?<|eot_id|>" + completion_text = "<|start_header_id|>assistant<|end_header_id|>\nHi there!" + + prompt_ids = llama_tokenizer(prompt_text, add_special_tokens=False)["input_ids"] + completion_ids = llama_tokenizer(completion_text, add_special_tokens=False)["input_ids"] + + pad_id = llama_tokenizer.pad_token_id + pad_width = 3 + prompt_tensor = torch.full((1, len(prompt_ids) + pad_width), pad_id, dtype=torch.long) + prompt_tensor[0, pad_width:] = torch.tensor(prompt_ids, dtype=torch.long) + prompt_mask = (prompt_tensor != pad_id).long() + + # model.generate() returns full sequences including left-padding from the input + completion_tensor = torch.tensor(completion_ids, dtype=torch.long).unsqueeze(0) + generated_sequence = torch.cat([prompt_tensor, completion_tensor], dim=1) + + class DummyModel: + def generate(self, input_ids, attention_mask, generation_config, return_dict_in_generate): + assert torch.equal(input_ids, prompt_tensor) + assert torch.equal(attention_mask, prompt_mask) + return SimpleNamespace(sequences=generated_sequence) + + generation_config = SimpleNamespace(max_completion_length=None, temperature=None, top_k=None, top_p=None) + new_ids, new_mask, new_labels, prompt_texts, completion_texts = GOLDTrainer.generate_on_policy_outputs( + trainer, + DummyModel(), + {"prompts": prompt_tensor, "prompt_attention_mask": prompt_mask}, + generation_config, + pad_id, + ) + + assert torch.equal(new_ids, generated_sequence) + if pad_id is not None: + expected_mask = (generated_sequence != pad_id).long() + assert torch.equal(new_mask, expected_mask) + else: + assert torch.all(new_mask == 1) + + padded_prompt_len = prompt_tensor.shape[1] + assert torch.all(new_labels[0, :padded_prompt_len] == -100) + assert torch.equal(new_labels[0, padded_prompt_len:], torch.tensor(completion_ids, dtype=torch.long)) + + assert prompt_texts[0] == llama_tokenizer.decode(prompt_ids, skip_special_tokens=False) + assert completion_texts[0] == llama_tokenizer.decode(completion_ids, skip_special_tokens=False) + + +@pytest.mark.slow +def test_generate_on_policy_outputs_masks_prompt_smollm(smollm_tokenizer, openr1_examples): + trainer = GOLDTrainer.__new__(GOLDTrainer) + trainer.processing_class = smollm_tokenizer + + collator = DataCollatorForChatML(tokenizer=smollm_tokenizer) + batch = collator([openr1_examples[0]]) + batch = {k: v.cpu() for k, v in batch.items()} + + class DummyModel: + def generate(self, input_ids, attention_mask, generation_config, return_dict_in_generate): + assert torch.equal(input_ids, batch["prompts"]) + assert torch.equal(attention_mask, batch["prompt_attention_mask"]) + return SimpleNamespace(sequences=batch["input_ids"]) + + generation_config = SimpleNamespace(max_completion_length=None, temperature=None, top_k=None, top_p=None) + pad_id = smollm_tokenizer.pad_token_id + new_ids, new_mask, new_labels, prompt_texts, completion_texts = GOLDTrainer.generate_on_policy_outputs( + trainer, + DummyModel(), + {"prompts": batch["prompts"], "prompt_attention_mask": batch["prompt_attention_mask"]}, + generation_config, + pad_id, + ) + + assert torch.equal(new_ids, batch["input_ids"]) + if pad_id is not None: + expected_mask = (batch["input_ids"] != pad_id).long() + assert torch.equal(new_mask, expected_mask) + else: + assert torch.all(new_mask == 1) + + prompt_len = int(batch["prompt_attention_mask"].sum().item()) + tail_labels = new_labels[0, prompt_len:] + expected_tail = batch["input_ids"][0, prompt_len:] + active_mask = tail_labels != -100 + assert torch.all(new_labels[0, :prompt_len] == -100) + assert torch.equal(tail_labels[active_mask], expected_tail[active_mask]) + assert torch.all(tail_labels[~active_mask] == -100) + + prompt_tokens = batch["prompts"][0, batch["prompt_attention_mask"][0].bool()] + decoded_prompt = smollm_tokenizer.decode(prompt_tokens.tolist(), skip_special_tokens=False) + assert prompt_texts[0] == decoded_prompt + + assistant_completion = openr1_examples[0]["messages"][-1]["content"].strip() + assert assistant_completion in completion_texts[0] + + +def test_generalized_jsd_loss_accepts_probability_inputs(): + student_probs = torch.tensor([[[0.6, 0.3, 0.1]]]) + teacher_probs = torch.tensor([[[0.5, 0.4, 0.1]]]) + mixture = 0.5 * (student_probs + teacher_probs) + expected = 0.5 * ( + torch.sum(student_probs * (torch.log(student_probs) - torch.log(mixture))) + + torch.sum(teacher_probs * (torch.log(teacher_probs) - torch.log(mixture))) + ) + + loss = GOLDTrainer.generalized_jsd_loss( + student_probs, + teacher_probs, + beta=0.5, + reduction="batchmean", + logits_are_probs=True, + ) + + torch.testing.assert_close(loss, expected) + + +def test_uldloss_handles_llama_student_qwen_teacher_sequence(llama_tokenizer, qwen_tokenizer): + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=0.6, + uld_hybrid_unmatched_weight=0.4, + ) + loss_fn = ULDLoss(config, student_tokenizer=llama_tokenizer, teacher_tokenizer=qwen_tokenizer) + + prompt = "User: Summarize the difference between llamas and alpacas." + completion = "Assistant: Llamas are taller while alpacas have softer wool." + + student_ids, student_labels = encode_prompt_completion(llama_tokenizer, prompt, completion) + teacher_ids, teacher_labels = encode_prompt_completion(qwen_tokenizer, prompt, completion) + + pad_id_student = llama_tokenizer.pad_token_id + pad_id_teacher = qwen_tokenizer.pad_token_id + max_length = max(len(student_ids), len(teacher_ids)) + + student_ids = pad_tokens(student_ids, pad_id_student, max_length) + teacher_ids = pad_tokens(teacher_ids, pad_id_teacher, max_length) + student_labels = pad_labels(student_labels, max_length) + teacher_labels = pad_labels(teacher_labels, max_length) + + student_input_ids = torch.tensor([student_ids]) + teacher_input_ids = torch.tensor([teacher_ids]) + student_labels = torch.tensor([student_labels]) + teacher_labels = torch.tensor([teacher_labels]) + + student_vocab = len(llama_tokenizer) + teacher_vocab = len(qwen_tokenizer) + + student_logits = torch.randn(1, max_length, student_vocab) + teacher_logits = torch.randn(1, max_length, teacher_vocab) + + loss = loss_fn( + student_logits=student_logits, + teacher_logits=teacher_logits, + student_labels=student_labels, + teacher_labels=teacher_labels, + student_input_ids=student_input_ids, + teacher_input_ids=teacher_input_ids, + ) + + assert torch.isfinite(loss) + assert loss.dim() == 0 + assert loss_fn.last_matched_loss is not None + assert loss_fn.last_unmatched_loss is not None + + +def test_uldloss_handles_smollm_student_qwen_teacher_sequence(smollm_tokenizer, qwen_tokenizer): + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=0.5, + uld_hybrid_unmatched_weight=0.5, + ) + loss_fn = ULDLoss(config, student_tokenizer=smollm_tokenizer, teacher_tokenizer=qwen_tokenizer) + + prompt = "User: Describe SmolLM3 in a sentence." + completion = "Assistant: SmolLM3 is a compact yet capable language model." + + student_ids, student_labels = encode_prompt_completion(smollm_tokenizer, prompt, completion) + teacher_ids, teacher_labels = encode_prompt_completion(qwen_tokenizer, prompt, completion) + + pad_id_student = smollm_tokenizer.pad_token_id + pad_id_teacher = qwen_tokenizer.pad_token_id + max_length = max(len(student_ids), len(teacher_ids)) + + student_ids = pad_tokens(student_ids, pad_id_student, max_length) + teacher_ids = pad_tokens(teacher_ids, pad_id_teacher, max_length) + student_labels = pad_labels(student_labels, max_length) + teacher_labels = pad_labels(teacher_labels, max_length) + + student_input_ids = torch.tensor([student_ids]) + teacher_input_ids = torch.tensor([teacher_ids]) + student_labels = torch.tensor([student_labels]) + teacher_labels = torch.tensor([teacher_labels]) + + student_vocab = len(smollm_tokenizer) + teacher_vocab = len(qwen_tokenizer) + + student_logits = torch.randn(1, max_length, student_vocab) + teacher_logits = torch.randn(1, max_length, teacher_vocab) + + loss = loss_fn( + student_logits=student_logits, + teacher_logits=teacher_logits, + student_labels=student_labels, + teacher_labels=teacher_labels, + student_input_ids=student_input_ids, + teacher_input_ids=teacher_input_ids, + ) + + assert torch.isfinite(loss) + assert loss.dim() == 0 + assert loss_fn.last_matched_loss is not None + assert loss_fn.last_unmatched_loss is not None + + +def test_uldloss_hybrid_config_beta_zero(llama_tokenizer, qwen_tokenizer): + config = build_config( + uld_use_hybrid_loss=True, + uld_hybrid_matched_weight=0.0, + uld_hybrid_unmatched_weight=1.0, + use_extended_uld=True, + uld_crossentropy_weight=0.0, + uld_distillation_weight=1.0, + uld_student_temperature=1.0, + uld_teacher_temperature=1.0, + temperature=1.0, + top_p=0.95, + top_k=0, + lmbda=1.0, + beta=0.0, + ) + loss_fn = ULDLoss(config, student_tokenizer=llama_tokenizer, teacher_tokenizer=qwen_tokenizer) + + prompt = "User: Explain how GOLD handles tokenizer mismatches." + completion = "Assistant: GOLD merges aligned subwords and applies hybrid ULD loss." + + student_ids, student_labels = encode_prompt_completion(llama_tokenizer, prompt, completion) + teacher_ids, teacher_labels = encode_prompt_completion(qwen_tokenizer, prompt, completion) + + pad_id_student = llama_tokenizer.pad_token_id + pad_id_teacher = qwen_tokenizer.pad_token_id + max_length = max(len(student_ids), len(teacher_ids)) + + student_ids = pad_tokens(student_ids, pad_id_student, max_length) + teacher_ids = pad_tokens(teacher_ids, pad_id_teacher, max_length) + student_labels = pad_labels(student_labels, max_length) + teacher_labels = pad_labels(teacher_labels, max_length) + + student_input_ids = torch.tensor([student_ids]) + teacher_input_ids = torch.tensor([teacher_ids]) + student_labels = torch.tensor([student_labels]) + teacher_labels = torch.tensor([teacher_labels]) + + student_vocab = len(llama_tokenizer) + teacher_vocab = len(qwen_tokenizer) + torch.manual_seed(0) + student_logits = torch.randn(1, max_length, student_vocab) + teacher_logits = torch.randn(1, max_length, teacher_vocab) + + loss = loss_fn( + student_logits=student_logits, + teacher_logits=teacher_logits, + student_labels=student_labels, + teacher_labels=teacher_labels, + student_input_ids=student_input_ids, + teacher_input_ids=teacher_input_ids, + ) + + assert torch.isfinite(loss) + assert loss.dim() == 0 + assert loss_fn.last_matched_loss is not None + assert loss_fn.last_unmatched_loss is not None + + expected = config.uld_hybrid_unmatched_weight * loss_fn.last_unmatched_loss + torch.testing.assert_close(loss, expected, atol=1e-6, rtol=1e-5) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_grpo_with_replay_buffer_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_grpo_with_replay_buffer_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..dd537d1a4a52f6acb4b17f7e86749d5ea5bef529 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_grpo_with_replay_buffer_trainer.py @@ -0,0 +1,292 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset + +from trl.experimental.grpo_with_replay_buffer import ( + GRPOWithReplayBufferConfig, + GRPOWithReplayBufferTrainer, + ReplayBuffer, +) + +from ..testing_utils import TrlTestCase + + +@pytest.mark.low_priority +class TestReplayBuffer: + def setup_method(self): + self.replay_buffer = ReplayBuffer(max_size=5) + + def test_add(self): + # Add elements to the replay buffer + scores = [0.5, 0.8, 0.3, 0.9, 0.7] + data = [ + {"id": 1}, + {"id": 2}, + {"id": 3}, + {"id": 4}, + {"id": 5}, + ] + self.replay_buffer.add(scores, data) + + # Check if the buffer contains the correct number of elements + assert len(self.replay_buffer.heap) == 5 + + # Check if the buffer maintains the min-heap property + heap_scores = [item[0] for item in self.replay_buffer.heap] + assert heap_scores[0] == min(heap_scores) + assert heap_scores[0] == 0.3 + + def test_add_more_than_maxlen(self): + # Add elements to the replay buffer + scores = [0.5, 0.8, 0.3, 0.9, 0.7, 0.6, 0.4] + data = [ + {"id": 1}, + {"id": 2}, + {"id": 3}, + {"id": 4}, + {"id": 5}, + {"id": 6}, + {"id": 7}, + ] + self.replay_buffer.add(scores, data) + + # Check if the buffer contains the correct number of elements + assert len(self.replay_buffer.heap) == 5 + + # Check if the buffer maintains the min-heap property + heap_scores = [item[0] for item in self.replay_buffer.heap] + assert heap_scores[0] == min(heap_scores) + assert heap_scores[0] == 0.5 # 0.3 and 0.4 should be removed + + def test_sample(self): + # Add elements to the replay buffer + scores = [0.5, 0.8, 0.3, 0.9, 0.7] + data = [ + {"id": 1}, + {"id": 2}, + {"id": 3}, + {"id": 4}, + {"id": 5}, + ] + self.replay_buffer.add(scores, data) + + # Sample elements from the buffer + sampled = self.replay_buffer.sample(num_samples=3) + + # Check if the sampled elements are from the buffer + assert len(sampled) == 3 + for item in sampled: + assert item in [entry[1] for entry in self.replay_buffer.heap] + + +@pytest.mark.low_priority +class TestUpdateWithReplayBuffer: + def setup_method(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + config = GRPOWithReplayBufferConfig( + replay_buffer_size=5, + ) + self.trainer = GRPOWithReplayBufferTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=config, + train_dataset=dataset, + ) + self.trainer.replay_buffer = ReplayBuffer(max_size=5) + self.trainer.num_generations = 2 + + def _prepopulate_buffer(self, with_pixels=False, with_logprobs=False): + scores = [0.1, 0.9] + data = [ + { + "prompt_ids": torch.tensor([[100, 101], [102, 103]]), + "prompt_mask": torch.ones(2, 2, dtype=torch.long), + "completion_ids": torch.tensor([[5, 6], [7, 8]]), + "completion_mask": torch.ones(2, 2, dtype=torch.long), + "advantages": torch.tensor([[0.5, 0.6]]), + **({"pixel_values": torch.randn(2, 3, 224, 224)} if with_pixels else {}), + **({"old_per_token_logps": torch.randn(2, 2)} if with_logprobs else {}), + }, + { + "prompt_ids": torch.tensor([[104, 105], [106, 107]]), + "prompt_mask": torch.ones(2, 2, dtype=torch.long), + "completion_ids": torch.tensor([[13, 14], [15, 16]]), + "completion_mask": torch.ones(2, 2, dtype=torch.long), + "advantages": torch.tensor([[0.8, 0.85]]), + **({"pixel_values": torch.randn(2, 3, 224, 224)} if with_pixels else {}), + **({"old_per_token_logps": torch.randn(2, 2)} if with_logprobs else {}), + }, + ] + self.trainer.replay_buffer.add(scores, data) + + def _make_inputs(self, group_advantages, with_pixels=False, with_logprobs=False): + inputs = { + "group_advantages": group_advantages, + "prompt_ids": torch.tensor([[1, 2], [3, 4], [5, 6], [7, 8]]), + "prompt_mask": torch.ones(4, 2, dtype=torch.long), + "completion_ids": torch.tensor([[9, 10], [11, 12], [13, 14], [15, 16]]), + "completion_mask": torch.ones(4, 2, dtype=torch.long), + "forward_kwargs": {"pixel_values": torch.randn(4, 3, 224, 224)} if with_pixels else {}, + "old_per_token_logps": torch.randn(4, 2) if with_logprobs else None, + } + inputs["group_std_rewards"] = group_advantages.std(dim=1).expand_as(group_advantages) + return inputs + + def test_update_with_replay_buffer_no_variance(self): + self._prepopulate_buffer(with_pixels=True, with_logprobs=True) + group_advantages = torch.tensor([[0.5, 0.5], [0.8, 0.8]]) # no variance + inputs = self._make_inputs(group_advantages, with_pixels=True, with_logprobs=True) + original_prompt_ids = inputs["prompt_ids"].clone() + + outputs = self.trainer.update_with_replay_buffer(**inputs, num_items_in_batch=4) + + assert outputs is not None + assert "pixel_values" in outputs + assert "old_per_token_logps" in outputs + assert len(self.trainer.replay_buffer.heap) == 2 + for pid in outputs["prompt_ids"]: + assert pid.tolist() not in original_prompt_ids.tolist() + + def test_update_with_replay_buffer_with_variance(self): + self._prepopulate_buffer() + group_advantages = torch.tensor([[0.6, 0.4], [0.7, 1.2]]) # has variance + inputs = self._make_inputs(group_advantages) + + sampled = self.trainer.update_with_replay_buffer(**inputs, num_items_in_batch=4) + + assert len(self.trainer.replay_buffer.heap) == 4 # grew + assert sampled is None + + def test_update_with_mixed_variance(self): + self._prepopulate_buffer() + group_advantages = torch.tensor([[0.6, 0.6], [0.3, 0.45]]) # one no-variance, one variance + inputs = self._make_inputs(group_advantages) + original_prompt_ids = inputs["prompt_ids"].clone().view(-1, self.trainer.num_generations, 2).tolist() + + outputs = self.trainer.update_with_replay_buffer(**inputs, num_items_in_batch=4) + + assert len(self.trainer.replay_buffer.heap) == 3 # grew by 1 + output_prompt_ids = outputs["prompt_ids"].view(-1, self.trainer.num_generations, 2).tolist() + + buffer_ids = [item[1]["prompt_ids"].tolist() for item in self.trainer.replay_buffer.heap] + found_from_buffer = any(pid in buffer_ids for pid in output_prompt_ids) + found_from_original = any(pid in original_prompt_ids for pid in output_prompt_ids) + + assert found_from_buffer + assert found_from_original + assert [[1, 2], [3, 4]] not in output_prompt_ids # excluded no-variance group + + def test_update_with_inputs_different_seq_len(self): + """ + Test with inputs where the sequence lengths are different from the prepopulated buffer. + """ + self._prepopulate_buffer() + pad_token_id = self.trainer.processing_class.pad_token_id + group_advantages = torch.tensor([[0.6, 0.6], [0.3, 0.45]]) # one no-variance, one variance + inputs = { + "group_advantages": group_advantages, + "prompt_ids": torch.tensor( + [ + [1, 2, pad_token_id], + [1, 2, pad_token_id], + [3, 4, 5], + [3, 4, 5], + ] + ), + "prompt_mask": torch.tensor([[1, 1, 0], [1, 1, 0], [1, 1, 1], [1, 1, 1]], dtype=torch.long), + "completion_ids": torch.tensor( + [ + [1009, 1010, pad_token_id], + [1011, 1012, 1013], + [1013, 1014, pad_token_id], + [1015, 1016, 1017], + ] + ), + "completion_mask": torch.tensor([[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]], dtype=torch.long), + "forward_kwargs": {}, + } + inputs["group_std_rewards"] = group_advantages.std(dim=1).expand_as(group_advantages) + + outputs_after_sampling = self.trainer.update_with_replay_buffer(**inputs, num_items_in_batch=4) + # Seq length of current batch should be preserved + assert outputs_after_sampling["prompt_ids"].shape[-1] == 3 + assert len(self.trainer.replay_buffer.heap) == 3 + output_prompt_ids = outputs_after_sampling["prompt_ids"].view(-1, self.trainer.num_generations, 3).tolist() + + buffered_prompt_completion_ids = [ + (item[1]["prompt_ids"].tolist(), item[1]["completion_ids"].tolist()) + for item in self.trainer.replay_buffer.heap + ] + buffered_prompt_ids, buffered_completion_ids = zip(*buffered_prompt_completion_ids, strict=True) + + # Check for new entry with seq len 3 in buffer + assert [[3, 4, 5], [3, 4, 5]] in buffered_prompt_ids # excluded no-variance group + assert [ + [1013, 1014, pad_token_id], + [1015, 1016, 1017], + ] in buffered_completion_ids # excluded no-variance group + + # Check that sampled outputs contain one group with prompt_ids starting with a pad token + assert [ + [pad_token_id, 101, 102], + [pad_token_id, 102, 103], + ] in output_prompt_ids or [ + [pad_token_id, 104, 105], + [pad_token_id, 106, 107], + ] in output_prompt_ids + + +@pytest.mark.low_priority +@pytest.mark.parametrize("scale_rewards", ["batch", "group"]) +class TestGRPOWithReplayBufferTrainer(TrlTestCase): + def test_training_with_replay_buffer(self, scale_rewards): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Guarantee that some rewards have 0 std + def custom_reward_func(completions, **kwargs): + if torch.rand(1).item() < 0.25: + return [0] * len(completions) # simulate some None rewards + else: + return torch.rand(len(completions)).tolist() + + training_args = GRPOWithReplayBufferConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=4, # reduce the batch size to reduce memory usage + num_generations=4, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + replay_buffer_size=8, + report_to="none", + scale_rewards=scale_rewards, + ) + trainer = GRPOWithReplayBufferTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[custom_reward_func], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gspo_token_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gspo_token_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..19391d55a188a90ad071f54f97db74f12e90dfeb --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_gspo_token_trainer.py @@ -0,0 +1,60 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import torch +from datasets import load_dataset +from transformers.utils import is_peft_available + +from trl import GRPOConfig +from trl.experimental.gspo_token import GRPOTrainer as GSPOTokenTrainer + +from ..testing_utils import TrlTestCase + + +if is_peft_available(): + pass + + +class TestGSPOTokenTrainer(TrlTestCase): + def test_training(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_iterations=2, # the importance sampling weights won't be 0 in this case + importance_sampling_level="sequence_token", + report_to="none", + ) + trainer = GSPOTokenTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_kto_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_kto_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..2f1af929a7eac8bf12070754409f76ad5935d77f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_kto_trainer.py @@ -0,0 +1,318 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import multiprocess +import pytest +import torch +from datasets import Dataset, load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer + +from trl.experimental.kto import KTOConfig, KTOTrainer +from trl.experimental.kto.kto_trainer import _get_kl_dataset + +from ..testing_utils import TrlTestCase, require_liger_kernel, require_peft + + +class TestKTOTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.ref_model = AutoModelForCausalLM.from_pretrained(self.model_id) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + @pytest.mark.parametrize( + "config_name, loss_type, pre_compute, eval_dataset", + [ + ("standard_preference", "kto", True, True), + ("standard_unpaired_preference", "kto", False, True), + ("conversational_implicit_prompt_preference", "apo_zero_unpaired", True, True), + ("standard_unpaired_preference", "apo_zero_unpaired", False, True), + ], + ) + def test_kto_trainer(self, config_name, loss_type, pre_compute, eval_dataset): + training_args = KTOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + eval_strategy="steps" if eval_dataset else "no", + beta=0.1, + precompute_ref_log_probs=pre_compute, + loss_type=loss_type, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = KTOTrainer( + model=self.model, + ref_model=self.ref_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"] if eval_dataset else None, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + def test_kto_trainer_with_ref_model_is_model(self): + training_args = KTOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + with pytest.raises(ValueError): + KTOTrainer( + model=self.model, + ref_model=self.model, # ref_model can't be the same as model + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + ) + + def test_tokenize_and_process_tokens(self): + # Pytest/CI often starts background threads before tests run. Under Python 3.12+, + # using "fork" in a multi-threaded process emits a DeprecationWarning and may deadlock. + # Force "spawn" to keep this multiprocessing test safe while still exercising `num_proc=2`. + multiprocess.set_start_method("spawn", force=True) + + training_args = KTOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + train_dataset = dummy_dataset["train"] + + trainer = KTOTrainer( + model=self.model, + ref_model=self.ref_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=train_dataset, + eval_dataset=dummy_dataset["test"], + ) + + # Verify the tokenization step: dataset stores raw token IDs (aligned with DPO style). + # prompt_ids must start with the tokenized prompt text. + prompt_ids = self.tokenizer(train_dataset["prompt"][0])["input_ids"] + assert trainer.train_dataset[0]["prompt_ids"][: len(prompt_ids)] == prompt_ids + # completion_ids are the raw answer tokens (no prompt prefix, no BOS/EOS added yet). + assert len(trainer.train_dataset[0]["completion_ids"]) > 0 + + # Verify the collator output (assembly, BOS/EOS insertion, labels). + example = trainer.train_dataset[0] + batch = trainer.data_collator([example]) + # completion_input_ids ends with EOS + assert batch["completion_input_ids"][0, -1].item() == self.tokenizer.eos_token_id + # completion_labels: prompt prefix masked with -100, answer+EOS unmasked and matching input_ids + completion_input_ids = batch["completion_input_ids"][0].tolist() + completion_labels = batch["completion_labels"][0].tolist() + first_unmasked = next(i for i, lbl in enumerate(completion_labels) if lbl != -100) + assert first_unmasked > 0 # at least the prompt is masked + assert completion_labels[first_unmasked:] == completion_input_ids[first_unmasked:] + + # Test corruption of (prompt, completion) pairs for KL dataset. + # _get_kl_dataset shifts completion_ids by one within each batch; prompt_ids are unchanged. + synthetic = Dataset.from_dict( + { + "prompt_ids": [[1, 2], [3, 4], [5, 6]], + "completion_ids": [[10, 11], [20, 21], [30, 31]], + "label": [True, False, True], + } + ) + for batch_size in [2, 3]: + rotated = synthetic.map(_get_kl_dataset, batched=True, batch_size=batch_size) + + # Verify that completion_ids have been rotated (differ from original). When the dataset length + # modulo batch_size equals 1, the last batch is unaltered: exclude it from the check. + for i in range(len(rotated) - 1): + assert synthetic["prompt_ids"][i] == rotated["prompt_ids"][i] + assert synthetic["completion_ids"][i] != rotated["completion_ids"][i] + + def test_kto_trainer_without_providing_ref_model(self): + training_args = KTOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=4, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + trainer = KTOTrainer( + model=self.model, + ref_model=None, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + @require_peft + def test_kto_trainer_without_providing_ref_model_with_lora(self): + from peft import LoraConfig + + lora_config = LoraConfig( + r=16, + lora_alpha=32, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + ) + + training_args = KTOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=4, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + trainer = KTOTrainer( + model=self.model, + ref_model=None, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + peft_config=lora_config, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + if "lora" in n: + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + @require_liger_kernel + def test_kto_trainer_with_liger(self): + """Test KTO trainer with Liger kernel enabled.""" + training_args = KTOConfig( + output_dir=self.tmp_dir, + report_to="none", + use_liger_kernel=True, # Enable Liger kernel + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + trainer = KTOTrainer( + model=self.model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # check the params have changed - ignore 0 biases + if param.sum() != 0: + assert not torch.equal(param, new_param) + + def test_compute_metrics(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + ref_model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + tokenizer.pad_token = tokenizer.eos_token + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_unpaired_preference") + + def dummy_compute_metrics(*args, **kwargs): + return {"test": 0.0} + + training_args = KTOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, + per_device_train_batch_size=2, + do_eval=True, + eval_strategy="steps", + eval_steps=1, + per_device_eval_batch_size=2, + report_to="none", + ) + + trainer = KTOTrainer( + model=model, + ref_model=ref_model, + args=training_args, + processing_class=tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + trainer.train() + + assert trainer.state.log_history[-2]["eval_test"] == 0.0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_merge_model_callback.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_merge_model_callback.py new file mode 100644 index 0000000000000000000000000000000000000000..fb63ac40c448dc560f132933984d38ed77eb9fc3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_merge_model_callback.py @@ -0,0 +1,84 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os + +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer +from transformers.trainer_utils import get_last_checkpoint + +from trl import DPOConfig, DPOTrainer +from trl.experimental.merge_model_callback import MergeConfig, MergeModelCallback + +from ..testing_utils import TrlTestCase, require_mergekit + + +@require_mergekit +class TestMergeModelCallback(TrlTestCase): + def setup_method(self): + self.model = AutoModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32" + ) + self.tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + self.dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + def test_callback(self): + training_args = DPOConfig( + output_dir=self.tmp_dir, + num_train_epochs=1, + report_to="none", + save_strategy="steps", + save_steps=1, + ) + config = MergeConfig() + merge_callback = MergeModelCallback(config) + trainer = DPOTrainer( + model=self.model, + args=training_args, + train_dataset=self.dataset, + processing_class=self.tokenizer, + callbacks=[merge_callback], + ) + trainer.train() + last_checkpoint = get_last_checkpoint(self.tmp_dir) + merged_path = os.path.join(last_checkpoint, "merged") + assert os.path.isdir(merged_path), "Merged folder does not exist in the last checkpoint." + + def test_every_checkpoint(self): + training_args = DPOConfig( + output_dir=self.tmp_dir, + num_train_epochs=1, + report_to="none", + save_strategy="steps", + save_steps=1, + ) + config = MergeConfig() + merge_callback = MergeModelCallback(config, merge_at_every_checkpoint=True) + trainer = DPOTrainer( + model=self.model, + args=training_args, + train_dataset=self.dataset, + processing_class=self.tokenizer, + callbacks=[merge_callback], + ) + trainer.train() + + checkpoints = sorted( + [os.path.join(self.tmp_dir, cp) for cp in os.listdir(self.tmp_dir) if cp.startswith("checkpoint-")] + ) + + for checkpoint in checkpoints: + merged_path = os.path.join(checkpoint, "merged") + assert os.path.isdir(merged_path), f"Merged folder does not exist in checkpoint {checkpoint}." diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_minillm_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_minillm_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9f3726f942ac39e85d641301592a60fec967df --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_minillm_trainer.py @@ -0,0 +1,57 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset + +from trl.experimental.minillm import MiniLLMConfig, MiniLLMTrainer + +from ..testing_utils import TrlTestCase + + +@pytest.mark.low_priority +class TestMiniLLMTrainer(TrlTestCase): + def test_train(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Initialize the trainer + training_args = MiniLLMConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=32, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = MiniLLMTrainer( + model="trl-internal-testing/small-Qwen3ForCausalLM", + teacher_model="trl-internal-testing/tiny-Qwen3ForCausalLM", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_modeling_value_head.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_modeling_value_head.py new file mode 100644 index 0000000000000000000000000000000000000000..0ba87e8dc1913db87377b83f0cd2712f8c322af7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_modeling_value_head.py @@ -0,0 +1,99 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import torch + +from trl.experimental.ppo import AutoModelForCausalLMWithValueHead +from trl.experimental.utils import create_reference_model + +from ..testing_utils import TrlTestCase + + +class TestReferenceModel(TrlTestCase): + def setup_method(self): + self.model = AutoModelForCausalLMWithValueHead.from_pretrained("trl-internal-testing/tiny-GPT2LMHeadModel") + self.test_input = torch.tensor([[0, 1, 2, 3]]) + self.optimizer = torch.optim.AdamW(self.model.parameters(), lr=1) + self.layer_format = "pretrained_model.transformer.h.{layer}.attn.c_attn.weight" + + def test_independent_reference(self): + layer_0 = self.layer_format.format(layer=0) + layer_1 = self.layer_format.format(layer=1) + + ref_model = create_reference_model(self.model) + + first_layer_before = self.model.get_parameter(layer_0).data.clone() + last_layer_before = self.model.get_parameter(layer_1).data.clone() # the model only has 2 layers + + first_ref_layer_before = ref_model.get_parameter(layer_0).data.clone() + last_ref_layer_before = ref_model.get_parameter(layer_1).data.clone() + + output = self.model(input_ids=self.test_input, labels=self.test_input) + output[1].backward() + self.optimizer.step() + + first_layer_after = self.model.get_parameter(layer_0).data.clone() + last_layer_after = self.model.get_parameter(layer_1).data.clone() + + first_ref_layer_after = ref_model.get_parameter(layer_0).data.clone() + last_ref_layer_after = ref_model.get_parameter(layer_1).data.clone() + + # before optimization ref and model are identical + assert (first_layer_before == first_ref_layer_before).all() + assert (last_layer_before == last_ref_layer_before).all() + + # ref model stays identical after optimization + assert (first_ref_layer_before == first_ref_layer_after).all() + assert (last_ref_layer_before == last_ref_layer_after).all() + + # optimized model changes + assert not (first_layer_before == first_layer_after).all() + assert not (last_layer_before == last_layer_after).all() + + def test_shared_layers(self): + layer_0 = self.layer_format.format(layer=0) + layer_1 = self.layer_format.format(layer=1) + + ref_model = create_reference_model(self.model, num_shared_layers=1) + + first_layer_before = self.model.get_parameter(layer_0).data.clone() + second_layer_before = self.model.get_parameter(layer_1).data.clone() + + first_ref_layer_before = ref_model.get_parameter(layer_0).data.clone() + second_ref_layer_before = ref_model.get_parameter(layer_1).data.clone() + + output = self.model(input_ids=self.test_input, labels=self.test_input) + output[1].backward() + self.optimizer.step() + + first_layer_after = self.model.get_parameter(layer_0).data.clone() + second_layer_after = self.model.get_parameter(layer_1).data.clone() + + first_ref_layer_after = ref_model.get_parameter(layer_0).data.clone() + second_ref_layer_after = ref_model.get_parameter(layer_1).data.clone() + + # before optimization ref and model are identical + assert (first_layer_before == first_ref_layer_before).all() + assert (second_layer_before == second_ref_layer_before).all() + + # ref model stays identical after optimization + assert (first_ref_layer_before == first_ref_layer_after).all() + assert (second_ref_layer_before == second_ref_layer_after).all() + + # first layer of optimized model stays the same + assert (first_layer_before == first_layer_after).all() + + # other layers in optimized model change + assert not (second_layer_before == second_layer_after).all() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_nash_md_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_nash_md_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..690d130fc712c9cc35cb9943d2fdef30c032c102 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_nash_md_trainer.py @@ -0,0 +1,198 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer, GenerationConfig +from transformers.utils import is_peft_available + +from trl.experimental.nash_md import NashMDConfig, NashMDTrainer +from trl.experimental.nash_md.nash_md_trainer import GeometricMixtureWrapper +from trl.experimental.utils import create_reference_model + +from ..testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +class TestGeometricMixtureWrapper(TrlTestCase): + def setup_method(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.device = "cuda" if torch.cuda.is_available() else "cpu" + self.model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32").to(self.device) + self.ref_model = create_reference_model(self.model).to(self.device) + self.generation_config = GenerationConfig.from_pretrained(model_id) + self.mixture_coef = 0.5 + self.wrapper = GeometricMixtureWrapper( + self.model, self.ref_model, self.generation_config, mixture_coef=self.mixture_coef + ) + + def test_forward(self): + input_ids = torch.tensor([[1, 2, 3, 4, 5]], device=self.device) + attention_mask = torch.ones_like(input_ids) + + output = self.wrapper(input_ids=input_ids, attention_mask=attention_mask) + + assert output is not None + assert hasattr(output, "logits") + assert output.logits.shape == (1, 5, self.model.config.vocab_size) + + def test_mixture_coefficient(self): + input_ids = torch.tensor([[1, 2, 3, 4, 5]], device=self.device) + attention_mask = torch.ones_like(input_ids) + + with torch.no_grad(): + model_output = self.model(input_ids=input_ids, attention_mask=attention_mask) + ref_model_output = self.ref_model(input_ids=input_ids, attention_mask=attention_mask) + wrapper_output = self.wrapper(input_ids=input_ids, attention_mask=attention_mask) + + expected_logits = torch.nn.functional.log_softmax( + self.mixture_coef * ref_model_output.logits + (1 - self.mixture_coef) * model_output.logits, dim=-1 + ) + + torch.testing.assert_close(wrapper_output.logits, expected_logits) + + def test_prepare_inputs_for_generation(self): + input_ids = torch.tensor([[1, 2, 3, 4, 5]], device=self.device) + attention_mask = torch.ones_like(input_ids) + + inputs = self.wrapper.prepare_inputs_for_generation(input_ids, attention_mask=attention_mask, use_cache=True) + + assert "input_ids" in inputs + assert "attention_mask" in inputs + assert not inputs.get("use_cache", False) + + +class TestNashMDTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.ref_model = AutoModelForCausalLM.from_pretrained(self.model_id) + self.reward_model = AutoModelForSequenceClassification.from_pretrained(self.model_id, num_labels=1) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_nash_md_trainer_training(self, config_name): + training_args = NashMDConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = NashMDTrainer( + model=self.model, + ref_model=self.ref_model, + reward_funcs=self.reward_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_with_peft(self): + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, bias="none", task_type="CAUSAL_LM") + training_args = NashMDConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = NashMDTrainer( + model=self.model, + reward_funcs=self.reward_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + peft_config=lora_config, + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_with_peft_and_ref_model(self): + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, bias="none", task_type="CAUSAL_LM") + training_args = NashMDConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = NashMDTrainer( + model=self.model, + ref_model=self.ref_model, + reward_funcs=self.reward_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + peft_config=lora_config, + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_pre_pefted_model_implicit_ref_with_reward_model(self): + lora_config = LoraConfig(r=8, lora_alpha=16, lora_dropout=0.1, bias="none", task_type="CAUSAL_LM") + # self.model from setUp is a base AutoModelForCausalLM + peft_model_instance = get_peft_model(self.model, lora_config) + + training_args = NashMDConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=1, # Keep small for quick test + max_steps=2, # Few steps + learning_rate=5.0e-7, + eval_strategy="no", + report_to="none", + remove_unused_columns=False, # Important for the dummy dataset + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only")["train"] + + trainer = NashMDTrainer( + model=peft_model_instance, # Pass the already PEFT model + ref_model=None, # Implicit reference from peft_model_instance's base + reward_funcs=self.reward_model, # To trigger GeometricMixtureWrapper path + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset, + # peft_config is not passed, as model is already PEFT + ) + + trainer.train() + + assert "train_loss" in trainer.state.log_history[-1] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_online_dpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_online_dpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..d074762f7bae3503756aad8d62d986aaa8a00c79 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_online_dpo_trainer.py @@ -0,0 +1,442 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +from datasets import Dataset, features, load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer +from transformers.utils import is_peft_available, is_vision_available + +from trl.experimental.online_dpo import OnlineDPOConfig, OnlineDPOTrainer + +from ..testing_utils import TrlTestCase, require_peft, require_torch_accelerator, require_vision, require_vllm + + +if is_peft_available(): + from peft import LoraConfig + +if is_vision_available(): + import numpy as np + from PIL import Image + from transformers import AutoModelForImageTextToText, AutoProcessor + + +class TestOnlineDPOTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.ref_model = AutoModelForCausalLM.from_pretrained(self.model_id) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + self.reward_model_id = "trl-internal-testing/tiny-LlamaForCausalLM-3.2" + self.reward_model = AutoModelForSequenceClassification.from_pretrained(self.reward_model_id, num_labels=1) + self.reward_tokenizer = AutoTokenizer.from_pretrained(self.reward_model_id) + self.reward_tokenizer.pad_token = self.reward_tokenizer.eos_token + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_training(self, config_name): + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = OnlineDPOTrainer( + model=self.model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + def test_training_model_str(self): + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = OnlineDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + def test_training_with_ref_model(self): + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = OnlineDPOTrainer( + model=self.model, + ref_model=self.ref_model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + def test_ref_model_is_model(self): + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + with pytest.raises(ValueError): + OnlineDPOTrainer( + model=self.model, + ref_model=self.model, # ref_model can't be the same as model + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + + @require_peft + def test_training_with_peft(self): + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, bias="none", task_type="CAUSAL_LM") + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = OnlineDPOTrainer( + model=self.model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + peft_config=lora_config, + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_with_peft_and_ref_model(self): + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, bias="none", task_type="CAUSAL_LM") + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = OnlineDPOTrainer( + model=self.model, + ref_model=self.ref_model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + peft_config=lora_config, + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + @require_torch_accelerator + @require_vllm + @pytest.mark.slow + def test_training_with_vllm_server(self, config_name): + def cleanup_vllm_communicator(trainer): + """Clean up vLLM communicator to avoid conflicts between test runs""" + try: + if hasattr(trainer, "vllm_client") and trainer.vllm_client is not None: + trainer.vllm_client.close_communicator() + except Exception: + pass # Continue if cleanup fails + + model_id = "trl-internal-testing/small-Qwen2ForCausalLM-2.5" # We need a bigger model + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_id) + tokenizer.pad_token = tokenizer.eos_token + + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + use_vllm=True, + vllm_mode="server", + vllm_gpu_memory_utilization=0.2, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = OnlineDPOTrainer( + model=model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + + # Ensure cleanup of vLLM communicator after the test + try: + trainer.train() + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + finally: + cleanup_vllm_communicator(trainer) + + @require_vllm + def test_training_with_vllm_colocate(self): + """Test vLLM colocate mode with our refactored implementation""" + model_id = "trl-internal-testing/small-Qwen2ForCausalLM-2.5" # We need a bigger model + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_id) + tokenizer.pad_token = tokenizer.eos_token + + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + use_vllm=True, + vllm_mode="colocate", + vllm_gpu_memory_utilization=0.2, + per_device_train_batch_size=1, + max_steps=2, + report_to="none", + # Test generation parameters + temperature=0.9, + top_p=0.95, + top_k=50, + repetition_penalty=1.1, + max_new_tokens=32, + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = OnlineDPOTrainer( + model=model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + + # Verify vLLM setup + assert trainer.use_vllm + assert trainer.vllm_mode == "colocate" + assert trainer.llm is not None + # self.assertIsNone(trainer.vllm_client) + # self.assertEqual(trainer.vllm_gpu_memory_utilization, 0.2) + + # Verify generation parameters + assert trainer.temperature == 0.9 + assert trainer.top_p == 0.95 + assert trainer.top_k == 50 + assert trainer.repetition_penalty == 1.1 + + # Verify generation config + assert trainer.generation_config is not None + assert trainer.generation_config.temperature == 0.9 + assert trainer.generation_config.top_p == 0.95 + assert trainer.generation_config.top_k == 50 + assert trainer.generation_config.repetition_penalty == 1.1 + assert trainer.generation_config.max_tokens == 32 + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + def test_vllm_config_validation(self): + """Test vLLM configuration validation""" + # Test valid vllm_mode values + config = OnlineDPOConfig(use_vllm=True, vllm_mode="server") + assert config.vllm_mode == "server" + + config = OnlineDPOConfig(use_vllm=True, vllm_mode="colocate") + assert config.vllm_mode == "colocate" + + # Test default values + config = OnlineDPOConfig() + assert config.vllm_mode == "colocate" + assert config.vllm_server_base_url is None + assert config.vllm_server_host == "0.0.0.0" + assert config.vllm_server_port == 8000 + assert config.vllm_server_timeout == 240.0 + assert config.vllm_gpu_memory_utilization == 0.55 + + # Test generation parameters + assert config.top_p == 1.0 + assert config.top_k == 0 + assert config.min_p is None + assert config.repetition_penalty == 1.0 + assert config.cache_implementation is None + assert config.generation_kwargs is None + + def test_generation_config_setup(self): + """Test that generation configuration is properly set up for both vLLM and transformers""" + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + use_vllm=False, + temperature=0.8, + top_p=0.9, + top_k=40, + repetition_penalty=1.2, + max_new_tokens=64, + generation_kwargs={"do_sample": False}, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = OnlineDPOTrainer( + model=self.model, + reward_funcs=self.reward_model, + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + reward_processing_classes=self.reward_tokenizer, + ) + + # Verify transformers generation config + assert not trainer.use_vllm + # When not using vLLM, these attributes should not be set + assert not (hasattr(trainer, "llm") and trainer.llm is not None) + assert not (hasattr(trainer, "vllm_client") and trainer.vllm_client is not None) + assert trainer.generation_config is not None + assert trainer.generation_config.temperature == 0.8 + assert trainer.generation_config.top_p == 0.9 + assert trainer.generation_config.top_k == 40 + assert trainer.generation_config.repetition_penalty == 1.2 + assert trainer.generation_config.max_new_tokens == 64 + assert not trainer.generation_config.do_sample # From generation_kwargs + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_training_with_reward_funcs(self, config_name): + def simple_reward_func(prompts, completions, completion_ids, **kwargs): + return [0.5 for _ in prompts] + + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + reward_weights=[0.7, 0.3], + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = OnlineDPOTrainer( + model=self.model, + reward_funcs=[simple_reward_func, simple_reward_func], + args=training_args, + train_dataset=dummy_dataset["train"], + processing_class=self.tokenizer, + ) + trainer.train() + + assert "train_loss" in trainer.state.log_history[-1] + assert len(trainer.reward_funcs) == 2 + assert trainer.reward_weights is not None + assert round(abs(trainer.reward_weights[0].item() - 0.7), 5) == 0 + assert round(abs(trainer.reward_weights[1].item() - 0.3), 5) == 0 + + +@require_vision +class TestOnlineDPOVisionTrainer(TrlTestCase): + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Idefics2ForConditionalGeneration", + "trl-internal-testing/tiny-LlavaForConditionalGeneration", + ], + ) + def test_online_dpo_vlm_trainer(self, model_id): + dataset_dict = { + "prompt": [ + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Describe the image."}]}], + [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What do you see?"}]}], + ], + "images": [ + [Image.fromarray(np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8))], + [Image.fromarray(np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8))], + ], + } + dataset = Dataset.from_dict(dataset_dict) + dataset = dataset.cast_column("images", features.Sequence(features.Image())) + + model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="float32") + reward_model = AutoModelForSequenceClassification.from_pretrained( + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", num_labels=1 + ) + processor = AutoProcessor.from_pretrained(model_id) + reward_tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-LlamaForCausalLM-3.2") + reward_tokenizer.pad_token = reward_tokenizer.eos_token + + training_args = OnlineDPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=1, + max_steps=2, + learning_rate=0.01, + report_to="none", + ) + trainer = OnlineDPOTrainer( + model=model, + reward_funcs=reward_model, + args=training_args, + processing_class=processor, + train_dataset=dataset, + eval_dataset=dataset, + reward_processing_classes=reward_tokenizer, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_orpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_orpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..e7c6bbb5917bc4092b32ab333770a45eafef5b09 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_orpo_trainer.py @@ -0,0 +1,177 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizer + +from trl.experimental.orpo import ORPOConfig, ORPOTrainer + +from ..testing_utils import TrlTestCase, require_peft + + +class TestORPOTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + # get t5 as seq2seq example: + model_id = "trl-internal-testing/tiny-T5ForConditionalGeneration" + self.t5_model = AutoModelForSeq2SeqLM.from_pretrained(model_id, dtype="float32") + self.t5_tokenizer = AutoTokenizer.from_pretrained(model_id) + + @pytest.mark.parametrize( + "name, config_name", + [ + ("qwen", "standard_preference"), + ("t5", "standard_implicit_prompt_preference"), + ("qwen", "conversational_preference"), + ], + ) + def test_orpo_trainer(self, name, config_name): + training_args = ORPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + if name == "qwen": + model = self.model + tokenizer = self.tokenizer + elif name == "t5": + model = self.t5_model + tokenizer = self.t5_tokenizer + training_args.is_encoder_decoder = True + + trainer = ORPOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + @pytest.mark.parametrize( + "config_name", + [ + "standard_preference", + "standard_implicit_prompt_preference", + "conversational_preference", + "conversational_implicit_prompt_preference", + ], + ) + @require_peft + def test_orpo_trainer_with_lora(self, config_name): + from peft import LoraConfig + + lora_config = LoraConfig( + r=16, + lora_alpha=32, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + ) + + training_args = ORPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=4, + learning_rate=9e-1, + eval_strategy="steps", + beta=0.1, + report_to="none", + ) + + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = ORPOTrainer( + model=self.model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + peft_config=lora_config, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + if "lora" in n: + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.equal(param, new_param) + + def test_compute_metrics(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + tokenizer.pad_token = tokenizer.eos_token + + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + def dummy_compute_metrics(*args, **kwargs): + return {"test": 0.0} + + training_args = ORPOConfig( + output_dir=self.tmp_dir, + remove_unused_columns=False, + per_device_train_batch_size=2, + do_eval=True, + eval_strategy="steps", + eval_steps=1, + per_device_eval_batch_size=2, + report_to="none", + ) + + trainer = ORPOTrainer( + model=model, + args=training_args, + processing_class=tokenizer, + train_dataset=dummy_dataset["train"], + eval_dataset=dummy_dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + trainer.train() + + assert trainer.state.log_history[-2]["eval_test"] == 0.0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_ppo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_ppo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..b3aea763ee3c83c1420a89f56fa6f5fcbedc83f2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_ppo_trainer.py @@ -0,0 +1,829 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import os + +import pytest +import torch +from datasets import load_dataset +from transformers import ( + AutoModelForCausalLM, + AutoModelForSeq2SeqLM, + AutoModelForSequenceClassification, + AutoTokenizer, + GenerationConfig, +) +from transformers.utils import is_peft_available + +from trl.experimental.ppo import ( + AutoModelForCausalLMWithValueHead, + AutoModelForSeq2SeqLMWithValueHead, + PPOConfig, + PPOTrainer, +) +from trl.experimental.ppo.ppo_trainer import batch_generation, masked_mean, masked_var, masked_whiten + +from ..testing_utils import ( + TrlTestCase, + require_bitsandbytes, + require_peft, + require_torch_gpu_if_bnb_not_multi_backend_enabled, +) + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +ALL_CAUSAL_LM_MODELS = [ + "trl-internal-testing/tiny-BloomForCausalLM", + "trl-internal-testing/tiny-CohereForCausalLM", + # "trl-internal-testing/tiny-FalconMambaForCausalLM", # FalconMambaForCausalLM modeling seems to be broken for now + "trl-internal-testing/tiny-Gemma2ForCausalLM", + "trl-internal-testing/tiny-GemmaForCausalLM", + "trl-internal-testing/tiny-GPT2LMHeadModel", + "trl-internal-testing/tiny-GPTNeoXForCausalLM", + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-LlamaForCausalLM-3", + "trl-internal-testing/tiny-MistralForCausalLM-0.1", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + "trl-internal-testing/tiny-OPTForCausalLM", + "trl-internal-testing/tiny-Phi3ForCausalLM-3", + "trl-internal-testing/tiny-Phi3ForCausalLM-3.5", + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", +] + +ALL_SEQ2SEQ_MODELS = [ + "trl-internal-testing/tiny-T5ForConditionalGeneration", + "trl-internal-testing/tiny-BartModel", +] + + +class TestBatchGeneration(TrlTestCase): + def setup_method(self): + # Initialize the tokenizer + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.device = "cuda" if torch.cuda.is_available() else "cpu" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32").to(self.device) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + + self.generation_config = GenerationConfig( + max_new_tokens=128, + temperature=0.5, + do_sample=True, + top_k=0, + pad_token_id=self.tokenizer.pad_token_id, + ) + + # Example input + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + self.examples = dataset["messages"] + self.mini_batch_size = 3 + + def test_mini_batch_generation(self): + batch = [ + self.tokenizer.apply_chat_template(example[:-1], add_generation_prompt=True, tokenize=False) + for example in self.examples + ] + queries = self.tokenizer(batch, padding=True, return_tensors="pt")["input_ids"].to(self.device) + bs, context_length = queries.shape + + query_responses, logits = batch_generation( + self.model, queries, self.mini_batch_size, self.tokenizer.pad_token_id, self.generation_config + ) + + max_length_query = query_responses.shape[1] + max_length_logits = max_length_query - context_length + + assert max_length_query > context_length + assert query_responses.shape == (bs, max_length_query) + assert logits.shape == (bs, max_length_logits, self.model.config.vocab_size) + + def test_single_batch_generation(self): + batch = [ + self.tokenizer.apply_chat_template(example[:-1], add_generation_prompt=True, tokenize=False) + for example in self.examples + ] + queries = self.tokenizer(batch, padding=True, return_tensors="pt")["input_ids"].to(self.device) + bs, context_length = queries.shape + + query_responses, logits = batch_generation( + self.model, queries, bs, self.tokenizer.pad_token_id, self.generation_config + ) + + max_length_query = query_responses.shape[1] + max_length_logits = max_length_query - context_length + + assert max_length_query > context_length + assert query_responses.shape == (bs, max_length_query) + assert logits.shape == (bs, max_length_logits, self.model.config.vocab_size) + + +class BaseTester: + class VHeadModelTester(TrlTestCase): + all_model_names = None + trl_model_class = None + transformers_model_class = None + + def setup_method(self): + self.device = "cuda" if torch.cuda.is_available() else "cpu" + + def test_value_head(self): + r""" + Test if the v-head is added to the model successfully + """ + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name) + assert hasattr(model, "v_head") + + def test_value_head_shape(self): + r""" + Test if the v-head has the correct shape + """ + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name) + assert model.v_head.summary.weight.shape[0] == 1 + + def test_value_head_init_random(self): + r""" + Test if the v-head has been randomly initialized. We can check that by making sure the bias is different + than zeros by default. + """ + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name) + assert not torch.allclose(model.v_head.summary.bias, torch.zeros_like(model.v_head.summary.bias)) + + def test_value_head_not_str(self): + r""" + Test if the v-head is added to the model successfully, by passing a non `PretrainedModel` as an argument to + `from_pretrained`. + """ + for model_name in self.all_model_names: + pretrained_model = self.transformers_model_class.from_pretrained(model_name) + model = self.trl_model_class.from_pretrained(pretrained_model) + assert hasattr(model, "v_head") + + def test_from_save_trl(self): + """ + Test if the model can be saved and loaded from a directory and get the same weights, including the + additional modules (e.g. v_head) + """ + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name) + + model.save_pretrained(self.tmp_dir) + + model_from_save = self.trl_model_class.from_pretrained(self.tmp_dir) + + # Check if the weights are the same + for key in model_from_save.state_dict(): + torch.testing.assert_close(model_from_save.state_dict()[key], model.state_dict()[key]) + + def test_from_save_trl_sharded(self): + """ + Test if the model can be saved and loaded from a directory and get the same weights - sharded case + """ + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name) + + model.save_pretrained(self.tmp_dir) + + model_from_save = self.trl_model_class.from_pretrained(self.tmp_dir) + + # Check if the weights are the same + for key in model_from_save.state_dict(): + torch.testing.assert_close(model_from_save.state_dict()[key], model.state_dict()[key]) + + def test_from_save_transformers_sharded(self): + """ + Test if the model can be saved and loaded using transformers and get the same weights - sharded case + """ + for model_name in self.all_model_names: + transformers_model = self.trl_model_class.transformers_parent_class.from_pretrained(model_name) + + trl_model = self.trl_model_class.from_pretrained(model_name) + + trl_model.save_pretrained(self.tmp_dir, max_shard_size="1MB") + transformers_model_from_save = self.trl_model_class.transformers_parent_class.from_pretrained( + self.tmp_dir + ) + + # Check if the weights are the same + for key in transformers_model.state_dict(): + torch.testing.assert_close( + transformers_model_from_save.state_dict()[key], transformers_model.state_dict()[key] + ) + + def test_from_save_transformers(self): + """ + Test if the model can be saved and loaded using transformers and get the same weights. We override the test + of the super class to check if the weights are the same. + """ + for model_name in self.all_model_names: + transformers_model = self.trl_model_class.transformers_parent_class.from_pretrained(model_name) + + trl_model = self.trl_model_class.from_pretrained(model_name) + + trl_model.save_pretrained(self.tmp_dir) + transformers_model_from_save = self.trl_model_class.transformers_parent_class.from_pretrained( + self.tmp_dir + ) + + # Check if the weights are the same + for key in transformers_model.state_dict(): + torch.testing.assert_close( + transformers_model_from_save.state_dict()[key], transformers_model.state_dict()[key] + ) + + # Check if the trl model has the same keys as the transformers model + # except the v_head + for key in trl_model.state_dict(): + if "v_head" not in key: + assert key in transformers_model.state_dict() + # check if the weights are the same + torch.testing.assert_close(trl_model.state_dict()[key], transformers_model.state_dict()[key]) + + # check if they have the same modules + assert set(transformers_model_from_save.state_dict().keys()) == set( + transformers_model.state_dict().keys() + ) + + +class TestCausalLMValueHeadModel(BaseTester.VHeadModelTester, TrlTestCase): + """ + Testing suite for v-head models. + """ + + all_model_names = ALL_CAUSAL_LM_MODELS + trl_model_class = AutoModelForCausalLMWithValueHead + transformers_model_class = AutoModelForCausalLM + + def teardown_method(self): + # free memory + gc.collect() + + def test_inference(self): + r""" + Test if the model can be used for inference and outputs 3 values + - logits, loss, and value states + """ + EXPECTED_OUTPUT_SIZE = 3 + + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name).to(self.device) + input_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], device=self.device) + outputs = model(input_ids) + + # Check if the outputs are of the right size - here + # we always output 3 values - logits, loss, and value states + assert len(outputs) == EXPECTED_OUTPUT_SIZE + + def test_dropout_config(self): + r""" + Test if we instantiate a model by adding `summary_drop_prob` to the config it will be added to the v_head + """ + for model_name in self.all_model_names: + pretrained_model = self.transformers_model_class.from_pretrained(model_name) + pretrained_model.config.summary_dropout_prob = 0.5 + model = self.trl_model_class.from_pretrained(pretrained_model) + + # Check if v head of the model has the same dropout as the config + assert model.v_head.dropout.p == pretrained_model.config.summary_dropout_prob + + def test_dropout_kwargs(self): + r""" + Test if we instantiate a model by adding `summary_drop_prob` to the config it will be added to the v_head + """ + for model_name in self.all_model_names: + v_head_kwargs = {"summary_dropout_prob": 0.5} + + model = self.trl_model_class.from_pretrained(model_name, **v_head_kwargs) + + # Check if v head of the model has the same dropout as the config + assert model.v_head.dropout.p == 0.5 + + model = self.trl_model_class.from_pretrained(model_name, summary_dropout_prob=0.5) + + # Check if v head of the model has the same dropout as the config + assert model.v_head.dropout.p == 0.5 + + @pytest.mark.parametrize("model_name", ALL_CAUSAL_LM_MODELS) + def test_generate(self, model_name): + r""" + Test if `generate` works for every model + """ + generation_config = GenerationConfig(max_new_tokens=9) + model = self.trl_model_class.from_pretrained(model_name).to(self.device) + input_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], device=self.device) + + # Just check if the generation works + _ = model.generate(input_ids, generation_config=generation_config) + + def test_transformers_bf16_kwargs(self): + r""" + Test if the transformers kwargs are correctly passed. Here we check that loading a model in half precision + works as expected, i.e. the weights of the `pretrained_model` attribute is loaded in half precision and you can + run a dummy forward pass without any issue. + """ + for model_name in self.all_model_names: + trl_model = self.trl_model_class.from_pretrained(model_name, dtype=torch.bfloat16).to(self.device) + + lm_head_namings = ["lm_head", "embed_out", "output_layer"] + + assert any(hasattr(trl_model.pretrained_model, lm_head_naming) for lm_head_naming in lm_head_namings), ( + "Can't test the model because it doesn't have any of the expected lm_head namings" + ) + + for lm_head_naming in lm_head_namings: + if hasattr(trl_model.pretrained_model, lm_head_naming): + assert getattr(trl_model.pretrained_model, lm_head_naming).weight.dtype == torch.bfloat16 + + dummy_input = torch.LongTensor([[0, 1, 0, 1]]).to(self.device) + + # check dummy forward pass works in half precision + _ = trl_model(dummy_input) + + @pytest.mark.skip(reason="This test needs to be run manually due to HF token issue.") + def test_push_to_hub(self): + for model_name in self.all_model_names: + model = AutoModelForCausalLMWithValueHead.from_pretrained(model_name) + if "sharded" in model_name: + model.push_to_hub(model_name + "-ppo", use_auth_token=True, max_shard_size="1MB") + else: + model.push_to_hub(model_name + "-ppo", use_auth_token=True) + + model_from_pretrained = AutoModelForCausalLMWithValueHead.from_pretrained(model_name + "-ppo") + # check all keys + assert model.state_dict().keys() == model_from_pretrained.state_dict().keys() + + for name, param in model.state_dict().items(): + ( + torch.testing.assert_close(param, model_from_pretrained.state_dict()[name]), + (f"Parameter {name} is not the same after push_to_hub and from_pretrained"), + ) + + +class TestSeq2SeqValueHeadModel(BaseTester.VHeadModelTester, TrlTestCase): + """ + Testing suite for v-head models. + """ + + all_model_names = ALL_SEQ2SEQ_MODELS + trl_model_class = AutoModelForSeq2SeqLMWithValueHead + transformers_model_class = AutoModelForSeq2SeqLM + + def teardown_method(self): + # free memory + gc.collect() + + def test_inference(self): + r""" + Test if the model can be used for inference and outputs 3 values + - logits, loss, and value states + """ + EXPECTED_OUTPUT_SIZE = 3 + + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name).to(self.device) + input_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], device=self.device) + decoder_input_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], device=self.device) + outputs = model(input_ids, decoder_input_ids=decoder_input_ids) + + # Check if the outputs are of the right size - here + # we always output 3 values - logits, loss, and value states + assert len(outputs) == EXPECTED_OUTPUT_SIZE + + def test_dropout_config(self): + r""" + Test if we instantiate a model by adding `summary_drop_prob` to the config it will be added to the v_head + """ + for model_name in self.all_model_names: + pretrained_model = self.transformers_model_class.from_pretrained(model_name) + pretrained_model.config.summary_dropout_prob = 0.5 + model = self.trl_model_class.from_pretrained(pretrained_model) + + # Check if v head of the model has the same dropout as the config + assert model.v_head.dropout.p == pretrained_model.config.summary_dropout_prob + + def test_dropout_kwargs(self): + r""" + Test if we instantiate a model by adding `summary_drop_prob` to the config it will be added to the v_head + """ + for model_name in self.all_model_names: + v_head_kwargs = {"summary_dropout_prob": 0.5} + + model = self.trl_model_class.from_pretrained(model_name, **v_head_kwargs) + + # Check if v head of the model has the same dropout as the config + assert model.v_head.dropout.p == 0.5 + + model = self.trl_model_class.from_pretrained(model_name, summary_dropout_prob=0.5) + + # Check if v head of the model has the same dropout as the config + assert model.v_head.dropout.p == 0.5 + + @pytest.mark.parametrize("model_name", ALL_SEQ2SEQ_MODELS) + def test_generate(self, model_name): + r""" + Test if `generate` works for every model + """ + generation_config = GenerationConfig(max_new_tokens=9) + model = self.trl_model_class.from_pretrained(model_name).to(self.device) + input_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], device=self.device) + decoder_input_ids = torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], device=self.device) + + # Just check if the generation works + _ = model.generate(input_ids, decoder_input_ids=decoder_input_ids, generation_config=generation_config) + + @pytest.mark.skip(reason="This test needs to be run manually due to HF token issue.") + def test_push_to_hub(self): + for model_name in self.all_model_names: + model = self.trl_model_class.from_pretrained(model_name) + if "sharded" in model_name: + model.push_to_hub(model_name + "-ppo", use_auth_token=True, max_shard_size="1MB") + else: + model.push_to_hub(model_name + "-ppo", use_auth_token=True) + + model_from_pretrained = self.trl_model_class.from_pretrained(model_name + "-ppo") + # check all keys + assert model.state_dict().keys() == model_from_pretrained.state_dict().keys() + + for name, param in model.state_dict().items(): + ( + torch.testing.assert_close(param, model_from_pretrained.state_dict()[name]), + (f"Parameter {name} is not the same after push_to_hub and from_pretrained"), + ) + + def test_transformers_bf16_kwargs(self): + r""" + Test if the transformers kwargs are correctly passed. Here we check that loading a model in half precision + works as expected, i.e. the weights of the `pretrained_model` attribute is loaded in half precision and you can + run a dummy forward pass without any issue. + """ + for model_name in self.all_model_names: + trl_model = self.trl_model_class.from_pretrained(model_name, dtype=torch.bfloat16).to(self.device) + + lm_head_namings = self.trl_model_class.lm_head_namings + + assert any(hasattr(trl_model.pretrained_model, lm_head_naming) for lm_head_naming in lm_head_namings) + + for lm_head_naming in lm_head_namings: + if hasattr(trl_model.pretrained_model, lm_head_naming): + assert getattr(trl_model.pretrained_model, lm_head_naming).weight.dtype == torch.bfloat16 + + dummy_input = torch.LongTensor([[0, 1, 0, 1]]).to(self.device) + + # check dummy forward pass works in half precision + _ = trl_model(input_ids=dummy_input, decoder_input_ids=dummy_input) + + +@require_peft +class TestPeftModel(TrlTestCase): + def setup_method(self): + self.causal_lm_model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.lora_config = LoraConfig( + r=16, + lora_alpha=32, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + ) + + def test_create_peft_model(self): + r""" + Simply creates a peft model and checks that it can be loaded. + """ + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + pretrained_model = get_peft_model(causal_lm_model, self.lora_config) + + _ = AutoModelForCausalLMWithValueHead.from_pretrained(pretrained_model) + + def test_peft_requires_grad(self): + r""" + Check that the value head of the returned model has requires_grad=True. + """ + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + pretrained_model = get_peft_model(causal_lm_model, self.lora_config) + + model = AutoModelForCausalLMWithValueHead.from_pretrained(pretrained_model) + + # Check that the value head has requires_grad=True + assert model.v_head.summary.weight.requires_grad + + def test_check_peft_model_nb_trainable_params(self): + r""" + Check that the number of trainable parameters is correct. + """ + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + pretrained_model = get_peft_model(causal_lm_model, self.lora_config) + + model = AutoModelForCausalLMWithValueHead.from_pretrained(pretrained_model) + + # Check that the number of trainable parameters is correct + nb_trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad) + assert nb_trainable_params == 905 + + # Check that the number of trainable param for the non-peft model is correct + non_peft_model = AutoModelForCausalLMWithValueHead.from_pretrained(self.causal_lm_model_id) + nb_trainable_params = sum(p.numel() for p in non_peft_model.parameters() if p.requires_grad) + assert nb_trainable_params == 2428641 + + def test_create_peft_model_from_config(self): + r""" + Simply creates a peft model and checks that it can be loaded. + """ + trl_model = AutoModelForCausalLMWithValueHead.from_pretrained( + self.causal_lm_model_id, peft_config=self.lora_config + ) + # Check that the number of trainable parameters is correct + nb_trainable_params = sum(p.numel() for p in trl_model.parameters() if p.requires_grad) + assert nb_trainable_params == 905 + + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + trl_model = AutoModelForCausalLMWithValueHead.from_pretrained(causal_lm_model, peft_config=self.lora_config) + # Check that the number of trainable parameters is correct + nb_trainable_params = sum(p.numel() for p in trl_model.parameters() if p.requires_grad) + assert nb_trainable_params == 905 + + @require_bitsandbytes + @require_torch_gpu_if_bnb_not_multi_backend_enabled + def test_create_bnb_peft_model_from_config(self): + r""" + Simply creates a peft model and checks that it can be loaded. + """ + from bitsandbytes.nn import Linear8bitLt + from transformers import BitsAndBytesConfig + + trl_model = AutoModelForCausalLMWithValueHead.from_pretrained( + self.causal_lm_model_id, + peft_config=self.lora_config, + quantization_config=BitsAndBytesConfig(load_in_8bit=True), + ) + # Check that the number of trainable parameters is correct + nb_trainable_params = sum(p.numel() for p in trl_model.parameters() if p.requires_grad) + assert nb_trainable_params == 905 + assert isinstance(trl_model.pretrained_model.model.model.layers[0].mlp.gate_proj, Linear8bitLt) + + causal_lm_model = AutoModelForCausalLM.from_pretrained( + self.causal_lm_model_id, quantization_config=BitsAndBytesConfig(load_in_8bit=True), device_map="auto" + ) + trl_model = AutoModelForCausalLMWithValueHead.from_pretrained(causal_lm_model, peft_config=self.lora_config) + # Check that the number of trainable parameters is correct + nb_trainable_params = sum(p.numel() for p in trl_model.parameters() if p.requires_grad) + assert nb_trainable_params == 905 + assert isinstance(trl_model.pretrained_model.model.model.layers[0].mlp.gate_proj, Linear8bitLt) + + def test_save_pretrained_peft(self): + r""" + Check that the model can be saved and loaded properly. + """ + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + pretrained_model = get_peft_model(causal_lm_model, self.lora_config) + + model = AutoModelForCausalLMWithValueHead.from_pretrained(pretrained_model) + + model.save_pretrained(self.tmp_dir) + + # check that the files `adapter_model.safetensors` and `adapter_config.json` are in the directory + assert os.path.isfile(f"{self.tmp_dir}/adapter_model.safetensors"), ( + f"{self.tmp_dir}/adapter_model.safetensors does not exist" + ) + assert os.path.exists(f"{self.tmp_dir}/adapter_config.json"), ( + f"{self.tmp_dir}/adapter_config.json does not exist" + ) + + # check also for `pytorch_model.bin` and make sure it only contains `v_head` weights + assert os.path.exists(f"{self.tmp_dir}/pytorch_model.bin"), f"{self.tmp_dir}/pytorch_model.bin does not exist" + + # check that only keys that starts with `v_head` are in the dict + maybe_v_head = torch.load(f"{self.tmp_dir}/pytorch_model.bin", weights_only=True) + assert all(k.startswith("v_head") for k in maybe_v_head.keys()), ( + f"keys in {self.tmp_dir}/pytorch_model.bin do not start with `v_head`" + ) + + model_from_pretrained = AutoModelForCausalLMWithValueHead.from_pretrained(self.tmp_dir) + + # check all the weights are the same + for p1, p2 in zip(model.named_parameters(), model_from_pretrained.named_parameters(), strict=True): + torch.testing.assert_close(p1[1], p2[1]), f"{p1[0]} != {p2[0]}" + + def test_load_pretrained_peft(self): + r""" + Check that the model saved with peft class interface can be loaded properly. + """ + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + pretrained_model = get_peft_model(causal_lm_model, self.lora_config) + + model = AutoModelForCausalLMWithValueHead.from_pretrained(pretrained_model) + + pretrained_model.save_pretrained(self.tmp_dir) + model_from_pretrained = AutoModelForCausalLMWithValueHead.from_pretrained(self.tmp_dir) + + # check that the files `adapter_model.safetensors` and `adapter_config.json` are in the directory + assert os.path.isfile(f"{self.tmp_dir}/adapter_model.safetensors"), ( + f"{self.tmp_dir}/adapter_model.safetensors does not exist" + ) + assert os.path.exists(f"{self.tmp_dir}/adapter_config.json"), ( + f"{self.tmp_dir}/adapter_config.json does not exist" + ) + + # check all the weights are the same + for p1, p2 in zip(model.named_parameters(), model_from_pretrained.named_parameters(), strict=True): + if p1[0] not in ["v_head.summary.weight", "v_head.summary.bias"]: + torch.testing.assert_close(p1[1], p2[1]), f"{p1[0]} != {p2[0]}" + + def test_continue_training_peft_model(self): + r""" + Load peft and checks that it can continue training. + """ + causal_lm_model = AutoModelForCausalLM.from_pretrained(self.causal_lm_model_id) + pretrained_model = get_peft_model(causal_lm_model, self.lora_config) + + pretrained_model.save_pretrained(self.tmp_dir) + # set is_trainable to True + model = AutoModelForCausalLMWithValueHead.from_pretrained(self.tmp_dir, is_trainable=True) + # Check that the number of trainable parameters is correct + nb_trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad) + assert nb_trainable_params == 905 + + +class TestCore(TrlTestCase): + """ + A wrapper class for testing core utils functions + """ + + def setup_method(self): + self.test_input = torch.Tensor([1, 2, 3, 4]) + self.test_mask = torch.Tensor([0, 1, 1, 0]) + self.test_input_unmasked = self.test_input[1:3] + + def test_masked_mean(self): + assert torch.mean(self.test_input_unmasked) == masked_mean(self.test_input, self.test_mask) + + def test_masked_var(self): + assert torch.var(self.test_input_unmasked) == masked_var(self.test_input, self.test_mask) + + def test_masked_whiten(self): + def whiten(values: torch.Tensor) -> torch.Tensor: + mean, var = torch.mean(values), torch.var(values) + return (values - mean) * torch.rsqrt(var + 1e-8) + + whiten_unmasked = whiten(self.test_input_unmasked) + whiten_masked = masked_whiten(self.test_input, self.test_mask)[1:3] + diffs = (whiten_unmasked - whiten_masked).sum() + assert abs(diffs.item()) < 0.00001 + + +class TestPPOTrainer(TrlTestCase): + def setup_method(self): + # Set up the models and tokenizer using the test model + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.ref_model = AutoModelForCausalLM.from_pretrained(self.model_id) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id, padding_side="left") + self.tokenizer.add_special_tokens({"pad_token": "[PAD]"}) + + # Add reward and value models as in ppo.py + reward_model_id = "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + self.value_model = AutoModelForSequenceClassification.from_pretrained(reward_model_id, num_labels=1) + self.reward_model = AutoModelForSequenceClassification.from_pretrained(reward_model_id, num_labels=1) + + # Load dataset + raw_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + def tokenize(example, tokenizer): + tokenized = tokenizer(text=example["prompt"]) + if tokenizer.eos_token_id is not None and tokenized["input_ids"][-1] != tokenizer.eos_token_id: + tokenized["input_ids"] = tokenized["input_ids"] + [tokenizer.eos_token_id] + tokenized["attention_mask"] = tokenized["attention_mask"] + [1] + return tokenized + + self.raw_dataset = raw_dataset.map(tokenize, fn_kwargs={"tokenizer": self.tokenizer}, remove_columns="prompt") + + def test_basic_training(self): + """Test basic PPO training configuration and verify model updates.""" + # Capture initial weights + initial_critic_weights = {} + initial_policy_weights = {} + for name, param in self.value_model.named_parameters(): + initial_critic_weights[name] = param.clone().detach() + for name, param in self.model.named_parameters(): + initial_policy_weights[name] = param.clone().detach() + + # Configure training args similar to example script + training_args = PPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=4, + per_device_eval_batch_size=2, + num_ppo_epochs=2, # Decrease number of PPO epochs to speed up test + report_to="none", + ) + + # Create trainer + trainer = PPOTrainer( + args=training_args, + processing_class=self.tokenizer, + model=self.model, + ref_model=self.ref_model, + reward_model=self.reward_model, + value_model=self.value_model, + train_dataset=self.raw_dataset["train"], + eval_dataset=self.raw_dataset["test"], + ) + + # Train + trainer.train() + + # Check if critic weights have been updated + critic_weights_updated = False + for name, param in trainer.model.value_model.named_parameters(): + if not torch.allclose(initial_critic_weights[name], param.to("cpu")): + critic_weights_updated = True + break + + # Check if policy weights have been updated + policy_weights_updated = False + for name, param in trainer.model.policy.named_parameters(): + if not torch.allclose(initial_policy_weights[name], param.to("cpu")): + policy_weights_updated = True + break + + assert critic_weights_updated, "Critic weights were not updated during training" + assert policy_weights_updated, "Policy weights were not updated during training" + + @require_peft + def test_peft_training(self): + """Test PPO training with PEFT configuration and verify model updates.""" + # Capture initial weights + initial_critic_weights = {} + initial_policy_weights = {} + for name, param in self.value_model.named_parameters(): + initial_critic_weights[name] = param.clone().detach() + for name, param in self.model.named_parameters(): + initial_policy_weights[name] = param.clone().detach() + + # Configure training args + training_args = PPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=4, + per_device_eval_batch_size=2, + num_ppo_epochs=2, # Decrease number of PPO epochs to speed up test + report_to="none", + ) + + # Configure PEFT + peft_config = LoraConfig( + r=32, + lora_alpha=16, + lora_dropout=0.05, + bias="none", + task_type="CAUSAL_LM", + ) + + # Create trainer with PEFT + trainer = PPOTrainer( + args=training_args, + processing_class=self.tokenizer, + model=self.model, + ref_model=None, + reward_model=self.reward_model, + value_model=self.value_model, + train_dataset=self.raw_dataset["train"], + eval_dataset=self.raw_dataset["test"], + peft_config=peft_config, + ) + + # Train + trainer.train() + + # Check if critic weights have been updated + critic_weights_updated = False + for name, param in trainer.model.value_model.named_parameters(): + if name in initial_critic_weights and not torch.allclose(initial_critic_weights[name], param.to("cpu")): + critic_weights_updated = True + break + + # Check if policy weights have been updated - for PEFT we check the LoRA weights + policy_weights_updated = False + for name, param in trainer.model.policy.named_parameters(): + if "lora" in name.lower() and param.requires_grad: # Only check LoRA weights + # New weights should be non-zero if they've been updated + if not torch.allclose(param, torch.zeros_like(param)): + policy_weights_updated = True + break + + assert critic_weights_updated, "Critic weights were not updated during training" + assert policy_weights_updated, "Policy LoRA weights were not updated during training" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_prm_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_prm_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..28c5adcbaa5b9eea28949ea77ecd174ec0905218 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_prm_trainer.py @@ -0,0 +1,376 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from unittest.mock import MagicMock + +import numpy as np +import pytest +import torch +from datasets import Dataset, load_dataset +from transformers import AutoModelForTokenClassification, AutoTokenizer, PreTrainedTokenizerBase +from transformers.utils import is_peft_available + +from trl.experimental.prm import PRMConfig, PRMTrainer +from trl.experimental.prm.prm_trainer import compute_accuracy + +from ..testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig, TaskType + + +class TestComputeAccuracy(TrlTestCase): + def test_token_classification_task(self): + eval_pred = ( + np.array( + [ + [[0.1, 0.9], [0.8, 0.2]], # Batch 1 + [[0.3, 0.7], [0.6, 0.4]], # Batch 2 + ] + ), + np.array([[0, 1], [1, 0]]), + ) + expected_accuracy = 0.5 # 2 matches, 2 mismatches + result = compute_accuracy(eval_pred) + assert round(abs(result["accuracy"] - expected_accuracy), 7) == 0 + + def test_token_classification_task_with_ignored_tokens_0(self): + eval_pred = ( + np.array( + [ + [[0.1, 0.9], [0.8, 0.2]], # Batch 1 + [[0.3, 0.7], [0.6, 0.4]], # Batch 2 + ] + ), + np.array([[1, 0], [1, -100]]), + ) + expected_accuracy = 1.0 # All non-ignored tokens match + result = compute_accuracy(eval_pred) + assert round(abs(result["accuracy"] - expected_accuracy), 7) == 0 + + def test_token_classification_task_with_ignored_tokens_1(self): + eval_pred = ( + np.array( + [ + [[0.1, 0.9], [0.8, 0.2]], # Batch 1 + [[0.3, 0.7], [0.6, 0.4]], # Batch 2 + ] + ), + np.array([[1, 1], [0, -100]]), + ) + expected_accuracy = 1 / 3 # 1 match, 2 mismatch, 1 ignored + result = compute_accuracy(eval_pred) + assert round(abs(result["accuracy"] - expected_accuracy), 7) == 0 + + def test_rewards_comparison_task(self, caplog): + eval_pred = ( + np.array( + [ + [0.9, 0.1], # Batch 1 + [0.6, 0.4], # Batch 2 + [0.5, 0.5], # Batch 3 (equal) + ] + ), + np.array([0, 1, 1]), + ) + expected_accuracy = 0.5 # 1 match, 1 mismatch, 1 equal (ignored) + + with caplog.at_level("WARNING", logger="trl.trainer.utils"): + result = compute_accuracy(eval_pred) + + assert round(abs(result["accuracy"] - expected_accuracy), 7) == 0 + expected_warning = ( + "There are 1 out of 3 instances where the predictions for both options are equal. " + "These instances are ignored in the accuracy computation." + ) + assert expected_warning in caplog.text + + +class TestTokenizeRow(TrlTestCase): + def setup_method(self): + # Set up the mock tokenizer with specific behaviors + self.tokenizer = MagicMock(spec=PreTrainedTokenizerBase) + self.tokenizer.bos_token_id = 0 + self.tokenizer.eos_token_id = 2 + + def mock_encode(text, add_special_tokens): + token_map = { + "Which number is larger, 9.8 or 9.11?": [465, 6766, 318, 298], + "11 is greater than 8.": [4, 322, 12], + "Hence, 9.11 > 9.8.": [4995, 11, 22], + "\n": [1030], + "\n\n": [1030, 1030], + } + + return token_map[text] + + def mock_tokenizer_call(text, add_special_tokens): + return {"input_ids": mock_encode(text, add_special_tokens)} + + self.tokenizer.encode.side_effect = mock_encode + self.tokenizer.side_effect = mock_tokenizer_call + + def test_tokenize_row_no_truncation(self): + # Define the input features + features = { + "prompt": "Which number is larger, 9.8 or 9.11?", + "completions": ["11 is greater than 8.", "Hence, 9.11 > 9.8."], + "labels": [True, False], + } + + # Call the method with no truncation + result = PRMTrainer.tokenize_row( + features=features, + tokenizer=self.tokenizer, + step_separator="\n", + max_length=None, + max_completion_length=None, + train_on_last_step_only=False, + is_eval=False, + ) + + assert result == { + "input_ids": [0, 465, 6766, 318, 298, 4, 322, 12, 1030, 4995, 11, 22, 1030], + "labels": [-100, -100, -100, -100, -100, -100, -100, -100, 1, -100, -100, -100, 0], + } + + def test_tokenize_row_train_on_last_step_only(self): + # Define the input features + features = { + "prompt": "Which number is larger, 9.8 or 9.11?", + "completions": ["11 is greater than 8.", "Hence, 9.11 > 9.8."], + "labels": [True, False], + } + + result = PRMTrainer.tokenize_row( + features=features, + tokenizer=self.tokenizer, + step_separator="\n", + max_length=None, + max_completion_length=None, + train_on_last_step_only=True, + is_eval=False, + ) + + assert result == { + "input_ids": [0, 465, 6766, 318, 298, 4, 322, 12, 1030, 4995, 11, 22, 1030], + "labels": [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, 0], + } + + def test_tokenize_row_completion_truncation(self): + # Define the input features + features = { + "prompt": "Which number is larger, 9.8 or 9.11?", + "completions": ["11 is greater than 8.", "Hence, 9.11 > 9.8."], + "labels": [True, False], + } + + # Call the method with truncation on the completion + result = PRMTrainer.tokenize_row( + features=features, + tokenizer=self.tokenizer, + step_separator="\n", + max_length=None, + max_completion_length=6, + train_on_last_step_only=False, + is_eval=False, + ) + + assert result == { + "input_ids": [0, 465, 6766, 318, 298, 4, 322, 12, 1030, 4995, 11], + "labels": [-100, -100, -100, -100, -100, -100, -100, -100, 1, -100, -100], + } + + def test_tokenize_row_prompt_completion_truncation(self): + # Define the input features + features = { + "prompt": "Which number is larger, 9.8 or 9.11?", + "completions": ["11 is greater than 8.", "Hence, 9.11 > 9.8."], + "labels": [True, False], + } + + # Call the method with truncation on the prompt and completion + result = PRMTrainer.tokenize_row( + features=features, + tokenizer=self.tokenizer, + step_separator="\n", + max_length=9, + max_completion_length=None, + train_on_last_step_only=False, + is_eval=False, + ) + + assert result == { + "input_ids": [0, 465, 6766, 318, 298, 4, 322, 12, 1030], + "labels": [-100, -100, -100, -100, -100, -100, -100, -100, 1], + } + + def test_tokenize_row_multi_token_separator(self): + # Define the input features + features = { + "prompt": "Which number is larger, 9.8 or 9.11?", + "completions": ["11 is greater than 8.", "Hence, 9.11 > 9.8."], + "labels": [True, False], + } + + # Call the method using multiple tokens as step_separator + result = PRMTrainer.tokenize_row( + features=features, + tokenizer=self.tokenizer, + step_separator="\n\n", + max_length=None, + max_completion_length=None, + train_on_last_step_only=False, + is_eval=False, + ) + + assert result == { + "input_ids": [0, 465, 6766, 318, 298, 4, 322, 12, 1030, 1030, 4995, 11, 22, 1030, 1030], + "labels": [-100, -100, -100, -100, -100, -100, -100, -100, -100, 1, -100, -100, -100, -100, 0], + } + + +class TestPRMTrainer(TrlTestCase): + def setup_method(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForTokenClassification.from_pretrained(model_id, dtype="float32") + self.tokenizer = AutoTokenizer.from_pretrained(model_id) + + @pytest.mark.parametrize("train_on_last_step_only", [True, False]) + def test_train_full(self, train_on_last_step_only): + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_stepwise_supervision", split="train") + training_args = PRMConfig( + output_dir=self.tmp_dir, + report_to="none", + train_on_last_step_only=train_on_last_step_only, + ) + trainer = PRMTrainer( + model=self.model, args=training_args, processing_class=self.tokenizer, train_dataset=dummy_dataset + ) + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12) + + def test_train_full_pretokenized(self): + dummy_dataset = Dataset.from_dict( + { + "labels": [ + [-100, -100, -100, -100, -100, -100, -100, -100, -100, 0, -100, -100, 1], + [-100, -100, -100, -100, -100, -100, -100, -100, 0, -100, -100, 1, -100, -100, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, 0, -100, -100, 1], + [-100, -100, -100, -100, -100, -100, -100, 1, -100, -100, 1], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, 1, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, 1], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, 1, -100, -100, -100, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, -100, -100, 0, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, 0, -100, -100, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, 1], + [-100, -100, -100, -100, -100, -100, 0], + [-100, -100, -100, -100, -100, -100, -100, -100, 1], + [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, 0], + ], + "input_ids": [ + [46518, 374, 2664, 1091, 11, 1077, 752, 1744, 1112, 198, 27261, 13, 198], + [98923, 374, 2664, 1091, 11, 315, 3308, 11, 198, 17995, 13, 198, 1576, 31273, 12850, 13, 198], + [16374, 374, 2664, 1091, 1112, 1077, 594, 2506, 432, 6770, 11, 198, 6351, 13, 198], + [31137, 374, 2664, 1091, 979, 4362, 11, 198, 16965, 13, 198], + [31019, 374, 2664, 1091, 304, 3793, 315, 5944, 11, 198, 24034, 13, 198], + [98491, 374, 2664, 1091, 1112, 5310, 369, 91494, 13, 198], + [4418, 2897, 14579, 5310, 979, 3800, 1349, 432, 13, 198], + [20366, 5048, 7629, 944, 3281, 3322, 11, 7241, 1112, 198, 807, 1795, 279, 5601, 13, 198], + [15802, 14976, 487, 33327, 1045, 31787, 63443, 11, 198, 52400, 13, 198], + [13877, 1265, 2581, 1494, 49394, 11, 198, 7241, 20975, 91681, 13, 198], + [641, 279, 3579, 315, 71768, 11, 25066, 279, 61361, 311, 7942, 13, 198], + [7039, 374, 2664, 1091, 2937, 13, 198], + [26155, 374, 3545, 2664, 1091, 34933, 26537, 13, 198], + [2679, 279, 8129, 374, 4135, 311, 10339, 11, 432, 2578, 387, 264, 1661, 2884, 13, 198], + ], + } + ) + + training_args = PRMConfig(output_dir=self.tmp_dir, report_to="none") + trainer = PRMTrainer( + model=self.model, args=training_args, processing_class=self.tokenizer, train_dataset=dummy_dataset + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: # ignore 0 biases + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12) + + @require_peft + def test_train_lora(self): + peft_config = LoraConfig( + task_type=TaskType.TOKEN_CLS, + inference_mode=False, + r=8, + lora_alpha=32, + lora_dropout=0.1, + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_stepwise_supervision", split="train") + training_args = PRMConfig(output_dir=self.tmp_dir, max_steps=3, report_to="none") + trainer = PRMTrainer( + model=self.model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset, + peft_config=peft_config, + ) + previous_trainable_params = {} + previous_non_trainable_params = {} + + # due to a change in the way the modules to save are dealt in PEFT. + trainable_params_name = ["lora", "modules_to_save"] + + # check gradients are not None + for n, param in trainer.model.named_parameters(): + if any(t in n for t in trainable_params_name): + previous_trainable_params[n] = param.clone() + else: + previous_non_trainable_params[n] = param.clone() + + trainer.train() + + assert trainer.state.log_history[(-1)]["train_loss"] is not None + + # Check that the parameters have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param, atol=1e-12, rtol=1e-12) + + # Check that the non trainable parameters have not changed + for n, param in previous_non_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + torch.testing.assert_close(param, new_param, atol=1e-12, rtol=1e-12) + + def test_tags(self): + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_stepwise_supervision", split="train") + training_args = PRMConfig(output_dir=self.tmp_dir, report_to="none") + trainer = PRMTrainer( + model=self.model, args=training_args, processing_class=self.tokenizer, train_dataset=dummy_dataset + ) + assert trainer.model.model_tags == trainer._tag_names diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_sdft_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_sdft_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..9ca9b6c579af0f90b50f24c267450da4ee84d29b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_sdft_trainer.py @@ -0,0 +1,342 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import Dataset +from transformers import AutoModelForCausalLM, TrainerCallback, TrainerControl, TrainerState, TrainingArguments +from transformers.utils import is_peft_available + +from trl.data_utils import maybe_apply_chat_template +from trl.experimental.sdft import SDFTConfig, SDFTTrainer + +from ..testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model, get_peft_model_state_dict + + from trl.experimental.self_distillation.peft_adapter_ema_callback import PEFTAdapterEMACallback + + +class SelfDistillationCaptureCallback(TrainerCallback): + def __init__(self): + self.captured_generation_prompt_text = None + self.captured_old_per_token_logps = None + self.generation_batch_build_count = 0 + + def on_generation_prompts_selected(self, generation_prompt_text=None, **kwargs): + if self.captured_generation_prompt_text is None and generation_prompt_text is not None: + self.captured_generation_prompt_text = generation_prompt_text[0] + + def on_self_distillation_batch_prepared(self, old_per_token_logps=None, **kwargs): + if self.captured_old_per_token_logps is None and old_per_token_logps is not None: + self.captured_old_per_token_logps = old_per_token_logps.detach().cpu() + + def on_generation_batch_built(self, **kwargs): + self.generation_batch_build_count += 1 + + +class TestSDFTTrainer(TrlTestCase): + def test_training_rejects_none_privileged_context(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2."], + "privileged_context": [None], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + num_generations=1, + ) + + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + with pytest.raises(ValueError, match="`privileged_context` must not be None"): + trainer.train() + + def test_training_with_generate_from_teacher(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2.", "Solve 3+3."], + "privileged_context": [ + "Teacher hint: answer with 4 and explain briefly.", + "Teacher hint: answer with 6 and explain briefly.", + ], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + num_generations=1, + generate_from_teacher=True, + ) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.captured_generation_prompt_text is not None + assert "Solve 2+2." in capture_callback.captured_generation_prompt_text + assert "Teacher hint" in capture_callback.captured_generation_prompt_text + + def test_training_with_chat_template_kwargs(self): + dataset = Dataset.from_dict( + { + "prompt": [ + [{"role": "user", "content": "Solve 2+2."}], + [{"role": "user", "content": "Solve 3+3."}], + ], + "privileged_context": [ + "Teacher hint: answer with 4.", + "Teacher hint: answer with 6.", + ], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + num_generations=1, + chat_template_kwargs={"enable_thinking": False}, + ) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + expected_prompt = maybe_apply_chat_template( + {"prompt": dataset[0]["prompt"]}, + trainer.processing_class, + **training_args.chat_template_kwargs, + )["prompt"] + + trainer.train() + + assert capture_callback.captured_generation_prompt_text == expected_prompt + + @require_peft + def test_training_with_peft_model(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2.", "Name the capital of France."], + "privileged_context": [ + "Example answer: 4.", + "Example answer: Paris.", + ], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + num_generations=1, + ) + + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig( + task_type="CAUSAL_LM", + target_modules=["q_proj", "v_proj"], + ), + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + @require_peft + def test_training_with_peft_model_and_sync_ref_model(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2.", "Name the capital of France."], + "privileged_context": [ + "Example answer: 4.", + "Example answer: Paris.", + ], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=2, + num_generations=1, + sync_ref_model=True, + ref_model_mixup_alpha=0.05, + ref_model_sync_steps=1, + ) + + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig( + task_type="CAUSAL_LM", + target_modules=["q_proj", "v_proj"], + ), + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + @require_peft + def test_peft_adapter_ema_callback(self): + model = AutoModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + device_map="cpu", + ) + lora_config = LoraConfig( + task_type="CAUSAL_LM", + target_modules=["q_proj", "v_proj"], + r=8, + ) + model = get_peft_model(model, lora_config, adapter_name="default") + + update_rate = 0.5 + callback = PEFTAdapterEMACallback( + model=model, + teacher_adapter_name="teacher", + update_rate=update_rate, + sync_steps=1, + ) + + # Initialize and verify teacher adapter was created with zero weights + callback._initialize_teacher_adapter() + assert "teacher" in model.peft_config + assert callback.shadow_weights is not None + + teacher_state = get_peft_model_state_dict(model, adapter_name="teacher") + for key, param in teacher_state.items(): + assert torch.all(param == 0), f"Teacher param {key} should be zero-initialized" + + # Verify shadow weights keys match student state dict keys + student_state = {k: v.clone() for k, v in get_peft_model_state_dict(model, adapter_name="default").items()} + assert set(callback.shadow_weights.keys()) == set(student_state.keys()) + + # Simulate a training step and verify EMA update + args = TrainingArguments(output_dir=self.tmp_dir) + state = TrainerState(global_step=1) + control = TrainerControl() + callback.on_step_end(args, state, control) + + # shadow = (1 - rate) * 0 + rate * student = rate * student + for key in callback.shadow_weights: + expected = update_rate * student_state[key] + torch.testing.assert_close(callback.shadow_weights[key], expected) + + # Verify teacher adapter received the shadow weights + teacher_state = get_peft_model_state_dict(model, adapter_name="teacher") + for key in teacher_state: + torch.testing.assert_close(teacher_state[key].float(), callback.shadow_weights[key]) + + def test_training_populates_old_log_probs_for_distillation_clipping_when_misaligned(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2.", "Solve 3+3."], + "privileged_context": [ + "Example answer: 4.", + "Example answer: 6.", + ], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + gradient_accumulation_steps=3, + steps_per_generation=2, + max_completion_length=8, + max_steps=1, + num_generations=1, + ) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.captured_old_per_token_logps is not None + + def test_training_reuses_buffered_generation_batches(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2.", "Solve 3+3."], + "privileged_context": [ + "Example answer: 4.", + "Example answer: 6.", + ], + } + ) + + training_args = SDFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + steps_per_generation=2, + max_completion_length=8, + max_steps=2, + num_generations=1, + ) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.generation_batch_build_count == 1 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_sdpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_sdpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..1bb666a7dcc1c3b1e4705e563ce951a219a99204 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_sdpo_trainer.py @@ -0,0 +1,497 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +from types import SimpleNamespace + +import torch +from datasets import Dataset, load_dataset +from transformers import TrainerCallback + +from trl.experimental.sdpo import SDPOConfig, SDPOTrainer + +from ..testing_utils import TrlTestCase + + +class SelfDistillationCaptureCallback(TrainerCallback): + def __init__(self): + self.captured_teacher_input_text = None + self.captured_teacher_input_texts = [] + self.captured_self_distillation_mask = None + self.captured_teacher_attention_mask = None + self.captured_completion_mask = None + self.captured_old_per_token_logps = None + + def on_teacher_context_built( + self, + processing_class=None, + teacher_input_ids=None, + teacher_attention_mask=None, + completion_mask=None, + self_distillation_mask=None, + **kwargs, + ): + if self.captured_teacher_input_text is None and teacher_input_ids is not None: + self.captured_teacher_input_text = processing_class.decode(teacher_input_ids[0], skip_special_tokens=True) + if teacher_input_ids is not None: + self.captured_teacher_input_texts.extend( + processing_class.decode(ids, skip_special_tokens=True) for ids in teacher_input_ids + ) + if self.captured_teacher_attention_mask is None and teacher_attention_mask is not None: + self.captured_teacher_attention_mask = teacher_attention_mask.detach().cpu() + if self.captured_completion_mask is None and completion_mask is not None: + self.captured_completion_mask = completion_mask.detach().cpu() + if self.captured_self_distillation_mask is None and self_distillation_mask is not None: + self.captured_self_distillation_mask = self_distillation_mask.detach().cpu() + + def on_self_distillation_batch_prepared(self, old_per_token_logps=None, **kwargs): + if self.captured_old_per_token_logps is None and old_per_token_logps is not None: + self.captured_old_per_token_logps = old_per_token_logps.detach().cpu() + + +class TestSDPOTrainer(TrlTestCase): + def test_training_with_positional_config_argument(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve 2+2."], + "privileged_context": ["Your earlier answer used the wrong format."], + } + ) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + generation_batch_size=2, + num_generations=2, + max_completion_length=8, + include_environment_feedback=True, + max_steps=1, + ) + + trainer = SDPOTrainer( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + lambda **kwargs: [0.0] * len(kwargs["prompts"]), + training_args, + dataset, + ) + + trainer.train() + + assert trainer.args.output_dir == self.tmp_dir + assert trainer.args.include_environment_feedback is True + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_vllm_config_defaults_match_reference_trainers(self): + config = SDPOConfig(output_dir=self.tmp_dir) + + assert config.vllm_mode == "colocate" + assert config.vllm_model_impl == "vllm" + + def test_generate_vllm_syncs_on_step_change_and_uses_mode_specific_num_generations(self): + class FakeTokenizer: + def __call__(self, text, **kwargs): + token_map = { + "Solve 2+2.": [11, 12], + "Check 3+3.": [21, 22], + } + return {"input_ids": [token_map[prompt] for prompt in text]} + + class FakeVLLMGeneration: + def __init__(self): + self.sync_weights_call_count = 0 + self.generate_calls = [] + + def sync_weights(self): + self.sync_weights_call_count += 1 + + def generate(self, prompts, images, num_generations): + self.generate_calls.append( + { + "prompts": prompts, + "images": images, + "num_generations": num_generations, + } + ) + completion_ids = [[100 + index] for index in range(len(prompts))] + return prompts, completion_ids, None, None + + trainer = object.__new__(SDPOTrainer) + trainer.use_vllm = True + trainer.max_prompt_length = 16 + trainer.num_generations = 2 + trainer.num_generations_eval = 3 + trainer.model = SimpleNamespace(training=True) + trainer.state = SimpleNamespace(global_step=4) + trainer._last_loaded_step = 3 + trainer.processing_class = FakeTokenizer() + trainer.vllm_generation = FakeVLLMGeneration() + trainer._apply_prompt_template = lambda prompts: prompts + + prompt_ids, completion_ids = trainer._generate(["Solve 2+2.", "Solve 2+2."]) + + assert prompt_ids == [[11, 12], [11, 12]] + assert completion_ids == [[100], [101]] + assert trainer.vllm_generation.sync_weights_call_count == 1 + assert trainer._last_loaded_step == 4 + assert trainer.vllm_generation.generate_calls == [ + { + "prompts": [[11, 12], [11, 12]], + "images": None, + "num_generations": 2, + } + ] + + trainer.model.training = False + eval_prompt_ids, eval_completion_ids = trainer._generate(["Check 3+3.", "Check 3+3.", "Check 3+3."]) + + assert eval_prompt_ids == [[21, 22], [21, 22], [21, 22]] + assert eval_completion_ids == [[100], [101], [102]] + assert trainer.vllm_generation.sync_weights_call_count == 1 + assert trainer.vllm_generation.generate_calls[-1] == { + "prompts": [[21, 22], [21, 22], [21, 22]], + "images": None, + "num_generations": 3, + } + + trainer.model.training = True + trainer.state.global_step = 5 + trainer._generate(["Solve 2+2.", "Solve 2+2."]) + + assert trainer.vllm_generation.sync_weights_call_count == 2 + assert trainer._last_loaded_step == 5 + + def test_training(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + distillation_topk=5, + full_logit_distillation=True, + distillation_is_clip=None, + ) + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if param.sum() != 0: + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Parameter {n} has not changed." + + def test_training_without_successful_rollouts(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + distillation_is_clip=None, + ) + + def zero_reward(**kwargs): + prompts = kwargs["prompts"] + return [0.0] * len(prompts) + + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=zero_reward, + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_populates_old_log_probs_for_distillation_clipping_when_misaligned(self): + dataset = Dataset.from_dict({"prompt": ["Solve 2+2.", "Solve 3+3."]}) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + gradient_accumulation_steps=3, + steps_per_generation=2, + num_generations=2, + max_completion_length=8, + max_steps=1, + ) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=lambda **kwargs: [0.0] * len(kwargs["prompts"]), + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.captured_old_per_token_logps is not None + + def test_evaluation_uses_num_generations_eval_for_teacher_grouping(self): + eval_dataset = Dataset.from_dict({"prompt": ["Alpha prompt", "Beta prompt", "Gamma prompt", "Delta prompt"]}) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + per_device_eval_batch_size=4, + generation_batch_size=3, + num_generations=3, + num_generations_eval=2, + max_completion_length=8, + success_reward_threshold=0.5, + dont_reprompt_on_self_success=False, + distillation_is_clip=None, + max_steps=1, + ) + + def eval_rewards(**kwargs): + prompts = kwargs["prompts"] + if len(prompts) == 4 and prompts.count("Alpha prompt") == 2 and prompts.count("Beta prompt") == 2: + return [1.0, 0.0, 0.0, 0.0] + return [0.0] * len(prompts) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=eval_rewards, + args=training_args, + train_dataset=eval_dataset.select(range(1)), + eval_dataset=eval_dataset, + callbacks=[capture_callback], + ) + + trainer.evaluate() + + assert capture_callback.captured_teacher_input_texts + alpha_teachers = [text for text in capture_callback.captured_teacher_input_texts if "Alpha prompt" in text] + beta_teachers = [text for text in capture_callback.captured_teacher_input_texts if "Beta prompt" in text] + assert alpha_teachers + assert beta_teachers + assert any("Correct solution:" in text for text in alpha_teachers) + assert all("Correct solution:" not in text for text in beta_teachers) + + def test_teacher_reprompt_preserves_curly_braces_in_solution_and_feedback(self): + dataset = Dataset.from_dict( + { + "prompt": ["Solve f(x) = {x^2}."], + "privileged_context": ['Feedback: use {"x": 2} as a check.'], + } + ) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + generation_batch_size=2, + num_generations=2, + max_completion_length=8, + include_environment_feedback=True, + success_reward_threshold=0.5, + dont_reprompt_on_self_success=False, + max_steps=1, + ) + + def reward_with_one_success(**kwargs): + prompts = kwargs["prompts"] + return [1.0, 0.0][: len(prompts)] + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_with_one_success, + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.captured_teacher_input_text is not None + assert "{{" not in capture_callback.captured_teacher_input_text + assert "}}" not in capture_callback.captured_teacher_input_text + + def test_training_with_conversational_prompts_preserves_context(self): + dataset = Dataset.from_dict( + { + "prompt": [ + [ + {"role": "system", "content": "You are a careful assistant."}, + {"role": "user", "content": "Solve 2+2."}, + ] + ] + } + ) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + generation_batch_size=2, + num_generations=2, + max_completion_length=8, + distillation_is_clip=None, + success_reward_threshold=0.5, + max_steps=1, + ) + + def first_only_reward(**kwargs): + """Only the first sample in each group succeeds — exercises dont_reprompt_on_self_success default.""" + return [1.0, 0.0][: len(kwargs["prompts"])] + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=first_only_reward, + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + # With dont_reprompt_on_self_success=True (default), sample 0 skips itself, + # but sample 1 finds sample 0's success and gets a teacher reprompt. + assert capture_callback.captured_teacher_input_text is not None + assert "careful assistant" in capture_callback.captured_teacher_input_text + assert "Solve 2+2" in capture_callback.captured_teacher_input_text + assert capture_callback.captured_self_distillation_mask is not None + + def test_training_with_feedback_only_reprompts_teacher(self): + dataset = Dataset.from_dict( + { + "prompt": [ + [ + {"role": "system", "content": "You are a careful assistant."}, + {"role": "user", "content": "Try the puzzle again."}, + ] + ], + "privileged_context": ["Your earlier answer violated the format requirements."], + } + ) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + generation_batch_size=2, + num_generations=2, + max_completion_length=8, + distillation_is_clip=None, + include_environment_feedback=True, + max_steps=1, + ) + + def zero_reward(**kwargs): + prompts = kwargs["prompts"] + return [0.0] * len(prompts) + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=zero_reward, + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.captured_teacher_input_text is not None + assert "format requirements" in capture_callback.captured_teacher_input_text + assert capture_callback.captured_self_distillation_mask is not None + assert capture_callback.captured_self_distillation_mask[0].item() == 1.0 + + def test_training_warns_when_sdpo_rewards_are_flat(self, caplog): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + diagnostics_warning_interval=2, + max_steps=2, + ) + + def zero_reward(**kwargs): + return [0.0] * len(kwargs["prompts"]) + + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=zero_reward, + args=training_args, + train_dataset=dataset, + ) + + with caplog.at_level(logging.WARNING): + trainer.train() + + assert "Observed flat SDPO rewards across all sampled generations" in caplog.text + assert "SDPO self-distillation is inactive because no reprompted samples were constructed" in caplog.text + + def test_training_preserves_teacher_completion_attention_mask(self): + dataset = Dataset.from_dict({"prompt": ["Solve 2+2."]}) + + training_args = SDPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + generation_batch_size=2, + num_generations=2, + max_completion_length=8, + success_reward_threshold=0.5, + max_steps=1, + ) + + def first_only_reward(**kwargs): + return [1.0, 0.0][: len(kwargs["prompts"])] + + capture_callback = SelfDistillationCaptureCallback() + trainer = SDPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=first_only_reward, + args=training_args, + train_dataset=dataset, + callbacks=[capture_callback], + ) + + trainer.train() + + assert capture_callback.captured_teacher_attention_mask is not None + assert capture_callback.captured_completion_mask is not None + + completion_length = capture_callback.captured_completion_mask.shape[1] + teacher_completion_attention = capture_callback.captured_teacher_attention_mask[0, -completion_length:] + assert torch.equal(teacher_completion_attention, capture_callback.captured_completion_mask[0]) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_ssd_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_ssd_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..0f49e12e102ca780f7fc7b87e67a59c2a8e5b277 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_ssd_trainer.py @@ -0,0 +1,218 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from datasets import load_dataset +from transformers.utils import is_peft_available + +from trl.experimental.ssd import SSDConfig, SSDTrainer + +from ..testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig + + +class TestSSDTrainer(TrlTestCase): + def test_vllm_config_defaults_match_reference_trainers(self): + config = SSDConfig(output_dir=self.tmp_dir) + + assert config.vllm_mode == "colocate" + assert config.vllm_model_impl == "vllm" + + def test_training_with_string_prompts(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_with_chat_prompts(self): + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_with_temperature_and_truncation(self): + """Test with SSD-paper-style hyperparameters: T_train=0.6, top_k=20, top_p=0.95.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=5e-6, + per_device_train_batch_size=1, + max_completion_length=16, + max_steps=1, + temperature=0.6, + top_k=20, + top_p=0.95, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_reuses_buffered_generation_batches(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + steps_per_generation=2, + max_completion_length=8, + max_steps=2, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_with_filter_empty_disabled(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + filter_empty=False, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_logs_ssd_metrics(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + logging_steps=1, + report_to="none", + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + # The log() override merges _metrics into log_history and clears the buffer. + last_log = trainer.state.log_history[-2] + assert "ssd/cross_entropy_loss" in last_log + assert "ssd/active_sample_ratio" in last_log + assert "completions/mean_length" in last_log + + @require_peft + def test_training_with_peft_model(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig( + task_type="CAUSAL_LM", + target_modules=["q_proj", "v_proj"], + ), + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + def test_training_with_disable_dropout_false(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = SSDConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=1, + max_completion_length=8, + max_steps=1, + disable_dropout=False, + ) + + trainer = SSDTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_tpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_tpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..4220d7296872be6d630b787f0b32ece93014c0ad --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_tpo_trainer.py @@ -0,0 +1,325 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +from datasets import load_dataset +from transformers.utils import is_peft_available + +from trl.experimental.tpo import TPOConfig, TPOTrainer +from trl.experimental.tpo.tpo_trainer import DataCollatorForTriplePreference + +from ..testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig + + +def _add_reference_column(example): + """Synthesize a `reference` (gold) completion for tests by reusing the chosen completion.""" + example["reference"] = example["chosen"] + return example + + +class TestDataCollatorForTriplePreference(TrlTestCase): + def test_padding_and_masks(self): + collator = DataCollatorForTriplePreference(pad_token_id=0) + examples = [ + {"prompt_ids": [1, 2, 3], "chosen_ids": [4, 5], "rejected_ids": [6], "reference_ids": [7, 8]}, + {"prompt_ids": [9, 10], "chosen_ids": [11], "rejected_ids": [12, 13], "reference_ids": [14]}, + ] + result = collator(examples) + + expected_input_ids = torch.tensor( + [ + [1, 2, 3, 4, 5], # prompt + chosen (example 1) + [9, 10, 11, 0, 0], # prompt + chosen (example 2, padded) + [1, 2, 3, 6, 0], # prompt + rejected (example 1, padded) + [9, 10, 12, 13, 0], # prompt + rejected (example 2, padded) + [1, 2, 3, 7, 8], # prompt + reference (example 1) + [9, 10, 14, 0, 0], # prompt + reference (example 2, padded) + ] + ) + expected_attention_mask = torch.tensor( + [ + [1, 1, 1, 1, 1], + [1, 1, 1, 0, 0], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 1], + [1, 1, 1, 0, 0], + ] + ) + expected_completion_mask = torch.tensor( + [ + [0, 0, 0, 1, 1], + [0, 0, 1, 0, 0], + [0, 0, 0, 1, 0], + [0, 0, 1, 1, 0], + [0, 0, 0, 1, 1], + [0, 0, 1, 0, 0], + ] + ) + + assert set(result.keys()) == {"input_ids", "attention_mask", "completion_mask"} + torch.testing.assert_close(result["input_ids"], expected_input_ids) + torch.testing.assert_close(result["attention_mask"], expected_attention_mask) + torch.testing.assert_close(result["completion_mask"], expected_completion_mask) + + def test_exclude_reference(self): + # When `include_reference=False`, the collator only emits the chosen/rejected halves so the per-step + # compute/memory cost matches DPO's `DataCollatorForPreference`. This is the layout used by + # `TPOTrainer` when `tpo_alpha=0.0`. + collator = DataCollatorForTriplePreference(pad_token_id=0, include_reference=False) + examples = [ + {"prompt_ids": [1, 2, 3], "chosen_ids": [4, 5], "rejected_ids": [6], "reference_ids": [7, 8]}, + {"prompt_ids": [9, 10], "chosen_ids": [11], "rejected_ids": [12, 13], "reference_ids": [14]}, + ] + result = collator(examples) + + expected_input_ids = torch.tensor( + [ + [1, 2, 3, 4, 5], # prompt + chosen (example 1) + [9, 10, 11, 0, 0], # prompt + chosen (example 2, padded) + [1, 2, 3, 6, 0], # prompt + rejected (example 1, padded) + [9, 10, 12, 13, 0], # prompt + rejected (example 2, padded) + ] + ) + assert result["input_ids"].shape == (4, 5) # 2 * B rows, no reference branch + torch.testing.assert_close(result["input_ids"], expected_input_ids) + assert set(result.keys()) == {"input_ids", "attention_mask", "completion_mask"} + + +class TestTPOTrainer(TrlTestCase): + def test_train(self): + # Get the dataset and synthesize a reference (gold) completion + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + dataset = dataset.map(_add_reference_column) + + # Initialize the trainer + training_args = TPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize("loss_type", ["sigmoid", "hinge", "ipo", "tpo-l"]) + def test_train_loss_types(self, loss_type): + # Get the dataset and synthesize a reference (gold) completion + dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + dataset = dataset.map(_add_reference_column) + + # Initialize the trainer + training_args = TPOConfig( + output_dir=self.tmp_dir, + loss_type=loss_type, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + eval_strategy="steps", + eval_steps=3, + ) + trainer = TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_conversational(self): + # Get the dataset and synthesize a reference (gold) completion + dataset = load_dataset("trl-internal-testing/zen", "conversational_preference", split="train") + dataset = dataset.map(_add_reference_column) + + # Initialize the trainer + training_args = TPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + report_to="none", + ) + trainer = TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_without_nll(self): + # Setting tpo_alpha=0.0 disables the NLL term, skips the corresponding cross-entropy, and also drops the + # reference branch from the collated batch so the model doesn't pay the extra forward-pass cost. + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + dataset = dataset.map(_add_reference_column) + + training_args = TPOConfig( + output_dir=self.tmp_dir, + tpo_alpha=0.0, + learning_rate=0.1, + report_to="none", + ) + trainer = TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # The default collator should drop the reference branch entirely when `tpo_alpha=0.0`. + assert isinstance(trainer.data_collator, DataCollatorForTriplePreference) + assert trainer.data_collator.include_reference is False + + # Verify the collated batch is 2 * per_device_train_batch_size (chosen + rejected only), not 3 * B. + batch = trainer.data_collator(list(trainer.train_dataset.select(range(2)))) + assert batch["input_ids"].shape[0] == 4 # 2 branches * 2 examples + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_implicit_prompt(self): + # Implicit-prompt variant: no `prompt` column, the prompt is embedded in `chosen`/`rejected` and (for TPO) + # also in `reference`. Regression test for the `extract_prompt` bug where the reference column was left + # untouched, silently doubling the prompt in the reference branch. + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Synthesize a reference column that shares the same implicit prompt as chosen/rejected + dataset = dataset.map(_add_reference_column) + + training_args = TPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + report_to="none", + ) + trainer = TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_implicit_prompt_mismatched_reference_raises(self): + # When the dataset has no `prompt` column and the `reference` completion does not share the implicit + # prompt prefix of `chosen`/`rejected`, the trainer must raise a clear error rather than silently + # corrupting the reference branch. + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + def _set_unrelated_reference(example): + example["reference"] = "unrelated completion without the shared prompt prefix." + return example + + dataset = dataset.map(_set_unrelated_reference) + + training_args = TPOConfig(output_dir=self.tmp_dir, report_to="none") + with pytest.raises(ValueError, match="implicit prompt"): + TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + def test_missing_reference_column_raises(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + training_args = TPOConfig(output_dir=self.tmp_dir, report_to="none") + with pytest.raises(ValueError, match="reference"): + TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + @require_peft + def test_train_with_peft(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + dataset = dataset.map(_add_reference_column) + + training_args = TPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + report_to="none", + ) + trainer = TPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + if "lora" in n: + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..b498d19eb05ab00ce809d0c3cb04384a2ab697f9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_utils.py @@ -0,0 +1,160 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from datasets import Dataset, load_dataset +from transformers import AutoTokenizer + +from trl.experimental.utils import DataCollatorForChatML, truncate_dataset + +from ..testing_utils import TrlTestCase + + +class TestDataCollatorForChatML(TrlTestCase): + def setup_method(self): + # Initialize the tokenizer + self.tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + if self.tokenizer.pad_token is None: + self.tokenizer.pad_token = self.tokenizer.eos_token + + # Define token IDs + self.bos_token_id = self.tokenizer.bos_token_id if self.tokenizer.bos_token_id is not None else 1 + self.eos_token_id = self.tokenizer.eos_token_id if self.tokenizer.eos_token_id is not None else 2 + # Token ID for "true", the last assistant's response in the example: + self.ignore_index = -100 + self.max_length = 1024 + self.messages_key = "messages" + + # Example input + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + self.examples = dataset.to_list() + + # Initialize the data collator + self.collator = DataCollatorForChatML( + tokenizer=self.tokenizer, + max_length=self.max_length, + ignore_index=self.ignore_index, + ) + + def test_data_collator_for_chatml(self): + # Process the data + data = self.collator(self.examples) + + # Verify basic shapes and types + assert "input_ids" in data + assert "attention_mask" in data + assert "labels" in data + assert "prompts" in data + assert "prompt_attention_mask" in data + + # Decode input_ids and labels for verification + input_ids = data["input_ids"][0].tolist() + labels = data["labels"][0].tolist() + prompt_only = data["prompts"][0].tolist() + + # Get the last assistant's response for comparison + last_message = self.examples[0][self.messages_key][-1] + assert last_message["role"] == "assistant", "Last message should be from assistant" + last_assistant_response = last_message["content"] + + # Verify that input_ids contain both prompt and response + decoded_input = self.tokenizer.decode(input_ids) + assert last_assistant_response in decoded_input, "Input should contain assistant's response" + + # Verify that prompts only contain the conversation up to the last response + decoded_prompt = self.tokenizer.decode(prompt_only) + assert last_assistant_response not in decoded_prompt, "Prompt should not contain assistant's response" + + # Verify labels are -100 for non-assistant parts + prompt_length = len(prompt_only) + assert all(label == self.ignore_index for label in labels[:prompt_length]), ( + "Labels should be ignore_index for prompt tokens" + ) + + # Verify labels match assistant response after prompt + # Add a filter to remove any trailing tokens after the first <|im_end|> + last_assistant_response_with_end = last_assistant_response + self.tokenizer.eos_token + last_assistant_response_tokens = self.tokenizer.encode( + last_assistant_response_with_end, add_special_tokens=False + ) + + response_labels = [] + for label in labels[prompt_length:]: + if label == self.ignore_index: + continue + response_labels.append(label) + if label == self.tokenizer.convert_tokens_to_ids("<|im_end|>"): + break + assert response_labels == last_assistant_response_tokens, "Labels should match assistant response tokens" + + # Verify there isn't a generation prompt at the end + generation_prompt = "<|im_start|>assistant" + assert not decoded_input.strip().endswith(generation_prompt), ( + f"Input should not end with generation prompt '{generation_prompt}'" + ) + + assert response_labels == last_assistant_response_tokens, "Labels should match assistant response tokens" + + +class TestTruncateExamples(TrlTestCase): + def test_with_dataset(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + "attention_mask": [[0, 1, 1], [0, 0, 1, 1], [1]], + } + dataset = Dataset.from_dict(examples) + dataset = dataset.with_format("numpy", dtype="float32") + format = dataset.format + max_length = 2 + expected_output = { + "input_ids": [[1, 2], [4, 5], [8]], + "attention_mask": [[0, 1], [0, 0], [1]], + } + dataset = truncate_dataset(dataset, max_length) + assert dataset.to_dict() == expected_output + assert format == dataset.format + + def test_with_iterable_dataset(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + "attention_mask": [[0, 1, 1], [0, 0, 1, 1], [1]], + } + dataset = Dataset.from_dict(examples).to_iterable_dataset() + dataset = dataset.with_format("numpy") + formatting = dataset._formatting + max_length = 2 + expected_output = { + "input_ids": [[1, 2], [4, 5], [8]], + "attention_mask": [[0, 1], [0, 0], [1]], + } + dataset = truncate_dataset(dataset, max_length) + num_examples = len(examples[next(iter(examples))]) + assert next(iter(dataset.with_format(None).batch(batch_size=num_examples))) == expected_output + assert formatting == dataset._formatting + + def test_with_extra_column(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + "attention_mask": [[0, 1, 1], [0, 0, 1, 1], [1]], + "my_column": ["a", "b", "c"], + } + dataset = Dataset.from_dict(examples) + max_length = 2 + expected_output = { + "input_ids": [[1, 2], [4, 5], [8]], + "attention_mask": [[0, 1], [0, 0], [1]], + "my_column": ["a", "b", "c"], + } + dataset = truncate_dataset(dataset, max_length) + assert dataset.to_dict() == expected_output diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_xpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_xpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..70ded3763d59e8123363aa1509df4da33238b392 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/experimental/test_xpo_trainer.py @@ -0,0 +1,146 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer +from transformers.utils import is_peft_available + +from trl.experimental.xpo import XPOConfig, XPOTrainer + +from ..testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +@pytest.mark.low_priority +class TestXPOTrainer(TrlTestCase): + def setup_method(self): + self.model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + self.model = AutoModelForCausalLM.from_pretrained(self.model_id, dtype="float32") + self.ref_model = AutoModelForCausalLM.from_pretrained(self.model_id) + self.reward_model = AutoModelForSequenceClassification.from_pretrained(self.model_id, num_labels=1) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) + self.tokenizer.pad_token = self.tokenizer.eos_token + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_xpo_trainer_training(self, config_name): + training_args = XPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + remove_unused_columns=False, + gradient_accumulation_steps=1, + learning_rate=9e-1, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", config_name) + + trainer = XPOTrainer( + model=self.model, + ref_model=self.ref_model, + reward_funcs=self.reward_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_with_peft(self): + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, bias="none", task_type="CAUSAL_LM") + training_args = XPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = XPOTrainer( + model=self.model, + reward_funcs=self.reward_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + peft_config=lora_config, + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_with_peft_and_ref_model(self): + lora_config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, bias="none", task_type="CAUSAL_LM") + training_args = XPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=2, + max_steps=3, + learning_rate=5.0e-7, + report_to="none", + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + trainer = XPOTrainer( + model=self.model, + ref_model=self.ref_model, + reward_funcs=self.reward_model, + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset["train"], + peft_config=lora_config, + ) + + trainer.train() + + # Check if training loss is available + assert "train_loss" in trainer.state.log_history[-1] + + @require_peft + def test_training_pre_pefted_model_implicit_ref(self): + lora_config = LoraConfig(r=8, lora_alpha=16, lora_dropout=0.1, bias="none", task_type="CAUSAL_LM") + peft_model_instance = get_peft_model(self.model, lora_config) + + training_args = XPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=1, + max_steps=2, + learning_rate=5.0e-7, + eval_strategy="no", + report_to="none", + remove_unused_columns=False, + ) + dummy_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only")["train"] + + trainer = XPOTrainer( + model=peft_model_instance, + ref_model=None, + reward_funcs=self.reward_model, # Using reward_model to ensure _generate_completions is used as expected + args=training_args, + processing_class=self.tokenizer, + train_dataset=dummy_dataset, + ) + + trainer.train() + + assert "train_loss" in trainer.state.log_history[-1] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/tasksmith_behavior.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/tasksmith_behavior.py new file mode 100644 index 0000000000000000000000000000000000000000..83fdac1267ba24acac358299d722f43dd99a72d7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/tasksmith_behavior.py @@ -0,0 +1,306 @@ +import copy +import pytest +import torch +import torch.nn.functional as F + + +# --------------------------------------------------------------------------- +# Ported CPU unit tests (identical IDs to the selected upstream tests) +# All new-API imports are inside test methods to avoid collection failures +# on the reverted code. +# --------------------------------------------------------------------------- + +class TestChunkedCrossEntropyLoss: + B, S, H, V = 2, 8, 4, 16 + CHUNK_SIZE = 3 # deliberately small: forces multiple chunks and a partial final chunk + + def _inputs(self, seed=0, ignore_positions=None, requires_grad=False): + torch.manual_seed(seed) + hidden = torch.randn(self.B, self.S, self.H, dtype=torch.float32, requires_grad=requires_grad) + weight = torch.randn(self.V, self.H, dtype=torch.float32, requires_grad=requires_grad) + labels = torch.randint(0, self.V, (self.B, self.S)) + if ignore_positions is not None: + labels[:, ignore_positions] = -100 + return hidden, weight, labels + + @staticmethod + def _reference(hidden, weight, labels, num_items_in_batch=None): + shift_h = hidden[..., :-1, :].reshape(-1, hidden.size(-1)) + shift_l = labels[..., 1:].reshape(-1) + logits = shift_h.float() @ weight.float().t() + if num_items_in_batch is None: + loss = F.cross_entropy(logits, shift_l, ignore_index=-100, reduction="mean") + else: + loss = F.cross_entropy(logits, shift_l, ignore_index=-100, reduction="sum") + loss = loss / num_items_in_batch + valid = shift_l != -100 + if valid.any(): + log_p = F.log_softmax(logits, dim=-1) + preds = logits.argmax(dim=-1) + accuracy = (preds[valid] == shift_l[valid]).float().mean() + entropy = -(log_p.exp() * log_p).sum(dim=-1)[valid].mean() + else: + accuracy = torch.zeros((), dtype=torch.float32) + entropy = torch.zeros((), dtype=torch.float32) + return loss, accuracy, entropy + + def test_forward_matches_cross_entropy(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs() + n_valid = (labels[..., 1:] != -100).sum() + loss_c, correct_c, ent_sum_c = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels) + loss_r, acc_r, ent_r = self._reference(hidden, weight, labels) + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(correct_c / n_valid, acc_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(ent_sum_c / n_valid, ent_r, atol=1e-5, rtol=1e-5) + + def test_forward_ignore_index(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + n_valid = (labels[..., 1:] != -100).sum() + loss_c, correct_c, ent_sum_c = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels) + loss_r, acc_r, ent_r = self._reference(hidden, weight, labels) + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(correct_c / n_valid, acc_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(ent_sum_c / n_valid, ent_r, atol=1e-5, rtol=1e-5) + + def test_num_items_in_batch_reduction(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + num_items = 5 + loss_c, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels, num_items_in_batch=num_items) + loss_r, *_ = self._reference(hidden, weight, labels, num_items_in_batch=num_items) + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + + def test_num_items_in_batch_tensor(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs() + num_items_tensor = torch.tensor(7, dtype=torch.float32) + loss_t, *_ = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, labels, num_items_in_batch=num_items_tensor + ) + loss_i, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels, num_items_in_batch=7) + torch.testing.assert_close(loss_t, loss_i, atol=1e-6, rtol=1e-6) + + def test_backward_matches_reference(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden_c, weight_c, labels = self._inputs(ignore_positions=slice(0, 3), requires_grad=True) + hidden_r = hidden_c.detach().clone().requires_grad_(True) + weight_r = weight_c.detach().clone().requires_grad_(True) + + loss_c, *_ = _chunked_cross_entropy_loss(hidden_c, weight_c, self.CHUNK_SIZE, labels) + loss_c.backward() + + loss_r, *_ = self._reference(hidden_r, weight_r, labels) + loss_r.backward() + + torch.testing.assert_close(hidden_c.grad, hidden_r.grad, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(weight_c.grad, weight_r.grad, atol=1e-5, rtol=1e-5) + + def test_all_ignored_returns_zero(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs(requires_grad=True) + bias = torch.zeros(self.V, dtype=torch.float32, requires_grad=True) + labels[:] = -100 + loss, correct, ent_sum = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, labels, lm_head_bias=bias + ) + assert loss.item() == 0.0 + assert correct.item() == 0.0 + assert ent_sum.item() == 0.0 + assert not torch.isnan(loss) + loss.backward() + assert hidden.grad is not None and hidden.grad.abs().sum().item() == 0.0 + assert weight.grad is not None and weight.grad.abs().sum().item() == 0.0 + assert bias.grad is not None and bias.grad.abs().sum().item() == 0.0 + + def test_shift_labels_matches_labels(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + loss_l, correct_l, ent_l = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels) + shift_labels = F.pad(labels, (0, 1), value=-100)[..., 1:].contiguous() + loss_s, correct_s, ent_s = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, shift_labels=shift_labels + ) + torch.testing.assert_close(loss_s, loss_l, atol=1e-6, rtol=1e-6) + torch.testing.assert_close(correct_s, correct_l, atol=1e-6, rtol=1e-6) + torch.testing.assert_close(ent_s, ent_l, atol=1e-6, rtol=1e-6) + + def test_requires_labels_or_shift_labels(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, _ = self._inputs() + with pytest.raises(ValueError): + _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE) + + def test_shift_labels_wins_when_both_provided(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + shift_labels = F.pad(labels, (0, 1), value=-100)[..., 1:].contiguous() + # Deliberately conflict with the pre-shifted targets, including their mask. + labels = (labels.clamp_min(0) + 1) % self.V + loss_both, *_ = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, labels=labels, shift_labels=shift_labels + ) + loss_shift, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, shift_labels=shift_labels) + torch.testing.assert_close(loss_both, loss_shift, atol=1e-6, rtol=1e-6) + + def test_lm_head_bias(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + torch.manual_seed(1) + bias = torch.randn(self.V, dtype=torch.float32) + + loss_c, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels, lm_head_bias=bias) + + logits_ref = F.linear(hidden[..., :-1, :], weight, bias).reshape(-1, self.V) + labels_ref = labels[..., 1:].reshape(-1) + valid = labels_ref != -100 + loss_r = F.cross_entropy(logits_ref[valid], labels_ref[valid], reduction="mean") + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + + +# --------------------------------------------------------------------------- +# GPU tests for _patch_chunked_ce_lm_head using tiny locally-initialized models +# --------------------------------------------------------------------------- + +def _make_tiny_llama(device): + """Build a tiny LlamaForCausalLM from scratch (no checkpoint download).""" + from transformers import LlamaConfig, LlamaForCausalLM + cfg = LlamaConfig( + hidden_size=32, + num_attention_heads=2, + num_key_value_heads=2, + num_hidden_layers=1, + intermediate_size=64, + vocab_size=128, + max_position_embeddings=64, + ) + model = LlamaForCausalLM(cfg).to(torch.float32).to(device) + return model + + +class TestPatchChunkedCELMHeadGPU: + """Tests for _patch_chunked_ce_lm_head on a real CUDA device.""" + + CHUNK_SIZE = 5 # small, forces multi-chunk loop + + def test_cuda_available(self): + assert torch.cuda.is_available(), "L4 GPU must be available for this task" + + def test_forward_loss_matches_reference(self): + """Patched forward loss must be numerically close to unpatched loss.""" + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + device = torch.device("cuda") + ref_model = _make_tiny_llama(device) + chunked_model = copy.deepcopy(ref_model) + _patch_chunked_ce_lm_head(chunked_model, chunk_size=self.CHUNK_SIZE) + + torch.manual_seed(0) + input_ids = torch.randint(0, 128, (2, 16), device=device) + labels = input_ids.clone() + labels[:, :4] = -100 + num_items = int((labels[..., 1:] != -100).sum()) + + with torch.no_grad(): + ref_out = ref_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + out = chunked_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + + torch.testing.assert_close(out.loss, ref_out.loss, atol=1e-4, rtol=1e-4) + assert out.logits is None, "logits must be None when labels are provided" + assert out.num_correct_tokens is not None + assert out.entropy_sum is not None + assert out.num_correct_tokens.item() >= 0 + assert out.entropy_sum.item() >= 0.0 + + def test_forward_no_labels_returns_original_logits(self): + """Without labels, the patched forward delegates to original and returns real logits.""" + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + device = torch.device("cuda") + ref_model = _make_tiny_llama(device) + chunked_model = copy.deepcopy(ref_model) + _patch_chunked_ce_lm_head(chunked_model, chunk_size=self.CHUNK_SIZE) + + torch.manual_seed(1) + input_ids = torch.randint(0, 128, (1, 8), device=device) + + with torch.no_grad(): + ref_out = ref_model(input_ids=input_ids) + out = chunked_model(input_ids=input_ids) + + assert out.logits is not None, "logits must be present when labels=None" + assert out.logits.shape == ref_out.logits.shape + torch.testing.assert_close(out.logits, ref_out.logits, atol=1e-5, rtol=1e-5) + + def test_backward_gradients_match_reference(self): + """Gradients on lm_head and base decoder weights must match the unpatched backward.""" + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + device = torch.device("cuda") + ref_model = _make_tiny_llama(device) + chunked_model = copy.deepcopy(ref_model) + _patch_chunked_ce_lm_head(chunked_model, chunk_size=self.CHUNK_SIZE) + + torch.manual_seed(2) + input_ids = torch.randint(0, 128, (2, 16), device=device) + labels = input_ids.clone() + labels[:, :4] = -100 + num_items = int((labels[..., 1:] != -100).sum()) + + ref_out = ref_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + ref_out.loss.backward() + + out = chunked_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + out.loss.backward() + + torch.testing.assert_close( + chunked_model.lm_head.weight.grad, + ref_model.lm_head.weight.grad, + atol=1e-4, rtol=1e-4, + ) + for name, ref_param in ref_model.model.named_parameters(): + if ref_param.grad is None: + continue + chunked_param = chunked_model.model.get_parameter(name) + torch.testing.assert_close( + chunked_param.grad, ref_param.grad, + atol=1e-4, rtol=1e-4, + msg=f"gradient mismatch on model.{name}", + ) + + def test_extra_output_fields_present(self): + """_ChunkedCELMHeadOutput must expose num_correct_tokens and entropy_sum.""" + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + device = torch.device("cuda") + model = _make_tiny_llama(device) + _patch_chunked_ce_lm_head(model, chunk_size=self.CHUNK_SIZE) + + torch.manual_seed(3) + input_ids = torch.randint(0, 128, (1, 8), device=device) + labels = input_ids.clone() + + with torch.no_grad(): + out = model(input_ids=input_ids, labels=labels) + + assert hasattr(out, "num_correct_tokens") + assert hasattr(out, "entropy_sum") + assert isinstance(out.num_correct_tokens, torch.Tensor) + assert isinstance(out.entropy_sum, torch.Tensor) + + +# --------------------------------------------------------------------------- +# Adjacent behavior: passes on both merged and reverted code +# --------------------------------------------------------------------------- + +class TestSFTConfigAdjacentBehavior: + """Basic SFTConfig behavior that predates the chunked_nll feature.""" + + def test_default_loss_type_is_nll(self): + """SFTConfig.loss_type defaults to 'nll' (unchanged by this PR).""" + from trl import SFTConfig + cfg = SFTConfig(output_dir="/tmp/test_sft_default") + assert cfg.loss_type == "nll" + + def test_dft_loss_type_accepted(self): + """SFTConfig accepts loss_type='dft' without error (pre-existing behavior).""" + from trl import SFTConfig + cfg = SFTConfig(output_dir="/tmp/test_sft_dft", loss_type="dft") + assert cfg.loss_type == "dft" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/tasksmith_chunked_contract.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/tasksmith_chunked_contract.py new file mode 100644 index 0000000000000000000000000000000000000000..c9bcadd5a4fcfaba0f59427fc76902d63052946e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/tasksmith_chunked_contract.py @@ -0,0 +1,396 @@ +"""Offline behavioral checks for the chunked SFT contract.""" + +import copy +import gc + +import pytest +import torch +import torch.nn.functional as F + + +def tiny_llama(): + from transformers import LlamaConfig, LlamaForCausalLM + + return LlamaForCausalLM(LlamaConfig( + vocab_size=128, hidden_size=32, intermediate_size=64, + num_hidden_layers=1, num_attention_heads=4, num_key_value_heads=2, + max_position_embeddings=128, pad_token_id=0, bos_token_id=1, + eos_token_id=2, attention_dropout=0.0, + )) + + +def trainer_inputs(directory, loss_type="chunked_nll", **overrides): + from datasets import Dataset + from tokenizers import Tokenizer + from tokenizers.models import WordLevel + from transformers import PreTrainedTokenizerFast + from trl import SFTConfig + + vocabulary = {"[PAD]": 0, "[BOS]": 1, "[EOS]": 2, "[UNK]": 3} + vocabulary.update({f"t{i}": i for i in range(4, 128)}) + tokenizer = PreTrainedTokenizerFast( + tokenizer_object=Tokenizer(WordLevel(vocabulary, unk_token="[UNK]")), + pad_token="[PAD]", bos_token="[BOS]", eos_token="[EOS]", unk_token="[UNK]", + ) + rows = [[1, 5, 8, 13, 21, 34, 55, 2], [1, 7, 11, 19, 23, 29, 31, 2]] + dataset = Dataset.from_dict({"input_ids": rows, "attention_mask": [[1] * 8] * 2}) + options = dict( + output_dir=str(directory), loss_type=loss_type, report_to="none", + bf16=False, fp16=False, gradient_checkpointing=False, + max_steps=1, per_device_train_batch_size=2, logging_steps=1, + save_strategy="no", disable_tqdm=True, max_length=128, + dataset_kwargs={"skip_prepare_dataset": True}, + ) + options.update(overrides) + return dict(model=tiny_llama(), args=SFTConfig(**options), + processing_class=tokenizer, train_dataset=dataset) + + +class TestChunkedContract: + def test_masked_projection_work(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + + torch.manual_seed(415) + # Count executed matrix arithmetic, not calls to a particular Python + # projection helper. Allow generous recomputation overhead, but not + # projection of thousands of masked positions followed by masking. + for pre_shifted in (False, True): + for n_valid in (0, 7): + h = torch.randn(1, 4097, 17, requires_grad=True) + w = torch.randn(257, 17, requires_grad=True) + b = torch.randn(257, requires_grad=True) + targets = torch.full((1, 4097), -100, dtype=torch.long) + positions = torch.tensor([3, 97, 521, 1031, 2051, 3079, 4095])[:n_valid] + targets[0, positions] = torch.arange(n_valid) * 13 + arguments = {"shift_labels" if pre_shifted else "labels": targets} + with torch.profiler.profile( + activities=[torch.profiler.ProfilerActivity.CPU], + with_flops=True, + ) as profile: + loss, correct, entropy = _chunked_cross_entropy_loss( + h, w, 4, lm_head_bias=b, **arguments + ) + loss.backward() + matrix_flops = sum( + event.flops or 0 for event in profile.key_averages() + if event.key in {"aten::mm", "aten::addmm", "aten::bmm"} + ) + assert matrix_flops <= 32 * n_valid * 2 * 17 * 257, matrix_flops + + # Independently check the outputs and gradients on the same + # sparse targets, so skipping useful work cannot satisfy this. + hr, wr, br = [x.detach().clone().requires_grad_() for x in (h, w, b)] + aligned_h = hr if pre_shifted else hr[:, :-1] + aligned_targets = targets if pre_shifted else targets[:, 1:] + valid = aligned_targets != -100 + if n_valid: + logits = F.linear(aligned_h[valid], wr, br) + expected = F.cross_entropy(logits, aligned_targets[valid]) + logp = logits.log_softmax(-1) + expected_correct = (logits.argmax(-1) == aligned_targets[valid]).sum() + expected_entropy = -(logp.exp() * logp).sum() + else: + expected = (hr.sum() + wr.sum() + br.sum()) * 0 + expected_correct = torch.tensor(0) + expected_entropy = torch.tensor(0.0) + expected.backward() + torch.testing.assert_close(loss, expected, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(correct.float(), expected_correct.float()) + torch.testing.assert_close(entropy, expected_entropy, atol=1e-5, rtol=1e-5) + for actual, reference in zip((h, w, b), (hr, wr, br)): + torch.testing.assert_close(actual.grad, reference.grad, atol=1e-5, rtol=1e-5) + + def test_patched_activation_memory(self): + from transformers import LlamaConfig, LlamaForCausalLM + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + + assert torch.cuda.is_available() + torch.manual_seed(416) + config = LlamaConfig( + vocab_size=32768, hidden_size=32, intermediate_size=64, + num_hidden_layers=1, num_attention_heads=4, num_key_value_heads=2, + max_position_embeddings=8192, pad_token_id=0, bos_token_id=1, + eos_token_id=2, attention_dropout=0.0, use_cache=False, + ) + # Avoid quadratic attention-score storage unrelated to the LM head. + config._attn_implementation = "sdpa" + model = LlamaForCausalLM(config).to(device="cuda", dtype=torch.bfloat16).train() + _patch_chunked_ce_lm_head(model, 256) + ids = torch.randint(3, 32768, (1, 17), device="cuda") + output = model(input_ids=ids, labels=ids) + output.loss.backward() + del output, ids + model.zero_grad(set_to_none=True) + gc.collect() + torch.cuda.synchronize() + + peaks = [] + for n in (1024, 4096): + ids = torch.randint(3, 32768, (1, n + 1), device="cuda") + labels = ids.clone() + torch.cuda.synchronize() + baseline = torch.cuda.memory_allocated() + torch.cuda.reset_peak_memory_stats() + output = model(input_ids=ids, labels=labels) + assert output.logits is None + assert torch.isfinite(output.loss) + # Training backpropagates loss after metrics have been consumed. + # Do not retain an unused differentiable entropy graph across backward. + loss = output.loss + del output + loss.backward() + torch.cuda.synchronize() + peaks.append(torch.cuda.max_memory_allocated() - baseline) + for parameter in (model.lm_head.weight, model.get_input_embeddings().weight): + assert parameter.grad is not None + assert torch.isfinite(parameter.grad).all() + assert parameter.grad.abs().sum() > 0 + del loss, ids, labels + model.zero_grad(set_to_none=True) + gc.collect() + # At 4096 valid tokens and vocabulary 32768, one full float32 + # logits tensor is 512 MiB. Default-sized chunks keep this activation + # compact; bounds leave headroom for parameter gradients and decoding. + print('TASKSMITH_MEMORY_PEAKS', peaks) + assert peaks[1] < 192 * 1024**2, peaks + assert peaks[1] - peaks[0] < 128 * 1024**2, peaks + + def test_unsupported_models(self, tmp_path): + from peft import LoraConfig, get_peft_model + from transformers import ( + CLIPImageProcessor, LlavaConfig, LlavaForConditionalGeneration, + LlavaProcessor, + ) + from trl import SFTTrainer + + kwargs = trainer_inputs(tmp_path / "peft_config") + kwargs["peft_config"] = LoraConfig( + task_type="CAUSAL_LM", r=2, lora_alpha=4, + target_modules=["q_proj", "v_proj"], + ) + with pytest.raises(NotImplementedError): + SFTTrainer(**kwargs) + + kwargs = trainer_inputs(tmp_path / "peft_model") + kwargs["model"] = get_peft_model( + kwargs["model"], + LoraConfig(task_type="CAUSAL_LM", r=2, lora_alpha=4, + target_modules=["q_proj", "v_proj"]), + ) + with pytest.raises(NotImplementedError): + SFTTrainer(**kwargs) + + kwargs = trainer_inputs(tmp_path / "vlm") + text_config = kwargs["model"].config.to_dict() + kwargs["model"] = LlavaForConditionalGeneration(LlavaConfig( + text_config=text_config, + vision_config=dict( + model_type="clip_vision_model", hidden_size=32, + intermediate_size=64, num_hidden_layers=2, + num_attention_heads=4, image_size=16, patch_size=8, + projection_dim=32, + ), + image_token_index=127, + )) + kwargs["processing_class"] = LlavaProcessor( + image_processor=CLIPImageProcessor( + size={"shortest_edge": 16}, + crop_size={"height": 16, "width": 16}, + ), + tokenizer=kwargs["processing_class"], + patch_size=8, + vision_feature_select_strategy="default", + ) + with pytest.raises(NotImplementedError): + SFTTrainer(**kwargs) + + def test_activation_memory(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + + assert torch.cuda.is_available() + device = torch.device("cuda") + torch.manual_seed(410) + # Warm up libraries before measuring incremental allocated memory. + h = torch.randn(1, 9, 64, device=device, dtype=torch.bfloat16, requires_grad=True) + w = torch.randn(32768, 64, device=device, dtype=torch.bfloat16, requires_grad=True) + labels = torch.randint(32768, (1, 9), device=device) + _chunked_cross_entropy_loss(h, w, 256, labels=labels)[0].backward() + del h, w, labels + gc.collect() + torch.cuda.synchronize() + + peaks = [] + for n in (1024, 4096): + h = torch.randn(1, n + 1, 64, device=device, dtype=torch.bfloat16, requires_grad=True) + w = torch.randn(32768, 64, device=device, dtype=torch.bfloat16, requires_grad=True) + labels = torch.randint(32768, (1, n + 1), device=device) + torch.cuda.synchronize() + baseline = torch.cuda.memory_allocated() + torch.cuda.reset_peak_memory_stats() + result = _chunked_cross_entropy_loss(h, w, 256, labels=labels) + loss, correct, entropy = result + assert torch.isfinite(correct) and torch.isfinite(entropy) + del result, correct, entropy + loss.backward() + torch.cuda.synchronize() + peaks.append(torch.cuda.max_memory_allocated() - baseline) + assert torch.isfinite(loss) + assert h.grad is not None and torch.isfinite(h.grad).all() + assert w.grad is not None and torch.isfinite(w.grad).all() + del loss, h, w, labels + gc.collect() + # At 4096 valid tokens and vocabulary 32768, one full float32 + # logits tensor is 512 MiB. Default-sized chunks keep this activation + # compact; bounds leave headroom for parameter gradients and decoding. + print('TASKSMITH_MEMORY_PEAKS', peaks) + assert peaks[1] < 192 * 1024**2, peaks + assert peaks[1] - peaks[0] < 128 * 1024**2, peaks + + def test_transformed_loss_and_gradients(self): + from trl.trainer.sft_trainer import _chunked_cross_entropy_loss + + for scale, cap in ((0.35, None), (1.0, 1.7), (0.6, 2.3)): + torch.manual_seed(411) + h = torch.randn(2, 11, 7, requires_grad=True) + w = torch.randn(29, 7, requires_grad=True) + b = torch.randn(29, requires_grad=True) + targets = torch.randint(29, (2, 11)) + targets[:, ::3] = -100 + hr, wr, br = [x.detach().clone().requires_grad_() for x in (h, w, b)] + valid = targets != -100 + logits = F.linear(hr[valid], wr, br) * scale + if cap is not None: + logits = cap * torch.tanh(logits / cap) + expected = F.cross_entropy(logits, targets[valid], reduction="sum") / 13 + logp = logits.log_softmax(-1) + correct = (logits.argmax(-1) == targets[valid]).sum() + entropy = -(logp.exp() * logp).sum() + result = _chunked_cross_entropy_loss( + h, w, 4, shift_labels=targets, num_items_in_batch=13, + lm_head_bias=b, logit_scale=scale, final_logit_softcapping=cap, + ) + for value in result: + assert isinstance(value, torch.Tensor) and value.ndim == 0 + torch.testing.assert_close(result[0], expected, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(result[1].float(), correct.float()) + torch.testing.assert_close(result[2], entropy, atol=1e-5, rtol=1e-5) + result[0].backward() + expected.backward() + for actual, reference in zip((h, w, b), (hr, wr, br)): + torch.testing.assert_close(actual.grad, reference.grad, atol=1e-5, rtol=1e-5) + + def test_model_postprocessing(self): + from transformers import CohereConfig, CohereForCausalLM, Gemma2Config, Gemma2ForCausalLM + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + + common = dict(vocab_size=128, hidden_size=32, intermediate_size=64, + num_hidden_layers=1, num_attention_heads=4, + num_key_value_heads=2, max_position_embeddings=128, + pad_token_id=0, bos_token_id=1, eos_token_id=2) + models = [ + CohereForCausalLM(CohereConfig(**common, logit_scale=0.3)), + Gemma2ForCausalLM(Gemma2Config(**common, head_dim=8, + final_logit_softcapping=1.2)), + ] + torch.manual_seed(412) + ids = torch.randint(3, 128, (2, 9)) + labels = ids.clone() + labels[:, :3] = -100 + for reference in models: + reference.eval() + model = copy.deepcopy(reference) + _patch_chunked_ce_lm_head(model, 3) + with torch.no_grad(): + expected = reference(input_ids=ids, labels=labels) + actual = model(input_ids=ids, labels=labels) + free_expected = reference(input_ids=ids) + free_actual = model(input_ids=ids) + assert actual.logits is None + torch.testing.assert_close(actual.loss, expected.loss, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(free_actual.logits, free_expected.logits, atol=1e-5, rtol=1e-5) + + def test_moe_auxiliary_loss(self): + from transformers import MixtralConfig, MixtralForCausalLM + from trl.trainer.sft_trainer import _patch_chunked_ce_lm_head + + torch.manual_seed(413) + reference = MixtralForCausalLM(MixtralConfig( + vocab_size=128, hidden_size=32, intermediate_size=64, + num_hidden_layers=1, num_attention_heads=4, num_key_value_heads=2, + num_local_experts=4, num_experts_per_tok=2, + max_position_embeddings=128, router_aux_loss_coef=0.3, + output_router_logits=True, pad_token_id=0, bos_token_id=1, eos_token_id=2, + )).eval() + model = copy.deepcopy(reference) + _patch_chunked_ce_lm_head(model, 3) + ids = torch.randint(3, 128, (2, 9)) + mask = torch.ones_like(ids) + mask[0, -2:] = 0 + labels = ids.clone() + labels[mask == 0] = -100 + labels[:, :2] = -100 + for enabled in (False, True): + reference.zero_grad(set_to_none=True) + model.zero_grad(set_to_none=True) + expected = reference(input_ids=ids, attention_mask=mask, labels=labels, + output_router_logits=enabled) + actual = model(input_ids=ids, attention_mask=mask, labels=labels, + output_router_logits=enabled) + assert actual.logits is None + torch.testing.assert_close(actual.loss, expected.loss, atol=1e-5, rtol=1e-5) + if enabled: + assert expected.aux_loss.item() > 0 + torch.testing.assert_close(actual.aux_loss, expected.aux_loss, atol=1e-5, rtol=1e-5) + expected.loss.backward() + actual.loss.backward() + for name, parameter in reference.named_parameters(): + if parameter.grad is not None: + torch.testing.assert_close(model.get_parameter(name).grad, parameter.grad, + atol=2e-5, rtol=2e-5) + + def test_trainer_training_and_metrics(self, tmp_path): + from trl import SFTTrainer + + torch.manual_seed(414) + kwargs = trainer_inputs(tmp_path) + reference = copy.deepcopy(kwargs["model"]).eval() + trainer = SFTTrainer(**kwargs) + device = next(trainer.model.parameters()).device + reference.to(device) + ids = torch.tensor([[1, 9, 12, 17, 20, 2], [1, 8, 11, 16, 19, 2]], device=device) + labels = ids.clone() + labels[0, :4] = -100 + labels[1, :2] = -100 + batch = dict(input_ids=ids, attention_mask=torch.ones_like(ids), labels=labels) + with torch.no_grad(): + expected = reference(**batch) + valid = labels[:, 1:] != -100 + logp = expected.logits[:, :-1].float().log_softmax(-1) + accuracy = (logp.argmax(-1)[valid] == labels[:, 1:][valid]).float().mean().item() + entropy = -(logp.exp() * logp).sum(-1)[valid].mean().item() + trainer.model.eval() + loss, output = trainer.compute_loss(trainer.model, dict(batch), return_outputs=True) + assert output.logits is None + torch.testing.assert_close(loss, expected.loss, atol=1e-5, rtol=1e-5) + assert trainer._metrics["eval"]["entropy"][-1] == pytest.approx(entropy, abs=1e-5) + assert trainer._metrics["eval"]["mean_token_accuracy"][-1] == pytest.approx(accuracy, abs=1e-5) + before = trainer.model.lm_head.weight.detach().clone() + trainer.train() + assert trainer.state.global_step == 1 + assert not torch.equal(before, trainer.model.lm_head.weight) + logged = [row for row in trainer.state.log_history if "entropy" in row] + assert logged and "mean_token_accuracy" in logged[-1] + assert 0 <= logged[-1]["mean_token_accuracy"] <= 1 + assert logged[-1]["entropy"] > 0 + + def test_trainer_validation(self, tmp_path): + from trl import SFTTrainer + + kwargs = trainer_inputs(tmp_path / "unknown", loss_type="not_a_loss") + with pytest.raises(ValueError) as error: + SFTTrainer(**kwargs) + for name in ("nll", "dft", "chunked_nll"): + assert name in str(error.value) + kwargs = trainer_inputs(tmp_path / "liger", use_liger_kernel=True) + with pytest.raises(ValueError): + SFTTrainer(**kwargs) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_activation_offloading.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_activation_offloading.py new file mode 100644 index 0000000000000000000000000000000000000000..35d8432d81d13f28e4bc1072dd30ae5228770d93 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_activation_offloading.py @@ -0,0 +1,209 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import torch +from torch import nn +from transformers import AutoModelForCausalLM +from transformers.testing_utils import torch_device +from transformers.utils import is_peft_available + +from trl.models.activation_offloading import NoOpManager, OffloadActivations + +from .testing_utils import TrlTestCase, require_peft, require_torch_accelerator + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +class TestActivationOffloading(TrlTestCase): + @require_torch_accelerator + @require_peft + def test_offloading_with_peft_models(self) -> None: + """Test that activation offloading works with PEFT models.""" + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id).to(torch_device) + peft_config = LoraConfig( + lora_alpha=16, + lora_dropout=0.1, + r=8, + bias="none", + task_type="CAUSAL_LM", + ) + + model = get_peft_model(model, peft_config) + inp = torch.randint(0, 100, (2, 10), device=torch_device) + + # First forward-backward pass without offloading + torch.manual_seed(42) + loss = model(inp, labels=inp).loss + loss.backward() + + # Store gradients - only from trainable parameters + grads_original = [] + for name, param in model.named_parameters(): + if param.requires_grad and param.grad is not None: + grads_original.append((name, param.grad.clone())) + + # Reset gradients + for p in model.parameters(): + if p.grad is not None: + p.grad = None + + # Second forward-backward pass with offloading + torch.manual_seed(42) + with OffloadActivations(): + loss_c = model(inp, labels=inp).loss + loss_c.backward() + + # Compare gradients - only trainable parameters + for name_orig, grad_orig in grads_original: + for name_param, param in model.named_parameters(): + if name_param == name_orig and param.requires_grad and param.grad is not None: + ( + torch.testing.assert_close(grad_orig, param.grad, rtol=1e-4, atol=1e-5), + (f"Gradient mismatch for {name_orig}"), + ) + + @require_torch_accelerator + def test_noop_manager_with_offloading(self): + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id).to(torch_device) + inp = torch.randint(0, 100, (2, 10), device=torch_device) + + # Run with offloading but disable for specific section + with OffloadActivations(): + # First forward-backward with normal offloading + torch.manual_seed(42) + out1 = model(inp, labels=inp) + out1.loss.backward() + grads1 = [p.grad.clone() for p in model.parameters()] + + # Reset grads + for p in model.parameters(): + p.grad = None + + # Second forward-backward with NoOpManager + with NoOpManager(): + torch.manual_seed(42) + out2 = model(inp, labels=inp) + out2.loss.backward() + + grads2 = [p.grad.clone() for p in model.parameters()] + + # Gradients should match as NoOpManager should have prevented offloading + for g1, g2 in zip(grads1, grads2, strict=True): + torch.testing.assert_close(g1, g2, rtol=1e-4, atol=1e-5) + + @require_torch_accelerator + def test_min_offload_size(self): + """Test that tensors smaller than min_offload_size aren't offloaded""" + model = nn.Sequential( + nn.Linear(5, 5), # Small layer that shouldn't be offloaded + nn.Linear(5, 1000), # Large layer that should be offloaded + ).to(torch_device) + + inp = torch.randn(2, 5, device=torch_device) + + with OffloadActivations(min_offload_size=1000): + out = model(inp) + out.sum().backward() + + # The test passes if no errors occur, as we're mainly testing + # that the logic handles both offloaded and non-offloaded tensors + + @require_torch_accelerator + def test_real_hf_model(self): + """Test with an actual HuggingFace model""" + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id).to(torch_device) + + # Create small input + inp = torch.randint(0, 100, (2, 10), device=torch_device) + + # Baseline without offloading + torch.manual_seed(42) + out1 = model(inp, labels=inp).loss + out1.backward() + grads1 = [p.grad.clone() for p in model.parameters()] + + # Reset grads + for p in model.parameters(): + p.grad = None + + # With offloading + with OffloadActivations(): + torch.manual_seed(42) + out2 = model(inp, labels=inp).loss + out2.backward() + + grads2 = [p.grad.clone() for p in model.parameters()] + + # Check outputs and gradients match + torch.testing.assert_close(out1, out2) + for g1, g2 in zip(grads1, grads2, strict=True): + torch.testing.assert_close(g1, g2) + + @require_torch_accelerator + def test_tensor_deduplication(self): + """Test that deduplication works correctly for tensors sharing storage""" + + class ModelWithViews(nn.Module): + def __init__(self): + super().__init__() + self.linear = nn.Linear(100, 100) + + def forward(self, x): + out = self.linear(x) + view1 = out.view(-1) + view2 = out.transpose(0, 1) + return view1.sum() + view2.sum() + + model = ModelWithViews().to(torch_device) + offload_ctx = OffloadActivations(min_offload_size=1) + offload_ctx.update_model_params(model) + + x = torch.randn(10, 100, device=torch_device, requires_grad=True) + with offload_ctx: + loss = model(x) + + total_tensor_ids = offload_ctx.tensor_id + assert total_tensor_ids > 0, "Should have created tensor IDs" + + # modified=True means offloaded to CPU, modified=False means kept on GPU (deduplicated) + deduplicated_count = sum(1 for _, modified, _, _, _ in offload_ctx.tracker.values() if not modified) + offloaded_count = sum(1 for _, modified, _, _, _ in offload_ctx.tracker.values() if modified) + + assert offloaded_count > 0, "Should have offloaded at least one tensor" + assert deduplicated_count > 0, "Should have deduplicated at least one tensor (view)" + + unique_storages_offloaded = len(offload_ctx.storage_to_tensor_id) + assert unique_storages_offloaded < total_tensor_ids, ( + f"Deduplication should result in fewer storages ({unique_storages_offloaded}) " + f"than total tensors ({total_tensor_ids})" + ) + + loss.backward() + + @require_torch_accelerator + def test_parameter_filtering(self): + """Test that model parameters are filtered during offloading""" + model = nn.Sequential(nn.Linear(10, 20), nn.Linear(20, 10)).to(torch_device) + offload_ctx = OffloadActivations() + offload_ctx.update_model_params(model) + + assert len(offload_ctx.param_storages) > 0, "Should have tracked parameter storages" + + param_ptrs = {p.data.untyped_storage().data_ptr() for p in model.parameters()} + assert offload_ctx.param_storages == param_ptrs, "Tracked storages should match parameter storages" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_callbacks.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_callbacks.py new file mode 100644 index 0000000000000000000000000000000000000000..ef2aa71d81644f11b5963974d3f5f849334a93fd --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_callbacks.py @@ -0,0 +1,238 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import os +from unittest.mock import call, patch + +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, Trainer, TrainingArguments + +from trl import BEMACallback, LogCompletionsCallback + +from .testing_utils import TrlTestCase, require_comet, require_wandb + + +class TestLogCompletionsCallback(TrlTestCase): + def setup_method(self): + self.model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + self.tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + self.tokenizer.pad_token = self.tokenizer.eos_token + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + dataset["train"] = dataset["train"].select(range(8)) + + def tokenize_function(examples): + out = self.tokenizer(examples["prompt"], padding="max_length", max_length=16, truncation=True) + out["labels"] = out["input_ids"].copy() + return out + + self.dataset = dataset.map(tokenize_function, batched=True) + + self.generation_config = GenerationConfig(max_length=32) + + @require_wandb + def test_basic_wandb(self): + import wandb + + training_args = TrainingArguments( + output_dir=self.tmp_dir, + eval_strategy="steps", + eval_steps=2, # evaluate every 2 steps + per_device_train_batch_size=2, # 8 samples in total so 4 batches of 2 per epoch + per_device_eval_batch_size=2, + report_to="wandb", + ) + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + eval_dataset=self.dataset["test"], + processing_class=self.tokenizer, + ) + completions_callback = LogCompletionsCallback(trainer, self.generation_config, num_prompts=2) + trainer.add_callback(completions_callback) + trainer.train() + + # Get the current run + completions_path = wandb.run.summary.completions["path"] + json_path = os.path.join(wandb.run.dir, completions_path) + with open(json_path) as f: + completions = json.load(f) + + # Check that the columns are correct + assert "step" in completions["columns"] + assert "prompt" in completions["columns"] + assert "completion" in completions["columns"] + + # Check that the prompt is in the log + assert self.dataset["test"][0]["prompt"] in completions["data"][0] + + @require_comet + def test_basic_comet(self): + import comet_ml + + training_args = TrainingArguments( + output_dir=self.tmp_dir, + eval_strategy="steps", + eval_steps=2, # evaluate every 2 steps + per_device_train_batch_size=2, # 8 samples in total so 4 batches of 2 per epoch + per_device_eval_batch_size=2, + report_to="comet_ml", + ) + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + eval_dataset=self.dataset["test"], + processing_class=self.tokenizer, + ) + completions_callback = LogCompletionsCallback(trainer, self.generation_config, num_prompts=2) + trainer.add_callback(completions_callback) + trainer.train() + + # close experiment to make sure all pending data are flushed + experiment = comet_ml.get_running_experiment() + assert experiment is not None + experiment.end() + + # get experiment assets and check that all required tables was logged + steps = len(self.dataset["train"]) + len(self.dataset["test"]) + tables_logged = int(steps / 2) + 1 # +1 to include zero step + + api_experiment = comet_ml.APIExperiment(previous_experiment=experiment.id) + tables = api_experiment.get_asset_list("dataframe") + assert tables is not None + assert len(tables) == tables_logged + assert all(table["fileName"] == "completions.csv" for table in tables) + + +class TestBEMACallback(TrlTestCase): + def setup_method(self): + self.model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + self.tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + self.tokenizer.pad_token = self.tokenizer.eos_token + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + def tokenize_function(examples, tokenizer): + out = tokenizer(examples["text"], padding="max_length", max_length=17) + out["labels"] = out["input_ids"].copy() + return out + + self.dataset = dataset.map( + tokenize_function, fn_kwargs={"tokenizer": self.tokenizer}, remove_columns=["text"], batched=True + ) + + def test_model_saved(self): + """Test that BEMACallback saves the BEMA model.""" + training_args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + bema_callback = BEMACallback(update_freq=2) + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + processing_class=self.tokenizer, + callbacks=[bema_callback], + ) + trainer.train() + + # Check that the BEMA model was saved and can be loaded + bema_path = os.path.join(self.tmp_dir, "bema") + assert os.path.isdir(bema_path), "BEMA directory was not created" + AutoModelForCausalLM.from_pretrained(bema_path) + + def test_update_frequency_0(self): + """Test that BEMA callback respects the update frequency.""" + training_args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + bema_callback = BEMACallback(update_freq=2) + + with patch.object(bema_callback, "_update_bema_weights") as mock_update: + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + processing_class=self.tokenizer, + callbacks=[bema_callback], + ) + + trainer.train() + + # Total 9 steps (17 samples, batch size 8, 3 epochs). + # BEMA starts after step 0 and updates every 2 steps → updates at 2, 4, 5, 8 + assert mock_update.call_args_list == [call(2), call(4), call(6), call(8)] + + def test_update_frequency_1(self): + """Test that BEMA callback respects the update frequency.""" + training_args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + bema_callback = BEMACallback(update_freq=3) + + with patch.object(bema_callback, "_update_bema_weights") as mock_update: + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + processing_class=self.tokenizer, + callbacks=[bema_callback], + ) + + trainer.train() + + # Total 9 steps (17 samples, batch size 8, 3 epochs). + # BEMA starts after step 0 and updates every 3 steps → updates at 3, 6, 9 + assert mock_update.call_args_list == [call(3), call(6), call(9)] + + def test_update_frequency_2(self): + """Test that BEMA callback respects the update frequency.""" + training_args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + bema_callback = BEMACallback(update_freq=2, update_after=3) + + with patch.object(bema_callback, "_update_bema_weights") as mock_update: + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + processing_class=self.tokenizer, + callbacks=[bema_callback], + ) + + trainer.train() + + # Total 9 steps (17 samples, batch size 8, 3 epochs). + # BEMA starts after step 3 and updates every 2 steps → updates at 5, 7, 9 + assert mock_update.call_args_list == [call(5), call(7), call(9)] + + def test_no_bema(self): + """Test that BEMACallback works without BEMA updates.""" + training_args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + bema_callback = BEMACallback(update_freq=2, bias_power=0.0) + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + processing_class=self.tokenizer, + callbacks=[bema_callback], + ) + trainer.train() + + def test_no_ema(self): + """Test that BEMACallback works without EMA updates.""" + training_args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + bema_callback = BEMACallback(update_freq=2, ema_power=0.0) + trainer = Trainer( + model=self.model, + args=training_args, + train_dataset=self.dataset["train"], + processing_class=self.tokenizer, + callbacks=[bema_callback], + ) + trainer.train() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_chat_template_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_chat_template_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..9ce97297a3ba69470d843eebbacbfa327f929232 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_chat_template_utils.py @@ -0,0 +1,874 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +import textwrap + +import pytest +import transformers +from packaging.version import Version +from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoProcessor, AutoTokenizer + +from trl import clone_chat_template +from trl.chat_template_utils import ( + add_response_schema, + get_training_chat_template, + is_chat_template_prefix_preserving, + parse_response, + supports_tool_calling, +) +from trl.data_utils import prepare_multimodal_messages + +from .testing_utils import TrlTestCase, require_jmespath, require_vision + + +class TestCloneChatTemplate(TrlTestCase): + def test_clone(self): + # This tokenizer doesn't have a chat_template by default + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + # This one has a chat_template by default + source = "trl-internal-testing/tiny-Qwen3ForCausalLM" + _, modified_tokenizer, _ = clone_chat_template(model, tokenizer, source) + + # Check if special tokens are correctly set + assert modified_tokenizer.eos_token == "<|im_end|>" + + def test_clone_with_resize(self): + # This tokenizer doesn't have a chat_template by default + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + # This one has a chat_template by default + source = "trl-internal-testing/tiny-Qwen3ForCausalLM" + modified_model, modified_tokenizer, _ = clone_chat_template( + model, tokenizer, source, resize_to_multiple_of=123 + ) + + # Check that the input embeddings have been resized to a multiple of 123 + assert (modified_model.vocab_size % 123) == 0 + # Check that the input embeddings size matches the tokenizer vocabulary size + assert model.vocab_size == len(modified_tokenizer.vocab) + + def test_clone_with_resize_and_extra_tokens_already_in_vocab(self): + # This tokenizer doesn't have a chat_template by default + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + # This one has a chat_template by default + source = "trl-internal-testing/tiny-Qwen3ForCausalLM" + # This will add , , ... to the tokenizer + modified_model, modified_tokenizer, _ = clone_chat_template( + model, tokenizer, source, resize_to_multiple_of=123 + ) + # Try if we can resize a tokenizer that already has extra these extra tokens + modified_model, modified_tokenizer, _ = clone_chat_template( + modified_model, modified_tokenizer, source, resize_to_multiple_of=124 + ) + + # Check that the input embeddings have been resized to a multiple of 123 + assert (modified_model.vocab_size % 124) == 0 + # Check that the input embeddings size matches the tokenizer vocabulary size + assert model.vocab_size == len(modified_tokenizer.vocab) + + def test_apply_new_chat_template(self): + # This tokenizer doesn't have a chat_template by default + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-BloomForCausalLM") + # This one has a chat_template by default + source = "trl-internal-testing/tiny-Qwen3ForCausalLM" + _, modified_tokenizer, _ = clone_chat_template(model, tokenizer, source) + messages = [ + {"role": "system", "content": "You are helpful"}, + {"role": "user", "content": "Hello"}, + {"role": "assistant", "content": "Hi, how can I help you?"}, + ] + prompt = modified_tokenizer.apply_chat_template(messages, tokenize=False) + + assert ( + prompt + == "<|im_start|>system\nYou are helpful<|im_end|>\n<|im_start|>user\nHello<|im_end|>\n<|im_start|>assistant\n\n\n\n\nHi, how can I help you?<|im_end|>\n" + ) + + def test_clone_with_sequence_classification_model(self): + # This tokenizer doesn't have a chat_template by default + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptNeoXForSequenceClassification") + model = AutoModelForSequenceClassification.from_pretrained( + "trl-internal-testing/tiny-GptNeoXForSequenceClassification" + ) + # This one has a chat_template by default + source = "trl-internal-testing/tiny-Qwen3ForCausalLM" + _, modified_tokenizer, _ = clone_chat_template(model, tokenizer, source) + + # Check if special tokens are correctly set + assert modified_tokenizer.eos_token == "<|im_end|>" + + +@pytest.mark.xfail( + condition=Version(transformers.__version__) < Version("5.0.0"), + reason="Response parsing is not supported in transformers versions below 5.0.0", + strict=True, +) +@require_jmespath +class TestAddResponseSchema: + @pytest.mark.parametrize( + "tokenizer_name", + [ + pytest.param("trl-internal-testing/tiny-Glm4MoeForCausalLM", id="glm4moe"), + pytest.param("trl-internal-testing/tiny-GptOssForCausalLM", id="gptoss"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3.1", id="llama3.1"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3.2", id="llama3.2"), + pytest.param("trl-internal-testing/tiny-Qwen3MoeForCausalLM", id="qwen3"), + ], + ) + def test_add_response_schema(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + tokenizer = add_response_schema(tokenizer) + messages = [ + {"role": "user", "content": "What is 3*4?"}, + { + "role": "assistant", + "tool_calls": [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}], + }, + ] + prefix = tokenizer.apply_chat_template(messages[:1], tokenize=False, add_generation_prompt=True) + text = tokenizer.apply_chat_template(messages, tokenize=False) + response = text[len(prefix) :] + # Here, we just test that the parsing doesn't raise an error. + # The correctness of the parsing is tested in TestParseResponse + tokenizer.parse_response(response) + + @pytest.mark.parametrize( + "processor_name", + [ + pytest.param("trl-internal-testing/tiny-Qwen3VLForConditionalGeneration", id="qwen3_vl"), + pytest.param("trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", id="qwen35"), + pytest.param("trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", id="qwen36"), + ], + ) + def test_add_response_schema_vlm(self, processor_name): + # For VLM processors, `add_response_schema` must set the schema on the inner tokenizer, since + # `parse_response` is a tokenizer method that reads `self.response_schema` from the tokenizer instance. + processor = AutoProcessor.from_pretrained(processor_name) + processor = add_response_schema(processor) + assert processor.tokenizer.response_schema is not None + messages = [ + {"role": "user", "content": [{"type": "text", "text": "What is 3*4?"}]}, + { + "role": "assistant", + # "content" is required here because VLM processors crash on tokenize=True without it + # (KeyError in processing_utils.py). See huggingface/transformers#45290. + "content": [{"type": "text", "text": ""}], + "tool_calls": [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}], + }, + ] + prefix = processor.apply_chat_template(messages[:1], tokenize=False, add_generation_prompt=True) + text = processor.apply_chat_template(messages, tokenize=False) + response = text[len(prefix) :] + # Here, we just test that the parsing doesn't raise an error. + # The correctness of the parsing is tested in TestParseResponse + processor.tokenizer.parse_response(response) + + +class TestSupportsToolCalling: + @pytest.mark.parametrize( + "model_id", + [ + pytest.param("trl-internal-testing/tiny-DeepseekV3ForCausalLM", id="deepseekv3"), + pytest.param("trl-internal-testing/tiny-DeepseekV3ForCausalLM-0528", id="deepseekv3-0528"), + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + id="gemma4", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Glm4MoeForCausalLM", + id="glm4moe", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="GLM4 tokenizer requires transformers>=5.0.0", + ), + ), + pytest.param("trl-internal-testing/tiny-GptOssForCausalLM", id="gptoss"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3.1", id="llama3.1"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3.2", id="llama3.2"), + pytest.param("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", id="qwen2.5"), + pytest.param("trl-internal-testing/tiny-Qwen3ForCausalLM", id="qwen3"), + pytest.param("trl-internal-testing/tiny-Qwen3MoeForCausalLM", id="qwen3moe"), + pytest.param( + "trl-internal-testing/tiny-Qwen3VLForConditionalGeneration", + id="qwen3_vl", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("4.57.0"), + reason="Qwen3-VL was introduced in transformers-4.57.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + id="qwen35", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="Qwen3.5 tokenizer requires transformers>=5.0.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + id="qwen36", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="Qwen3.5 tokenizer requires transformers>=5.0.0", + ), + ), + ], + ) + def test_supports_tool_calling(self, model_id): + tokenizer = AutoTokenizer.from_pretrained(model_id) + assert supports_tool_calling(tokenizer) is True + + @pytest.mark.parametrize( + "model_id", + [ + # No chat template + pytest.param("trl-internal-testing/tiny-BartModel", id="bart"), + pytest.param("trl-internal-testing/tiny-BloomForCausalLM", id="bloom"), + pytest.param("trl-internal-testing/tiny-GPT2LMHeadModel", id="gpt2"), + pytest.param("trl-internal-testing/tiny-GPTNeoXForCausalLM", id="gptneox"), + pytest.param("trl-internal-testing/tiny-GptNeoXForSequenceClassification", id="gptneox-seq"), + pytest.param("trl-internal-testing/tiny-OPTForCausalLM", id="opt"), + pytest.param("trl-internal-testing/tiny-T5ForConditionalGeneration", id="t5"), + # TemplateError: rejects tool role sequence + pytest.param("trl-internal-testing/tiny-CohereForCausalLM", id="cohere"), + pytest.param("trl-internal-testing/tiny-FalconMambaForCausalLM", id="falconmamba"), + pytest.param("trl-internal-testing/tiny-GemmaForCausalLM", id="gemma"), + pytest.param("trl-internal-testing/tiny-Gemma2ForCausalLM", id="gemma2"), + pytest.param("trl-internal-testing/tiny-Gemma3ForConditionalGeneration", id="gemma3"), + pytest.param("trl-internal-testing/tiny-Idefics2ForConditionalGeneration", id="idefics2"), + pytest.param("trl-internal-testing/tiny-Idefics3ForConditionalGeneration", id="idefics3"), + pytest.param("trl-internal-testing/tiny-LlavaNextForConditionalGeneration", id="llava_next"), + pytest.param("trl-internal-testing/tiny-MistralForCausalLM-0.1", id="mistral0.1"), + pytest.param("trl-internal-testing/tiny-MistralForCausalLM-0.2", id="mistral0.2"), + pytest.param("trl-internal-testing/tiny-SmolVLMForConditionalGeneration", id="smolvlm"), + # Silently drops both tool_calls and tool messages + pytest.param("trl-internal-testing/tiny-Cohere2ForCausalLM", id="cohere2"), + pytest.param("trl-internal-testing/tiny-LlavaForConditionalGeneration", id="llava"), + pytest.param("trl-internal-testing/tiny-Phi3ForCausalLM-3", id="phi3"), + pytest.param("trl-internal-testing/tiny-Phi3ForCausalLM-3.5", id="phi3.5"), + # Renders tool message content as plain text but drops assistant tool_calls + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3", id="llama3"), + pytest.param("trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", id="qwen2_vl"), + pytest.param("trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", id="qwen2.5_vl"), + ], + ) + def test_does_not_support_tool_calling(self, model_id): + tokenizer = AutoTokenizer.from_pretrained(model_id) + assert supports_tool_calling(tokenizer) is False + + +class TestIsChatTemplatePrefixPreserving: + def test_prefix_preserving_template(self): + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen3MoeForCausalLM") + # docstyle-ignore + tokenizer.chat_template = textwrap.dedent(r""" + {%- for message in messages %} + + {%- if message.role == 'user' %} + {{- '<|im_start|>user\n' + message.content + '<|im_end|>\n' }} + {%- elif message.role == 'assistant' %} + {{- '<|im_start|>assistant\n' + message.content }} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '' + tool_call.name + '' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == 'tool' %} + {{- '<|im_start|>tool\n' + message.content + '<|im_end|>\n' }} + {%- endif %} + + {%- endfor %} + + {%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- endif %}""") + assert is_chat_template_prefix_preserving(tokenizer) is True + + def test_non_prefix_preserving_template(self): + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen3MoeForCausalLM") + # The following template is quite typical of models like Qwen3 and GPT-OSS, where the thinking part (even + # empty) is only present for last assistant message, which makes it non-prefix-preserving: appending a tool + # message changes the earlier output. + # docstyle-ignore + tokenizer.chat_template = textwrap.dedent(r""" + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} + {%- endif %} + {%- set ns = namespace(last_query_index=messages|length - 1) %} + {%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if message.role == "user" and message.content is string %} + {%- set ns.last_query_index = index %} + {%- break %} + {%- endif %} + {%- endfor %} + {%- for message in messages %} + {%- set content = message.content if message.content is string else '' %} + {%- if message.role == "user" or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- if loop.index0 > ns.last_query_index %} + {%- if loop.last or (not loop.last and reasoning_content) %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '' + tool_call.name + '' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {{- '<|im_start|>tool\n' + content + '<|im_end|>\n' }} + {%- endif %} + {%- endfor %} + {%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- endif %} + {%- endif %}""") + assert is_chat_template_prefix_preserving(tokenizer) is False + + @require_vision + def test_prefix_preserving_template_processor(self): + processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-Qwen3VLForConditionalGeneration") + # Simple prefix-preserving template that mirrors how Qwen-VL templates emit image tokens: a list-of-blocks + # content is iterated, and `{"type": "image"}` blocks are rendered as `<|vision_start|><|image_pad|><|vision_end|>`. + # docstyle-ignore + processor.chat_template = textwrap.dedent(r""" + {%- for message in messages %} + + {%- if message.role == 'user' %} + {{- '<|im_start|>user\n' }} + {%- if message.content is string %} + {{- message.content }} + {%- else %} + {%- for content in message.content %} + {%- if content.type == 'image' or 'image' in content %} + {{- '<|vision_start|><|image_pad|><|vision_end|>' }} + {%- elif 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == 'assistant' %} + {{- '<|im_start|>assistant\n' }} + {%- if message.content is string %} + {{- message.content }} + {%- else %} + {%- for content in message.content %} + {%- if 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '' + tool_call.name + '' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == 'tool' %} + {{- '<|im_start|>tool\n' }} + {%- if message.content is string %} + {{- message.content }} + {%- else %} + {%- for content in message.content %} + {%- if 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- endif %} + + {%- endfor %} + + {%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- endif %}""") + assert is_chat_template_prefix_preserving(processor) is True + + +@pytest.mark.parametrize( + "tokenizer_name", + [ + pytest.param("trl-internal-testing/tiny-DeepseekV3ForCausalLM", id="deepseekv3"), + pytest.param("trl-internal-testing/tiny-GemmaForCausalLM", id="gemma"), + pytest.param("trl-internal-testing/tiny-Gemma2ForCausalLM", id="gemma2"), + pytest.param( + "trl-internal-testing/tiny-Glm4MoeForCausalLM", + id="glm4moe", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="GLM4 tokenizer requires transformers>=5.0.0", + ), + ), + pytest.param("trl-internal-testing/tiny-GptOssForCausalLM", id="gptoss"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3", id="llama3"), + pytest.param("trl-internal-testing/tiny-Phi3ForCausalLM-3", id="phi3"), + pytest.param("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", id="qwen2.5"), + pytest.param("trl-internal-testing/tiny-Qwen3MoeForCausalLM", id="qwen3"), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + id="qwen36", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="Qwen3.5 tokenizer requires transformers>=5.0.0", + ), + ), + ], +) +class TestGetTrainingChatTemplate: + def test_new_chat_template_is_prefix_preserving(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + tokenizer.chat_template = get_training_chat_template(tokenizer) + # Prefix-preservation is only meaningful for templates that actually support tool messages — the check + # itself renders one. Skip the assertion for tool-less templates (e.g. Gemma). + if not supports_tool_calling(tokenizer): + pytest.skip("Template does not support tool calling; prefix-preservation check is not applicable.") + assert is_chat_template_prefix_preserving(tokenizer) is True + + def test_behavior_unchanged_single_user_no_generation_prompt(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [{"role": "user", "content": "What color is the sky?"}] + before = tokenizer.apply_chat_template(messages, tokenize=False) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_single_user_with_generation_prompt(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [{"role": "user", "content": "What color is the sky?"}] + before = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template( + messages, + tokenize=False, + add_generation_prompt=True, + chat_template=new_chat_template, + ) + assert before == after + + def test_behavior_unchanged_single_user_and_final_assistant_plain_content(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ] + before = tokenizer.apply_chat_template(messages, tokenize=False) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_final_assistant_with_reasoning_content(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [ + {"role": "user", "content": "What color is the sky?"}, + { + "role": "assistant", + "content": "It is blue.", + "reasoning_content": "The sky appears blue due to Rayleigh scattering.", + }, + ] + before = tokenizer.apply_chat_template(messages, tokenize=False) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_final_assistant_with_existing_think_tags(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [ + {"role": "user", "content": "What color is the sky?"}, + { + "role": "assistant", + "content": "\nThe sky scatters shorter wavelengths.\n\n\nIt is blue.", + }, + ] + before = tokenizer.apply_chat_template(messages, tokenize=False) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_assistant_with_tool_calls(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + tool_calls = [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}] + messages = [ + {"role": "user", "content": "Multiply 3 by 4."}, + {"role": "assistant", "content": "I will call a tool.", "tool_calls": tool_calls}, + ] + messages_before = copy.deepcopy(messages) + if tokenizer_name == "trl-internal-testing/tiny-DeepseekV3ForCausalLM": + # Best-effort fallback for templates that reject dict args (e.g. DeepSeek-V3). This is a chat template + # bug (see transformers#45419), and the training chat template fixes it to avoid blocking users. + messages_before[1]["tool_calls"][0]["function"]["arguments"] = '{"a": 3, "b": 4}' + + before = tokenizer.apply_chat_template(messages_before, tokenize=False) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_with_tools_with_and_without_system_message(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + tools = [ + { + "type": "function", + "function": { + "name": "multiply", + "description": "Multiply two numbers.", + "parameters": { + "type": "object", + "properties": { + "a": {"type": "number"}, + "b": {"type": "number"}, + }, + "required": ["a", "b"], + }, + }, + } + ] + messages = [{"role": "user", "content": "Multiply 3 by 4."}] + before = tokenizer.apply_chat_template(messages, tokenize=False, tools=tools) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, tools=tools, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_with_tools_with_system_message(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + if not supports_tool_calling(tokenizer): + pytest.skip("Template does not support tool calling; skipping tool_calls test.") + tools = [ + { + "type": "function", + "function": { + "name": "multiply", + "description": "Multiply two numbers.", + "parameters": { + "type": "object", + "properties": {"a": {"type": "number"}, "b": {"type": "number"}}, + "required": ["a", "b"], + }, + }, + } + ] + messages = [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Multiply 3 by 4."}, + ] + before = tokenizer.apply_chat_template(messages, tokenize=False, tools=tools) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template(messages, tokenize=False, tools=tools, chat_template=new_chat_template) + assert before == after + + def test_behavior_unchanged_generation_prompt_with_enable_thinking_false(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [{"role": "user", "content": "What color is the sky?"}] + before = tokenizer.apply_chat_template( + messages, tokenize=False, add_generation_prompt=True, enable_thinking=False + ) + new_chat_template = get_training_chat_template(tokenizer) + after = tokenizer.apply_chat_template( + messages, + tokenize=False, + add_generation_prompt=True, + enable_thinking=False, + chat_template=new_chat_template, + ) + assert before == after + + def test_assistant_masks(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ] + chat_template = get_training_chat_template(tokenizer) + result = tokenizer.apply_chat_template( + messages, chat_template=chat_template, return_assistant_tokens_mask=True, return_dict=True + ) + masks = result["assistant_masks"] + assert 1 in masks + # The first tokens (user turn) should not be masked + assert masks[0] == 0 + # The last tokens (assistant turn ending with <|im_end|>) should be masked + assert masks[-1] == 1 + + def test_assistant_masks_multi_turn(self, tokenizer_name): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_name) + messages = [ + {"role": "user", "content": "Hi"}, + {"role": "assistant", "content": "Hello!"}, + {"role": "user", "content": "Bye"}, + {"role": "assistant", "content": "Goodbye!"}, + ] + chat_template = get_training_chat_template(tokenizer) + result = tokenizer.apply_chat_template( + messages, chat_template=chat_template, return_assistant_tokens_mask=True, return_dict=True + ) + masks = result["assistant_masks"] + # Should have two masked regions (two assistant turns): 0→1, 1→0, 0→1 + transitions = sum(1 for i in range(1, len(masks)) if masks[i] != masks[i - 1]) + assert transitions == 3 + + +@pytest.mark.parametrize( + "model_name", + [ + pytest.param("trl-internal-testing/tiny-Glm4MoeForCausalLM", id="glm4moe"), + pytest.param("trl-internal-testing/tiny-GptOssForCausalLM", id="gptoss"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3.1", id="llama3.1"), + pytest.param("trl-internal-testing/tiny-LlamaForCausalLM-3.2", id="llama3.2"), + pytest.param("trl-internal-testing/tiny-Qwen3MoeForCausalLM", id="qwen3"), + pytest.param("trl-internal-testing/tiny-Qwen3VLForConditionalGeneration", id="qwen3_vl"), + pytest.param("trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", id="qwen35"), + pytest.param("trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", id="qwen36"), + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + id="gemma4", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + ], +) +@pytest.mark.xfail( + condition=Version(transformers.__version__) < Version("5.0.0"), + reason="Response parsing is not supported in transformers versions below 5.0.0", + strict=True, +) +@require_jmespath +class TestParseResponse: + def _load(self, model_name): + if "ForCausalLM" in model_name: + self.is_vlm = False + processing_class = AutoTokenizer.from_pretrained(model_name) + response_schema = getattr(processing_class, "response_schema", None) + elif "ForConditionalGeneration" in model_name: + self.is_vlm = True + processing_class = AutoProcessor.from_pretrained(model_name) + response_schema = getattr(processing_class.tokenizer, "response_schema", None) + + if response_schema is None: + processing_class = add_response_schema(processing_class) + + return processing_class + + def test_parse_response(self, model_name): + processing_class = self._load(model_name) + messages = [ + {"role": "user", "content": "What is 3*4?"}, + {"role": "assistant", "content": "12"}, + ] + expected = messages[-1] + messages = prepare_multimodal_messages(messages) if self.is_vlm else messages + prefix = processing_class.apply_chat_template( + messages[:1], add_generation_prompt=True, tokenize=True, return_dict=True + ).input_ids + text = processing_class.apply_chat_template(messages, tokenize=True, return_dict=True).input_ids + if self.is_vlm: + prefix = prefix[0] + text = text[0] + response = text[len(prefix) :] + parsed = parse_response(processing_class, response) + assert parsed == expected + + def test_parse_response_with_reasoning_content(self, model_name): + if model_name in ( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + "trl-internal-testing/tiny-GptOssForCausalLM", + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-Qwen3VLForConditionalGeneration", + ): + pytest.skip("This tokenizer doesn't support inline reasoning_content.") + + processing_class = self._load(model_name) + messages = [ + {"role": "user", "content": "What is 3*4?"}, + {"role": "assistant", "reasoning_content": "Hmmm.", "content": "12"}, + ] + expected = messages[-1] + messages = prepare_multimodal_messages(messages) if self.is_vlm else messages + # enable_thinking=True is required here because for Qwen3.5, the thinking is disabled by default for the + # generation prompt. + prefix = processing_class.apply_chat_template( + messages[:1], add_generation_prompt=True, enable_thinking=True, tokenize=True, return_dict=True + ).input_ids + text = processing_class.apply_chat_template(messages, tokenize=True, return_dict=True).input_ids + if self.is_vlm: + prefix = prefix[0] + text = text[0] + response = text[len(prefix) :] + parsed = parse_response(processing_class, response) + assert parsed == expected + + def test_parse_response_tool_call(self, model_name): + processing_class = self._load(model_name) + tool_calls = [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}] + messages = [ + {"role": "user", "content": "What is 3*4?"}, + { + "role": "assistant", + # "content" is required here because VLM processors crash on tokenize=True without it + # (KeyError in processing_utils.py). See huggingface/transformers#45290. + "content": "", + "tool_calls": tool_calls, + }, + ] + expected = messages[-1] + messages = prepare_multimodal_messages(messages) if self.is_vlm else messages + prefix = processing_class.apply_chat_template( + messages[:1], add_generation_prompt=True, tokenize=True, return_dict=True + ).input_ids + text = processing_class.apply_chat_template(messages, tokenize=True, return_dict=True).input_ids + if self.is_vlm: + prefix = prefix[0] + text = text[0] + response = text[len(prefix) :] + parsed = parse_response(processing_class, response) + assert parsed == expected + + def test_parse_response_tool_call_with_content(self, model_name): + if model_name in ( + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + ): + pytest.skip("Llama 3.1 / 3.2 templates only allow a single tool call per assistant turn, with no content.") + processing_class = self._load(model_name) + tool_calls = [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}] + messages = [ + {"role": "user", "content": "What is 3*4?"}, + {"role": "assistant", "content": "Let's call the tool.", "tool_calls": tool_calls}, + ] + expected = messages[-1] + messages = prepare_multimodal_messages(messages) if self.is_vlm else messages + prefix = processing_class.apply_chat_template( + messages[:1], add_generation_prompt=True, tokenize=True, return_dict=True + ).input_ids + text = processing_class.apply_chat_template(messages, tokenize=True, return_dict=True).input_ids + if self.is_vlm: + prefix = prefix[0] + text = text[0] + response = text[len(prefix) :] + parsed = parse_response(processing_class, response) + assert parsed == expected + + def test_parse_response_tool_call_without_arguments(self, model_name): + processing_class = self._load(model_name) + tool_calls = [{"type": "function", "function": {"name": "ping", "arguments": {}}}] + messages = [ + {"role": "user", "content": "Ping the service."}, + { + "role": "assistant", + # "content" is required here because VLM processors crash on tokenize=True without it + # (KeyError in processing_utils.py). See huggingface/transformers#45290. + "content": "", + "tool_calls": tool_calls, + }, + ] + expected = messages[-1] + messages = prepare_multimodal_messages(messages) if self.is_vlm else messages + prefix = processing_class.apply_chat_template( + messages[:1], add_generation_prompt=True, tokenize=True, return_dict=True + ).input_ids + text = processing_class.apply_chat_template(messages, tokenize=True, return_dict=True).input_ids + if self.is_vlm: + prefix = prefix[0] + text = text[0] + response = text[len(prefix) :] + parsed = parse_response(processing_class, response) + assert parsed == expected + + def test_parse_response_multiple_tool_calls(self, model_name): + if model_name in ( + "trl-internal-testing/tiny-GptOssForCausalLM", + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + ): + pytest.skip("This template only renders one tool call per assistant message.") + processing_class = self._load(model_name) + tool_calls = [ + {"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}, + {"type": "function", "function": {"name": "addition", "arguments": {"a": 4, "b": 3}}}, + ] + messages = [ + {"role": "user", "content": "What is 3*4?"}, + { + "role": "assistant", + # "content" is required here because VLM processors crash on tokenize=True without it + # (KeyError in processing_utils.py). See huggingface/transformers#45290. + "content": "", + "tool_calls": tool_calls, + }, + ] + expected = messages[-1] + messages = prepare_multimodal_messages(messages) if self.is_vlm else messages + prefix = processing_class.apply_chat_template( + messages[:1], add_generation_prompt=True, tokenize=True, return_dict=True + ).input_ids + text = processing_class.apply_chat_template(messages, tokenize=True, return_dict=True).input_ids + if self.is_vlm: + prefix = prefix[0] + text = text[0] + response = text[len(prefix) :] + parsed = parse_response(processing_class, response) + assert parsed == expected + + def test_parse_response_malformed_tool_call(self, model_name): + if model_name != "trl-internal-testing/tiny-Qwen3MoeForCausalLM": + pytest.skip("For simplicity, we only test the malformed tool call case on one tokenizer.") + processing_class = self._load(model_name) + text = '\n{"name": "multiply", "arguments": {"a": 3, "b": 4}\n<|im_end|>' + assistant_text = processing_class(text)["input_ids"] + parsed = parse_response(processing_class, assistant_text) + expected = { + "role": "assistant", + "content": '\n{"name": "multiply", "arguments": {"a": 3, "b": 4}\n', + } + + assert parsed == expected diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_cli.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_cli.py new file mode 100644 index 0000000000000000000000000000000000000000..30c75cddca413fb9ffcace4d238a07ffcf7031ed --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_cli.py @@ -0,0 +1,140 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from io import StringIO +from unittest.mock import patch + +import pytest +import yaml + +from .testing_utils import TrlTestCase + + +@pytest.mark.parametrize("command", ["dpo", "grpo", "kto", "reward", "rloo", "sft"]) +def test_help_no_type_error(command): + # Regression test for https://github.com/huggingface/trl/issues/5099: + # TrainingArguments help strings with unescaped "%" caused TypeError in argparse. + from trl.cli import main + + with pytest.raises(SystemExit) as exc_info: + with patch("sys.argv", ["trl", command, "--help"]), patch("sys.stdout", new_callable=StringIO): + main() + assert exc_info.value.code == 0 + + +class TestCLI(TrlTestCase): + def test_dpo(self): + from trl.cli import main + + command = f"trl dpo --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_preference --report_to none" + with patch("sys.argv", command.split(" ")): + main() + + def test_dpo_multiple_loss_types(self): + from trl.cli import main + + command = f"trl dpo --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_preference --report_to none --loss_type sigmoid bco_pair --loss_weights 1.0 0.5" + with patch("sys.argv", command.split(" ")): + main() + + @patch("sys.stdout", new_callable=StringIO) + def test_env(self, mock_stdout): + from trl.cli import main + + command = "trl env" + with patch("sys.argv", command.split(" ")): + main() + assert "TRL version: " in mock_stdout.getvalue().strip() + + def test_grpo(self): + from trl.cli import main + + command = f"trl grpo --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --reward_model_name_or_path trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_prompt_only --num_generations 4 --max_completion_length 32 --report_to none" + with patch("sys.argv", command.split(" ")): + main() + + def test_kto(self): + from trl.cli import main + + command = f"trl kto --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_unpaired_preference --report_to none" + with patch("sys.argv", command.split(" ")): + main() + + def test_reward(self): + from trl.cli import main + + command = f"trl reward --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_implicit_prompt_preference --report_to none" + with patch("sys.argv", command.split(" ")): + main() + + def test_rloo(self): + from trl.cli import main + + command = f"trl rloo --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --reward_model_name_or_path trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_prompt_only --num_generations 2 --max_completion_length 32 --report_to none" + with patch("sys.argv", command.split(" ")): + main() + + def test_sft(self): + from trl.cli import main + + command = f"trl sft --output_dir {self.tmp_dir} --model_name_or_path trl-internal-testing/tiny-Qwen2ForCausalLM-2.5 --dataset_name trl-internal-testing/zen --dataset_config standard_language_modeling --report_to none" + with patch("sys.argv", command.split(" ")): + main() + + def test_sft_config_file(self): + from trl.cli import main + + output_dir = os.path.join(self.tmp_dir, "output") + + # Create a temporary config file + config_path = os.path.join(self.tmp_dir, "config.yaml") + config_content = { + "model_name_or_path": "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "dataset_name": "trl-internal-testing/zen", + "dataset_config": "standard_language_modeling", + "report_to": "none", + "output_dir": output_dir, + "lr_scheduler_type": "cosine_with_restarts", + } + with open(config_path, "w") as config_file: + yaml.dump(config_content, config_file) + + # Test the CLI with config file + command = f"trl sft --config {config_path}" + with patch("sys.argv", command.split(" ")): + main() + + # Verify that output directory was created + assert os.path.exists(output_dir) + + def test_vllm_serve_config_file(self): + """ + Test `trl vllm-serve --config config.yaml` must not raise "the following arguments are required: --model" when + the required field is satisfied by the config file rather than the command line. + """ + from trl.cli import main + + config_path = os.path.join(self.tmp_dir, "config.yaml") + with open(config_path, "w") as f: + yaml.dump({"model": "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5"}, f) + + # Patch the actual function that `VllmServeCommand.run` imports as `vllm_serve_main` + with patch("trl.scripts.vllm_serve.main") as mock_serve: + with patch("sys.argv", ["trl", "vllm-serve", "--config", config_path]): + main() + + mock_serve.assert_called_once() + script_args = mock_serve.call_args.args[0] + assert script_args.model == "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_cli_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_cli_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..cabb8f38bd2234ca3e698e01e0664b83a51f0813 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_cli_utils.py @@ -0,0 +1,426 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import tempfile +from dataclasses import dataclass +from unittest.mock import mock_open, patch + +import pytest +from datasets import DatasetDict, load_dataset + +from trl import DatasetMixtureConfig, TrlParser, get_dataset +from trl.scripts.utils import DatasetConfig + +from .testing_utils import TrlTestCase + + +@dataclass +class MyDataclass: + arg1: int + arg2: str = "default" + + +@dataclass +class InvalidDataclass: + config: str # This should raise an error in the TrlParser + + +class TestTrlParser(TrlTestCase): + def test_init_without_config_field(self): + """Test initialization without 'config' field in the dataclasses.""" + parser = TrlParser(dataclass_types=[MyDataclass]) + assert isinstance(parser, TrlParser) + + def test_init_with_config_field(self): + """Test initialization with a 'config' field in the dataclass (should raise ValueError).""" + with pytest.raises(ValueError, match="has a field named 'config'"): + TrlParser(dataclass_types=[InvalidDataclass]) + + @patch("builtins.open", mock_open(read_data="env:\n VAR1: value1\n VAR2: value2\narg1: 2")) + @patch("yaml.safe_load") + @patch("os.environ", new_callable=dict) # Mock os.environ as a dictionary + def test_parse_args_and_config_with_valid_config(self, mock_environ, mock_yaml_load): + """Test parse_args_and_config method with valid arguments and config.""" + mock_yaml_load.return_value = {"env": {"VAR1": "value1", "VAR2": "value2"}, "arg1": 2} + + parser = TrlParser(dataclass_types=[MyDataclass]) + + args = ["--arg2", "value", "--config", "config.yaml"] # don't set arg1 to test default value + + # Simulate the config being loaded and environment variables being set + result_args = parser.parse_args_and_config(args) + + # Set the environment variables using the mock + mock_environ["VAR1"] = "value1" + mock_environ["VAR2"] = "value2" + + # Ensure that the environment variables were set correctly + assert mock_environ.get("VAR1") == "value1" + assert mock_environ.get("VAR2") == "value2" + + # Check the parsed arguments + assert len(result_args) == 1 + assert isinstance(result_args[0], MyDataclass) + assert result_args[0].arg1 == 2 + assert result_args[0].arg2 == "value" + + @patch("builtins.open", mock_open(read_data="arg1: 2")) + @patch("yaml.safe_load") + def test_parse_args_and_arg_override_config(self, mock_yaml_load): + """Test parse_args_and_config method and check that arguments override the config.""" + mock_yaml_load.return_value = {"arg1": 2} # this arg is meant to be overridden + + parser = TrlParser(dataclass_types=[MyDataclass]) + + args = ["--arg1", "3", "--config", "config.yaml"] # override arg1 default with 3 + + # Simulate the config being loaded and arguments being passed + result_args = parser.parse_args_and_config(args) + + # Check the parsed arguments + assert len(result_args) == 1 + assert isinstance(result_args[0], MyDataclass) + assert result_args[0].arg1 == 3 + + @patch("builtins.open", mock_open(read_data="env: not_a_dict")) + @patch("yaml.safe_load") + def test_parse_args_and_config_with_invalid_env(self, mock_yaml_load): + """Test parse_args_and_config method when the 'env' field is not a dictionary.""" + mock_yaml_load.return_value = {"env": "not_a_dict"} + + parser = TrlParser(dataclass_types=[MyDataclass]) + + args = ["--arg1", "2", "--arg2", "value", "--config", "config.yaml"] + + with pytest.raises(ValueError, match="`env` field should be a dict in the YAML file."): + parser.parse_args_and_config(args) + + def test_parse_args_and_config_without_config(self): + """Test parse_args_and_config without the `--config` argument.""" + parser = TrlParser(dataclass_types=[MyDataclass]) + + args = ["--arg1", "2", "--arg2", "value"] + + # Simulate no config, just parse args normally + result_args = parser.parse_args_and_config(args) + + # Check that the arguments are parsed as is + assert len(result_args) == 1 + assert isinstance(result_args[0], MyDataclass) + assert result_args[0].arg1 == 2 + assert result_args[0].arg2 == "value" + + def test_set_defaults_with_config(self): + """Test set_defaults_with_config updates the defaults.""" + parser = TrlParser(dataclass_types=[MyDataclass]) + + # Update defaults + parser.set_defaults_with_config(arg1=42) + + # Ensure the default value is updated + result_args = parser.parse_args_and_config([]) + assert len(result_args) == 1 + assert isinstance(result_args[0], MyDataclass) + assert result_args[0].arg1 == 42 + + def test_parse_args_and_config_with_remaining_strings(self): + parser = TrlParser(dataclass_types=[MyDataclass]) + + args = ["--arg1", "2", "--arg2", "value", "remaining"] + + # Simulate no config, just parse args normally + result_args = parser.parse_args_and_config(args, return_remaining_strings=True) + + # Check that the arguments are parsed as is + assert len(result_args) == 2 + assert isinstance(result_args[0], MyDataclass) + assert result_args[0].arg1 == 2 + assert result_args[0].arg2 == "value" + assert result_args[1] == ["remaining"] + + @patch("builtins.open", mock_open(read_data="remaining_string_in_config: abc")) + @patch("yaml.safe_load") + def test_parse_args_and_config_with_remaining_strings_in_config_and_args(self, mock_yaml_load): + mock_yaml_load.return_value = {"remaining_string_in_config": "abc"} + + parser = TrlParser(dataclass_types=[MyDataclass]) + + args = ["--arg1", "2", "--remaining_string_in_args", "def", "--config", "config.yaml"] + + # Simulate the config being loaded and arguments being passed + result_args = parser.parse_args_and_config(args, return_remaining_strings=True) + + # Check that the arguments are parsed as is + assert len(result_args) == 2 + assert isinstance(result_args[0], MyDataclass) + assert result_args[0].arg1 == 2 + assert result_args[1] == ["--remaining_string_in_config", "abc", "--remaining_string_in_args", "def"] + + @patch("builtins.open", mock_open(read_data="arg1: 2\narg2: config_value")) + @patch("yaml.safe_load") + def test_subparsers_with_config_defaults(self, mock_yaml_load): + """Test that config defaults are applied to all subparsers.""" + mock_yaml_load.return_value = {"arg1": 2, "arg2": "config_value"} + + # Create the main parser + parser = TrlParser() + + # Add subparsers + subparsers = parser.add_subparsers(dest="command", parser_class=TrlParser) + + # Create a subparser for a specific command + subparsers.add_parser("subcommand", dataclass_types=[MyDataclass]) + + # Parse with config file + args = ["subcommand", "--config", "config.yaml"] + result_args = parser.parse_args_and_config(args) + + # Check main parser arguments + assert len(result_args) == 1 + + # Check that config values were applied to the subparser + assert result_args[0].arg1 == 2 # Default from config + assert result_args[0].arg2 == "config_value" # Default from config + + @patch("builtins.open", mock_open(read_data="arg1: 2\narg2: config_value")) + @patch("yaml.safe_load") + def test_subparsers_with_config_defaults_and_arg_override(self, mock_yaml_load): + """Test that config defaults are applied to all subparsers.""" + mock_yaml_load.return_value = {"arg1": 2, "arg2": "config_value"} + + # Create the main parser + parser = TrlParser() + + # Add subparsers + subparsers = parser.add_subparsers(dest="command", parser_class=TrlParser) + + # Create a subparser for a specific command + subparsers.add_parser("subcommand", dataclass_types=[MyDataclass]) + + # Test with command line arguments overriding config + args = ["subcommand", "--arg1", "3", "--config", "config.yaml"] + result_args = parser.parse_args_and_config(args) + + # Command line arguments should override config + assert result_args[0].arg1 == 3 + assert result_args[0].arg2 == "config_value" # Still from config + + @patch("builtins.open", mock_open(read_data="arg1: 2\nthis_arg_does_not_exist: config_value")) + @patch("yaml.safe_load") + def test_subparsers_with_config_defaults_and_arg_override_wrong_name(self, mock_yaml_load): + """Test that config defaults are applied to all subparsers.""" + mock_yaml_load.return_value = {"arg1": 2, "this_arg_does_not_exist": "config_value"} + + # Create the main parser + parser = TrlParser() + + # Add subparsers + subparsers = parser.add_subparsers(dest="command", parser_class=TrlParser) + + # Create a subparser for a specific command + subparsers.add_parser("subcommand", dataclass_types=[MyDataclass]) + + # Test with command line arguments overriding config + args = ["subcommand", "--arg1", "3", "--config", "config.yaml"] + with pytest.raises(ValueError): + parser.parse_args_and_config(args) + + parser.parse_args_and_config(args, fail_with_unknown_args=False) + + @patch("builtins.open", mock_open(read_data="arg1: 2\narg2: config_value")) + @patch("yaml.safe_load") + def test_subparsers_multiple_with_config_defaults(self, mock_yaml_load): + """Test that config defaults are applied to all subparsers.""" + mock_yaml_load.return_value = {"arg1": 2, "arg2": "config_value"} + + # Create the main parser + parser = TrlParser() + + # Add subparsers + subparsers = parser.add_subparsers(dest="command", parser_class=TrlParser) + + # Create a subparser for a specific command + subparsers.add_parser("subcommand0", dataclass_types=[MyDataclass]) + subparsers.add_parser("subcommand1", dataclass_types=[MyDataclass]) + + for idx in range(2): + # Parse with config file + args = [f"subcommand{idx}", "--config", "config.yaml"] + result_args = parser.parse_args_and_config(args) + + # Check main parser arguments + assert len(result_args) == 1 + + # Check that config values were applied to the subparser + assert result_args[0].arg1 == 2 # Default from config + assert result_args[0].arg2 == "config_value" # Default from config + + +class TestGetDataset: + def test_single_dataset_with_config(self): + mixture_config = DatasetMixtureConfig( + datasets=[DatasetConfig(path="trl-internal-testing/zen", name="standard_language_modeling")] + ) + result = get_dataset(mixture_config) + expected = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + assert expected["train"][:] == result["train"][:] + + def test_single_dataset_preference_config(self): + mixture_config = DatasetMixtureConfig( + datasets=[DatasetConfig(path="trl-internal-testing/zen", name="standard_preference")] + ) + result = get_dataset(mixture_config) + expected = load_dataset("trl-internal-testing/zen", "standard_preference") + assert expected["train"][:] == result["train"][:] + + def test_single_dataset_streaming(self): + mixture_config = DatasetMixtureConfig( + datasets=[DatasetConfig(path="trl-internal-testing/zen", name="standard_language_modeling")], + streaming=True, + ) + result = get_dataset(mixture_config) + expected = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + assert expected["train"].to_list() == list(result["train"]) + + def test_dataset_mixture_basic(self): + dataset_config1 = DatasetConfig( + path="trl-internal-testing/zen", name="standard_prompt_completion", split="train", columns=["prompt"] + ) + dataset_config2 = DatasetConfig( + path="trl-internal-testing/zen", name="standard_preference", split="train", columns=["prompt"] + ) + mixture_config = DatasetMixtureConfig(datasets=[dataset_config1, dataset_config2]) + result = get_dataset(mixture_config) + assert isinstance(result, DatasetDict) + assert "train" in result + train_dataset = result["train"] + assert train_dataset.column_names == ["prompt"] + prompts = train_dataset["prompt"] + expected_first_half = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + assert prompts[: len(prompts) // 2] == expected_first_half["prompt"] + expected_second_half = load_dataset("trl-internal-testing/zen", "standard_prompt_completion", split="train") + assert prompts[len(prompts) // 2 :] == expected_second_half["prompt"] + + def test_dataset_mixture_with_weights(self): + dataset_config1 = DatasetConfig( + path="trl-internal-testing/zen", name="standard_prompt_completion", split="train[:50%]", columns=["prompt"] + ) + dataset_config2 = DatasetConfig( + path="trl-internal-testing/zen", name="standard_preference", split="train[:50%]", columns=["prompt"] + ) + mixture_config = DatasetMixtureConfig(datasets=[dataset_config1, dataset_config2]) + result = get_dataset(mixture_config) + assert isinstance(result, DatasetDict) + assert "train" in result + train_dataset = result["train"] + assert train_dataset.column_names == ["prompt"] + prompts = train_dataset["prompt"] + expected_first_half = load_dataset("trl-internal-testing/zen", "standard_preference", split="train[:50%]") + assert prompts[: len(prompts) // 2] == expected_first_half["prompt"] + expected_second_half = load_dataset( + "trl-internal-testing/zen", "standard_prompt_completion", split="train[:50%]" + ) + assert prompts[len(prompts) // 2 :] == expected_second_half["prompt"] + + def test_dataset_mixture_with_test_split(self): + mixture_config = DatasetMixtureConfig( + datasets=[DatasetConfig(path="trl-internal-testing/zen", name="standard_language_modeling")], + test_split_size=2, + ) + result = get_dataset(mixture_config) + assert isinstance(result, DatasetDict) + assert "train" in result + assert "test" in result + assert len(result["train"]) == 15 + assert len(result["test"]) == 2 + + def test_empty_dataset_mixture_raises_error(self): + mixture_config = DatasetMixtureConfig(datasets=[]) + + with pytest.raises(ValueError, match="No datasets were loaded"): + get_dataset(mixture_config) + + def test_mixture_multiple_different_configs(self): + dataset_config1 = DatasetConfig( + path="trl-internal-testing/zen", name="conversational_preference", split="train", columns=["prompt"] + ) + dataset_config2 = DatasetConfig( + path="trl-internal-testing/zen", name="conversational_prompt_only", split="test" + ) + mixture_config = DatasetMixtureConfig(datasets=[dataset_config1, dataset_config2]) + result = get_dataset(mixture_config) + assert isinstance(result, DatasetDict) + assert "train" in result + assert len(result["train"]) > 0 + + def test_trlparser_parses_yaml_config_correctly(self): + # Prepare YAML content exactly like your example + # docstyle-ignore + yaml_content = """ + datasets: + - path: trl-internal-testing/zen + name: standard_prompt_only + - path: trl-internal-testing/zen + name: standard_preference + columns: + - prompt + """ + + # Write YAML to a temporary file + with tempfile.NamedTemporaryFile("w+", suffix=".yaml") as tmpfile: + tmpfile.write(yaml_content) + tmpfile.flush() + parser = TrlParser((DatasetMixtureConfig,)) + args = parser.parse_args_and_config(args=["--config", tmpfile.name])[0] + + # Assert that we got DatasetMixtureConfig instance + assert isinstance(args, DatasetMixtureConfig) + + # Assert datasets list length + assert len(args.datasets) == 2 + + # Check first dataset + dataset_config1 = args.datasets[0] + assert isinstance(dataset_config1, DatasetConfig) + assert dataset_config1.path == "trl-internal-testing/zen" + assert dataset_config1.name == "standard_prompt_only" + assert dataset_config1.columns is None # No columns specified + + # Check second dataset + dataset_config2 = args.datasets[1] + assert isinstance(dataset_config2, DatasetConfig) + assert dataset_config2.path == "trl-internal-testing/zen" + assert dataset_config2.name == "standard_preference" + assert dataset_config2.columns == ["prompt"] # Columns specified + + def test_trlparser_parses_yaml_and_loads_dataset(self): + # Prepare YAML content exactly like your example + # docstyle-ignore + yaml_content = """ + datasets: + - path: trl-internal-testing/zen + name: standard_language_modeling + """ + + # Write YAML to a temporary file + with tempfile.NamedTemporaryFile("w+", suffix=".yaml") as tmpfile: + tmpfile.write(yaml_content) + tmpfile.flush() + parser = TrlParser((DatasetMixtureConfig,)) + args = parser.parse_args_and_config(args=["--config", tmpfile.name])[0] + + # Load the dataset using get_dataset + result = get_dataset(args) + expected = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + assert expected["train"][:] == result["train"][:] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_data_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_data_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3498a8f1850f71bd6fb2f42f43a2bf06fe529134 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_data_utils.py @@ -0,0 +1,1268 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +import textwrap +from time import strftime + +import pytest +import transformers +from datasets import Dataset, DatasetDict +from packaging.version import Version +from transformers import AutoProcessor, AutoTokenizer, is_vision_available + +from trl.data_utils import ( + apply_chat_template, + extract_prompt, + is_conversational, + is_conversational_from_value, + maybe_apply_chat_template, + maybe_convert_to_chatml, + maybe_extract_prompt, + maybe_unpair_preference_dataset, + pack_dataset, + prepare_multimodal_messages, + prepare_multimodal_messages_vllm, + unpair_preference_dataset, +) + +from .testing_utils import TrlTestCase, require_vision + + +if is_vision_available(): + from PIL import Image + + +@require_vision +class TestPrepareMultimodalMessages: + def test_basic_user_assistant_conversation(self): + """Test basic conversation with user and assistant messages.""" + messages = [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ] + image = Image.new("RGB", (10, 10), color="blue") + messages = prepare_multimodal_messages(messages, images=[image]) + + expected = [ + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + { + "role": "assistant", + "content": [{"type": "text", "text": "It is blue."}], + }, + ] + + assert messages == expected + + def test_first_user_message_gets_image(self): + """Test that only the first user message gets an image.""" + messages = [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + {"role": "user", "content": "How about the grass?"}, + ] + + image = Image.new("RGB", (10, 10), color="blue") + messages = prepare_multimodal_messages(messages, images=[image]) + + expected = [ + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + { + "role": "assistant", + "content": [{"type": "text", "text": "It is blue."}], + }, + { + "role": "user", + "content": [{"type": "text", "text": "How about the grass?"}], + }, + ] + + assert messages == expected + + def test_multiple_images(self): + """Test that multiple images are added to the first user message.""" + messages = [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ] + images = [Image.new("RGB", (10, 10), color=color) for color in ["red", "green", "blue"]] + messages = prepare_multimodal_messages(messages, images=images) + + expected = [ + { + "role": "user", + "content": [ + {"type": "image", "image": images[0]}, + {"type": "image", "image": images[1]}, + {"type": "image", "image": images[2]}, + {"type": "text", "text": "What color is the sky?"}, + ], + }, + { + "role": "assistant", + "content": [{"type": "text", "text": "It is blue."}], + }, + ] + + assert messages == expected + + def test_system_message_transformation(self): + """Test that system messages are properly transformed.""" + messages = [ + {"role": "system", "content": "You are a helpful assistant"}, + {"role": "user", "content": "What color is the sky?"}, + ] + + image = Image.new("RGB", (10, 10), color="blue") + messages = prepare_multimodal_messages(messages, images=[image]) + + expected = [ + { + "role": "system", + "content": [{"type": "text", "text": "You are a helpful assistant"}], + }, + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + ] + + assert messages == expected + + def test_already_prepared_messages_unchanged(self): + """Test that messages with list content are not modified.""" + messages = [ + {"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant"}]}, + {"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What color is the sky?"}]}, + {"role": "assistant", "content": [{"type": "text", "text": "It is blue."}]}, + ] + + image = Image.new("RGB", (10, 10), color="blue") + messages = prepare_multimodal_messages(messages, images=[image]) + + expected = [ + { + "role": "system", + "content": [{"type": "text", "text": "You are a helpful assistant"}], + }, + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + { + "role": "assistant", + "content": [{"type": "text", "text": "It is blue."}], + }, + ] + + assert messages == expected + + def test_mixed_prepared_and_unprepared_messages(self): + """Test handling of mixed prepared and unprepared messages.""" + messages = [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": [{"type": "text", "text": "It is blue."}]}, + {"role": "user", "content": "What about the grass?"}, + ] + + image = Image.new("RGB", (10, 10), color="blue") + messages = prepare_multimodal_messages(messages, images=[image]) + + expected = [ + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + { + "role": "assistant", + "content": [{"type": "text", "text": "It is blue."}], + }, + { + "role": "user", + "content": [{"type": "text", "text": "What about the grass?"}], + }, + ] + + assert messages == expected + + def test_message_with_tool_calling_turns(self): + """Test that both the assistant tool call and the tool role turns messages are properly transformed.""" + messages = [ + {"role": "user", "content": "What's the weather like in New York?"}, + { + "role": "assistant", + "tool_calls": [ + { + "type": "tool", + "function": {"name": "get_current_weather", "arguments": {"location": "New York"}}, + } + ], + }, + {"role": "tool", "name": "get_current_weather", "content": "22.0"}, + {"role": "assistant", "content": "The current weather in New York is 22.0 degrees Celsius."}, + ] + + messages = prepare_multimodal_messages(messages) + + expected = [ + { + "role": "user", + "content": [{"type": "text", "text": "What's the weather like in New York?"}], + }, + { + "role": "assistant", + "tool_calls": [ + { + "type": "tool", + "function": {"name": "get_current_weather", "arguments": {"location": "New York"}}, + } + ], + }, + {"role": "tool", "name": "get_current_weather", "content": [{"type": "text", "text": "22.0"}]}, + { + "role": "assistant", + "content": [{"type": "text", "text": "The current weather in New York is 22.0 degrees Celsius."}], + }, + ] + + assert messages == expected + + def test_prepared_image_blocks_without_new_images(self): + """Test that existing image payloads are preserved when no new images are provided.""" + image = Image.new("RGB", (10, 10), color="blue") + messages = [ + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + {"role": "assistant", "content": "It is blue."}, + ] + + messages = prepare_multimodal_messages(messages) + + expected = [ + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "What color is the sky?"}], + }, + {"role": "assistant", "content": [{"type": "text", "text": "It is blue."}]}, + ] + + assert messages == expected + + +@require_vision +class TestPrepareMultimodalMessagesVLLM: + def test_single_image_conversion(self): + messages = [ + { + "role": "user", + "content": [ + {"type": "image", "image": Image.new("RGB", (10, 10), color="blue")}, + {"type": "text", "text": "What color is the sky?"}, + ], + } + ] + + result = prepare_multimodal_messages_vllm(messages) + + # Original should remain unchanged (deepcopy test) + assert messages[0]["content"][0]["type"] == "image" + + # Converted version should have correct structure + assert result[0]["content"][0]["type"] == "image_pil" + assert "image_pil" in result[0]["content"][0] + assert "image" not in result[0]["content"][0] + assert isinstance(result[0]["content"][0]["image_pil"], Image.Image) + assert result[0]["content"][1]["type"] == "text" + + def test_mixed_content_conversion(self): + messages = [ + { + "role": "user", + "content": [ + {"type": "text", "text": "What color is the sky?"}, + {"type": "image", "image": Image.new("RGB", (10, 10), color="blue")}, + ], + } + ] + + result = prepare_multimodal_messages_vllm(messages) + + # The image part should be converted, text should be unchanged + assert result[0]["content"][0]["type"] == "text" + assert result[0]["content"][1]["type"] == "image_pil" + + def test_no_images(self): + messages = [{"role": "user", "content": [{"type": "text", "text": "What color is the sky?"}]}] + + result = prepare_multimodal_messages_vllm(messages) + + # Should be identical since there are no images + assert result == messages + # And a deepcopy — not the same object + assert result is not messages + assert result[0] is not messages[0] + + def test_multiple_messages(self): + messages = [ + { + "role": "user", + "content": [ + {"type": "text", "text": "What color is the sky?"}, + {"type": "image", "image": Image.new("RGB", (10, 10), color="blue")}, + ], + }, + { + "role": "assistant", + "content": [{"type": "text", "text": "It is blue."}], + }, + ] + + result = prepare_multimodal_messages_vllm(messages) + + assert result[0]["content"][1]["type"] == "image_pil" + assert result[1]["content"][0]["type"] == "text" + assert result[1]["content"][0]["text"] == "It is blue." + + def test_deepcopy_integrity(self): + messages = [ + { + "role": "user", + "content": [ + {"type": "text", "text": "What color is the sky?"}, + {"type": "image", "image": Image.new("RGB", (10, 10), color="blue")}, + ], + }, + ] + original = copy.deepcopy(messages) + + _ = prepare_multimodal_messages_vllm(messages) + + # Original should not be mutated + assert messages == original + + +class TestIsConversational(TrlTestCase): + # fmt: off + conversational_examples = [ + { # Language modeling + "messages": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ], + }, + { # Prompt-only + "prompt": [{"role": "user", "content": "What color is the sky?"}], + }, + { # Prompt-completion + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "completion": [{"role": "assistant", "content": "It is blue."}], + }, + { # Preference + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "chosen": [{"role": "assistant", "content": "It is blue."}], + "rejected": [{"role": "assistant", "content": "It is green."}], + }, + { # Preference with implicit prompt + "chosen": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ], + "rejected": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is green."}, + ], + }, + { # Preference with tool calls + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "chosen": [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_color", "arguments": {"what": "sky"}}}]}, + {"role": "tool", "name": "get_color", "content": "blue"}, + {"role": "assistant", "content": "It is blue."}, + ], + "rejected": [ + {"role": "assistant", "tool_calls": [{"type": "function", "function": {"name": "get_color", "arguments": {"what": "tree"}}}]}, + {"role": "tool", "name": "get_color", "content": "green"}, + {"role": "assistant", "content": "It is green."}, + ], + "tools": [ + { + "type": "function", + "function": { + "description": "Gets the color.", + "name": "get_color", + "parameters": {"properties": {"what": {"description": "What to get the color of.", "type": "string"}}, "required": ["what"], "type": "object"}, + "return": {"description": "The color.", "type": "string"}, + }, + }, + ], + }, + { # Unpaired preference + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "completion": [{"role": "assistant", "content": "It is blue."}], + "label": True, + }, + { # Language modeling with harmony + "messages": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + }, + { # Prompt-only with harmony + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + }, + { # Prompt-completion with harmony + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + "completion": [ + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + }, + { # Preference with harmony + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + "chosen": [ + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + "rejected": [ + {"role": "assistant", "thinking": "The user asks the color of the tree...", "content": "It is green."}, + ], + }, + { # Preference with implicit prompt and harmony + "chosen": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + "rejected": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "thinking": "The user asks the color of the tree...", "content": "It is green."}, + ], + }, + { # Unpaired preference with harmony + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + "completion": [ + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + "label": True, + }, + ] + # fmt: on + + non_conversational_examples = [ + {"prompt": "The sky is", "completion": " blue."}, + {"text": "The sky is blue."}, + {"prompt": "The sky is"}, + {"prompt": "The sky is", "chosen": " blue.", "rejected": " green."}, + {"prompt": "The sky is", "completion": " blue.", "label": True}, + ] + + @pytest.mark.parametrize("example", conversational_examples) + def test_conversational(self, example): + assert is_conversational(example) + + @pytest.mark.parametrize("example", non_conversational_examples) + def test_non_conversational(self, example): + assert not is_conversational(example) + + +class TestIsConversationalFromValue(TrlTestCase): + def test_positive_1(self): + example = { + "conversations": [ + {"from": "user", "value": "What color is the sky?"}, + {"from": "assistant", "value": "It is blue."}, + ], + } + assert is_conversational_from_value(example) + + def test_negative_1(self): + example = { + "messages": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ], + } + assert not is_conversational_from_value(example) + + def test_negative_2(self): + example = {"text": "The sky is blue."} + assert not is_conversational_from_value(example) + + +class TestApplyChatTemplate(TrlTestCase): + tokenizers = [ + "trl-internal-testing/tiny-CohereForCausalLM", + "trl-internal-testing/tiny-Cohere2ForCausalLM", + "trl-internal-testing/tiny-DeepseekV3ForCausalLM", + "trl-internal-testing/tiny-DeepseekV3ForCausalLM-0528", + "trl-internal-testing/tiny-FalconMambaForCausalLM", + "trl-internal-testing/tiny-Gemma2ForCausalLM", + "trl-internal-testing/tiny-GemmaForCausalLM", + "trl-internal-testing/tiny-GptOssForCausalLM", + pytest.param( + "trl-internal-testing/tiny-Glm4MoeForCausalLM", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="GLM4 tokenizer requires transformers>=5.0.0", + ), + ), + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-LlamaForCausalLM-3", + "trl-internal-testing/tiny-MistralForCausalLM-0.1", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + "trl-internal-testing/tiny-Phi3ForCausalLM-3", + "trl-internal-testing/tiny-Phi3ForCausalLM-3.5", + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "trl-internal-testing/tiny-Qwen3ForCausalLM", + pytest.param( + "trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="Qwen3.5 tokenizer requires transformers>=5.0.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="Qwen3.5 tokenizer requires transformers>=5.0.0", + ), + ), + ] + + conversational_examples = [ + { # Language modeling + "messages": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ], + }, + { # Prompt-only + "prompt": [{"role": "user", "content": "What color is the sky?"}], + }, + { # Prompt-completion + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "completion": [{"role": "assistant", "content": "It is blue."}], + }, + { # Preference + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "chosen": [{"role": "assistant", "content": "It is blue."}], + "rejected": [{"role": "assistant", "content": "It is green."}], + }, + { # Preference with implicit prompt + "chosen": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ], + "rejected": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is green."}, + ], + }, + { # Unpaired preference + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "completion": [{"role": "assistant", "content": "It is blue."}], + "label": True, + }, + ] + + non_conversational_examples = [ + {"text": "The sky is blue."}, # Language modeling + {"prompt": "The sky is"}, # Prompt-only + {"prompt": "The sky is", "completion": " blue."}, # Prompt-completion + {"prompt": "The sky is", "chosen": " blue.", "rejected": " green."}, # Preference + {"chosen": "The sky is blue.", "rejected": "The sky is green."}, # Preference with implicit prompt + {"prompt": "The sky is", "completion": " blue.", "label": True}, # Unpaired preference + ] + + @pytest.mark.parametrize("example", conversational_examples) + @pytest.mark.parametrize("tokenizer_id", tokenizers) + def test_apply_chat_template(self, tokenizer_id, example): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_id) + result = apply_chat_template(example, tokenizer) + + # Checking if the result is a dictionary + assert isinstance(result, dict) + + # The chat template should be applied to the following keys + for key in ["prompt", "chosen", "rejected", "completion"]: + if key in example: + assert key in result + assert isinstance(result[key], str) + + # Exception for messages, the key is "text" once the chat template is applied + if "messages" in example: + assert "text" in result + assert isinstance(result["text"], str) + + # The label should be kept + if "label" in example: + assert "label" in result + assert isinstance(result["label"], bool) + assert result["label"] == example["label"] + + # both conversational and non-conversational examples + @pytest.mark.parametrize("example", conversational_examples + non_conversational_examples) + @pytest.mark.parametrize("tokenizer_id", tokenizers) + def test_maybe_apply_chat_template(self, tokenizer_id, example): + tokenizer = AutoTokenizer.from_pretrained(tokenizer_id) + result = maybe_apply_chat_template(example, tokenizer) + + # Checking if the result is a dictionary + assert isinstance(result, dict) + + # The chat template should be applied to the following keys + for key in ["prompt", "chosen", "rejected", "completion"]: + if key in example: + assert key in result + assert isinstance(result[key], str) + + # Exception for messages, the key is "text" once the chat template is applied + if "messages" in example: + assert "text" in result + assert isinstance(result["text"], str) + + # The label should be kept + if "label" in example: + assert "label" in result + assert isinstance(result["label"], bool) + assert result["label"] == example["label"] + + def test_apply_chat_template_with_chat_template_kwargs(self): + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen3ForCausalLM") + + example = { + "prompt": [{"role": "user", "content": "What color is the sky?"}], + # with this tokenizer, when you pass enable_thinking=False, it will add "\n\n\n\n" + "chat_template_kwargs": {"enable_thinking": False}, + } + result = apply_chat_template(example, tokenizer) + + # docstyle-ignore + expected = textwrap.dedent("""\ + <|im_start|>user + What color is the sky?<|im_end|> + <|im_start|>assistant + + + + + """) + + assert result["prompt"] == expected + + def test_apply_chat_template_with_tools(self): + tokenizer = AutoProcessor.from_pretrained("trl-internal-testing/tiny-LlamaForCausalLM-3.2") + + # Define dummy test tools + def get_current_temperature(location: str): + """ + Gets the temperature at a given location. + + Args: + location: The location to get the temperature for + """ + return 22.0 + + # Define test case + test_case = { + "prompt": [ + {"content": "What's the temperature in London?", "role": "user"}, + ] + } + # Test with tools + result_with_tools = apply_chat_template(test_case, tokenizer, tools=[get_current_temperature]) + + # Verify tools are included in the output + assert "get_current_temperature" in result_with_tools["prompt"] + + # Test without tools + result_without_tools = apply_chat_template(test_case, tokenizer, tools=None) + + # Verify tools are not included in the output + assert "get_current_temperature" not in result_without_tools["prompt"] + + +class TestApplyChatTemplateHarmony(TrlTestCase): + def test_language_modeling(self): + messages = { + "messages": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + } + output = apply_chat_template( + messages, + processing_class=AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM"), + reasoning_effort="low", + model_identity="You are HuggingGPT.", + ) + + # docstyle-ignore + expected = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant<|channel|>analysis<|message|>The user asks the color of the sky...<|end|><|start|>assistant<|channel|>final<|message|>It is blue.<|return|>""") + + assert output["text"] == expected + + def test_prompt_only(self): + messages = { + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + } + output = apply_chat_template( + messages, + processing_class=AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM"), + reasoning_effort="low", + model_identity="You are HuggingGPT.", + ) + + # docstyle-ignore + expected = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant""") + + assert output["prompt"] == expected + + def test_prompt_completion(self): + messages = { + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + "completion": [ + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + } + output = apply_chat_template( + messages, + processing_class=AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM"), + reasoning_effort="low", + model_identity="You are HuggingGPT.", + ) + + # docstyle-ignore + expected_prompt = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant""") + expected_completion = "<|channel|>analysis<|message|>The user asks the color of the sky...<|end|><|start|>assistant<|channel|>final<|message|>It is blue.<|return|>" + + assert output["prompt"] == expected_prompt + assert output["completion"] == expected_completion + + def test_preference(self): + messages = { + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + "chosen": [ + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + "rejected": [ + {"role": "assistant", "thinking": "The user asks the color of the tree...", "content": "It is green."}, + ], + } + output = apply_chat_template( + messages, + processing_class=AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM"), + reasoning_effort="low", + model_identity="You are HuggingGPT.", + ) + + # docstyle-ignore + expected_prompt = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant""") + expected_chosen = "<|channel|>analysis<|message|>The user asks the color of the sky...<|end|><|start|>assistant<|channel|>final<|message|>It is blue.<|return|>" + expected_rejected = "<|channel|>analysis<|message|>The user asks the color of the tree...<|end|><|start|>assistant<|channel|>final<|message|>It is green.<|return|>" + + assert output["prompt"] == expected_prompt + assert output["chosen"] == expected_chosen + assert output["rejected"] == expected_rejected + + def test_preference_with_implicit_prompt(self): + messages = { + "chosen": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + "rejected": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "thinking": "The user asks the color of the tree...", "content": "It is green."}, + ], + } + output = apply_chat_template( + messages, + processing_class=AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM"), + reasoning_effort="low", + model_identity="You are HuggingGPT.", + ) + + # docstyle-ignore + expected_chosen = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant<|channel|>analysis<|message|>The user asks the color of the sky...<|end|><|start|>assistant<|channel|>final<|message|>It is blue.<|return|>""") + + # docstyle-ignore + expected_rejected = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant<|channel|>analysis<|message|>The user asks the color of the tree...<|end|><|start|>assistant<|channel|>final<|message|>It is green.<|return|>""") + + assert output["chosen"] == expected_chosen + assert output["rejected"] == expected_rejected + + def test_unpaired_preference(self): + messages = { + "prompt": [ + {"role": "system", "content": "Respond in a friendly manner."}, + {"role": "user", "content": "What color is the sky?"}, + ], + "completion": [ + {"role": "assistant", "thinking": "The user asks the color of the sky...", "content": "It is blue."}, + ], + "label": True, + } + output = apply_chat_template( + messages, + processing_class=AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM"), + reasoning_effort="low", + model_identity="You are HuggingGPT.", + ) + + # docstyle-ignore + expected_prompt = textwrap.dedent(f"""\ + <|start|>system<|message|>You are HuggingGPT. + Knowledge cutoff: 2024-06 + Current date: {strftime("%Y-%m-%d")} + + Reasoning: low + + # Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions + + Respond in a friendly manner. + + <|end|><|start|>user<|message|>What color is the sky?<|end|><|start|>assistant""") + expected_completion = "<|channel|>analysis<|message|>The user asks the color of the sky...<|end|><|start|>assistant<|channel|>final<|message|>It is blue.<|return|>" + + assert output["prompt"] == expected_prompt + assert output["completion"] == expected_completion + assert output["label"] + + +class TestUnpairPreferenceDataset(TrlTestCase): + paired_dataset = Dataset.from_dict( + { + "prompt": ["The sky is", "The sun is"], + "chosen": [" blue.", " in the sky."], + "rejected": [" green.", " in the sea."], + } + ) + + unpaired_dataset = Dataset.from_dict( + { + "prompt": ["The sky is", "The sun is", "The sky is", "The sun is"], + "completion": [" blue.", " in the sky.", " green.", " in the sea."], + "label": [True, True, False, False], + } + ) + + def test_unpair_preference_dataset(self): + # Test that a paired dataset is correctly converted to unpaired + unpaired_dataset = unpair_preference_dataset(self.paired_dataset) + assert unpaired_dataset.to_dict() == self.unpaired_dataset.to_dict(), ( + "The paired dataset should be converted to unpaired." + ) + + def test_unpair_preference_dataset_dict(self): + # Test that a paired dataset dict is correctly converted to unpaired + paired_dataset_dict = DatasetDict({"abc": self.paired_dataset}) + unpaired_dataset_dict = unpair_preference_dataset(paired_dataset_dict) + assert unpaired_dataset_dict["abc"].to_dict() == self.unpaired_dataset.to_dict(), ( + "The paired dataset should be converted to unpaired." + ) + + def test_maybe_unpair_preference_dataset(self): + # Test that a paired dataset is correctly converted to unpaired with maybe_unpair_preference_dataset + unpaired_dataset = maybe_unpair_preference_dataset(self.paired_dataset) + assert unpaired_dataset.to_dict() == self.unpaired_dataset.to_dict(), ( + "The paired dataset should be converted to unpaired." + ) + + def test_maybe_unpair_preference_dataset_dict(self): + # Test that a paired dataset dict is correctly converted to unpaired with maybe_unpair_preference_dataset + paired_dataset_dict = DatasetDict({"abc": self.paired_dataset}) + unpaired_dataset_dict = maybe_unpair_preference_dataset(paired_dataset_dict) + assert unpaired_dataset_dict["abc"].to_dict() == self.unpaired_dataset.to_dict(), ( + "The paired dataset should be converted to unpaired." + ) + + def test_maybe_unpair_preference_dataset_already_paired(self): + # Test that a paired dataset remains unchanged with maybe_unpair_preference_dataset + unpaired_dataset = maybe_unpair_preference_dataset(self.unpaired_dataset) + assert unpaired_dataset.to_dict() == self.unpaired_dataset.to_dict(), ( + "The unpaired dataset should remain unchanged." + ) + + def test_maybe_unpair_preference_dataset_dict_already_paired(self): + # Test that a paired dataset dict remains unchanged with maybe_unpair_preference_dataset + unpaired_dataset_dict = maybe_unpair_preference_dataset(DatasetDict({"abc": self.unpaired_dataset})) + assert unpaired_dataset_dict["abc"].to_dict() == self.unpaired_dataset.to_dict(), ( + "The unpaired dataset should remain unchanged." + ) + + +class TestExtractPrompt(TrlTestCase): + example_implicit_prompt_conversational = { + "chosen": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ], + "rejected": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is green."}, + ], + } + + example_explicit_prompt_conversational = { + "prompt": [ + {"role": "user", "content": "What color is the sky?"}, + ], + "chosen": [ + {"role": "assistant", "content": "It is blue."}, + ], + "rejected": [ + {"role": "assistant", "content": "It is green."}, + ], + } + + example_implicit_prompt_standard = { + "chosen": "The sky is blue.", + "rejected": "The sky is green.", + } + + example_explicit_prompt_standard = { + "prompt": "The sky is", + "chosen": " blue.", + "rejected": " green.", + } + + def test_extract_prompt_conversational(self): + # Test that the prompt is correctly extracted from the dataset + example_extracted_prompt = extract_prompt(self.example_implicit_prompt_conversational) + assert example_extracted_prompt == self.example_explicit_prompt_conversational, ( + "The prompt is not correctly extracted from the dataset." + ) + + def test_maybe_extract_prompt_conversational(self): + # Test that the prompt is correctly extracted from the dataset with maybe_extract_prompt + example_extracted_prompt = maybe_extract_prompt(self.example_implicit_prompt_conversational) + assert example_extracted_prompt == self.example_explicit_prompt_conversational, ( + "The prompt is not correctly extracted from the dataset." + ) + + def test_maybe_extract_prompt_conversational_already_explicit(self): + # Test that the prompt remains unchanged with maybe_extract_prompt + example_extracted_prompt = maybe_extract_prompt(self.example_explicit_prompt_conversational) + assert example_extracted_prompt == self.example_explicit_prompt_conversational, ( + "The prompt should remain unchanged." + ) + + def test_extract_prompt_standard(self): + # Test that the prompt is correctly extracted from the dataset + example_extracted_prompt = extract_prompt(self.example_implicit_prompt_standard) + assert example_extracted_prompt == self.example_explicit_prompt_standard, ( + "The prompt is not correctly extracted from the dataset." + ) + + def test_maybe_extract_prompt_standard(self): + # Test that the prompt is correctly extracted from the dataset with maybe_extract_prompt + example_extracted_prompt = maybe_extract_prompt(self.example_implicit_prompt_standard) + assert example_extracted_prompt == self.example_explicit_prompt_standard, ( + "The prompt is not correctly extracted from the dataset." + ) + + def test_maybe_extract_prompt_standard_already_explicit(self): + # Test that the prompt remains unchanged with maybe_extract_prompt + example_extracted_prompt = maybe_extract_prompt(self.example_explicit_prompt_standard) + assert example_extracted_prompt == self.example_explicit_prompt_standard, "The prompt should remain unchanged." + + +class TestPackDatasetWrapped(TrlTestCase): + def test_with_dataset(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + "attention_mask": [[0, 1, 1], [0, 0, 1, 1], [1]], + } + dataset = Dataset.from_dict(examples) + dataset = dataset.with_format("numpy", dtype="float32") + format = dataset.format + seq_length = 3 + expected_output = { + "input_ids": [[1, 2, 3], [4, 5, 6], [7, 8]], + "attention_mask": [[0, 1, 1], [0, 0, 1], [1, 1]], + } + dataset = pack_dataset(dataset, seq_length, strategy="wrapped") + assert dataset.to_dict() == expected_output + assert format == dataset.format + + def test_with_iterable_dataset(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + "attention_mask": [[0, 1, 1], [0, 0, 1, 1], [1]], + } + dataset = Dataset.from_dict(examples).to_iterable_dataset() + dataset = dataset.with_format("numpy") + formatting = dataset._formatting + seq_length = 3 + expected_output = { + "input_ids": [[1, 2, 3], [4, 5, 6], [7, 8]], + "attention_mask": [[0, 1, 1], [0, 0, 1], [1, 1]], + } + dataset = pack_dataset(dataset, seq_length, strategy="wrapped") + num_examples = len(examples[next(iter(examples))]) + assert next(iter(dataset.with_format(None).batch(batch_size=num_examples))) == expected_output + assert formatting == dataset._formatting + + +class TestPackDatasetBfd(TrlTestCase): + def test_with_dataset(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + } + dataset = Dataset.from_dict(examples) + dataset = dataset.with_format("numpy", dtype="float32") + format = dataset.format + seq_length = 4 + expected_output = { + "input_ids": [[4, 5, 6, 7], [1, 2, 3, 8]], + "seq_lengths": [[4], [3, 1]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd") + expected_format = dataset.format + assert dataset.to_dict() == expected_output + assert "seq_lengths" in expected_format["columns"] + expected_format["columns"].remove("seq_lengths") + assert format == dataset.format + + def test_with_iterable_dataset(self): + examples = { + "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + } + dataset = Dataset.from_dict(examples).to_iterable_dataset() + dataset = dataset.with_format("numpy") + formatting = dataset._formatting + seq_length = 4 + expected_output = { + "input_ids": [[4, 5, 6, 7], [1, 2, 3, 8]], + "seq_lengths": [[4], [3, 1]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd") + num_examples = len(examples[next(iter(examples))]) + assert next(iter(dataset.with_format(None).batch(batch_size=num_examples))) == expected_output + assert formatting == dataset._formatting + + def test_with_overlong_0(self): + examples = { + "input_ids": [[1, 2, 3, 4, 5], [6, 7], [8, 9, 10, 11], [12]], + } + dataset = Dataset.from_dict(examples) + seq_length = 4 + expected_output = { + "input_ids": [[1, 2, 3, 4], [8, 9, 10, 11], [6, 7, 5, 12]], + "seq_lengths": [[4], [4], [2, 1, 1]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd_split") + assert dataset.to_dict() == expected_output + + def test_with_overlong_two_coluns(self): + examples = { + "col1": [[1, -2, 3, -4, 5, -6], [7, -8, 9], [-10, 11, -12], [13, -14, 15, -16]], + "col2": [[-1, 2, -3, 4, -5, 6], [-7, 8, -9], [10, -11, 12], [-13, 14, -15, 16]], + } + dataset = Dataset.from_dict(examples) + seq_length = 4 + expected_output = { + "col1": [[1, -2, 3, -4], [13, -14, 15, -16], [7, -8, 9], [-10, 11, -12], [5, -6]], + "col2": [[-1, 2, -3, 4], [-13, 14, -15, 16], [-7, 8, -9], [10, -11, 12], [-5, 6]], + "seq_lengths": [[4], [4], [3], [3], [2]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd_split") + assert dataset.to_dict() == expected_output + + def test_with_non_power_of_2(self): + examples = { + "input_ids": [[1, 2, 3, 4, 5], [6], [7, 8, 9, 10], [11, 12, 13]], + } + dataset = Dataset.from_dict(examples) + seq_length = 5 + expected_output = { + "input_ids": [[1, 2, 3, 4, 5], [7, 8, 9, 10, 6], [11, 12, 13]], + "seq_lengths": [[5], [4, 1], [3]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd_split") + assert dataset.to_dict() == expected_output + + def test_default_no_split(self): + """Test default 'bfd' strategy for SFT datasets (truncates overflow).""" + examples = { + "input_ids": [[1, 2, 3, 4, 5], [6, 7], [8, 9, 10, 11], [12]], + } + dataset = Dataset.from_dict(examples) + seq_length = 4 + # With default 'bfd' strategy, overflow tokens are discarded + expected_output = { + "input_ids": [[1, 2, 3, 4], [8, 9, 10, 11], [6, 7, 12]], + "seq_lengths": [[4], [4], [2, 1]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd") + assert dataset.to_dict() == expected_output + + def test_with_empty_sequences(self): + examples = { + "input_ids": [[1, 2], [], [3, 4, 5], [], [6]], + } + dataset = Dataset.from_dict(examples) + seq_length = 4 + expected_output = { + "input_ids": [[3, 4, 5, 6], [1, 2]], + "seq_lengths": [[3, 1], [2]], + } + dataset = pack_dataset(dataset, seq_length, strategy="bfd_split") + assert dataset.to_dict() == expected_output + + +class TestMaybeConvertToChatML(TrlTestCase): + def test_with_conversations_key(self): + # Particular case where the key is "conversations": we rename it to "messages" + example = { + "conversations": [ + {"from": "user", "value": "What color is the sky?"}, + {"from": "assistant", "value": "It is blue."}, + ] + } + expected_output = { + "messages": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ] + } + assert maybe_convert_to_chatml(example) == expected_output + + def test_without_conversations_key(self): + # Same as before, but we don't rename the keys + example = { + "prompt": [{"from": "user", "value": "What color is the sky?"}], + "completion": [{"from": "assistant", "value": "It is blue."}], + } + expected_output = { + "prompt": [{"role": "user", "content": "What color is the sky?"}], + "completion": [{"role": "assistant", "content": "It is blue."}], + } + assert maybe_convert_to_chatml(example) == expected_output + + def test_not_conversional(self): + # When not needed, the example should remain unchanged + example = {"text": "The sky is blue."} + assert maybe_convert_to_chatml(example) == example + + def test_already_chatml(self): + # When the example is already in ChatML format, it should remain unchanged + example = { + "messages": [ + {"role": "user", "content": "What color is the sky?"}, + {"role": "assistant", "content": "It is blue."}, + ] + } + assert maybe_convert_to_chatml(example) == example diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_dpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_dpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..5000c0f449a7601eac83eb2ac9c030e552665bc6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_dpo_trainer.py @@ -0,0 +1,1322 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +import torch +import transformers +from datasets import load_dataset +from packaging.version import Version +from packaging.version import parse as parse_version +from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig +from transformers.utils import is_peft_available + +from trl import DPOConfig, DPOTrainer +from trl.trainer.dpo_trainer import DataCollatorForPreference, DataCollatorForVisionPreference + +from .testing_utils import ( + TrlTestCase, + require_ampere_or_newer, + require_bitsandbytes, + require_kernels, + require_liger_kernel, + require_peft, + require_vision, +) + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +class TestDataCollatorForPreference(TrlTestCase): + def test_padding_and_masks(self): + collator = DataCollatorForPreference(pad_token_id=0) + examples = [ + {"prompt_ids": [1, 2, 3], "chosen_ids": [4, 5], "rejected_ids": [6]}, + {"prompt_ids": [7, 8], "chosen_ids": [9, 10], "rejected_ids": [11, 12, 13]}, + ] + result = collator(examples) + + expected_input_ids = torch.tensor( + [ + [1, 2, 3, 4, 5], # prompt + chosen (example 1) + [7, 8, 9, 10, 0], # prompt + chosen (example 2, padded) + [1, 2, 3, 6, 0], # prompt + rejected (example 1, padded) + [7, 8, 11, 12, 13], # prompt + rejected (example 2) + ] + ) + expected_attention_mask = torch.tensor( + [ + [1, 1, 1, 1, 1], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 1], + ] + ) + expected_completion_mask = torch.tensor( + [ + [0, 0, 0, 1, 1], # chosen completion (example 1) + [0, 0, 1, 1, 0], # chosen completion (example 2, padded) + [0, 0, 0, 1, 0], # rejected completion (example 1, padded) + [0, 0, 1, 1, 1], # rejected completion (example 2) + ] + ) + + assert set(result.keys()) == {"input_ids", "attention_mask", "completion_mask"} + torch.testing.assert_close(result["input_ids"], expected_input_ids) + torch.testing.assert_close(result["attention_mask"], expected_attention_mask) + torch.testing.assert_close(result["completion_mask"], expected_completion_mask) + + def test_optional_reference_logps(self): + collator = DataCollatorForPreference(pad_token_id=0) + examples = [ + { + "prompt_ids": [1, 2], + "chosen_ids": [3], + "rejected_ids": [4], + "ref_chosen_logps": 0.1, + "ref_rejected_logps": 0.2, + }, + { + "prompt_ids": [5], + "chosen_ids": [6, 7], + "rejected_ids": [8, 9], + "ref_chosen_logps": 0.3, + "ref_rejected_logps": 0.4, + }, + ] + result = collator(examples) + + expected_ref_chosen_logps = torch.tensor([0.1, 0.3]) + expected_ref_rejected_logps = torch.tensor([0.2, 0.4]) + + assert set(result.keys()) == { + "input_ids", + "attention_mask", + "completion_mask", + "ref_chosen_logps", + "ref_rejected_logps", + } + torch.testing.assert_close(result["ref_chosen_logps"], expected_ref_chosen_logps) + torch.testing.assert_close(result["ref_rejected_logps"], expected_ref_rejected_logps) + + def test_with_pad_to_multiple_of(self): + collator = DataCollatorForPreference(pad_token_id=0, pad_to_multiple_of=5) + examples = [ + {"prompt_ids": [1], "chosen_ids": [2], "rejected_ids": [3]}, + {"prompt_ids": [4, 5], "chosen_ids": [6, 7], "rejected_ids": [8, 9]}, + ] + result = collator(examples) + + expected_input_ids = torch.tensor( + [ + [1, 2, 0, 0, 0], # prompt + chosen (example 1, padded to multiple of 5) + [4, 5, 6, 7, 0], # prompt + chosen (example 2) + [1, 3, 0, 0, 0], # prompt + rejected (example 1, padded to multiple of 5) + [4, 5, 8, 9, 0], # prompt + rejected (example 2) + ] + ) + + assert set(result.keys()) == {"input_ids", "attention_mask", "completion_mask"} + torch.testing.assert_close(result["input_ids"], expected_input_ids) + + +class TestDataCollatorForVisionPreference(TrlTestCase): + @pytest.mark.skipif( + Version(transformers.__version__) < Version("5.3.0"), + reason="mm_token_type_ids are returned by default since transformers-5.3.0 (see transformers#43972)", + ) + @require_vision + def test_mm_token_type_ids_shape(self): + # Regression test: when the processor returns mm_token_type_ids (e.g. Qwen2.5-VL after + # transformers#43972), the collator must concatenate it with zeros for the completion part + # so that its shape matches input_ids. Without the fix this raises an IndexError in the model. + from PIL import Image + from transformers import AutoProcessor + + processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration") + collator = DataCollatorForVisionPreference(processor) + image = Image.new("RGB", (16, 16)) + examples = [ + { + "images": [image], + "prompt": [{"role": "user", "content": "What is this?"}], + "chosen": [{"role": "assistant", "content": "A red square."}], + "rejected": [{"role": "assistant", "content": "A blue circle."}], + } + ] + output = collator(examples) + assert "mm_token_type_ids" in output + assert output["mm_token_type_ids"].shape == output["input_ids"].shape, ( + f"mm_token_type_ids shape {output['mm_token_type_ids'].shape} != " + f"input_ids shape {output['input_ids'].shape}" + ) + + +class TestDPOTrainer(TrlTestCase): + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "trl-internal-testing/tiny-Qwen3MoeForCausalLM", + "trl-internal-testing/tiny-GptOssForCausalLM", + ], + ) + def test_train(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = DPOTrainer(model=model_id, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # Special case for harmony + def test_train_gpt_oss(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/harmony", "preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-GptOssForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_model(self): + # Instantiate the model + model = AutoModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + dtype="float32", + ) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = DPOTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize( + "loss_type", + [ + "sigmoid", + "hinge", + "ipo", + "exo_pair", + "nca_pair", + "robust", + "bco_pair", + "sppo_hard", + "aot", + "aot_unpaired", + "apo_zero", + "apo_down", + "discopop", + "sft", + ], + ) + def test_train_loss_types(self, loss_type): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + loss_type=loss_type, + label_smoothing=1e-3 if loss_type == "exo_pair" else 0.0, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + eval_strategy="steps", + eval_steps=3, + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_multi_loss_types(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + loss_type=["sigmoid", "bco_pair", "sft"], # this specific combination is used in MPO + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_wpo(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + use_weighting=True, + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_ld(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ld_alpha=0.5, + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize( + "f_divergence_type", + ["reverse_kl", "forward_kl", "js_divergence", "alpha_divergence"], + ) + def test_train_with_f_divergence(self, f_divergence_type): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + f_divergence_type=f_divergence_type, + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_explicit_ref_model(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + report_to="none", + ) + # When specifying a ref model, it's usually because we want it to be a different checkpoint, but for testing + # purposes we will just just use the same checkpoint + ref_model = AutoModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32" + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + ref_model=ref_model, + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + new_ref_param = trainer.ref_model.get_parameter(n) + torch.testing.assert_close(param, new_ref_param), f"Reference model parameter {n} has changed" + + def test_training_with_sync_ref_model(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + sync_ref_model=True, + ref_model_sync_steps=2, # reduce sync steps to ensure a sync happens + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + assert trainer.ref_model is not None + previous_ref_params = {n: param.clone() for n, param in trainer.ref_model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + new_ref_param = trainer.ref_model.get_parameter(n) + assert not torch.equal(previous_ref_params[n], new_ref_param), f"Ref Parameter {n} has not changed." + + def test_train_model_dtype(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + model_init_kwargs={"dtype": torch.float16}, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + # For some reasonn model.layers.0.input_layernorm.weight doesn't change in GitHub Actions but does + # locally. We ignore this parameter for now + if "layernorm" in n: + continue + new_param = trainer.model.get_parameter(n) + # Check the torch dtype + assert new_param.dtype == torch.float16 + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_dense_with_peft_config_lora(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=1.0, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + trainer = DPOTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_moe_with_peft_config(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-GptOssForCausalLM" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + trainer = DPOTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(target_parameters=["mlp.experts.down_proj", "mlp.experts.gate_up_proj"]), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_peft_model(self): + # Get the base model + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + + # Get the base model parameter names + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Turn the model into a peft model + lora_config = LoraConfig() + model = get_peft_model(model, lora_config) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=1.0, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = DPOTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n and "ref" not in n: # and the peft params to be different (except base and ref) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # In practice, this test is the same as `test_train_dense_with_peft_config_lora`, since gradient checkpointing is + # enabled by default in `DPOTrainer`. We keep it as a regression guard: if the default ever changes, we still + # explicitly test PEFT + gradient checkpointing, which has caused issues in the past. + @require_peft + def test_train_with_peft_config_and_gradient_checkpointing(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + gradient_checkpointing=True, + report_to="none", + ) + + trainer = DPOTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_liger_kernel + def test_train_with_liger(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + use_liger_kernel=True, + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_iterable_dataset(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train", streaming=True) + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_steps=3, + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_kernels + @require_ampere_or_newer # Flash attention 2 requires Ampere or newer GPUs + def test_train_padding_free(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + padding_free=True, + model_init_kwargs={"attn_implementation": "kernels-community/flash-attn2"}, + bf16=True, # flash_attention_2 only supports bf16 and fp16 + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_chat_template_kwargs(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + # The following template is a simplified version of the Qwen chat template, where an additional argument + # `role_capital` is used to control the capitalization of roles. + tokenizer.chat_template = '{%- if messages[0]["role"] == "system" -%} {{ "<|im_start|>" + ("SYSTEM" if role_capital else "system") + "\\n" + messages[0]["content"] + "<|im_end|>\\n" }}{%- else -%} {{ "<|im_start|>" + ("SYSTEM" if role_capital else "system") + "\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n" }}{%- endif -%}{%- for message in messages -%} {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) -%} {{ "<|im_start|>" + (message.role.upper() if role_capital else message.role) + "\\n" + message.content + "<|im_end|>\\n" }} {%- elif message.role == "assistant" -%} {{ "<|im_start|>" + ("ASSISTANT" if role_capital else "assistant") }} {%- if message.content -%} {{ "\\n" + message.content }} {%- endif -%} {{ "<|im_end|>\\n" }} {%- elif message.role == "tool" -%} {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") -%} {{ "<|im_start|>" + ("USER" if role_capital else "user") }} {%- endif -%} {{ "\\n\\n" + message.content + "\\n" }} {%- if loop.last or (messages[loop.index0 + 1].role != "tool") -%} {{ "<|im_end|>\\n" }} {%- endif -%} {%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%} {{ "<|im_start|>" + ("ASSISTANT" if role_capital else "assistant") + "\\n" }}{%- endif -%}' + + dataset = dataset.add_column( + "chat_template_kwargs", [{"role_capital": bool(i % 2)} for i in range(len(dataset))] + ) + assert "chat_template_kwargs" in dataset.features + + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + processing_class=tokenizer, + ) + + # Assert trainer uses the same chat template as tokenizer + assert trainer.processing_class.chat_template == tokenizer.chat_template + + # Assert chat_template is applied + for i in range(2): + role = "SYSTEM" if i else "system" + system_prompt = ( + f"<|im_start|>{role}\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>" + ) + system_prompt_ids = trainer.processing_class(system_prompt)["input_ids"] + assert trainer.train_dataset[i]["prompt_ids"][: len(system_prompt_ids)] == system_prompt_ids + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_toolcall_data(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/toolcall", "preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_eval(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + # Initialize the trainer + training_args = DPOConfig(output_dir=self.tmp_dir, eval_strategy="steps", eval_steps=3, report_to="none") + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Train the model + trainer.train() + + # Check that the eval loss is not None + assert trainer.state.log_history[0]["eval_loss"] is not None + + def test_train_with_multiple_eval_dataset(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + # Initialize the trainer + training_args = DPOConfig(output_dir=self.tmp_dir, eval_strategy="steps", eval_steps=3, report_to="none") + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset={"data1": dataset["test"], "data2": dataset["test"]}, + ) + # Train the model + trainer.train() + + # Check that the eval losses are not None + assert trainer.state.log_history[-3]["eval_data1_loss"] is not None + assert trainer.state.log_history[-2]["eval_data2_loss"] is not None + + def test_train_with_compute_metrics(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference") + + def dummy_compute_metrics(eval_pred): + return {"my_metric": 0.123} + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + eval_strategy="steps", + eval_steps=3, + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + # Train the model + trainer.train() + + # Check that the custom metric is logged + assert trainer.state.log_history[-2]["eval_my_metric"] == 0.123 + + # In practice, this test is the same as `test_train`, since gradient checkpointing is enabled by default in + # `DPOTrainer`. We keep it as a regression guard: if the default ever changes, we still explicitly test gradient + # checkpointing, which has caused issues in the past. + def test_train_with_gradient_checkpointing(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + gradient_checkpointing=True, + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_tag_added(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + train_dataset=dataset, + ) + + for tag in ["dpo", "trl"]: + assert tag in trainer.model.model_tags + + @require_peft + def test_tag_added_peft(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + for tag in ["dpo", "trl"]: + assert tag in trainer.model.model_tags + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + # "trl-internal-testing/tiny-Idefics2ForConditionalGeneration", high memory peak, skipped for now + # "trl-internal-testing/tiny-Idefics3ForConditionalGeneration", high memory peak, skipped for now + "trl-internal-testing/tiny-LlavaForConditionalGeneration", + "trl-internal-testing/tiny-LlavaNextForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + # "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", seems not to support bf16 properly + pytest.param( + "trl-internal-testing/tiny-Qwen3VLForConditionalGeneration", + marks=[ + pytest.mark.skipif( + Version(transformers.__version__) < Version("4.57.0"), + reason="Qwen3-VL series were introduced in transformers-4.57.0", + ), + ], + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + ], + ) + @require_vision + def test_train_vlm(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + per_device_train_batch_size=2, # VLM training is memory intensive, reduce batch size to avoid OOM + report_to="none", + ) + trainer = DPOTrainer(model=model_id, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # For some reason, these params are not updated. This is probably not related to TRL, but to + # the model itself. We should investigate this further, but for now we just skip these params. + # fmt: off + if ( + model_id == "trl-internal-testing/tiny-Gemma3ForConditionalGeneration" and "model.vision_tower.vision_model.head" in n or + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "model.vision_tower.vision_model.post_layernorm" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "vision_tower.vision_model.encoder.layers.1" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "model.vision_tower.encoder.layers.1" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "model.vision_tower.post_layernorm" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "model.vision_tower.vision_model.post_layernorm" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "vision_tower.vision_model.encoder.layers.1" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "model.vision_tower.encoder.layers.1" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "model.vision_tower.post_layernorm" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-Qwen3VLForConditionalGeneration" and "model.visual.deepstack_merger_list" in n + ): + # fmt: on + continue + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @pytest.mark.xfail( + parse_version(transformers.__version__) < parse_version("4.57.0"), + reason="Mixing text-only and image+text examples is only supported in transformers >= 4.57.0", + strict=False, + ) + @require_vision + def test_train_vlm_multi_image(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen-multi-image", "conversational_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + per_device_train_batch_size=1, # VLM training is memory intensive, reduce batch size to avoid OOM + report_to="none", + ) + trainer = DPOTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + # Gemma 3n uses a timm encoder, making it difficult to create a smaller variant for testing. + # To ensure coverage, we run tests on the full model but mark them as slow to exclude from default runs. + @pytest.mark.slow + @require_vision + @pytest.mark.skip(reason="Model google/gemma-3n-E2B-it is gated and requires HF token") + def test_train_vlm_gemma_3n(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_preference", split="train") + + # Initialize the trainer + training_args = DPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + per_device_train_batch_size=1, # VLM training is memory intensive, reduce batch size to avoid OOM + model_init_kwargs={"dtype": "bfloat16"}, + report_to="none", + ) + trainer = DPOTrainer(model="google/gemma-3n-E2B-it", args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if "model.audio_tower" in n or "model.embed_audio" in n: + # The audio embedding parameters are not updated because this dataset contains no audio data + continue + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @pytest.mark.parametrize( + "dataset_config", + ["conversational_preference", "standard_preference"], + ) + @require_vision + def test_train_vlm_text_only_data(self, model_id, dataset_config): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", dataset_config, split="train") + + # Initialize the trainer + training_args = DPOConfig(output_dir=self.tmp_dir, report_to="none") + trainer = DPOTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n.startswith("model.visual"): + torch.testing.assert_close(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is updated" + else: + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @require_vision + def test_train_vlm_with_max_length(self): + # Regression test for #5283: mm_token_type_ids must be truncated alongside input_ids when max_length is set, + # otherwise a shape mismatch crashes the model forward pass. + # max_length=37 truncates 1 completion token (total_len=38) while keeping all image tokens (prompt_len=34) safe. + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_preference", split="train") + training_args = DPOConfig( + output_dir=self.tmp_dir, + max_length=37, # total_len=38, prompt_len=34 — truncates completion, not image tokens + per_device_train_batch_size=2, + report_to="none", + ) + trainer = DPOTrainer( + model="trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + args=training_args, + train_dataset=dataset, + ) + trainer.train() + assert trainer.state.log_history[-1]["train_loss"] is not None + + @require_peft + @require_bitsandbytes + def test_peft_with_quantization(self): + # Get the base model + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + + quantization_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_use_double_quant=True, + bnb_4bit_quant_type="nf4", + bnb_4bit_compute_dtype=torch.float16, + ) + model = AutoModelForCausalLM.from_pretrained( + model_id, + dtype="float32", + quantization_config=quantization_config, + ) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_preference", split="train") + + # Initialize the trainer with the already configured PeftModel + training_args = DPOConfig(output_dir=self.tmp_dir, learning_rate=0.1, report_to="none") + trainer = DPOTrainer(model=model, args=training_args, train_dataset=dataset, peft_config=LoraConfig()) + + # Save initial parameters to check they change during training + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that training completed successfully + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["mean_token_accuracy"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # In bitsandbytes, bias parameters are automatically cast to the input dtype during the forward pass if + # their dtype doesn’t match. This causes the module to change unexpectedly during the first forward pass of + # the training. To handle this, we cast these specific bias parameters to float32 before comparison. + # https://github.com/bitsandbytes-foundation/bitsandbytes/blob/45553f7392e524eacf400b132cfe01261f6477be/bitsandbytes/nn/modules.py#L518 + # We still need to investigate why the compute dtype ends up being different than for these parameters. + if n in [ + "base_model.model.model.layers.1.self_attn.k_proj.bias", + "base_model.model.model.layers.1.self_attn.q_proj.base_layer.bias", + "base_model.model.model.layers.1.self_attn.v_proj.base_layer.bias", + ]: + param = param.float() + + if "lora" not in n: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "lora" in n: # We expect the peft parameters to be different + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + else: + raise ValueError(f"Unexpected parameter {n} in model: {trainer.model}") + + @require_vision + def test_train_vlm_keep_end_raises(self): + # Regression test for #5285: keep_end with a VLM must raise at init time, not silently corrupt training. + # Image tokens live at the start of the sequence (in the prompt); keep_end would drop them. + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_preference", split="train") + with pytest.warns(FutureWarning, match="keep_end.*deprecated"): + training_args = DPOConfig( + output_dir=self.tmp_dir, + max_length=32, + truncation_mode="keep_end", + report_to="none", + ) + with pytest.raises(ValueError, match="truncation_mode='keep_end' is not supported for vision-language models"): + DPOTrainer( + model="trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + args=training_args, + train_dataset=dataset, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_grpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_grpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..8f3e14660d8c160eefccb6a274188d593a128f28 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_grpo_trainer.py @@ -0,0 +1,3341 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import os +import warnings +from collections.abc import Callable +from types import SimpleNamespace +from unittest.mock import MagicMock, patch + +import numpy as np +import pytest +import torch +import transformers +from accelerate.utils.memory import release_memory +from datasets import Dataset, Features, Image, Value, load_dataset +from packaging.version import Version +from transformers import ( + AutoModelForCausalLM, + AutoModelForImageTextToText, + AutoModelForSequenceClassification, + AutoProcessor, + AutoTokenizer, + BitsAndBytesConfig, +) +from transformers.testing_utils import backend_empty_cache, torch_device +from transformers.utils import is_peft_available + +from trl import GRPOConfig, GRPOTrainer +from trl.import_utils import is_liger_kernel_available +from trl.trainer.utils import get_kbit_device_map + +from .testing_utils import ( + TrlTestCase, + require_ampere_or_newer, + require_bitsandbytes, + require_jmespath, + require_kernels, + require_liger_kernel, + require_peft, + require_torch_accelerator, + require_vision, + require_vllm, +) + + +if is_peft_available(): + from peft import LoraConfig, PeftModel, get_peft_model + + +def multiply_tool(a: int, b: int) -> int: + """ + Multiplies two integers. + + Args: + a: The first integer. + b: The second integer. + + Returns: + The product of the two integers. + """ + return a * b + + +async def async_multiply_tool(a: int, b: int) -> int: + """ + Asynchronously multiplies two integers. + + Args: + a: The first integer. + b: The second integer. + + Returns: + The product of the two integers. + """ + return a * b + + +class TestGetHighEntropyMask(TrlTestCase): + def get_high_entropy_mask(self, entropies, mask, threshold): + """Helper method to test the get_high_entropy_mask functionality.""" + # Create a mock trainer with minimal setup + from unittest.mock import Mock + + # Create a mock accelerator + mock_accelerator = Mock() + mock_accelerator.num_processes = 1 # Single process for testing + + # Create a minimal trainer instance just to access the method + trainer = Mock(spec=GRPOTrainer) + trainer.accelerator = mock_accelerator + trainer.accelerator.gather = lambda x: x + trainer.accelerator.pad_across_processes = lambda x, dim, pad_index: x + + # Call the actual method from GRPOTrainer + return GRPOTrainer.get_high_entropy_mask(trainer, entropies, mask, threshold) + + def test_compute_entropy_mask_0(self): + # We have a total of 12 tokens out of which 10 are non-pad. + # for a top_entropy_quantile of 0.8, we expect the top 20% i.e 2 non-pad tokens corresponding to + # the highest entropy to be unmasked. + # In our example these will be the tokens corresponding to the entropies 0.9 and 1.0 since 1.1 and 1.2 are pad + # tokens they are excluded from the entropy threshold calculation. + entropies = torch.tensor([[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0.7, 0.8, 0.9, 1.0, 1.1, 1.2]]) + mask = torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0]]) + entropy_mask = self.get_high_entropy_mask(entropies, mask, threshold=0.8) + expected_mask = torch.tensor([[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0]], dtype=torch.bool) + torch.testing.assert_close(entropy_mask, expected_mask) + + def test_compute_entropy_mask_1(self): + # Another example with a different set of entropies and a different mask. + entropies = torch.tensor([[0.1, 0.2, 0.3, 1.4, 0.5, 0.14], [0.5, 0.6, 0.7, 0.8, 0.9, 1.0]]) + mask = torch.tensor([[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0]]) + entropy_mask = self.get_high_entropy_mask(entropies, mask, threshold=0.8) + expected_mask = torch.tensor([[0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0]], dtype=torch.bool) + torch.testing.assert_close(entropy_mask, expected_mask) + + def test_compute_entropy_mask_lower_threshold(self): + # For a threshold of 0.5 we expect the top half of the non-pad tokens to be unmasked. + entropies = torch.tensor([[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0.7, 0.8, 0.9, 1.0, 1.1, 1.2]]) + mask = torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0]]) + entropy_mask = self.get_high_entropy_mask(entropies, mask, threshold=0.5) + expected_mask = torch.tensor([[0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0]], dtype=torch.bool) + torch.testing.assert_close(entropy_mask, expected_mask) + + def test_compute_entropy_threshold_0(self): + # If the threshold is 0.0 then we expect the mask to be all ones for non-pad tokens. + entropies = torch.tensor([[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0.7, 0.8, 0.9, 1.0, 1.1, 1.2]]) + mask = torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0]]) + entropy_mask = self.get_high_entropy_mask(entropies, mask, threshold=0.0) + expected_mask = torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0]], dtype=torch.bool) + torch.testing.assert_close(entropy_mask, expected_mask) + + def test_compute_entropy_threshold_1(self): + # If the threshold is 1.0 then we expect the mask to be all zeros BUT ONE VALUE. + entropies = torch.tensor([[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0.7, 0.8, 0.9, 1.0, 1.1, 1.2]]) + mask = torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0]]) + entropy_mask = self.get_high_entropy_mask(entropies, mask, threshold=1.0) + expected_mask = torch.tensor([[0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]], dtype=torch.bool) + torch.testing.assert_close(entropy_mask, expected_mask) + + def test_compute_entropy_all_masked(self): + # If there are no non-pad tokens we expect the mask to be all zeros. + entropies = torch.tensor([[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0.7, 0.8, 0.9, 1.0, 1.1, 1.2]]) + mask = torch.tensor([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) + entropy_mask = self.get_high_entropy_mask(entropies, mask, threshold=0.5) + expected_mask = torch.tensor([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]], dtype=torch.bool) + torch.testing.assert_close(entropy_mask, expected_mask) + + +class TestGRPORolloutDispatch: + def _make_trainer(self): + trainer = object.__new__(GRPOTrainer) + trainer.accelerator = SimpleNamespace( + device=torch.device("cpu"), + is_main_process=True, + gather=lambda t: t, + ) + trainer.args = SimpleNamespace(report_to=[]) + trainer.model = SimpleNamespace(training=True) + trainer.state = SimpleNamespace(global_step=2, num_input_tokens_seen=0) + trainer._last_loaded_step = 1 + trainer.use_vllm = False + trainer.use_transformers_paged = False + trainer.vllm_generation = SimpleNamespace(sync_weights=MagicMock()) + trainer.processing_class = SimpleNamespace( + batch_decode=MagicMock(return_value=["decoded"]), + ) + trainer._tokenizer = SimpleNamespace(eos_token_id=2, pad_token_id=0) + trainer.tools = None + trainer._metrics = { + "train": { + "num_tokens": [], + **{ + k: [] + for k in [ + "completions/mean_length", + "completions/min_length", + "completions/max_length", + "completions/clipped_ratio", + "completions/mean_terminated_length", + "completions/min_terminated_length", + "completions/max_terminated_length", + ] + }, + } + } + return trainer + + def test_generate_prefers_rollout_func(self): + trainer = self._make_trainer() + trainer.rollout_func = MagicMock( + return_value={ + "prompt_ids": [[1]], + "completion_ids": [[2]], + "logprobs": [[-0.1]], + "env_mask": [[1]], + } + ) + + result = trainer._generate(["prompt"]) + + assert result[0] == [[1]] # prompt_ids + assert result[1] == [[2]] # completion_ids + assert result[2] == [[1]] # tool_mask (from env_mask) + trainer.rollout_func.assert_called_once_with(["prompt"], trainer) + + def test_generate_rollout_func_syncs_vllm_weights_when_needed(self): + trainer = self._make_trainer() + trainer.use_vllm = True + trainer.rollout_func = MagicMock( + return_value={"prompt_ids": [[1]], "completion_ids": [[2]], "logprobs": [[0.0]]} + ) + + trainer._generate(["prompt"]) + + trainer.vllm_generation.sync_weights.assert_called_once() + assert trainer._last_loaded_step == trainer.state.global_step + trainer.rollout_func.assert_called_once_with(["prompt"], trainer) + + def test_generate_rollout_func_raises_when_required_keys_are_missing(self): + trainer = self._make_trainer() + trainer.rollout_func = MagicMock(return_value={"prompt_ids": [[1]], "completion_ids": [[2]]}) + + with pytest.raises(ValueError, match="rollout_func must return keys"): + trainer._generate(["prompt"]) + + +class TestGRPOTrainer(TrlTestCase): + def test_init_minimal(self): + # Test that GRPOTrainer can be instantiated with only model, reward_model and train_dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + train_dataset=dataset, + ) + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_training(self, config_name): + dataset = load_dataset("trl-internal-testing/zen", config_name, split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize("loss_type", ["bnpo", "dr_grpo", "dapo", "cispo", "sapo", "luspo", "vespo"]) + def test_training_loss_types(self, loss_type): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + importance_sampling_level="sequence" if loss_type == "luspo" else "token", + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=32, # reduce the completion length to reduce memory usage + gradient_accumulation_steps=2, # set to 2 to test than DAPO can operate with accumulated batch + loss_type=loss_type, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_eval(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + per_device_eval_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + eval_strategy="steps", + eval_steps=2, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + trainer.train() + + def test_training_with_num_generations_eval(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + per_device_eval_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_generations_eval=1, + eval_strategy="steps", + eval_steps=2, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + trainer.train() + + # Regression test for eval_on_start with loss_type="grpo" (one of the loss types that depends on + # current_gradient_accumulation_steps): evaluation runs before the first training step, when that value is still + # unset. Previously this caused the initial eval to crash. + def test_training_eval_on_start(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + per_device_eval_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + loss_type="grpo", + eval_strategy="steps", + eval_steps=2, + eval_on_start=True, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + trainer.train() + + def test_training_multiple_iterations(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_iterations=2, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_peft + def test_training_peft_config(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n: # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + @require_peft + def test_training_peft_model(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + lora_config = LoraConfig() + model = get_peft_model(model, lora_config) + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n and "ref" not in n: # and the peft params to be different (except base and ref) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + # In practice, this test is the same as `test_training_peft_config`, since gradient checkpointing is enabled by + # default in `GRPOTrainer`. We keep it as a regression guard: if the default ever changes, we still explicitly test + # PEFT + gradient checkpointing, which has caused issues in the past. + @require_peft + def test_training_peft_with_gradient_checkpointing(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + gradient_checkpointing=True, # enable gradient checkpointing + report_to="none", + ) + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n: # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + def test_training_different_reward_model(self): + # Use a reward model different from the model: different chat template, tokenization, etc. + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + reward_model_id = "trl-internal-testing/tiny-LlamaForSequenceClassification-3.2" + reward_model = AutoModelForSequenceClassification.from_pretrained(reward_model_id) + reward_tokenizer = AutoTokenizer.from_pretrained(reward_model_id) + # By default, the trainer uses the eos token as the padding token. However, for Llama models, the eos token + # appears in the chat template. Using it as a pad token disrupts the reward calculation, as the calculation + # considers the score of the last token before the first pad token. To ensure correct reward calculations, + # we use a separate pad token instead. + reward_tokenizer.pad_token = "<|finetune_right_pad_id|>" + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_model, + args=training_args, + train_dataset=dataset, + reward_processing_classes=reward_tokenizer, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_reward_func_standard(self): + # Test if trainer can handle reward function with standard format + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_reward_func_conversational(self): + # Test if trainer can handle reward function with conversational format + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that gives higher scores to longer completion content.""" + completion_contents = [completion[0]["content"] for completion in completions] + return [float(len(content)) for content in completion_contents] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_reward_funcs(self): + # Test that GRPOTrainer can be instantiated with multiple reward functions + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def reward_func2(completions, **kwargs): + """Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func1, reward_func2], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_sync_and_async_reward_funcs(self): + # Test that GRPOTrainer can be instantiated with multiple reward functions one of which is async + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def sync_reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def sync_reward_func2(completions, **kwargs): + return [1 for _ in completions] + + async def async_reward_func(completions, **kwargs): + """Async Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[sync_reward_func1, sync_reward_func2, async_reward_func], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_reward_funcs_with_None_output(self): + """Test that a valid math reward function is processed correctly while the code reward function returns None.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def applicable_reward_func(completions, **kwargs): + """A reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def non_applicable_reward_func(completions, **kwargs): + """A reward function that returns None for all inputs, as it is not applicable to this sample.""" + return [None] * len(completions) + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[ + applicable_reward_func, + non_applicable_reward_func, + ], # One applicable, one non applicable + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = { + n: param.clone() for n, param in trainer.model.named_parameters() if param.requires_grad + } + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_reward_funcs_with_weights(self): + """Test that GRPOTrainer can handle multiple reward functions with weights.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def reward_func2(completions, **kwargs): + """Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + reward_weights=[0.7, 0.3], # weight of reward_func1 and reward_func2 respectively + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func1, reward_func2], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that training logs contain both reward metrics + assert trainer.state.log_history[-1]["train_loss"] is not None + assert "rewards/reward_func1/mean" in trainer.state.log_history[-1] + assert "rewards/reward_func1/std" in trainer.state.log_history[-1] + assert "rewards/reward_func2/mean" in trainer.state.log_history[-1] + assert "rewards/reward_func2/std" in trainer.state.log_history[-1] + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize("multi_objective_aggregation", ["sum_then_normalize", "normalize_then_sum"]) + def test_reward_metric_reflects_reward_weights(self, multi_objective_aggregation): + """Test that the logged 'reward' metric uses reward_weights, not an unweighted sum.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def constant_reward_1(completions, **kwargs): + return [1.0] * len(completions) + + def constant_reward_0(completions, **kwargs): + return [0.0] * len(completions) + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + reward_weights=[0.7, 0.3], + multi_objective_aggregation=multi_objective_aggregation, + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[constant_reward_1, constant_reward_0], + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + log = trainer.state.log_history[-1] + # With reward_weights=[0.7, 0.3] and rewards [1.0, 0.0]: + # weighted reward = 0.7*1.0 + 0.3*0.0 = 0.7 + # unweighted reward = 1.0 + 0.0 = 1.0 + assert abs(log["reward"] - 0.7) < 1e-5, ( + f"Expected logged reward to be ~0.7 (weighted), got {log['reward']}. " + "The reward metric should reflect reward_weights." + ) + + def test_training_multiple_mixed_reward_funcs(self): + # Test if the trainer can handle a mix of reward functions and reward models + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func, "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5"], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_reward_func_additional_column(self): + # Test if trainer can handle reward function that rely on additional columns in the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Add a column to the dataset (dummy example, the column could be anything) + some_values = list(range(len(dataset))) + dataset = dataset.add_column("some_values", some_values) + + def reward_func(completions, some_values, **kwargs): + """Reward function that rewards completions with lengths closer to the values in some_values.""" + return [ + float(abs(len(completion) - value)) for completion, value in zip(completions, some_values, strict=True) + ] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_sync_ref_model(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + beta=0.1, # ensure ref model is created so sync can update it + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + sync_ref_model=True, + ref_model_sync_steps=2, # reduce sync steps to ensure a sync happens + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + assert trainer.ref_model is not None + previous_ref_params = {n: param.clone() for n, param in trainer.ref_model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + new_ref_param = trainer.ref_model.get_parameter(n) + assert not torch.equal(previous_ref_params[n], new_ref_param), f"Ref Parameter {n} has not changed." + + def test_training_beta_non_zero(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + beta=0.1, # set beta to non-zero value to test the case where the reference model is used + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_pad_to_multiple_of(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + pad_to_multiple_of=8, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_get_off_policy_mask(self): + """ + Test the logic of off-policy masking: + - Keep if Advantage >= 0 + - Keep if KL <= threshold + - Drop if Advantage < 0 AND KL > threshold + """ + mask = torch.ones((3, 4)) # B=3 sequences, T=4 tokens + + advantages = torch.tensor([1.0, -1.0, -1.0]).unsqueeze(-1) + sampling_per_token_logps = torch.zeros((3, 4)) + per_token_logps = torch.zeros((3, 4)) + + per_token_logps[0, :] = -2.0 # Pos adv + High KL (0−(−2)=2) -> Keep + per_token_logps[1, :] = -0.5 # Neg adv + Low KL (0.5) -> Keep + per_token_logps[2, :] = -2.0 # Neg adv + High KL (2.0) -> Drop + + off_policy_threshold = 1.0 + + expected_mask = torch.tensor([[1.0], [1.0], [0.0]]) + + off_policy_mask = GRPOTrainer.get_off_policy_mask( + advantages, per_token_logps, sampling_per_token_logps, mask, off_policy_threshold + ) + + torch.testing.assert_close(off_policy_mask, expected_mask) + + def test_get_off_policy_mask_padding(self): + """Test that padding is correctly ignored in KL calculation.""" + mask = torch.tensor([[1.0, 1.0, 0.0, 0.0]]) # 2 valid tokens + advantages = torch.tensor([[-1.0]]) # Negative advantage + + sampling_per_token_logps = torch.zeros((1, 4)) + per_token_logps = torch.zeros((1, 4)) + + # Valid tokens have High KL (2.0) + per_token_logps[0, 0] = -2.0 + per_token_logps[0, 1] = -2.0 + + # Padding tokens have abnormal values (should be ignored) + per_token_logps[0, 2] = -10_000.0 + per_token_logps[0, 3] = 10_000.0 + + off_policy_threshold = 1.0 + + # Avg KL on valid tokens = (2+2)/2 = 2.0 > 1.0 -> Drop + expected_mask = torch.tensor([[0.0]]) + + off_policy_mask = GRPOTrainer.get_off_policy_mask( + advantages, per_token_logps, sampling_per_token_logps, mask, off_policy_threshold + ) + + torch.testing.assert_close(off_policy_mask, expected_mask) + + # Now test with Low KL on valid tokens + per_token_logps[0, 0] = -0.5 + per_token_logps[0, 1] = -0.5 + # Avg KL = 0.5 <= 1.0 -> Keep + expected_mask_keep = torch.tensor([[1.0]]) + + off_policy_mask_keep = GRPOTrainer.get_off_policy_mask( + advantages, per_token_logps, sampling_per_token_logps, mask, off_policy_threshold + ) + + torch.testing.assert_close(off_policy_mask_keep, expected_mask_keep) + + def test_training_with_off_policy_mask(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + off_policy_mask_threshold=0.5, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_liger_kernel + @pytest.mark.xfail(reason="Off-Policy Masking isn't compatible with Liger yet.") + def test_training_with_off_policy_mask_with_liger(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + off_policy_mask_threshold=0.5, + use_liger_kernel=True, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_liger_kernel + def test_compute_liger_loss_passes_vllm_is_ratio(self): + """Test that importance_sampling_ratio from inputs is passed to liger_grpo_loss as vllm_is_ratio.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + use_liger_kernel=True, + report_to="none", + logging_strategy="no", + ) + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Mock _generate_and_score_completions to inject importance_sampling_ratio + original_gen = trainer._generate_and_score_completions + + def gen_with_is_ratio(*args, **kwargs): + result = original_gen(*args, **kwargs) + B, T = result["completion_ids"].shape + result["importance_sampling_ratio"] = torch.full((B, T), 0.5, device=result["completion_ids"].device) + return result + + with ( + patch.object(trainer, "_generate_and_score_completions", side_effect=gen_with_is_ratio), + patch.object(trainer.liger_grpo_loss, "forward", wraps=trainer.liger_grpo_loss.forward) as mock_forward, + ): + trainer.train() + + # Verify vllm_is_ratio was passed in every call to liger_grpo_loss + assert mock_forward.call_count > 0, "liger_grpo_loss.forward was never called" + for call in mock_forward.call_args_list: + vllm_is_ratio = call.kwargs.get("vllm_is_ratio") + assert vllm_is_ratio is not None, ( + "vllm_is_ratio should not be None when importance_sampling_ratio is present" + ) + assert (vllm_is_ratio == 0.5).all(), ( + "vllm_is_ratio values should match the injected importance_sampling_ratio" + ) + + release_memory(trainer.model, trainer) + + def test_training_with_bias_correction_kl(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + beta=0.1, # set beta to non-zero value to test the case where the reference model is used + use_bias_correction_kl=True, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_name", + ["trl-internal-testing/tiny-Qwen3ForCausalLM", "trl-internal-testing/tiny-Gemma2ForCausalLM"], + # Gemma2 has the input word embeddings and lm_head tied, Qwen3 does not + ) + def test_training_with_cast_lm_head_to_fp32(self, model_name): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + cast_lm_head_to_fp32=True, + ) + trainer = GRPOTrainer( + model=model_name, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.model.lm_head.weight.dtype == torch.float32 + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_entropy_filter(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + top_entropy_quantile=0.2, + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_peft + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_and_peft(self): + """Test that training works with vLLM for generation.""" + model = AutoModelForCausalLM.from_pretrained( + "Qwen/Qwen2.5-0.5B-Instruct", dtype="float32" + ) # tiny model is too small for vLLM + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + ) + lora_config = LoraConfig( + target_modules="all-linear", + # test with non-default modules as it adds extra keys in state_dict that we need to handle + modules_to_save=["embed_tokens", "lm_head"], + ) + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + peft_config=lora_config, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n and "original_module" not in n: + # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_structured_outputs(self): + """Test that training works with vLLM for generation with structured outputs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + vllm_structured_outputs_regex=r"\n.*\n\n\n.*\n", + ) + trainer = GRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", # tiny model is too small for vLLM + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_importance_sampling_correction(self): + """Test that training works with vLLM for generation with structured outputs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + vllm_importance_sampling_correction=True, + vllm_importance_sampling_cap=3.0, + ) + trainer = GRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", # tiny model is too small for vLLM + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_additional_generation_kwargs(self): + """Test that training works with additional generation kwargs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + top_p=0.9, + top_k=10, + min_p=0.01, + repetition_penalty=1.1, + ) + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_with_additional_generation_kwargs(self): + """Test that training works with vLLM and additional generation kwargs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + top_p=0.9, + top_k=10, + min_p=0.01, + repetition_penalty=1.1, + ) + + trainer = GRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", # tiny model is too small for vLLM + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_normalize_then_sum_aggregation(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def reward_func2(completions, **kwargs): + """Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + multi_objective_aggregation="normalize_then_sum", + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func1, reward_func2], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize("scale_rewards", [False, "group", "batch", True, "none"]) + def test_training_scale_rewards(self, scale_rewards): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + scale_rewards=scale_rewards, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @patch("transformers.generation.utils.GenerationMixin.generate") + def test_training_with_mask_truncated_completions(self, mock_generate): + """Test that training works with mask_truncated_completions=True parameter.""" + + # We mock the generate method because the model's random weights make it extremely unlikely to produce a + # sequence containing the EOS token within the allowed max_completion_length. As a result, all tokens are + # masked in the loss, the model doesn't update, and the final check (which verifies the update) fails. + def fake_generate(input_ids, **kwargs): + # pad_token_id = 151643; eos_token_id = 151645 + completion_ids = torch.tensor( + [ + [1, 2, 3, 4, 5, 6, 7, 8], # this one is truncated + [9, 10, 11, 151645, 151643, 151643, 151643, 151643], # this one contains eos + [12, 13, 14, 15, 16, 17, 18, 151645], # particular case, eos is generated just within the limit + ], + device=input_ids.device, + ) + return torch.cat([input_ids, completion_ids], dim=1) + + mock_generate.side_effect = fake_generate + + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + mask_truncated_completions=True, # Enable masking of truncated completions + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_mask_truncated_completions_all_masked(self): + """ + Test that when all generated completions are truncated (i.e., none contain an EOS token), and + mask_truncated_completions=True, the model receives no effective learning signal and therefore does not update + its parameters. + + Here, we don't mock the generate method, be we rely on the fact that the model the probability of generating + the EOS token is extremely low, so all generated completions are truncated. + """ + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + mask_truncated_completions=True, # Enable masking of truncated completions + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert torch.equal(param, new_param), f"Parameter {n} has changed." + + def test_warning_raised_all_rewards_none(self, caplog): + """Test that a proper warning is raised when all rewards are None.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def always_none_reward_func(completions, **kwargs): + """Reward function that always returns None.""" + return [None] * len(completions) + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=always_none_reward_func, + args=training_args, + train_dataset=dataset, + ) + + with caplog.at_level("WARNING", logger="trl.trainer.grpo_trainer"): + trainer.train() + + expected_warning = "All reward functions returned None for the following kwargs:" + assert expected_warning in caplog.text + + def test_training_num_generations_larger_than_batch_size(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_generations=6, # the number of generations is larger than the batch size, but + gradient_accumulation_steps=2, # gradient accumulation should allow that + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_delta_clipping(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + delta=2.0, # set delta to a non-None value + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_dataloader_workers(self): + # Pytest/CI often starts background threads before tests run. With Python 3.12, using the default "fork" start + # method in a multi-threaded process emits a DeprecationWarning and may deadlock. + # + # We force "spawn" here to make multiprocessing safe under pytest when DataLoader workers are enabled. This is + # test-environment–specific and not required by the training logic itself. + # + # This means the test does not cover "fork". However, "spawn" is stricter (requires full picklability and clean + # state) and avoids fork-after-threads issues that pytest cannot reliably test anyway. Fork-specific behavior, + # if needed, should be tested in a clean process outside pytest. + torch.multiprocessing.set_start_method("spawn", force=True) + + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + dataloader_num_workers=2, # use multiple dataloader workers + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_generation_kwargs(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + # Pass gen kwargs + generation_kwargs={"do_sample": True, "top_k": 50, "num_beams": 2, "length_penalty": -0.1}, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_reward_func_accessing_trainer_state(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + trainer_state = kwargs.get("trainer_state") + assert trainer_state is not None + # transformers.TrainerState instance should have a `global_step` property. + assert hasattr(trainer_state, "global_step") + return [float(len(set(completion))) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + trainer.train() + + def test_training_reward_func_with_log_extra(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + log_extra = kwargs.get("log_extra") + assert log_extra is not None + log_extra("test_column", [completion[:5] for completion in completions]) + return [float(len(completion)) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + log_completions=True, + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + trainer.train() + assert "test_column" in trainer._logs["extra"] + + def test_training_reward_func_with_log_metric(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + log_metric = kwargs.get("log_metric") + assert log_metric is not None + log_metric("custom_accuracy", 0.75) + return [float(len(completion)) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + trainer.train() + # log_metric appends to _metrics, which gets averaged and merged into log_history + logged_keys = {k for entry in trainer.state.log_history for k in entry} + assert "custom_accuracy" in logged_keys + + def test_prepare_input_called_with_correct_data(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_completion_length=8, # reduce the completion length to reduce memory usage + gradient_accumulation_steps=3, # can be anything in this test + # steps_per_generation*per_device_train_batch_size=24 is divisible by num_generations=4 + steps_per_generation=4, + num_generations=4, + per_device_train_batch_size=6, # reduce the batch size to reduce memory usage + num_iterations=2, + shuffle_dataset=False, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + # steps_per_generation=4, per_device_train_batch_size=6 and num_generations=4, so we expect a + # generation batch of 24 samples (steps_per_generation * per_device_train_batch_size), containing 6 + # different prompts (steps_per_generation * per_device_train_batch_size // num_generations), each repeated + # 4 times (num_generations). + expected_first_generation_batch = ( + [{"prompt": "Beautiful is better than"}] * 4 + + [{"prompt": "Explicit is"}] * 4 + + [{"prompt": "Simple is better"}] * 4 + + [{"prompt": "Complex"}] * 4 + + [{"prompt": "Flat is better than"}] * 4 + + [{"prompt": "Sparse is better"}] * 4 + ) + expected_second_generation_batch = ( + [{"prompt": "Readability"}] * 4 + + [{"prompt": "Special cases aren't special"}] * 4 + + [{"prompt": "Although practicality beats"}] * 4 + + [{"prompt": "Errors should never"}] * 4 + + [{"prompt": "Unless explicitly"}] * 4 + + [{"prompt": "In the face of ambiguity, refuse"}] * 4 + ) + + with patch.object(GRPOTrainer, "training_step", wraps=trainer.training_step) as mock_prepare: + trainer.train() + # 3 epochs * 2 iterations * 2 generation batches to cover the dataset * 4 steps_per_generation + assert mock_prepare.call_count == 48 + for i in range(0, 8): # Generation batch repeated 8 times (steps_per_generation*num_iterations) + assert mock_prepare.call_args_list[i].args[1] == expected_first_generation_batch + for i in range(8, 16): + assert mock_prepare.call_args_list[i].args[1] == expected_second_generation_batch + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + "trl-internal-testing/tiny-LlavaNextForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + # "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", seems not to support bf16 properly + ], + ) + @require_vision + def test_training_vlm(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + params_to_skip = ( + "model.vision_tower.", + "model.multi_modal_projector.", + "model.visual.", + "model.image_newline", + ) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_vision + def test_training_vlm_with_pad_to_multiple_of(self): + # Models like Gemma3 use other forward keyword arguments like token_type_ids that also need to be padded when + # using pad_to_multiple_of, so we test that the trainer correctly pads all the necessary inputs in this case. + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + pad_to_multiple_of=7, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + def test_training_vlm_beta_non_zero(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + beta=0.1, # set beta to non-zero value to test the case where the reference model is used + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + params_to_skip = ("model.visual.",) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + @require_peft + def test_training_vlm_peft(self, model_id): + model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model=model, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(target_modules=["q_proj", "v_proj"]), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n: # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + def test_training_vlm_and_importance_sampling(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + steps_per_generation=2, # increase the steps per generation to trigger IS + report_to="none", + ) + trainer = GRPOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + params_to_skip = ("model.visual.",) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + pytest.param( + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + marks=pytest.mark.xfail( + (Version("5.2.0") < Version(transformers.__version__)) + and not is_liger_kernel_available(min_version="0.8.0"), + reason="Upstream issue tracked at https://github.com/linkedin/Liger-Kernel/issues/1117", + ), + ), + ], + ) + @require_vision + @require_liger_kernel + def test_training_vlm_and_liger(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + use_liger_kernel=True, # enable Liger kernel + report_to="none", + ) + trainer = GRPOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + params_to_skip = ("model.visual.",) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + ], + ) + @require_vision + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vlm_and_vllm(self, model_id) -> None: + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + vllm_mode="server", + ) + trainer = GRPOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + def test_training_vlm_multi_image(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-multi-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = GRPOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_sequence_importance_sampling(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_iterations=2, # the importance sampling weights won't be 0 in this case + importance_sampling_level="sequence", + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_chat_template_kwargs(self): + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + chat_template_kwargs={"enable_thinking": False}, + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.xfail( + condition=Version(transformers.__version__) < Version("5.0.0"), + reason="Tool parsing is not supported in transformers versions below 5.0.0", + strict=True, + ) + @require_jmespath + @pytest.mark.parametrize("tools", [[multiply_tool], [async_multiply_tool]]) + def test_training_with_tools(self, tools: list[Callable]): + # In this test, we define a simple tool that multiplies two integers. Regardless of the input prompt, + # the model will generate 3 completions, 2 of which will be valid tool calls. Among the 2 tool calls, one will + # succeed and the other will fail (because of a wrong argument name). + + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, + num_generations=3, + max_completion_length=128, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen3MoeForCausalLM", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + tools=tools, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + tool_name = tools[0].__name__ + + def fake_generate(input_ids, **kwargs): + if input_ids.shape[0] == 3: # first call + # fmt: off + if tool_name == "multiply_tool": + completion_ids = torch.tensor( + [ + # '\n{"name": "multiply_tool", "arguments": {"a": 3, "b": 4}}\n<|im_end|>' + [151657, 198, 4913, 606, 788, 330, 64648, 22785, 497, 330, 16370, 788, 5212, 64, 788, 220, 18, 11, 330, 65, 788, 220, 19, 11248, 151658, 151645], + # an invalid tool call with wrong argument name + # '\n{"name": "multiply_tool", "arguments": {"a": 3, "c": 4}}\n<|im_end|>' + [151657, 198, 4913, 606, 788, 330, 64648, 22785, 497, 330, 16370, 788, 5212, 64, 788, 220, 18, 11, 330, 66, 788, 220, 19, 11248, 151658, 151645], + # "I don't know any tool<|im_end|>" + [40, 1513, 944, 1414, 894, 5392, 151645, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643], + ], + device=input_ids.device, + ) + elif tool_name == "async_multiply_tool": + completion_ids = torch.tensor( + [ + # '\n{"name": "async_multiply_tool", "arguments": {"a": 3, "b": 4}}\n<|im_end|>' + [151657, 198, 4913, 606, 788, 330, 7692, 93054, 22785, 497, 330, 16370, 788, 5212, 64, 788, 220, 18, 11, 330, 65, 788, 220, 19, 11248, 151658, 151645], + # an invalid tool call with wrong argument name + # '\n{"name": "async_multiply_tool", "arguments": {"a": 3, "c": 4}}\n<|im_end|>' + [151657, 198, 4913, 606, 788, 330, 7692, 93054, 22785, 497, 330, 16370, 788, 5212, 64, 788, 220, 18, 11, 330, 66, 788, 220, 19, 11248, 151658, 151645], + # "I don't know any tool<|im_end|>" + [40, 1513, 944, 1414, 894, 5392, 151645, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643], + ], + device=input_ids.device, + ) + # fmt: on + else: # second call will only have two inputs in the batch, because two examples have a tool call. + completion_ids = torch.tensor( + [ + # 'Done!<|im_end|>' + [17453, 0, 151645], + # 'Done!<|im_end|>' + [17453, 0, 151645], + ], + device=input_ids.device, + ) + return torch.cat([input_ids, completion_ids], dim=-1) + + with patch.object(trainer.model, "generate", side_effect=fake_generate): + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["tools/call_frequency"] is not None + assert trainer.state.log_history[-1]["tools/call_frequency"] == pytest.approx(2 / 3) + assert trainer.state.log_history[-1]["tools/failure_frequency"] is not None + assert trainer.state.log_history[-1]["tools/failure_frequency"] == pytest.approx(1 / 2) + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.xfail( + condition=Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + strict=True, + ) + @require_jmespath + @require_vision + def test_training_with_tools_multimodal_response(self): + # Test that tools returning images (multimodal responses) work correctly with a VLM. + # The tool returns a list of content blocks including an image. + from PIL import Image as PILImage + + def screenshot_tool() -> list: + """ + Takes a screenshot and returns it. + + Returns: + A list of content blocks with the screenshot image. + """ + img = PILImage.new("RGB", (64, 64), color="red") + return [{"type": "image", "image": img}, {"type": "text", "text": "Here is the screenshot"}] + + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=512, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + tools=[screenshot_tool], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + def fake_generate(input_ids, **kwargs): + if input_ids.shape[0] == 3: # first call + # fmt: off + completion_ids = torch.tensor( + [ + # '\n\n\n<|im_end|>' + [248058, 198, 27, 1628, 13744, 30091, 22076, 29, 198, 510, 1628, 29, 198, 248059, 248046], + # "I don't know any tool<|im_end|>" + padding + [40, 1459, 914, 1366, 866, 5224, 248046, 248044, 248044, 248044, 248044, 248044, 248044, 248044, 248044], + # '\n\n\n<|im_end|>' + [248058, 198, 27, 1628, 13744, 30091, 22076, 29, 198, 510, 1628, 29, 198, 248059, 248046], + ], + device=input_ids.device, + ) + # fmt: on + else: # second call: 2 tool calls succeeded + completion_ids = torch.tensor( + [ + # 'Done!<|im_end|>' + [16936, 0, 248046], + # 'Done!<|im_end|>' + [16936, 0, 248046], + ], + device=input_ids.device, + ) + return torch.cat([input_ids, completion_ids], dim=-1) + + with patch.object(trainer.model, "generate", side_effect=fake_generate): + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["tools/call_frequency"] == pytest.approx(2 / 3) + assert trainer.state.log_history[-1]["tools/failure_frequency"] == pytest.approx(0.0) + + # Check that the params have changed (skip vision parts, see test_training_vlm) + params_to_skip = ("model.visual.",) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.xfail( + condition=Version(transformers.__version__) < Version("5.2.0"), + reason="Environment factory support is not available in transformers versions below 5.2.0", + strict=True, + ) + @require_jmespath + @patch.dict(os.environ, {"TRL_EXPERIMENTAL_SILENCE": "1"}) + def test_training_with_environment_factory(self): + # In this test, we define a simple tool that increments an internal counter. Regardless of the input prompt, + # the model will generate 3 completions, 2 of which will be valid tool calls. Among the 2 tool calls, one will + # succeed and the other will fail (because of a wrong tool name). + + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + class DummyEnvironment: + def reset(self, **kwargs): + self._counter = 0 + + def increment(self, step: int) -> int: + """ + Increment the internal counter. + + Args: + step: Value to add to the counter. + + Returns: + The updated counter value. + """ + self._counter += step + return self._counter + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, + num_generations=3, + report_to="none", + ) + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen3MoeForCausalLM", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + environment_factory=DummyEnvironment, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + def fake_generate(input_ids, **kwargs): + if input_ids.shape[0] == 3: # first call + # fmt: off + completion_ids = torch.tensor( + [ + # '\n{"name": "increment", "arguments": {"step": 1}}\n<|im_end|>' + [151657, 198, 4913, 606, 788, 330, 35744, 497, 330, 16370, 788, 5212, 9520, 788, 220, 16, 11248, 151658, 151645, 151643], + # an invalid tool call with wrong tool name + # '\n{"name": "decrement", "arguments": {"step": 2}}\n<|im_end|>' + [151657, 198, 4913, 606, 788, 330, 450, 13477, 497, 330, 16370, 788, 5212, 9520, 788, 220, 17, 11248, 151658, 151645], + # "I won't increment<|im_end|>" + [40, 2765, 944, 16252, 151645, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643, 151643], + ], + device=input_ids.device, + ) + # fmt: on + else: # second call will only have two inputs in the batch, because two examples have a tool call. + completion_ids = torch.tensor( + [ + # 'Done!<|im_end|>' + [17453, 0, 151645], + # 'Done!<|im_end|>' + [17453, 0, 151645], + ], + device=input_ids.device, + ) + return torch.cat([input_ids, completion_ids], dim=-1) + + with patch.object(trainer.model, "generate", side_effect=fake_generate): + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["tools/call_frequency"] is not None + assert trainer.state.log_history[-1]["tools/call_frequency"] == pytest.approx(2 / 3) + assert trainer.state.log_history[-1]["tools/failure_frequency"] is not None + assert trainer.state.log_history[-1]["tools/failure_frequency"] == pytest.approx(1 / 2) + + # Check the states of the environment + assert trainer.environments[0]._counter == 1 # should have been incremented once + assert trainer.environments[1]._counter == 0 # shouldn't have been incremented because the tool call failed + assert trainer.environments[2]._counter == 0 # shouldn't have been incremented because no tool call was made + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.xfail( + condition=Version(transformers.__version__) < Version("5.0.0"), + reason="Tool parsing is not supported in transformers versions below 5.0.0", + strict=True, + ) + @require_jmespath + def test_training_with_malformed_tool_calls(self): + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, + num_generations=3, + max_completion_length=128, + report_to="none", + ) + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen3MoeForCausalLM", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + tools=[multiply_tool], + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + def fake_generate(input_ids, **kwargs): + # If input_ids.shape[0] < 3, it means that it's a second call, which should not happen here + assert input_ids.shape[0] == 3 + # fmt: off + completion_ids = torch.tensor( + [ + # '\n{"arguments": {"a": 3, "b": 4}}\n<|im_end|>' + [151657, 198, 4913, 16370, 788, 5212, 64, 788, 220, 18, 11, 330, 65, 788, 220, 19, 11248, 151658, 151645, 151643, 151643, 151643, 151643, 151643], + # '\n{"arguments": {"a": 3, "b": 4}}\n<|im_end|>' + [27, 14172, 6659, 397, 4913, 16370, 788, 5212, 64, 788, 220, 18, 11, 330, 65, 788, 220, 19, 11248, 522, 14172, 6659, 29, 151645], + # '\n{"arguments": {a: 3, b: 4}}\n<|im_end|>' + [151657, 198, 4913, 16370, 788, 314, 64, 25, 220, 18, 11, 293, 25, 220, 19, 11248, 151658, 151645, 151643, 151643, 151643, 151643, 151643, 151643], + ], + device=input_ids.device, + ) + # fmt: on + return torch.cat([input_ids, completion_ids], dim=-1) + + with patch.object(trainer.model, "generate", side_effect=fake_generate): + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_mismatched_reward_processing_classes_length(self): + """Test that mismatched length between reward_funcs and reward_processing_classes raises error.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Use two reward models + reward_models = [ + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + "trl-internal-testing/tiny-Qwen3ForSequenceClassification", + ] + + # Create a single processing class (tokenizer) + single_processing_class = AutoTokenizer.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + ) + + training_args = GRPOConfig(output_dir=self.tmp_dir, report_to="none") + + with pytest.raises(ValueError, match="must match"): + GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_models, + reward_processing_classes=single_processing_class, # only one, but need two + args=training_args, + train_dataset=dataset, + ) + + def test_correct_reward_processing_classes_list(self): + """Test that correct list of reward_processing_classes works properly.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Use two reward models + reward_models = [ + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + "trl-internal-testing/tiny-Qwen3ForSequenceClassification", + ] + + # Create processing classes + processing_class1 = AutoTokenizer.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + ) + processing_class2 = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen3ForSequenceClassification") + + training_args = GRPOConfig(output_dir=self.tmp_dir, report_to="none") + + # Correct list length should work + correct_processing_classes = [processing_class1, processing_class2] + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_models, + reward_processing_classes=correct_processing_classes, + args=training_args, + train_dataset=dataset, + ) + + assert len(trainer.reward_processing_classes) == len(reward_models) + + def test_single_reward_model_with_single_processing_class(self): + """Test that single reward model with single processing class works.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Use single reward model + reward_model = "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + + # Create a single processing class (tokenizer) + single_processing_class = AutoTokenizer.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + ) + + training_args = GRPOConfig(output_dir=self.tmp_dir, report_to="none") + + trainer = GRPOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_model, + reward_processing_classes=single_processing_class, # single object for single reward model + args=training_args, + train_dataset=dataset, + ) + + assert len(trainer.reward_processing_classes) == 1 + assert trainer.reward_processing_classes[0] == single_processing_class + + +@pytest.mark.slow +@require_torch_accelerator +class TestGRPOTrainerSlow(TrlTestCase): + def setup_method(self): + self.train_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + self.eval_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="test") + self.max_length = 128 + + def teardown_method(self): + gc.collect() + backend_empty_cache(torch_device) + gc.collect() + + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_liger_kernel + def test_training_with_liger_grpo_kernel(self, model_name): + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, + num_generations=3, + use_liger_kernel=True, + max_completion_length=self.max_length, + report_to="none", + logging_strategy="no", + ) + + model = AutoModelForCausalLM.from_pretrained(model_name, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_name) + tokenizer.pad_token = tokenizer.eos_token if tokenizer.pad_token is None else tokenizer.pad_token + + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + processing_class=tokenizer, + ) + from liger_kernel.chunked_loss import LigerFusedLinearGRPOLoss + + assert isinstance(trainer.liger_grpo_loss, LigerFusedLinearGRPOLoss) + + previous_trainable_params = {n: param.clone() for n, param in model.named_parameters()} + + trainer.train() + + for n, param in previous_trainable_params.items(): + new_param = model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + release_memory(model, trainer) + + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_liger_kernel + @require_peft + def test_training_with_liger_grpo_kernel_and_peft(self, model_name): + from peft import LoraConfig, TaskType + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, + num_generations=3, + use_liger_kernel=True, + max_completion_length=self.max_length, + report_to="none", + logging_strategy="no", + ) + + model = AutoModelForCausalLM.from_pretrained(model_name, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_name) + tokenizer.pad_token = tokenizer.eos_token if tokenizer.pad_token is None else tokenizer.pad_token + + # Configure PEFT with LoRA + peft_config = LoraConfig( + task_type=TaskType.CAUSAL_LM, + inference_mode=False, + r=8, + lora_alpha=32, + lora_dropout=0.1, + target_modules=["q_proj", "v_proj"], + ) + + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + processing_class=tokenizer, + peft_config=peft_config, + ) + from liger_kernel.chunked_loss import LigerFusedLinearGRPOLoss + + assert isinstance(trainer.liger_grpo_loss, LigerFusedLinearGRPOLoss) + + # Verify PEFT adapter is properly initialized + from peft import PeftModel + + assert isinstance(trainer.model, PeftModel), "Model should be wrapped with PEFT" + + # Store adapter weights before training + previous_trainable_params = { + n: param.clone() for n, param in trainer.model.named_parameters() if param.requires_grad + } + assert len(previous_trainable_params) > 0, "No trainable parameters found in PEFT model" + + trainer.train() + + # Verify adapter weights have changed after training + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + release_memory(model, trainer) + + @require_liger_kernel + def test_liger_grpo_kernel_importance_sampling(self): + model_name = "trl-internal-testing/tiny-LlamaForCausalLM-3.2" + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, + num_generations=3, + use_liger_kernel=True, + max_completion_length=self.max_length, + importance_sampling_level="sequence", + report_to="none", + logging_strategy="no", + ) + + model = AutoModelForCausalLM.from_pretrained(model_name, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_name) + tokenizer.pad_token = tokenizer.eos_token if tokenizer.pad_token is None else tokenizer.pad_token + + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + processing_class=tokenizer, + ) + from liger_kernel.chunked_loss import LigerFusedLinearGRPOLoss + + assert isinstance(trainer.liger_grpo_loss, LigerFusedLinearGRPOLoss) + + previous_trainable_params = {n: param.clone() for n, param in model.named_parameters()} + + trainer.train() + + for n, param in previous_trainable_params.items(): + new_param = model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + release_memory(model, trainer) + + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + def test_training_with_transformers_paged(self, model_name): + """Test that training works with transformers paged implementation (requires GPU).""" + if Version(transformers.__version__) < Version("4.57.0"): + pytest.xfail("Bug in transformers solved in GH#40692, released in 4.57.0.") + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + use_transformers_paged=True, # Enable transformers paged implementation + report_to="none", + logging_strategy="no", + ) + + model = AutoModelForCausalLM.from_pretrained(model_name, dtype="float32") + + trainer = GRPOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=self.train_dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + release_memory(model, trainer) + + @pytest.mark.parametrize( + "model_name", + [ + "HuggingFaceTB/SmolVLM-Instruct", # Only test the smaller model to avoid OOM + ], + ) + @require_kernels + @require_ampere_or_newer # Flash attention 2 requires Ampere or newer GPUs + @require_bitsandbytes + @require_peft + def test_vlm_training(self, model_name): + """ + Test VLM training with aggressive memory optimization. + + This test uses multiple memory reduction techniques: + - 4-bit quantization with double quantization + - LoRA with very low rank (r=4) + - Minimal batch size (1) with gradient accumulation + - Small images (64x64 instead of 224x224) + - Short sequences (max_completion_length=8) + - Only 4 training samples + - Only 1 training step + - Gradient checkpointing and bfloat16 + """ + + # Create processor once outside the data generator + processor = AutoProcessor.from_pretrained(model_name, use_fast=True, padding_side="left") + conversation = [ + { + "role": "user", + "content": [ + {"type": "image"}, + {"type": "text", "text": "What is in the image?"}, + ], + }, + ] + prompt = processor.apply_chat_template(conversation, add_generation_prompt=True) + + def data_gen(num_samples): + for _ in range(num_samples): + yield { + "prompt": prompt, + "image": np.random.uniform(low=0.0, high=255.0, size=(64, 64, 3)).astype( + np.uint8 + ), # Much smaller images + } + + dataset = Dataset.from_generator( + data_gen, gen_kwargs={"num_samples": 4}, features=Features(image=Image(), prompt=Value(dtype="string")) + ) + # reduce memory requirements as much as possible + quantization_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_compute_dtype="bfloat16", + bnb_4bit_quant_type="nf4", + bnb_4bit_use_double_quant=True, + bnb_4bit_quant_storage="bfloat16", + ) + model = AutoModelForImageTextToText.from_pretrained( + model_name, + attn_implementation="kernels-community/flash-attn2", + dtype="float32", + device_map=get_kbit_device_map(), + quantization_config=quantization_config, + ) + + def reward_func(prompts, completions, **kwargs): + # simple nonsensical reward + return [-((len(c) - 25) ** 2) + 100 for c in completions] + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=1, # Minimal batch size + gradient_accumulation_steps=2, # Maintain effective batch size + num_generations=2, + max_completion_length=8, # Much shorter completions + bf16=True, # Use bfloat16 precision + max_steps=1, # Only do 1 training step to save time and memory + report_to="none", + logging_strategy="no", + ) + lora_config = LoraConfig( + task_type="CAUSAL_LM", + r=4, # Much lower rank for minimal memory + lora_alpha=8, # Reduced alpha proportionally + lora_dropout=0.1, + target_modules=["q_proj", "v_proj"], # Minimal target modules + # For VLM models, we typically want to freeze the vision encoder + # and only adapt the language model parameters + modules_to_save=None, + ) + + try: + trainer = GRPOTrainer( + model=model, + processing_class=processor, + reward_funcs=[reward_func], + args=training_args, + train_dataset=dataset, + peft_config=lora_config, + ) + + assert isinstance(trainer.model, PeftModel) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that LoRA parameters have changed + # For VLM models, we're more permissive about which parameters can change + lora_params_changed = False + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if "lora" in n.lower(): # LoRA parameters should change + if not torch.equal(param, new_param): + lora_params_changed = True + + # At least some LoRA parameters should have changed during training + assert lora_params_changed, "No LoRA parameters were updated during training." + + except torch.OutOfMemoryError as e: + pytest.skip(f"Skipping VLM training test due to insufficient GPU memory: {e}") + except Exception as e: + # Check for other memory-related errors + if any(keyword in str(e).lower() for keyword in ["memory", "cuda", "out of memory", "insufficient"]): + pytest.skip(f"Skipping VLM training test due to hardware constraints: {e}") + else: + raise + + release_memory(model, trainer) + + @require_vllm + @require_bitsandbytes + @require_peft + def test_vlm_processor_vllm_colocate_mode(self): + """ + Test that VLM processors work with vLLM in colocate mode. + + This test uses multiple memory optimization techniques to ensure it runs on limited hardware: + - LoRA (Low-Rank Adaptation) with minimal rank (r=4) + - 4-bit quantization with BitsAndBytesConfig + - Gradient checkpointing + - bfloat16 precision + - Minimal batch sizes and sequence lengths + - Very low GPU memory utilization (5%) + """ + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + config = GRPOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=1, # Minimal batch size + gradient_accumulation_steps=2, # Make effective batch size 2, divisible by num_generations + num_generations=2, + max_completion_length=4, # Very short completions to reduce memory + use_vllm=True, # Enable vLLM + vllm_mode="colocate", # Use colocate mode to avoid server dependency + vllm_gpu_memory_utilization=0.05, # Use minimal GPU memory (5%) + bf16=True, # Use bfloat16 to reduce memory + report_to="none", + logging_strategy="no", + ) + + # Create a VLM processor + processor = AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM-Instruct", use_fast=True, padding_side="left") + + # Verify processor has both required attributes for VLM detection + assert hasattr(processor, "tokenizer") + assert hasattr(processor, "image_processor") + + def dummy_reward_func(completions, **kwargs): + return [1.0] * len(completions) + + # Use LoRA configuration for memory efficiency + lora_config = LoraConfig( + r=4, # Very low rank for minimal memory + lora_alpha=8, + target_modules=["q_proj", "v_proj"], # Minimal target modules + lora_dropout=0.1, + bias="none", + task_type="CAUSAL_LM", + ) + + # Use 4-bit quantization for further memory reduction + quantization_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_compute_dtype=torch.bfloat16, + bnb_4bit_quant_type="nf4", + bnb_4bit_use_double_quant=True, + ) + + original_env = {} + required_env_vars = { + "RANK": "0", + "LOCAL_RANK": "0", + "WORLD_SIZE": "1", + "LOCAL_WORLD_SIZE": "1", + "MASTER_ADDR": "localhost", + "MASTER_PORT": "12355", + } + + for key, value in required_env_vars.items(): + original_env[key] = os.environ.get(key) + os.environ[key] = value + + try: + # Test VLM processor with vLLM colocate mode + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + try: + # Load model with quantization for memory efficiency + model = AutoModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + quantization_config=quantization_config, + dtype=torch.bfloat16, + ) + + trainer = GRPOTrainer( + model=model, + reward_funcs=dummy_reward_func, + args=config, + train_dataset=dataset, + processing_class=processor, # VLM processor + peft_config=lora_config, # Use LoRA for memory efficiency + ) + + # Should detect VLM processor correctly and allow vLLM + assert trainer.use_vllm, "vLLM should be enabled for VLM processors in colocate mode" + assert trainer.vllm_mode == "colocate", "Should use colocate mode" + + # Check if signature columns were set properly + if trainer._signature_columns is not None: + # Should include 'image' in signature columns for VLM processors + assert "image" in trainer._signature_columns, ( + "Should include 'image' in signature columns for VLM" + ) + + # Should not emit any warnings about VLM incompatibility + incompatibility_warnings = [ + str(w_item.message) + for w_item in w + if "does not support VLMs" in str(w_item.message) + or "not compatible" in str(w_item.message).lower() + ] + assert len(incompatibility_warnings) == 0, ( + f"Should not emit VLM incompatibility warnings, but got: {incompatibility_warnings}" + ) + + # Test passes if we get this far without exceptions + + except Exception as e: + # If vLLM fails to initialize due to hardware constraints or other issues, that's expected + if any( + keyword in str(e).lower() + for keyword in [ + "outofmemoryerror", + "cuda", + "memory", + "insufficient", + "no such device", + "free memory", + "gpu memory utilization", + "decrease gpu memory", + ] + ): + pytest.skip(f"Skipping vLLM colocate test due to hardware constraints: {e}") + elif "KeyError" in str(e) and "RANK" in str(e): + pytest.skip(f"Skipping vLLM colocate test due to environment setup issues: {e}") + elif "ValueError" in str(e) and "memory" in str(e).lower(): + pytest.skip(f"Skipping vLLM colocate test due to memory constraints: {e}") + else: + raise + finally: + # Restore original environment variables + for key, original_value in original_env.items(): + if original_value is None: + os.environ.pop(key, None) + else: + os.environ[key] = original_value + + release_memory(model, trainer) + + @require_vllm + def test_training_vllm(self): + """Test that training works with vLLM for generation.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = GRPOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + logging_strategy="no", + use_vllm=True, + ) + + try: + trainer = GRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", # tiny models are too small for vLLM + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + except Exception as e: + # If vLLM fails to initialize due to hardware constraints or other issues, that's expected + if any( + keyword in str(e).lower() + for keyword in [ + "outofmemoryerror", + "cuda", + "memory", + "insufficient", + "no such device", + "free memory", + "gpu memory utilization", + "decrease gpu memory", + ] + ): + pytest.skip(f"Skipping vLLM training test due to hardware constraints: {e}") + elif "KeyError" in str(e) and "RANK" in str(e): + pytest.skip(f"Skipping vLLM training test due to environment setup issues: {e}") + elif "ValueError" in str(e) and "memory" in str(e).lower(): + pytest.skip(f"Skipping vLLM training test due to memory constraints: {e}") + else: + raise + + release_memory(trainer.model, trainer) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_model_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_model_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..7e3fde991ddcf4469b3efccb78bb412e1da1e8a6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_model_utils.py @@ -0,0 +1,34 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from transformers import AutoModelForCausalLM + +from trl.models.utils import disable_gradient_checkpointing + + +class TestDisableGradientCheckpointing: + def test_when_disabled(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + assert model.is_gradient_checkpointing is False + with disable_gradient_checkpointing(model): + assert model.is_gradient_checkpointing is False + assert model.is_gradient_checkpointing is False + + def test_when_enabled(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + model.gradient_checkpointing_enable() + assert model.is_gradient_checkpointing is True + with disable_gradient_checkpointing(model): + assert model.is_gradient_checkpointing is False + assert model.is_gradient_checkpointing is True diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_reward_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_reward_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..c2503f32926a90c9815460be2b0a81a58f62e5ea --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_reward_trainer.py @@ -0,0 +1,959 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import pathlib + +import pytest +import torch +from datasets import load_dataset +from transformers import AutoModelForSequenceClassification, AutoTokenizer +from transformers.utils import is_peft_available + +from trl import RewardConfig, RewardTrainer +from trl.trainer.reward_trainer import DataCollatorForPreference + +from .testing_utils import TrlTestCase, require_peft + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +class TestDataCollatorForPreference(TrlTestCase): + def test_basic_padding(self): + """Test basic padding functionality without completion masks.""" + collator = DataCollatorForPreference(pad_token_id=0) + examples = [ + {"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5]}, + {"chosen_ids": [6, 7], "rejected_ids": [8]}, + ] + + result = collator(examples) + + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [6, 7, 0], [4, 5, 0], [8, 0, 0]])) + torch.testing.assert_close( + result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0], [1, 1, 0], [1, 0, 0]]) + ) + + def test_pad_to_multiple_of(self): + """Test padding to multiple of specified value.""" + collator = DataCollatorForPreference(pad_token_id=0, pad_to_multiple_of=4) + examples = [ + {"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5]}, + {"chosen_ids": [6, 7], "rejected_ids": [8]}, + ] + + result = collator(examples) + + torch.testing.assert_close( + result["input_ids"], torch.tensor([[1, 2, 3, 0], [6, 7, 0, 0], [4, 5, 0, 0], [8, 0, 0, 0]]) + ) + torch.testing.assert_close( + result["attention_mask"], torch.tensor([[1, 1, 1, 0], [1, 1, 0, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) + ) + + def test_single_example(self): + """Test collator with a single example.""" + collator = DataCollatorForPreference(pad_token_id=0) + examples = [{"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5]}] + + result = collator(examples) + + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + + def test_different_pad_token_id(self): + """Test with different pad token ID.""" + collator = DataCollatorForPreference(pad_token_id=999) + examples = [ + {"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5]}, + {"chosen_ids": [6, 7], "rejected_ids": [8]}, + ] + + result = collator(examples) + + torch.testing.assert_close( + result["input_ids"], torch.tensor([[1, 2, 3], [6, 7, 999], [4, 5, 999], [8, 999, 999]]) + ) + torch.testing.assert_close( + result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0], [1, 1, 0], [1, 0, 0]]) + ) + + def test_collate_with_margin(self): + collator = DataCollatorForPreference(pad_token_id=0) + examples = [ + {"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5], "margin": 0.1}, + {"chosen_ids": [6, 7], "rejected_ids": [8], "margin": 0.2}, + ] + + result = collator(examples) + + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [6, 7, 0], [4, 5, 0], [8, 0, 0]])) + torch.testing.assert_close( + result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0], [1, 1, 0], [1, 0, 0]]) + ) + torch.testing.assert_close(result["margin"], torch.tensor([0.1, 0.2])) + + +class TestRewardTrainer(TrlTestCase): + def test_raises_error_when_model_num_labels_not_one(self): + """Test that RewardTrainer raises ValueError when model doesn't have num_labels=1.""" + model = AutoModelForSequenceClassification.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + dtype="float32", + # num_labels=2, # Defaults to 2 num_labels for causal models + ) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + with pytest.raises(ValueError, match=r"reward models require `num_labels=1`"): + RewardTrainer(model=model, args=training_args, train_dataset=dataset) + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "trl-internal-testing/tiny-Qwen3MoeForCausalLM", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + ], + ) + def test_train(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer(model=model_id, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize( + "config_name", + [ + "standard_preference", + "conversational_preference", + "standard_implicit_prompt_preference", + "conversational_implicit_prompt_preference", + ], + ) + def test_train_dataset_types(self, config_name): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", config_name, split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_model(self): + # Instantiate the model + model = AutoModelForSequenceClassification.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + num_labels=1, # required for reward models + dtype="float32", + ) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_from_sequence_classification_model(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_model_dtype(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig( + output_dir=self.tmp_dir, + model_init_kwargs={"dtype": torch.float16}, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + # For some reasonn model.layers.0.input_layernorm.weight doesn't change in GitHub Actions but does + # locally. We ignore this parameter for now + if "layernorm" in n: + continue + new_param = trainer.model.get_parameter(n) + # Check the torch dtype + assert new_param.dtype == torch.float16 + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_dense_with_peft_config(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForSequenceClassification.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + + trainer = RewardTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_moe_with_peft_config(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen3MoeForCausalLM" + model = AutoModelForSequenceClassification.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + + trainer = RewardTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(target_modules=["gate_proj", "up_proj", "down_proj", "score"]), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_peft_model(self): + # Get the base model + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForSequenceClassification.from_pretrained( + model_id, + num_labels=1, # required for reward models + dtype="float32", + ) + + # Get the base model parameter names + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Turn the model into a peft model + lora_config = LoraConfig() + model = get_peft_model(model, lora_config) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # In practice, this test is the same as `test_train_dense_with_peft_config`, since gradient checkpointing is + # enabled by default in `RewardTrainer`. We keep it as a regression guard: if the default ever changes, we still + # explicitly test PEFT + gradient checkpointing, which has caused issues in the past. + @require_peft + def test_train_with_peft_config_and_gradient_checkpointing(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForSequenceClassification.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, gradient_checkpointing=True, report_to="none") + + trainer = RewardTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize("use_reentrant", [True, False]) + @require_peft + def test_train_with_peft_config_and_gradient_checkpointing_reentrant(self, use_reentrant): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + model = AutoModelForSequenceClassification.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig( + output_dir=self.tmp_dir, + gradient_checkpointing=True, + gradient_checkpointing_kwargs={"use_reentrant": use_reentrant}, + report_to="none", + ) + + trainer = RewardTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize( + "chosen_column,rejected_column,expect_deprecation_warning", + [ + ("chosen_ids", "rejected_ids", False), + ("chosen_input_ids", "rejected_input_ids", True), + ], + ) + def test_train_with_pretokenized_data(self, chosen_column, rejected_column, expect_deprecation_warning): + # Get the dataset + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + tokenizer = AutoTokenizer.from_pretrained(model_id) + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + def tokenize_example(example): + return { + chosen_column: tokenizer(example["chosen"]).input_ids, + rejected_column: tokenizer(example["rejected"]).input_ids, + } + + # Apply tokenization + tokenized_dataset = dataset.map(tokenize_example, remove_columns=["chosen", "rejected"]) + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + if expect_deprecation_warning: + with pytest.warns(FutureWarning, match=r"will not be supported in v1"): + trainer = RewardTrainer(model=model_id, args=training_args, train_dataset=tokenized_dataset) + else: + trainer = RewardTrainer(model=model_id, args=training_args, train_dataset=tokenized_dataset) + + assert "chosen_ids" in trainer.train_dataset.column_names + assert "rejected_ids" in trainer.train_dataset.column_names + assert "chosen_input_ids" not in trainer.train_dataset.column_names + assert "rejected_input_ids" not in trainer.train_dataset.column_names + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_iterable_dataset(self): + # Get the dataset + dataset = load_dataset( + "trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train", streaming=True + ) + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, max_steps=3, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_chat_template_kwargs(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + # The following template is a simplified version of the Qwen chat template, where an additional argument + # `role_capital` is used to control the capitalization of roles. + tokenizer.chat_template = '{%- if messages[0]["role"] == "system" -%} {{ "<|im_start|>" + ("SYSTEM" if role_capital else "system") + "\\n" + messages[0]["content"] + "<|im_end|>\\n" }}{%- else -%} {{ "<|im_start|>" + ("SYSTEM" if role_capital else "system") + "\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n" }}{%- endif -%}{%- for message in messages -%} {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) -%} {{ "<|im_start|>" + (message.role.upper() if role_capital else message.role) + "\\n" + message.content + "<|im_end|>\\n" }} {%- elif message.role == "assistant" -%} {{ "<|im_start|>" + ("ASSISTANT" if role_capital else "assistant") }} {%- if message.content -%} {{ "\\n" + message.content }} {%- endif -%} {{ "<|im_end|>\\n" }} {%- elif message.role == "tool" -%} {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") -%} {{ "<|im_start|>" + ("USER" if role_capital else "user") }} {%- endif -%} {{ "\\n\\n" + message.content + "\\n" }} {%- if loop.last or (messages[loop.index0 + 1].role != "tool") -%} {{ "<|im_end|>\\n" }} {%- endif -%} {%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%} {{ "<|im_start|>" + ("ASSISTANT" if role_capital else "assistant") + "\\n" }}{%- endif -%}' + + dataset = dataset.add_column( + "chat_template_kwargs", [{"role_capital": bool(i % 2)} for i in range(len(dataset))] + ) + assert "chat_template_kwargs" in dataset.features + + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + processing_class=tokenizer, + ) + + # Assert trainer uses the same chat template as tokenizer + assert trainer.processing_class.chat_template == tokenizer.chat_template + + # Assert chat_template is applied + for i in range(2): + role = "SYSTEM" if i else "system" + system_prompt = ( + f"<|im_start|>{role}\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>" + ) + system_prompt_ids = trainer.processing_class(system_prompt)["input_ids"] + assert trainer.train_dataset[i]["chosen_ids"][: len(system_prompt_ids)] == system_prompt_ids + assert trainer.train_dataset[i]["rejected_ids"][: len(system_prompt_ids)] == system_prompt_ids + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_set_chat_template_from_model(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, chat_template_path="Qwen/Qwen3-4B", report_to="none") + # trl-internal-testing/tiny-GPTNeoXForCausalLM doesn't have a chat template set by default + trainer = RewardTrainer( + model="trl-internal-testing/tiny-GPTNeoXForCausalLM", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # RewardTrainer uses a mean-free loss that cancels uniform shifts in output scores. Since GPT-NeoX models + # include a final LayerNorm, its bias consistently receives zero gradient and remains unchanged, so we skip + # this parameter. + if n == "gpt_neox.final_layer_norm.bias": + continue + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_set_chat_template_from_path(self, lazy_shared_datadir): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig( + output_dir=self.tmp_dir, + chat_template_path=str(lazy_shared_datadir / "template.jinja"), + report_to="none", + ) + # trl-internal-testing/tiny-GPTNeoXForCausalLM doesn't have a chat template set by default + trainer = RewardTrainer( + model="trl-internal-testing/tiny-GPTNeoXForCausalLM", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # RewardTrainer uses a mean-free loss that cancels uniform shifts in output scores. Since GPT-NeoX models + # include a final LayerNorm, its bias consistently receives zero gradient and remains unchanged, so we skip + # this parameter. + if n == "gpt_neox.final_layer_norm.bias": + continue + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # Check that the template saved in the output directory is the same as the one used for training + template_path = pathlib.Path(self.tmp_dir) / "checkpoint-9" / "chat_template.jinja" + assert template_path.exists(), f"Chat template not found at {template_path}" + + with open(template_path) as f: + template_content = f.read() + with open(training_args.chat_template_path) as f: + original_template_content = f.read() + assert template_content == original_template_content, "Chat template content does not match the original" + + def test_train_toolcall_data(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/toolcall", "preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_toolcall_data_as_json(self): + # Tabular backends (Arrow/Parquet) can insert `None` for missing keys in nested structures. + # If `tools` is stored as a list of dicts and examples use different dict schemas, nulls may + # be introduced and break tool processing. This test ensures we also support `tools` provided + # as a list of dicts. + dataset = load_dataset("trl-internal-testing/toolcall", "preference", split="train") + + def convert_to_json(example): + return {"tools": json.loads(example["tools"])} + + dataset = dataset.map(convert_to_json) + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_eval(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, eval_strategy="steps", eval_steps=3, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Train the model + trainer.train() + + # Check that the eval loss is not None + assert trainer.state.log_history[0]["eval_loss"] is not None + + def test_train_with_multiple_eval_dataset(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, eval_strategy="steps", eval_steps=3, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset={"data1": dataset["test"], "data2": dataset["test"]}, + ) + # Train the model + trainer.train() + + # Check that the eval losses are not None + assert trainer.state.log_history[-3]["eval_data1_loss"] is not None + assert trainer.state.log_history[-2]["eval_data2_loss"] is not None + + def test_train_with_compute_metrics(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference") + + def dummy_compute_metrics(eval_pred): + return {"my_metric": 0.123} + + # Initialize the trainer + training_args = RewardConfig( + output_dir=self.tmp_dir, + eval_strategy="steps", + eval_steps=3, + report_to="none", + ) + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + # Train the model + trainer.train() + + # Check that the custom metric is logged + assert trainer.state.log_history[-2]["eval_my_metric"] == 0.123 + + # In practice, this test is the same as `test_train`, since gradient checkpointing is enabled by default in + # `RewardTrainer`. We keep it as a regression guard: if the default ever changes, we still explicitly test gradient + # checkpointing, which has caused issues in the past. + def test_train_with_gradient_checkpointing(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, gradient_checkpointing=True, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize("use_reentrant", [True, False]) + def test_train_with_gradient_checkpointing_reentrant(self, use_reentrant): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig( + output_dir=self.tmp_dir, + gradient_checkpointing=True, + gradient_checkpointing_kwargs={"use_reentrant": use_reentrant}, + report_to="none", + ) + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_tag_added(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + train_dataset=dataset, + ) + + for tag in ["reward-trainer", "trl"]: + assert tag in trainer.model.model_tags + + @require_peft + def test_tag_added_peft(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + for tag in ["reward-trainer", "trl"]: + assert tag in trainer.model.model_tags + + def test_train_with_margin(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + def add_margin(example): + # dummy margin based on the length of the chosen summary + return {"margin": len(example["chosen"])} + + dataset = dataset.map(add_margin) + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_center_rewards_coefficient(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = RewardConfig(output_dir=self.tmp_dir, center_rewards_coefficient=0.01, report_to="none") + trainer = RewardTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rewards.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rewards.py new file mode 100644 index 0000000000000000000000000000000000000000..890ee95fdef823428ed86e08a328faa101f3f3de --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rewards.py @@ -0,0 +1,215 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import threading + +from trl.rewards import accuracy_reward, get_soft_overlong_punishment, reasoning_accuracy_reward, think_format_reward + +from .testing_utils import TrlTestCase, require_math_latex + + +class TestThinkFormatReward(TrlTestCase): + def test_valid_format(self): + completions = [ + "This is my reasoning.This is my answer.", # Simple, one-line reasoning + "\nThis is my reasoning.\n\nThis is my answer.", # Multiline reasoning + "\nThis is\nmy reasoning.\n\nThis is my answer.", # Multiline reasoning + "\nThis is my reasoning.\nThis is my answer.", # Reasoning including other tags + "\nThis is my answer.", # Empty reasoning + ] + completions = [[{"content": completion}] for completion in completions] + expected_rewards = [1.0, 1.0, 1.0, 1.0, 1.0] # All should be valid + rewards = think_format_reward(completions) + assert rewards == expected_rewards + + def test_invalid_format(self): + completions = [ + "\nThis is my reasoning.\nThis is my answer.", # No closing + "This is my reasoning.\nThis is my answer.", # No closing + "This is my reasoning. This is my answer.", # No tags + "This is my reasoning.\nThis is my answer.", # No tags + "This is my reasoning.\nThis is my answer.", # No opening + "This is my reasoning.This is my answer.", # No opening + "Thisis my reasoning.\nThis is my answer.", # tag in the middle + "This ismy reasoning.This is my answer.", # Nested tags + "This is\nmy\nreasoning.\nThis is my answer.", # Multiline + ] + completions = [[{"content": completion}] for completion in completions] + expected_rewards = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # All should be invalid + rewards = think_format_reward(completions) + assert rewards == expected_rewards + + def test_mixed_format(self): + completions = [ + "This is my reasoning.This is my answer.", # Valid + "\nThis is my reasoning.\n\nThis is my answer.", # Valid + "This is my reasoning.\nThis is my answer.", # Invalid + "This is my reasoning. This is my answer.", # Invalid + ] + completions = [[{"content": completion}] for completion in completions] + expected_rewards = [1.0, 1.0, 0.0, 0.0] + rewards = think_format_reward(completions) + assert rewards == expected_rewards + + +class TestSoftOverlongPunishmentReward: + def test_soft_overlong_punishment_short_completion(self): + """Test soft overlong punishment reward function with a short completion.""" + # length 50, with max=100 and soft cache=20, reward should be 0. + reward_fn = get_soft_overlong_punishment(max_completion_len=100, soft_punish_cache=20) + completion_ids = [[1] * 50] # 50 <= 80 + rewards = reward_fn(completion_ids=completion_ids) + assert rewards == [0] + + def test_soft_overlong_punishment_long_completion(self): + """Test soft overlong punishment reward function with a longer than max completion.""" + # 110 > 100, reward should be -1. + reward_fn = get_soft_overlong_punishment(max_completion_len=100, soft_punish_cache=20) + completion_ids = [[1] * 110] + rewards = reward_fn(completion_ids) + assert rewards == [-1] + + def test_soft_overlong_punishment_intermediate_completion(self): + """Test soft overlong punishment reward function for intermediate length completion.""" + reward_fn = get_soft_overlong_punishment(max_completion_len=100, soft_punish_cache=20) + completion_ids = [[1] * 90] # 90 is between 80 and 100 + rewards = reward_fn(completion_ids) + assert round(abs(rewards[0] - -0.5), 4) == 0 + + +class TestAccuracyReward: + @require_math_latex + def test_accuracy_reward_correct_answer(self): + """Test accuracy_reward with a correct answer.""" + completion = [[{"content": r"\boxed{\frac{63}{400}}"}], [{"content": r"\boxed{\frac{63}{400}}"}]] + solution = [r"\frac{63}{400}", "63/400"] + rewards = accuracy_reward(completion, solution) + assert rewards[0] == 1.0 + assert rewards[1] == 1.0 + + @require_math_latex + def test_accuracy_reward_wrong_answer(self): + """Test accuracy_reward with an incorrect answer.""" + completion = [[{"content": r"\boxed{\frac{64}{400}}"}]] + solution = [r"\frac{63}{400}"] + rewards = accuracy_reward(completion, solution) + assert rewards[0] == 0.0 + + @require_math_latex + def test_accuracy_reward_wrong_answer_no_latex(self): + """Test accuracy_reward with an incorrect answer and gold solution with no latex.""" + completion = [[{"content": r"\boxed{3}"}]] + solution = ["6"] + rewards = accuracy_reward(completion, solution) + assert rewards[0] == 0.0 + + @require_math_latex + def test_accuracy_reward_unparsable_gold(self): + """Test accuracy_reward with an unparsable gold solution.""" + completion = [ + [{"content": "Answer is forty two."}], + [{"content": r"Some other content. \boxed{43}."}], + ] + solution = [ + "Answer is forty two.", + "Answer is forty three.", + ] + rewards = accuracy_reward(completion, solution) + assert rewards[0] is None + assert rewards[1] is None + + @require_math_latex + def test_accuracy_reward_in_worker_thread(self): + """Test that accuracy_reward works when called from a non-main thread.""" + completions = [[{"content": r"\boxed{\frac{1}{3}}"}]] + solutions = [r"\frac{1}{3}"] + results = [] + exceptions = [] + + def target(): + try: + results.extend(accuracy_reward(completions, solutions)) + except Exception as e: + exceptions.append(e) + + t = threading.Thread(target=target) + t.start() + t.join() + + assert not exceptions, f"accuracy_reward raised in worker thread: {exceptions[0]}" + assert results == [1.0] + + +class TestReasoningAccuracyReward: + @require_math_latex + def test_correct_answer_yields_unit_reward(self): + completions = [ + [{"content": r" Reasoning content \boxed{\frac{63}{400}}"}], + [{"content": r"Reasoning content \boxed{\frac{63}{400}}"}], + ] + solutions = [r"\frac{63}{400}", r"\frac{63}{400}"] + rewards = reasoning_accuracy_reward(completions, solutions) + assert rewards[0] == 1.0 + assert rewards[1] == 1.0 + + @require_math_latex + def test_correct_answer_with_custom_tags_yields_unit_reward(self): + completions = [ + [{"content": r" Reasoning content \boxed{\frac{63}{400}}"}], + ] + solutions = [ + r"\frac{63}{400}", + ] + rewards = reasoning_accuracy_reward(completions, solutions, reasoning_delimiters=[""]) + assert rewards[0] == 1.0 + + @require_math_latex + def test_incorrect_answer_yields_zero_reward(self): + completion = [[{"content": r" Reasoning content \boxed{\frac{64}{400}}"}]] + solution = [r"\frac{63}{400}"] + rewards = reasoning_accuracy_reward(completion, solution) + assert rewards[0] == 0.0 + + @require_math_latex + def test_correct_answer_in_reasoning_yields_zero_reward(self): + completions = [ + [{"content": r" My answer is \boxed{42} Some other text."}], + [{"content": r" The answer is \boxed{42} Here's a wrong answer: \boxed{43}."}], + ] + solutions = [r"\boxed{42}", r"\boxed{42}"] + rewards = reasoning_accuracy_reward(completions, solutions) + assert rewards[0] == 0.0 + assert rewards[1] == 0.0 + + @require_math_latex + def test_incomplete_reasoning_yields_zero_reward(self): + completions = [ + [{"content": r" Incomplete reasoning without closing tag"}], + [{"content": r"Correct answer \frac{63}{400} but completely missing reasoning content"}], + ] + solutions = [r"\frac{63}{400}", r"\frac{63}{400}"] + rewards = reasoning_accuracy_reward(completions, solutions) + assert rewards[0] == 0.0 + assert rewards[1] == 0.0 + + @require_math_latex + def test_unparsable_gold_solution_yields_none_reward(self): + completions = [ + [{"content": r" Reasoning content \boxed{42}"}], + ] + solutions = [ + "forty two", + ] + rewards = reasoning_accuracy_reward(completions, solutions) + assert rewards[0] is None diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rich_progress_callback.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rich_progress_callback.py new file mode 100644 index 0000000000000000000000000000000000000000..9c6a256b8a9805730b96a3d69d11a82a851e3266 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rich_progress_callback.py @@ -0,0 +1,64 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import torch +import torch.nn as nn +from datasets import Dataset +from transformers import Trainer, TrainingArguments + +from trl.trainer.callbacks import RichProgressCallback + +from .testing_utils import TrlTestCase, require_rich + + +class DummyModel(nn.Module): + def __init__(self): + super().__init__() + self.a = nn.Parameter(torch.tensor(1.0)) + + def forward(self, x): + return self.a * x + + +@require_rich +class TestRichProgressCallback(TrlTestCase): + def setup_method(self): + self.dummy_model = DummyModel() + self.dummy_train_dataset = Dataset.from_list([{"x": 1.0, "y": 2.0}] * 5) + self.dummy_val_dataset = Dataset.from_list([{"x": 1.0, "y": 2.0}] * 101) + + def test_rich_progress_callback_logging(self): + training_args = TrainingArguments( + output_dir=self.tmp_dir, + per_device_eval_batch_size=2, + per_device_train_batch_size=2, + num_train_epochs=4, + eval_strategy="steps", + eval_steps=1, + logging_strategy="steps", + logging_steps=1, + save_strategy="no", + report_to="none", + disable_tqdm=True, + ) + callbacks = [RichProgressCallback()] + trainer = Trainer( + model=self.dummy_model, + train_dataset=self.dummy_train_dataset, + eval_dataset=self.dummy_val_dataset, + args=training_args, + callbacks=callbacks, + ) + + trainer.train() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rloo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rloo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..1bea5a80d7d1119406c4e929cfe22cc9ec7f553a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_rloo_trainer.py @@ -0,0 +1,1718 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from unittest.mock import patch + +import pytest +import torch +import transformers +from datasets import load_dataset +from packaging.version import Version +from transformers import ( + AutoModelForCausalLM, + AutoModelForImageTextToText, + AutoModelForSequenceClassification, + AutoTokenizer, +) +from transformers.utils import is_peft_available + +from trl import RLOOConfig, RLOOTrainer + +from .testing_utils import TrlTestCase, require_peft, require_vision, require_vllm + + +if is_peft_available(): + from peft import LoraConfig, get_peft_model + + +class TestRLOOTrainer(TrlTestCase): + def test_init_minimal(self): + # Test that RLOOTrainer can be instantiated with only model, reward_model and train_dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + train_dataset=dataset, + ) + + @pytest.mark.parametrize("config_name", ["standard_prompt_only", "conversational_prompt_only"]) + def test_training(self, config_name): + dataset = load_dataset("trl-internal-testing/zen", config_name, split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_eval(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + per_device_eval_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + eval_strategy="steps", + eval_steps=2, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + trainer.train() + + def test_training_with_num_generations_eval(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + per_device_eval_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_generations_eval=1, + eval_strategy="steps", + eval_steps=2, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + trainer.train() + + def test_training_multiple_iterations(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_iterations=2, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_peft + def test_training_peft_config(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n: # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + @require_peft + def test_training_peft_model(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + lora_config = LoraConfig() + model = get_peft_model(model, lora_config) + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n and "ref" not in n: # and the peft params to be different (except base and ref) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + # In practice, this test is the same as `test_training_peft_config`, since gradient checkpointing is enabled by + # default in `RLOOTrainer`. We keep it as a regression guard: if the default ever changes, we still explicitly test + # PEFT + gradient checkpointing, which has caused issues in the past. + @require_peft + def test_training_peft_with_gradient_checkpointing(self): + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + gradient_checkpointing=True, # enable gradient checkpointing + report_to="none", + ) + trainer = RLOOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n: # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + def test_training_different_reward_model(self): + # Use a reward model different from the model: different chat template, tokenization, etc. + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + reward_model_id = "trl-internal-testing/tiny-LlamaForSequenceClassification-3.2" + reward_model = AutoModelForSequenceClassification.from_pretrained(reward_model_id) + reward_tokenizer = AutoTokenizer.from_pretrained(reward_model_id) + # By default, the trainer uses the eos token as the padding token. However, for Llama models, the eos token + # appears in the chat template. Using it as a pad token disrupts the reward calculation, as the calculation + # considers the score of the last token before the first pad token. To ensure correct reward calculations, + # we use a separate pad token instead. + reward_tokenizer.pad_token = "<|finetune_right_pad_id|>" + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_model, + args=training_args, + train_dataset=dataset, + reward_processing_classes=reward_tokenizer, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_reward_func_standard(self): + # Test if trainer can handle reward function with standard format + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_reward_func_conversational(self): + # Test if trainer can handle reward function with conversational format + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that gives higher scores to longer completion content.""" + completion_contents = [completion[0]["content"] for completion in completions] + return [float(len(content)) for content in completion_contents] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_reward_funcs(self): + # Test that RLOOTrainer can be instantiated with multiple reward functions + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def reward_func2(completions, **kwargs): + """Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func1, reward_func2], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_sync_and_async_reward_funcs(self): + # Test that RLOOTrainer can be instantiated with multiple reward functions one of which is async + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def sync_reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def sync_reward_func2(completions, **kwargs): + return [1 for _ in completions] + + async def async_reward_func(completions, **kwargs): + """Async Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[sync_reward_func1, sync_reward_func2, async_reward_func], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_reward_funcs_with_None_output(self): + """Test that a valid math reward function is processed correctly while the code reward function returns None.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def applicable_reward_func(completions, **kwargs): + """A reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def non_applicable_reward_func(completions, **kwargs): + """A reward function that returns None for all inputs, as it is not applicable to this sample.""" + return [None] * len(completions) + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[ + applicable_reward_func, + non_applicable_reward_func, + ], # One applicable, one non applicable + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = { + n: param.clone() for n, param in trainer.model.named_parameters() if param.requires_grad + } + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_reward_funcs_with_weights(self): + """Test that RLOOTrainer can handle multiple reward functions with weights.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func1(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + def reward_func2(completions, **kwargs): + """Reward function that rewards completions with more unique letters.""" + return [float(len(set(completion))) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + reward_weights=[0.7, 0.3], # weight of reward_func1 and reward_func2 respectively + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func1, reward_func2], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that training logs contain both reward metrics + assert trainer.state.log_history[-1]["train_loss"] is not None + assert "rewards/reward_func1/mean" in trainer.state.log_history[-1] + assert "rewards/reward_func1/std" in trainer.state.log_history[-1] + assert "rewards/reward_func2/mean" in trainer.state.log_history[-1] + assert "rewards/reward_func2/std" in trainer.state.log_history[-1] + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_reward_metric_reflects_reward_weights(self): + """Test that the logged 'reward' metric uses reward_weights, not an unweighted sum.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def constant_reward_1(completions, **kwargs): + return [1.0] * len(completions) + + def constant_reward_0(completions, **kwargs): + return [0.0] * len(completions) + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + reward_weights=[0.7, 0.3], + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[constant_reward_1, constant_reward_0], + args=training_args, + train_dataset=dataset, + ) + + trainer.train() + + log = trainer.state.log_history[-1] + # With reward_weights=[0.7, 0.3] and rewards [1.0, 0.0]: + # weighted reward = 0.7*1.0 + 0.3*0.0 = 0.7 + # unweighted reward = 1.0 + 0.0 = 1.0 + assert abs(log["reward"] - 0.7) < 1e-5, ( + f"Expected logged reward to be ~0.7 (weighted), got {log['reward']}. " + "The reward metric should reflect reward_weights." + ) + + def test_training_multiple_mixed_reward_funcs(self): + # Test if the trainer can handle a mix of reward functions and reward models + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion)) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=[reward_func, "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5"], + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_reward_func_additional_column(self): + # Test if trainer can handle reward function that rely on additional columns in the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Add a column to the dataset (dummy example, the column could be anything) + some_values = list(range(len(dataset))) + dataset = dataset.add_column("some_values", some_values) + + def reward_func(completions, some_values, **kwargs): + """Reward function that rewards completions with lengths closer to the values in some_values.""" + return [ + float(abs(len(completion) - value)) for completion, value in zip(completions, some_values, strict=True) + ] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_sync_ref_model(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + beta=0.1, # ensure ref model is created so sync can update it + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + sync_ref_model=True, + ref_model_sync_steps=2, # reduce sync steps to ensure a sync happens + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + assert trainer.ref_model is not None + previous_ref_params = {n: param.clone() for n, param in trainer.ref_model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + new_ref_param = trainer.ref_model.get_parameter(n) + assert not torch.equal(previous_ref_params[n], new_ref_param), f"Ref Parameter {n} has not changed." + + def test_training_beta_zero(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = RLOOConfig( + output_dir=self.tmp_dir, + beta=0.0, # set beta to zero value to test the case where the reference model is not used + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_pad_to_multiple_of(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + pad_to_multiple_of=8, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_peft + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_and_peft(self): + """Test that training works with vLLM for generation.""" + model = AutoModelForCausalLM.from_pretrained( + "Qwen/Qwen2.5-0.5B-Instruct", dtype="float32" + ) # tiny model is too small for vLLM + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + ) + lora_config = LoraConfig( + target_modules="all-linear", + # test with non-default modules as it adds extra keys in state_dict that we need to handle + modules_to_save=["embed_tokens", "lm_head"], + ) + trainer = RLOOTrainer( + model=model, + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + peft_config=lora_config, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n and "original_module" not in n: + # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_structured_outputs(self): + """Test that training works with vLLM for generation with structured outputs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + vllm_structured_outputs_regex=r"\n.*\n\n\n.*\n", + ) + trainer = RLOOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", # tiny model is too small for vLLM + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_additional_generation_kwargs(self): + """Test that training works with additional generation kwargs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + top_p=0.9, + top_k=10, + min_p=0.01, + repetition_penalty=1.1, + ) + + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vllm_with_additional_generation_kwargs(self): + """Test that training works with vLLM and additional generation kwargs.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + top_p=0.9, + top_k=10, + min_p=0.01, + repetition_penalty=1.1, + ) + + trainer = RLOOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", # tiny model is too small for vLLM + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_normalized_advantages(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + normalize_advantages=True, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_clipped_rewards(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + reward_clip_range=(-1, 1), + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @patch("transformers.generation.utils.GenerationMixin.generate") + def test_training_with_mask_truncated_completions(self, mock_generate): + """Test that training works with mask_truncated_completions=True parameter.""" + + # We mock the generate method because the model's random weights make it extremely unlikely to produce a + # sequence containing the EOS token within the allowed max_completion_length. As a result, all tokens are + # masked in the loss, the model doesn't update, and the final check (which verifies the update) fails. + def fake_generate(input_ids, **kwargs): + # pad_token_id = 151643; eos_token_id = 151645 + completion_ids = torch.tensor( + [ + [1, 2, 3, 4, 5, 6, 7, 8], # this one is truncated + [9, 10, 11, 151645, 151643, 151643, 151643, 151643], # this one contains eos + [12, 13, 14, 15, 16, 17, 18, 151645], # particular case, eos is generated just within the limit + ], + device=input_ids.device, + ) + return torch.cat([input_ids, completion_ids], dim=1) + + mock_generate.side_effect = fake_generate + + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + mask_truncated_completions=True, # Enable masking of truncated completions + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_mask_truncated_completions_all_masked(self): + """ + Test that when all generated completions are truncated (i.e., none contain an EOS token), and + mask_truncated_completions=True, the model receives no effective learning signal and therefore does not update + its parameters. + + Here, we don't mock the generate method, be we rely on the fact that the model the probability of generating + the EOS token is extremely low, so all generated completions are truncated. + """ + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + mask_truncated_completions=True, # Enable masking of truncated completions + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert torch.equal(param, new_param), f"Parameter {n} has changed." + + def test_warning_raised_all_rewards_none(self, caplog): + """Test that a proper warning is raised when all rewards are None.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def always_none_reward_func(completions, **kwargs): + """Reward function that always returns None.""" + return [None] * len(completions) + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=always_none_reward_func, + args=training_args, + train_dataset=dataset, + ) + + with caplog.at_level("WARNING", logger="trl.trainer.rloo_trainer"): + trainer.train() + + expected_warning = "All reward functions returned None for the following kwargs:" + assert expected_warning in caplog.text + + def test_training_num_generations_larger_than_batch_size(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + num_generations=6, # the number of generations is larger than the batch size, but + gradient_accumulation_steps=2, # gradient accumulation should allow that + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_multiple_dataloader_workers(self): + # Pytest/CI often starts background threads before tests run. With Python 3.12, using the default "fork" start + # method in a multi-threaded process emits a DeprecationWarning and may deadlock. + # + # We force "spawn" here to make multiprocessing safe under pytest when DataLoader workers are enabled. This is + # test-environment–specific and not required by the training logic itself. + # + # This means the test does not cover "fork". However, "spawn" is stricter (requires full picklability and clean + # state) and avoids fork-after-threads issues that pytest cannot reliably test anyway. Fork-specific behavior, + # if needed, should be tested in a clean process outside pytest. + torch.multiprocessing.set_start_method("spawn", force=True) + + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + dataloader_num_workers=2, # use multiple dataloader workers + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_generation_kwargs(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + # Pass gen kwargs + generation_kwargs={"do_sample": True, "top_k": 50, "num_beams": 2, "length_penalty": -0.1}, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_reward_func_accessing_trainer_state(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + trainer_state = kwargs.get("trainer_state") + assert trainer_state is not None + # transformers.TrainerState instance should have a `global_step` property. + assert hasattr(trainer_state, "global_step") + return [float(len(set(completion))) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + trainer.train() + + def test_training_reward_func_with_log_extra(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + log_extra = kwargs.get("log_extra") + assert log_extra is not None + log_extra("test_column", [completion[:5] for completion in completions]) + return [float(len(completion)) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + log_completions=True, + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + trainer.train() + assert "test_column" in trainer._logs["extra"] + + def test_training_reward_func_with_log_metric(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + def reward_func(completions, **kwargs): + log_metric = kwargs.get("log_metric") + assert log_metric is not None + log_metric("custom_accuracy", 0.75) + return [float(len(completion)) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + trainer.train() + # log_metric appends to _metrics, which gets averaged and merged into log_history + logged_keys = {k for entry in trainer.state.log_history for k in entry} + assert "custom_accuracy" in logged_keys + + def test_prepare_input_called_with_correct_data(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_completion_length=8, # reduce the completion length to reduce memory usage + gradient_accumulation_steps=3, # can be anything in this test + # steps_per_generation*per_device_train_batch_size=24 is divisible by num_generations=4 + steps_per_generation=4, + num_generations=4, + per_device_train_batch_size=6, # reduce the batch size to reduce memory usage + num_iterations=2, + shuffle_dataset=False, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + # steps_per_generation=4, per_device_train_batch_size=6 and num_generations=4, so we expect a + # generation batch of 24 samples (steps_per_generation * per_device_train_batch_size), containing 6 + # different prompts (steps_per_generation * per_device_train_batch_size // num_generations), each repeated + # 4 times (num_generations). + expected_first_generation_batch = ( + [{"prompt": "Beautiful is better than"}] * 4 + + [{"prompt": "Explicit is"}] * 4 + + [{"prompt": "Simple is better"}] * 4 + + [{"prompt": "Complex"}] * 4 + + [{"prompt": "Flat is better than"}] * 4 + + [{"prompt": "Sparse is better"}] * 4 + ) + expected_second_generation_batch = ( + [{"prompt": "Readability"}] * 4 + + [{"prompt": "Special cases aren't special"}] * 4 + + [{"prompt": "Although practicality beats"}] * 4 + + [{"prompt": "Errors should never"}] * 4 + + [{"prompt": "Unless explicitly"}] * 4 + + [{"prompt": "In the face of ambiguity, refuse"}] * 4 + ) + + with patch.object(RLOOTrainer, "training_step", wraps=trainer.training_step) as mock_prepare: + trainer.train() + # 3 epochs * 2 iterations * 2 generation batches to cover the dataset * 4 steps_per_generation + assert mock_prepare.call_count == 48 + for i in range(0, 8): # Generation batch repeated 8 times (steps_per_generation*num_iterations) + assert mock_prepare.call_args_list[i].args[1] == expected_first_generation_batch + for i in range(8, 16): + assert mock_prepare.call_args_list[i].args[1] == expected_second_generation_batch + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + "trl-internal-testing/tiny-LlavaNextForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + # "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", seems not to support bf16 properly + ], + ) + @require_vision + def test_training_vlm(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + params_to_skip = ( + "model.vision_tower.", + "model.multi_modal_projector.", + "model.visual.", + "model.image_newline", + ) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @require_vision + def test_training_vlm_with_pad_to_multiple_of(self): + # Models like Gemma3 use other forward keyword arguments like token_type_ids that also need to be padded when + # using pad_to_multiple_of, so we test that the trainer correctly pads all the necessary inputs in this case. + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + pad_to_multiple_of=7, + report_to="none", + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + def test_training_vlm_beta_non_zero(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + beta=0.1, # set beta to non-zero value to test the case where the reference model is used + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + # Because of the way the tiny models are initialized, the gradient does not flow properly through the + # vision parts of the model, so we skip them. Ideally, we should fix the init of these models. + params_to_skip = ("model.visual.",) + for n, param in previous_trainable_params.items(): + if n.startswith(params_to_skip): + continue + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + @require_peft + def test_training_vlm_peft(self, model_id): + model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model=model, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(target_modules=["q_proj", "v_proj"]), + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model params to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed." + elif "base_layer" not in n: # We expect the peft params to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + ], + ) + @require_vision + @require_vllm + @pytest.mark.skip(reason="We should add a mock for the vLLM server.") + def test_training_vlm_and_vllm(self, model_id) -> None: + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + use_vllm=True, + vllm_mode="server", + ) + trainer = RLOOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @require_vision + def test_training_vlm_multi_image(self, model_id): + dataset = load_dataset("trl-internal-testing/zen-multi-image", "conversational_prompt_only", split="train") + + def reward_func(completions, **kwargs): + """Reward function that rewards longer completions.""" + return [float(len(completion[0]["content"])) for completion in completions] + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + ) + trainer = RLOOTrainer( + model=model_id, + reward_funcs=reward_func, + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_training_with_chat_template_kwargs(self): + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train") + + training_args = RLOOConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + per_device_train_batch_size=3, # reduce the batch size to reduce memory usage + num_generations=3, # reduce the number of generations to reduce memory usage + max_completion_length=8, # reduce the completion length to reduce memory usage + report_to="none", + chat_template_kwargs={"enable_thinking": False}, + ) + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", + reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + args=training_args, + train_dataset=dataset, + ) + + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check that the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.equal(param, new_param), f"Parameter {n} has not changed." + + def test_mismatched_reward_processing_classes_length(self): + """Test that mismatched length between reward_funcs and reward_processing_classes raises error.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Use two reward models + reward_models = [ + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + "trl-internal-testing/tiny-Qwen3ForSequenceClassification", + ] + + # Create a single processing class (tokenizer) + single_processing_class = AutoTokenizer.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + ) + + training_args = RLOOConfig(output_dir=self.tmp_dir, report_to="none") + + with pytest.raises(ValueError, match="must match"): + RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_models, + reward_processing_classes=single_processing_class, # only one, but need two + args=training_args, + train_dataset=dataset, + ) + + def test_correct_reward_processing_classes_list(self): + """Test that correct list of reward_processing_classes works properly.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Use two reward models + reward_models = [ + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5", + "trl-internal-testing/tiny-Qwen3ForSequenceClassification", + ] + + # Create processing classes + processing_class1 = AutoTokenizer.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + ) + processing_class2 = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen3ForSequenceClassification") + + training_args = RLOOConfig(output_dir=self.tmp_dir, report_to="none") + + # Correct list length should work + correct_processing_classes = [processing_class1, processing_class2] + + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_models, + reward_processing_classes=correct_processing_classes, + args=training_args, + train_dataset=dataset, + ) + + assert len(trainer.reward_processing_classes) == len(reward_models) + + def test_single_reward_model_with_single_processing_class(self): + """Test that single reward model with single processing class works.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train") + + # Use single reward model + reward_model = "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + + # Create a single processing class (tokenizer) + single_processing_class = AutoTokenizer.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5" + ) + + training_args = RLOOConfig(output_dir=self.tmp_dir, report_to="none") + + trainer = RLOOTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + reward_funcs=reward_model, + reward_processing_classes=single_processing_class, # single object for single reward model + args=training_args, + train_dataset=dataset, + ) + + assert len(trainer.reward_processing_classes) == 1 + assert trainer.reward_processing_classes[0] == single_processing_class diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_sft_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_sft_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..bafbe746b04298cdab41f89f3b4e8c059d07301f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_sft_trainer.py @@ -0,0 +1,2630 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +import gc +import json +import pathlib +from unittest.mock import MagicMock, patch + +import pytest +import torch +import torch.nn.functional as F +import transformers +from accelerate.utils.memory import release_memory +from datasets import load_dataset +from packaging.version import Version +from packaging.version import parse as parse_version +from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TrainingArguments +from transformers.testing_utils import backend_empty_cache, torch_device +from transformers.utils import is_peft_available + +from trl import SFTConfig, SFTTrainer +from trl.trainer.sft_trainer import ( + DataCollatorForLanguageModeling, + _chunked_cross_entropy_loss, + _patch_chunked_ce_lm_head, + dft_loss, +) + +from .testing_utils import ( + TrlTestCase, + ignore_warnings, + require_ampere_or_newer, + require_bitsandbytes, + require_kernels, + require_liger_kernel, + require_peft, + require_torch_accelerator, + require_torch_multi_accelerator, + require_vision, +) + + +if is_peft_available(): + import peft + from peft import ( + LoraConfig, + PeftModel, + PrefixTuningConfig, + PromptEncoderConfig, + PromptTuningConfig, + TaskType, + get_peft_model, + ) + + +class TestDFTLoss(TrlTestCase): + def test_dft_loss(self): + batch_size = 2 + seq_len = 3 + vocab_size = 2 + # All tokens have the same probability + logits = torch.fill(torch.empty(batch_size, seq_len, vocab_size), torch.rand(1).item()) + outputs = MagicMock() + outputs.logits = logits + labels = torch.tensor([[1, 0, 0], [0, 1, -100]]) + ce_loss = torch.nn.functional.cross_entropy( + logits.view(-1, vocab_size), labels.view(-1), ignore_index=-100, reduction="mean" + ) + # We need to account for the logits shift operation so we don't consider the first tokens + # in each row of the batch + num_items_in_batch = 3 + # Dft loss + predicted_dft_loss = dft_loss(outputs, labels, num_items_in_batch) + # If we have just two tokens in our vocab and all logits are the same, + # dft scales the ce_loss per token by 0.5. So the dft_loss should be ce_loss/2 + torch.testing.assert_close(ce_loss / 2.0, predicted_dft_loss, atol=1e-4, rtol=1e-4) + + +class TestDataCollatorForLanguageModeling(TrlTestCase): + def test_basic_padding(self): + """Test basic padding functionality without completion masks.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0) + examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3], [4, 5, -100]])) + + def test_completion_mask(self): + """Test completion mask functionality.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0) + examples = [ + {"input_ids": [1, 2, 3], "completion_mask": [0, 1, 1]}, + {"input_ids": [4, 5], "completion_mask": [0, 1]}, + ] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, 2, 3], [-100, 5, -100]])) + + def test_completion_only_loss_disabled(self): + """Test behavior when completion_only_loss is disabled.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, completion_only_loss=False) + examples = [ + {"input_ids": [1, 2, 3], "completion_mask": [0, 1, 1]}, + {"input_ids": [4, 5], "completion_mask": [0, 1]}, + ] + + result = collator(examples) + + # Labels should not be masked when completion_only_loss=False + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3], [4, 5, -100]])) + + def test_padding_free_mode(self): + """Test padding-free mode where sequences are concatenated.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, padding_free=True) + examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "position_ids", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3, 4, 5]])) + torch.testing.assert_close(result["position_ids"], torch.tensor([[0, 1, 2, 0, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, 2, 3, -100, 5]])) + + def test_padding_free_with_completion_mask(self): + """Test padding-free mode with completion masks.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, padding_free=True) + examples = [ + {"input_ids": [1, 2, 3], "completion_mask": [0, 0, 1]}, + {"input_ids": [4, 5], "completion_mask": [1, 1]}, + ] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "position_ids", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3, 4, 5]])) + torch.testing.assert_close(result["position_ids"], torch.tensor([[0, 1, 2, 0, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, -100, 3, -100, 5]])) + + def test_packing(self): + """Test that when using packing with position_ids, attention_mask is dropped with fa2.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, padding_free=True) + + # Simulate packed sequences with position_ids that restart (typical of BFD packing) + examples = [ + {"input_ids": [1, 2, 3, 4, 5, 6], "seq_lengths": [3, 3]}, + {"input_ids": [7, 8, 9, 10, 11], "seq_lengths": [4, 1]}, + ] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "position_ids", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]])) + torch.testing.assert_close(result["position_ids"], torch.tensor([[0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, 2, 3, -100, 5, 6, -100, 8, 9, 10, -100]])) + + def test_pad_to_multiple_of(self): + """Test padding to multiple of specified value.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, pad_to_multiple_of=4) + examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3, 0], [4, 5, 0, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1, 0], [1, 1, 0, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3, -100], [4, 5, -100, -100]])) + + def test_pad_to_multiple_of_and_padding_free(self): + """Test padding to multiple of specified value.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, padding_free=True, pad_to_multiple_of=4) + examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "position_ids", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3, 4, 5, 0, 0, 0]])) + torch.testing.assert_close(result["position_ids"], torch.tensor([[0, 1, 2, 0, 1, 0, 0, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, 2, 3, -100, 5, -100, -100, -100]])) + + def test_custom_position_ids_but_no_padding_free(self): + """Test that custom position_ids are ignored if padding_free is False.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0) + examples = [{"input_ids": [1, 2, 3], "seq_lengths": [1, 2]}, {"input_ids": [4, 5], "seq_lengths": [2]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3], [4, 5, -100]])) + + def test_single_example(self): + """Test collator with a single example.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0) + examples = [{"input_ids": [1, 2, 3, 4]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3, 4]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3, 4]])) + + def test_different_pad_token_id(self): + """Test with different pad token ID.""" + collator = DataCollatorForLanguageModeling(pad_token_id=999) + examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 999]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3], [4, 5, -100]])) + + def test_assistant_masks(self): + """Test handling of assistant masks in examples.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0) + examples = [ + {"input_ids": [1, 2, 3], "assistant_masks": [0, 1, 1]}, + {"input_ids": [4, 5], "assistant_masks": [0, 1]}, + ] + + result = collator(examples) + + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, 2, 3], [-100, 5, -100]])) + + def test_max_length_keep_start(self): + """Test that sequences longer than max_length are truncated from the start.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, max_length=3) + examples = [{"input_ids": [1, 2, 3, 4, 5]}, {"input_ids": [6, 7, 8]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [6, 7, 8]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3], [6, 7, 8]])) + + def test_max_length_keep_end(self): + """Test that sequences longer than max_length are truncated from the end (keeping last tokens).""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, max_length=3, truncation_mode="keep_end") + examples = [{"input_ids": [1, 2, 3, 4, 5]}, {"input_ids": [6, 7, 8]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[3, 4, 5], [6, 7, 8]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[3, 4, 5], [6, 7, 8]])) + + def test_max_length_no_truncation_needed(self): + """Test that max_length larger than sequences does not alter the output.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, max_length=10) + examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [4, 5, 0]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 0]])) + torch.testing.assert_close(result["labels"], torch.tensor([[1, 2, 3], [4, 5, -100]])) + + def test_max_length_with_completion_mask(self): + """Test that truncation is applied correctly when completion masks are present.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, max_length=3) + examples = [ + {"input_ids": [1, 2, 3, 4, 5], "completion_mask": [0, 0, 1, 1, 1]}, + {"input_ids": [6, 7, 8], "completion_mask": [0, 1, 1]}, + ] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[1, 2, 3], [6, 7, 8]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[-100, -100, 3], [-100, 7, 8]])) + + def test_max_length_keep_end_with_completion_mask(self): + """Test keep_end truncation with completion masks preserves the final tokens.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, max_length=3, truncation_mode="keep_end") + examples = [ + {"input_ids": [1, 2, 3, 4, 5], "completion_mask": [0, 0, 1, 1, 1]}, + {"input_ids": [6, 7, 8], "completion_mask": [0, 1, 1]}, + ] + + result = collator(examples) + + assert set(result.keys()) == {"input_ids", "attention_mask", "labels"} + torch.testing.assert_close(result["input_ids"], torch.tensor([[3, 4, 5], [6, 7, 8]])) + torch.testing.assert_close(result["attention_mask"], torch.tensor([[1, 1, 1], [1, 1, 1]])) + torch.testing.assert_close(result["labels"], torch.tensor([[3, 4, 5], [-100, 7, 8]])) + + def test_max_length_invalid_truncation_mode(self): + """Test that an invalid truncation_mode raises ValueError.""" + collator = DataCollatorForLanguageModeling(pad_token_id=0, max_length=3, truncation_mode="invalid") + examples = [{"input_ids": [1, 2, 3, 4, 5]}] + + with pytest.raises(ValueError, match="Unsupported truncation mode"): + collator(examples) + + def test_single_example_single_doc(self): + batch_seq_lengths = [[5]] + result = DataCollatorForLanguageModeling.get_position_ids_from_packed_seq_lengths(batch_seq_lengths) + assert len(result) == 1 + assert torch.equal(result[0], torch.arange(5)) + + def test_single_example_multiple_docs(self): + batch_seq_lengths = [[3, 2]] + result = DataCollatorForLanguageModeling.get_position_ids_from_packed_seq_lengths(batch_seq_lengths) + assert len(result) == 1 + # First sequence: 0, 1, 2; second sequence: 0, 1 + assert torch.equal(result[0], torch.tensor([0, 1, 2, 0, 1])) + + def test_multiple_examples(self): + batch_seq_lengths = [[2, 2], [3]] + result = DataCollatorForLanguageModeling.get_position_ids_from_packed_seq_lengths(batch_seq_lengths) + assert len(result) == 2 + assert torch.equal(result[0], torch.tensor([0, 1, 0, 1])) + assert torch.equal(result[1], torch.arange(3)) + + +class TestSFTTrainer(TrlTestCase): + def test_init_with_training_arguments(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + args = TrainingArguments(output_dir=self.tmp_dir, report_to="none") + SFTTrainer(model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=args, train_dataset=dataset) + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Cohere2ForCausalLM", + pytest.param( + "trl-internal-testing/tiny-Glm4MoeForCausalLM", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="GLM4 tokenizer requires transformers>=5.0.0", + ), + ), + "trl-internal-testing/tiny-GptOssForCausalLM", + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "trl-internal-testing/tiny-Qwen3MoeForCausalLM", + ], + ) + def test_train(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer(model=model_id, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # Special case for harmony + def test_train_gpt_oss(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/harmony", "language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-GptOssForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_model(self): + # Instantiate the model + model = AutoModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + dtype="float32", + ) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_dft_loss(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + loss_type="dft", + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + eval_strategy="steps", + eval_steps=3, + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_chunked_nll_loss(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, loss_type="chunked_nll", report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_moe_model_with_aux_loss(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + report_to="none", + model_init_kwargs={"output_router_logits": True}, + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen3MoeForCausalLM", args=training_args, train_dataset=dataset + ) + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss and aux loss are not None + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["aux_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_formatting_func(self): + # Dummy formatting function + def formatting_prompts_func(example): + chosen, rejected = example["chosen"], example["rejected"] + return f"### Chosen: {chosen}\n### Rejected: {rejected}" + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_implicit_prompt_preference", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + formatting_func=formatting_prompts_func, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_model_dtype(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + model_init_kwargs={"dtype": torch.float16}, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + report_to="none", + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + # For some reasonn model.layers.0.input_layernorm.weight doesn't change in GitHub Actions but does + # locally. We ignore this parameter for now + if "layernorm" in n: + continue + new_param = trainer.model.get_parameter(n) + # Check the torch dtype + assert new_param.dtype == torch.float16 + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_dense_with_peft_config_lora(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize( + "peft_type", + [ + "prompt_tuning", + "prefix_tuning", + "prompt_encoder", + ], + ) + @require_peft + def test_train_with_peft_config_prompt_tuning(self, peft_type): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer, p-tuning doesn't support gradient checkpointing + training_args = SFTConfig(bf16=False, output_dir=self.tmp_dir, report_to="none", gradient_checkpointing=False) + if peft_type == "prompt_tuning": + peft_config = PromptTuningConfig( + task_type=TaskType.CAUSAL_LM, + num_virtual_tokens=4, + tokenizer_name_or_path="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + ) + elif peft_type == "prefix_tuning": + if parse_version(peft.__version__) <= Version("0.17.1"): + pytest.xfail( + "Prefix tuning with device_map='auto' is broken in peft 0.17.1 and below. See " + "https://github.com/huggingface/peft/issues/2821" + ) + peft_config = PrefixTuningConfig( + task_type=TaskType.CAUSAL_LM, + num_virtual_tokens=4, + ) + elif peft_type == "prompt_encoder": + peft_config = PromptEncoderConfig( + task_type=TaskType.CAUSAL_LM, + num_virtual_tokens=4, + encoder_hidden_size=model.config.hidden_size, # This will be overwritten below + ) + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=peft_config, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + else: # We expect the peft parameters to be different + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_moe_with_peft_config(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-GptOssForCausalLM" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(target_parameters=["mlp.experts.down_proj", "mlp.experts.gate_up_proj"]), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_peft + def test_train_peft_model(self): + # Get the base model + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + + # Get the base model parameter names + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Turn the model into a peft model + lora_config = LoraConfig() + model = get_peft_model(model, lora_config) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # In practice, this test is the same as `test_train_dense_with_peft_config_lora`, since gradient checkpointing is + # enabled by default in `SFTTrainer`. We keep it as a regression guard: if the default ever changes, we still + # explicitly test PEFT + gradient checkpointing, which has caused issues in the past. + @require_peft + def test_train_with_peft_config_and_gradient_checkpointing(self): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, gradient_checkpointing=True, report_to="none") + + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize("use_reentrant", [True, False]) + @require_peft + def test_train_with_peft_config_and_gradient_checkpointing_reentrant(self, use_reentrant): + # Get the base model parameter names + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + model = AutoModelForCausalLM.from_pretrained(model_id, dtype="float32") + base_param_names = [f"base_model.model.{n}" for n, _ in model.named_parameters()] + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + gradient_checkpointing=True, + gradient_checkpointing_kwargs={"use_reentrant": use_reentrant}, + report_to="none", + ) + + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n in base_param_names: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "base_layer" not in n: # We expect the peft parameters to be different (except for the base layer) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_liger_kernel + def test_train_with_liger(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, use_liger_kernel=True, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_torch_accelerator + @require_liger_kernel + def test_compute_loss_skip_logits_on_eval_without_metrics_with_liger(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train[:1]") + + training_args = SFTConfig( + output_dir=self.tmp_dir, + use_liger_kernel=False, + report_to="none", + max_length=8, + bf16=False, + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + compute_metrics=None, + ) + trainer.args.use_liger_kernel = True + trainer.model.eval() + + captured = {} + + def mock_super_compute_loss(model, inputs, return_outputs=False, num_items_in_batch=None): + captured["skip_logits"] = inputs.get("skip_logits") + dummy_loss = torch.tensor(1.0, requires_grad=True) + dummy_outputs = MagicMock() + dummy_outputs.token_accuracy = None + dummy_outputs.logits = torch.randn(1, 5, trainer.model.config.vocab_size) + return (dummy_loss, dummy_outputs) + + inputs = { + "input_ids": torch.tensor([[1, 2, 3, 4, 5]]), + "labels": torch.tensor([[1, 2, 3, 4, 5]]), + "attention_mask": torch.tensor([[1, 1, 1, 1, 1]]), + } + + with patch("transformers.Trainer.compute_loss", side_effect=mock_super_compute_loss): + trainer.compute_loss(trainer.model, inputs) + + assert captured["skip_logits"] is True + + @require_torch_accelerator + @require_liger_kernel + def test_predict_does_not_skip_logits_with_liger(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train[:1]") + + training_args = SFTConfig( + output_dir=self.tmp_dir, + use_liger_kernel=False, + report_to="none", + max_length=8, + bf16=False, + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + compute_metrics=None, + ) + trainer.args.use_liger_kernel = True + trainer.model.eval() + + captured = {} + + def mock_super_compute_loss(model, inputs, return_outputs=False, num_items_in_batch=None): + captured["skip_logits"] = inputs.get("skip_logits") + dummy_loss = torch.tensor(1.0, requires_grad=True) + dummy_outputs = (dummy_loss, torch.randn(1, 5, trainer.model.config.vocab_size)) + return (dummy_loss, dummy_outputs) + + with patch("transformers.Trainer.compute_loss", side_effect=mock_super_compute_loss): + trainer.predict(trainer.train_dataset) + + assert captured["skip_logits"] is False + + def test_train_with_non_chatml_conversational_data(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + + # Rename role/content to from/value to ensure SFT works with non-chatML conversational data + def rename_fields(example: list[dict]): + return {"conversations": [{"from": m["role"], "value": m["content"]} for m in example["messages"]]} + + dataset = dataset.map(rename_fields, remove_columns="messages") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_pretokenized_data(self): + # Get the dataset + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + tokenizer = AutoTokenizer.from_pretrained(model_id) + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + def tokenize_example(example): + return tokenizer(example["text"]) + + # Apply tokenization + tokenized_dataset = dataset.map(tokenize_example, remove_columns=["text"]) + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer(model=model_id, args=training_args, train_dataset=tokenized_dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_skip_prepare_dataset_passes_truncation_to_text_collator(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train[:2]") + with pytest.warns(FutureWarning, match="keep_end.*deprecated"): + training_args = SFTConfig( + output_dir=self.tmp_dir, + max_length=16, + truncation_mode="keep_end", + dataset_kwargs={"skip_prepare_dataset": True}, + report_to="none", + ) + + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + assert isinstance(trainer.data_collator, DataCollatorForLanguageModeling) + assert trainer.data_collator.max_length == 16 + assert trainer.data_collator.truncation_mode == "keep_end" + + def test_padding_free_without_packing_and_max_length_raises(self): + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train[:2]") + training_args = SFTConfig( + output_dir=self.tmp_dir, + max_length=16, + padding_free=True, + report_to="none", + ) + + with pytest.raises(ValueError, match="`max_length` is not enforced"): + SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + def test_train_with_iterable_dataset(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train", streaming=True) + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, max_steps=3, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @require_kernels + @require_ampere_or_newer # Flash attention 2 requires Ampere or newer GPUs + def test_train_padding_free(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + padding_free=True, + model_init_kwargs={"attn_implementation": "kernels-community/flash-attn2"}, + bf16=True, # flash_attention_2 only supports bf16 and fp16 + report_to="none", + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize("packing_strategy", ["bfd", "wrapped"]) + @ignore_warnings(message="You are using packing, but the attention implementation is not.*", category=UserWarning) + @ignore_warnings(message="Padding-free training is enabled, but the attention.*", category=UserWarning) + def test_train_packing(self, packing_strategy): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, packing=True, packing_strategy=packing_strategy, max_length=10, report_to="none" + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @ignore_warnings(message="You are using packing, but the attention implementation is not.*", category=UserWarning) + @ignore_warnings(message="Padding-free training is enabled, but the attention.*", category=UserWarning) + def test_eval_packing(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + packing=True, + max_length=64, + report_to="none", + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Check the number of sequences in train and eval datasets + num_train_seqs = sum(len(x) for x in trainer.train_dataset["seq_lengths"]) + num_eval_seqs = sum(len(x) for x in trainer.eval_dataset["seq_lengths"]) + assert num_train_seqs == 17 # we should still have 17 seqs + assert num_eval_seqs == 2 # we should still have 2 seqs + + # Check that all sequences are shorter than the max length + assert all(sum(x) <= 64 for x in trainer.train_dataset["seq_lengths"]) + assert all(sum(x) <= 64 for x in trainer.eval_dataset["seq_lengths"]) + + # Check the number of sequences in train and eval datasets + assert len(trainer.train_dataset["input_ids"]) == 3 # w/ this dataset, we end up with 46 seqs + assert len(trainer.eval_dataset["input_ids"]) == 1 # w/ this dataset, we end up with 6 seqs + + @ignore_warnings(message="You are using packing, but the attention implementation is not.*", category=UserWarning) + @ignore_warnings(message="Padding-free training is enabled, but the attention.*", category=UserWarning) + def test_only_train_packing(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + packing=True, + eval_packing=False, + max_length=64, + report_to="none", + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Check the number of sequences in train dataset + num_train_seqs = sum(len(x) for x in trainer.train_dataset["seq_lengths"]) + assert num_train_seqs == 17 # we should still have 17 seqs + + # We expect eval dataset not having "seq_lengths" as eval_packing is False + assert "seq_lengths" not in trainer.eval_dataset + + # Check that all sequences are shorter than the max length + assert all(sum(x) <= 64 for x in trainer.train_dataset["seq_lengths"]) + + # Check the number of sequences in train and eval datasets + assert len(trainer.train_dataset["input_ids"]) == 3 # w/ this dataset, we end up with 46 seqs + assert len(trainer.eval_dataset["input_ids"]) == 2 # w/ this dataset, we end up with 6 seqs + + def test_train_with_chat_template_kwargs(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + + tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5") + # The following template is a simplified version of the Qwen chat template, where an additional argument + # `role_capital` is used to control the capitalization of roles. + tokenizer.chat_template = '{%- if messages[0]["role"] == "system" -%} {{ "<|im_start|>" + ("SYSTEM" if role_capital else "system") + "\\n" + messages[0]["content"] + "<|im_end|>\\n" }}{%- else -%} {{ "<|im_start|>" + ("SYSTEM" if role_capital else "system") + "\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n" }}{%- endif -%}{%- for message in messages -%} {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) -%} {{ "<|im_start|>" + (message.role.upper() if role_capital else message.role) + "\\n" + message.content + "<|im_end|>\\n" }} {%- elif message.role == "assistant" -%} {{ "<|im_start|>" + ("ASSISTANT" if role_capital else "assistant") }} {%- if message.content -%} {{ "\\n" + message.content }} {%- endif -%} {{ "<|im_end|>\\n" }} {%- elif message.role == "tool" -%} {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") -%} {{ "<|im_start|>" + ("USER" if role_capital else "user") }} {%- endif -%} {{ "\\n\\n" + message.content + "\\n" }} {%- if loop.last or (messages[loop.index0 + 1].role != "tool") -%} {{ "<|im_end|>\\n" }} {%- endif -%} {%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%} {{ "<|im_start|>" + ("ASSISTANT" if role_capital else "assistant") + "\\n" }}{%- endif -%}' + + dataset = dataset.add_column( + "chat_template_kwargs", [{"role_capital": bool(i % 2)} for i in range(len(dataset))] + ) + assert "chat_template_kwargs" in dataset.features + + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + processing_class=tokenizer, + ) + + # Assert trainer uses the same chat template as tokenizer + assert trainer.processing_class.chat_template == tokenizer.chat_template + + # Assert chat_template is applied + for i in range(2): + role = "SYSTEM" if i else "system" + system_prompt = ( + f"<|im_start|>{role}\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>" + ) + system_prompt_ids = trainer.processing_class(system_prompt)["input_ids"] + assert trainer.train_dataset[i]["input_ids"][: len(system_prompt_ids)] == system_prompt_ids + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_assistant_only(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, assistant_only_loss=True, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_completion_only(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_completion", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, completion_only_loss=True, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_completion_only_harmony(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/harmony", "prompt_completion", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, completion_only_loss=True, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-GptOssForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_assistant_only_and_completion_only(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_completion", split="train") + + # To test this case, we need to add user messages in the completion (they'll be masked in the loss) + def add_to_completion(example): + example["completion"].append(example["prompt"][0]) + example["completion"].append(example["completion"][0]) + return example + + dataset = dataset.map(add_to_completion) + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, assistant_only_loss=True, completion_only_loss=True, report_to="none" + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_assistant_only_iterable_dataset(self): + # Get the dataset + dataset = load_dataset( + "trl-internal-testing/zen", "conversational_language_modeling", split="train", streaming=True + ) + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, assistant_only_loss=True, max_steps=3, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen3ForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_set_chat_template_from_model(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, chat_template_path="Qwen/Qwen3-4B", report_to="none") + # trl-internal-testing/tiny-GPTNeoXForCausalLM doesn't have a chat template set by default + trainer = SFTTrainer( + model="trl-internal-testing/tiny-GPTNeoXForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_set_chat_template_from_path(self, lazy_shared_datadir): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "conversational_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + chat_template_path=str(lazy_shared_datadir / "template.jinja"), + report_to="none", + ) + # trl-internal-testing/tiny-GPTNeoXForCausalLM doesn't have a chat template set by default + trainer = SFTTrainer( + model="trl-internal-testing/tiny-GPTNeoXForCausalLM", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + # Check that the template saved in the output directory is the same as the one used for training + template_path = pathlib.Path(self.tmp_dir) / "checkpoint-9" / "chat_template.jinja" + assert template_path.exists(), f"Chat template not found at {template_path}" + + with open(template_path) as f: + template_content = f.read() + with open(training_args.chat_template_path) as f: + original_template_content = f.read() + assert template_content == original_template_content, "Chat template content does not match the original" + + def test_train_toolcall_data(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/toolcall", "language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_toolcall_data_as_json(self): + # Tabular backends (Arrow/Parquet) can insert `None` for missing keys in nested structures. + # If `tools` is stored as a list of dicts and examples use different dict schemas, nulls may + # be introduced and break tool processing. This test ensures we also support `tools` provided + # as a list of dicts. + # Get the dataset + dataset = load_dataset("trl-internal-testing/toolcall", "language_modeling", split="train") + + def convert_to_json(example): + return {"tools": json.loads(example["tools"])} + + dataset = dataset.map(convert_to_json) + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_train_with_eval(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, eval_strategy="steps", eval_steps=3, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + ) + + # Train the model + trainer.train() + + # Check that the eval loss is not None + assert trainer.state.log_history[0]["eval_loss"] is not None + + def test_train_with_multiple_eval_dataset(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, eval_strategy="steps", eval_steps=3, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset={"data1": dataset["test"], "data2": dataset["test"]}, + ) + # Train the model + trainer.train() + + # Check that the eval losses are not None + assert trainer.state.log_history[-3]["eval_data1_loss"] is not None + assert trainer.state.log_history[-2]["eval_data2_loss"] is not None + + def test_train_with_compute_metrics(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling") + + def dummy_compute_metrics(eval_pred): + return {"my_metric": 0.123} + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + eval_strategy="steps", + eval_steps=3, + report_to="none", + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset["train"], + eval_dataset=dataset["test"], + compute_metrics=dummy_compute_metrics, + ) + + # Train the model + trainer.train() + + # Check that the custom metric is logged + assert trainer.state.log_history[-2]["eval_my_metric"] == 0.123 + + # In practice, this test is the same as `test_train`, since gradient checkpointing is enabled by default in + # `SFTTrainer`. We keep it as a regression guard: if the default ever changes, we still explicitly test gradient + # checkpointing, which has caused issues in the past. + def test_train_with_gradient_checkpointing(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, gradient_checkpointing=True, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + @pytest.mark.parametrize("use_reentrant", [True, False]) + def test_train_with_gradient_checkpointing_reentrant(self, use_reentrant): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + gradient_checkpointing=True, + gradient_checkpointing_kwargs={"use_reentrant": use_reentrant}, + report_to="none", + ) + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", args=training_args, train_dataset=dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + def test_tag_added(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + train_dataset=dataset, + ) + + for tag in ["sft", "trl"]: + assert tag in trainer.model.model_tags + + @require_peft + def test_tag_added_peft(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + train_dataset=dataset, + peft_config=LoraConfig(), + ) + + for tag in ["sft", "trl"]: + assert tag in trainer.model.model_tags + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + # "trl-internal-testing/tiny-Idefics2ForConditionalGeneration", high memory peak, skipped for now + # "trl-internal-testing/tiny-Idefics3ForConditionalGeneration", high memory peak, skipped for now + "trl-internal-testing/tiny-LlavaForConditionalGeneration", + "trl-internal-testing/tiny-LlavaNextForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + # "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", seems not to support bf16 properly + pytest.param( + "trl-internal-testing/tiny-Qwen3VLForConditionalGeneration", + marks=[ + pytest.mark.skipif( + Version(transformers.__version__) < Version("4.57.0"), + reason="Qwen3-VL series were introduced in transformers-4.57.0", + ), + ], + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-Qwen3_5MoeForConditionalGeneration-3.6", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.2.0"), + reason="Qwen3.5 models were introduced in transformers-5.2.0", + ), + ), + ], + ) + @require_vision + def test_train_vlm(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + report_to="none", + ) + trainer = SFTTrainer(model=model_id, args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # For some reason, these params are not updated. This is probably not related to TRL, but to + # the model itself. We should investigate this further, but for now we just skip these params. + # fmt: off + if ( + model_id == "trl-internal-testing/tiny-Gemma3ForConditionalGeneration" and "model.vision_tower.vision_model.head" in n or + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "model.vision_tower.vision_model.post_layernorm" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "vision_tower.vision_model.encoder.layers.1" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "model.vision_tower.encoder.layers.1" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-LlavaForConditionalGeneration" and "model.vision_tower.post_layernorm" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "model.vision_tower.vision_model.post_layernorm" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "vision_tower.vision_model.encoder.layers.1" in n or # transformers < 5.6.0 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "model.vision_tower.encoder.layers.1" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-LlavaNextForConditionalGeneration" and "model.vision_tower.post_layernorm" in n or # transformers >= 5.6.0, see #5497 + model_id == "trl-internal-testing/tiny-Qwen3VLForConditionalGeneration" and "model.visual.deepstack_merger_list" in n + ): + # fmt: on + continue + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @pytest.mark.xfail( + parse_version(transformers.__version__) < parse_version("4.57.0"), + reason="Mixing text-only and image+text examples is only supported in transformers >= 4.57.0", + strict=False, + ) + @require_vision + def test_train_vlm_multi_image(self, model_id): + # Get the dataset + dataset = load_dataset( + "trl-internal-testing/zen-multi-image", "conversational_prompt_completion", split="train" + ) + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + report_to="none", + ) + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + # Special case for Gemma, as it uses token_type_ids, and we need to ensure they are properly in the collator: + "trl-internal-testing/tiny-Gemma3ForConditionalGeneration", + pytest.param( + "trl-internal-testing/tiny-Gemma4ForConditionalGeneration", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.5.0"), + reason="Gemma4 models were introduced in transformers-5.5.0", + ), + ), + ], + ) + @require_vision + def test_train_vlm_prompt_completion(self, model_id): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_prompt_completion", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + report_to="none", + ) + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + # Gemma 3n uses a timm encoder, making it difficult to create a smaller variant for testing. + # To ensure coverage, we run tests on the full model but mark them as slow to exclude from default runs. + @pytest.mark.slow + @require_vision + @pytest.mark.skip(reason="Model google/gemma-3n-E2B-it is gated and requires HF token") + def test_train_vlm_gemma_3n(self): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen-image", "conversational_language_modeling", split="train") + + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + learning_rate=0.1, # use higher lr because gradients are tiny and default lr can stall updates + max_length=None, # for VLMs, truncating can remove image tokens, leading to errors + per_device_train_batch_size=1, # VLM training is memory intensive, reduce batch size to avoid OOM + model_init_kwargs={"dtype": "bfloat16"}, + report_to="none", + ) + trainer = SFTTrainer(model="google/gemma-3n-E2B-it", args=training_args, train_dataset=dataset) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if "model.audio_tower" in n or "model.embed_audio" in n: + # The audio embedding parameters are not updated because this dataset contains no audio data + continue + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen2_5_VLForConditionalGeneration", + ], + ) + @pytest.mark.parametrize( + "dataset_config", + [ + "conversational_language_modeling", + "conversational_prompt_completion", + "standard_language_modeling", # Regression test for #5334 + "standard_prompt_completion", + ], + ) + @require_vision + def test_train_vlm_text_only_data(self, model_id, dataset_config): + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", dataset_config, split="train") + + # Initialize the trainer + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model=model_id, + args=training_args, + train_dataset=dataset, + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if n.startswith("model.visual"): + torch.testing.assert_close(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is updated" + else: + assert not torch.allclose(param, new_param, rtol=1e-12, atol=1e-12), f"Param {n} is not updated" + + @require_peft + def test_prompt_tuning(self): + """Test that SFT works with Prompt Tuning.""" + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer( + model="trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + args=training_args, + train_dataset=dataset, + peft_config=PromptEncoderConfig(task_type=TaskType.CAUSAL_LM, num_virtual_tokens=8), + ) + + # Save initial parameters to check they change during training + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that training completed successfully + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["mean_token_accuracy"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if "base_model" in n: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "prompt_encoder" in n: # We expect the peft parameters to be different + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + else: + raise ValueError(f"Unexpected parameter {n} in model: {trainer.model}") + + @require_peft + @require_bitsandbytes + def test_peft_with_quantization(self): + # Get the base model + model_id = "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5" + + quantization_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_use_double_quant=True, + bnb_4bit_quant_type="nf4", + bnb_4bit_compute_dtype=torch.float16, + ) + model = AutoModelForCausalLM.from_pretrained( + model_id, + dtype="float32", + quantization_config=quantization_config, + ) + + # Get the dataset + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + # Initialize the trainer with the already configured PeftModel + training_args = SFTConfig(output_dir=self.tmp_dir, learning_rate=0.1, report_to="none") + trainer = SFTTrainer(model=model, args=training_args, train_dataset=dataset, peft_config=LoraConfig()) + + # Save initial parameters to check they change during training + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that training completed successfully + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["mean_token_accuracy"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + # In bitsandbytes, bias parameters are automatically cast to the input dtype during the forward pass if + # their dtype doesn’t match. This causes the module to change unexpectedly during the first forward pass of + # the training. To handle this, we cast these specific bias parameters to float32 before comparison. + # https://github.com/bitsandbytes-foundation/bitsandbytes/blob/45553f7392e524eacf400b132cfe01261f6477be/bitsandbytes/nn/modules.py#L518 + # We still need to investigate why the compute dtype ends up being different than for these parameters. + if n in [ + "base_model.model.model.layers.1.self_attn.k_proj.bias", + "base_model.model.model.layers.1.self_attn.q_proj.base_layer.bias", + "base_model.model.model.layers.1.self_attn.v_proj.base_layer.bias", + ]: + param = param.float() + + if "lora" not in n: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "lora" in n: # We expect the peft parameters to be different + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + else: + raise ValueError(f"Unexpected parameter {n} in model: {trainer.model}") + + @require_peft + def test_prompt_tuning_peft_model(self): + """Test that SFT works with Prompt Tuning and a pre-converted PeftModel""" + model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", dtype="float32") + model = get_peft_model(model, PromptEncoderConfig(task_type=TaskType.CAUSAL_LM, num_virtual_tokens=8)) + + dataset = load_dataset("trl-internal-testing/zen", "standard_language_modeling", split="train") + + training_args = SFTConfig(output_dir=self.tmp_dir, report_to="none") + trainer = SFTTrainer(model=model, args=training_args, train_dataset=dataset) + + # Save initial parameters to check they change during training + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + trainer.train() + + # Check that training completed successfully + assert trainer.state.log_history[-1]["train_loss"] is not None + assert trainer.state.log_history[-1]["mean_token_accuracy"] is not None + + # Check the peft params have changed and the base model params have not changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + if "base_model" in n: # We expect the base model parameters to be the same + torch.testing.assert_close(param, new_param), f"Parameter {n} has changed" + elif "prompt_encoder" in n: # We expect the peft parameters to be different + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + else: + raise ValueError(f"Unexpected parameter {n} in model: {trainer.model}") + + +@pytest.mark.slow +@require_torch_accelerator +@require_peft +class TestSFTTrainerSlow(TrlTestCase): + def setup_method(self): + self.train_dataset = load_dataset("stanfordnlp/imdb", split="train[:10%]") + self.eval_dataset = load_dataset("stanfordnlp/imdb", split="test[:10%]") + self.max_length = 128 + self.peft_config = LoraConfig( + lora_alpha=16, + lora_dropout=0.1, + r=8, + bias="none", + task_type="CAUSAL_LM", + ) + + def teardown_method(self): + gc.collect() + backend_empty_cache(torch_device) + gc.collect() + + @pytest.mark.parametrize("packing", [True, False]) + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + def test_sft_trainer_transformers_mp(self, model_name, packing): + """ + Simply tests if passing a transformers model to `SFTTrainer` loads and runs the trainer as expected in mixed + precision. + """ + training_args = SFTConfig( + output_dir=self.tmp_dir, + logging_strategy="no", + report_to="none", + per_device_train_batch_size=2, + max_steps=10, + fp16=True, # this is sufficient to enable amp + packing=packing, + max_length=self.max_length, + ) + + model = AutoModelForCausalLM.from_pretrained(model_name, dtype="float32") + tokenizer = AutoTokenizer.from_pretrained(model_name) + + trainer = SFTTrainer( + model, + args=training_args, + processing_class=tokenizer, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + ) + + trainer.train() + + release_memory(model, trainer) + + @pytest.mark.parametrize("device_map", [{"": 0}, "auto"]) + @pytest.mark.parametrize( + "gradient_checkpointing_kwargs", [None, {"use_reentrant": False}, {"use_reentrant": True}] + ) + @pytest.mark.parametrize("packing", [True, False]) + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_torch_multi_accelerator + def test_sft_trainer_transformers_mp_gc_device_map( + self, model_name, packing, gradient_checkpointing_kwargs, device_map + ): + """ + Simply tests if passing a transformers model to `SFTTrainer` loads and runs the trainer as expected in mixed + precision + different scenarios of gradient_checkpointing (single, multi-gpu, etc). + """ + training_args = SFTConfig( + output_dir=self.tmp_dir, + logging_strategy="no", + report_to="none", + per_device_train_batch_size=2, + max_steps=10, + packing=packing, + max_length=self.max_length, + fp16=True, # this is sufficient to enable amp + gradient_checkpointing=True, # default, here for clarity + gradient_checkpointing_kwargs=gradient_checkpointing_kwargs, + ) + + model = AutoModelForCausalLM.from_pretrained(model_name, dtype="float32", device_map=device_map) + tokenizer = AutoTokenizer.from_pretrained(model_name) + + trainer = SFTTrainer( + model, + args=training_args, + processing_class=tokenizer, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + ) + + trainer.train() + + release_memory(model, trainer) + + @pytest.mark.parametrize( + "gradient_checkpointing_kwargs", [None, {"use_reentrant": False}, {"use_reentrant": True}] + ) + @pytest.mark.parametrize("packing", [True, False]) + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_peft + @require_bitsandbytes + def test_sft_trainer_transformers_mp_gc_peft_qlora(self, model_name, packing, gradient_checkpointing_kwargs): + """ + Simply tests if passing a transformers model + PEFT + bnb to `SFTTrainer` loads and runs the trainer as + expected in mixed precision + different scenarios of gradient_checkpointing. + """ + training_args = SFTConfig( + output_dir=self.tmp_dir, + logging_strategy="no", + report_to="none", + per_device_train_batch_size=2, + max_steps=10, + packing=packing, + max_length=self.max_length, + gradient_checkpointing=True, # default, here for clarity + gradient_checkpointing_kwargs=gradient_checkpointing_kwargs, + ) + + quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16) + + model = AutoModelForCausalLM.from_pretrained( + model_name, dtype="float32", quantization_config=quantization_config + ) + tokenizer = AutoTokenizer.from_pretrained(model_name) + + trainer = SFTTrainer( + model, + args=training_args, + processing_class=tokenizer, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + peft_config=self.peft_config, + ) + + assert isinstance(trainer.model, PeftModel) + + trainer.train() + + release_memory(model, trainer) + + @pytest.mark.parametrize("packing", [True, False]) + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_peft + @require_bitsandbytes + def test_sft_trainer_with_chat_format_qlora(self, model_name, packing): + """ + Simply tests if using setup_chat_format with a transformers model + peft + bnb config to `SFTTrainer` loads and + runs the trainer as expected. + """ + train_dataset = load_dataset("trl-internal-testing/dolly-chatml-sft", split="train") + + training_args = SFTConfig( + packing=packing, + max_length=self.max_length, + output_dir=self.tmp_dir, + logging_strategy="no", + report_to="none", + per_device_train_batch_size=2, + max_steps=10, + ) + + quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16) + + model = AutoModelForCausalLM.from_pretrained( + model_name, dtype="float32", quantization_config=quantization_config + ) + tokenizer = AutoTokenizer.from_pretrained(model_name) + + trainer = SFTTrainer( + model, + args=training_args, + processing_class=tokenizer, + train_dataset=train_dataset, + peft_config=self.peft_config, + ) + + assert isinstance(trainer.model, PeftModel) + + trainer.train() + + release_memory(model, trainer) + + @pytest.mark.parametrize("packing", [True, False]) + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_liger_kernel + def test_sft_trainer_with_liger(self, model_name, packing): + """ + Tests if passing use_liger=True to SFTConfig loads and runs the trainer with AutoLigerKernelForCausalLM as + expected. + """ + import importlib + + def cleanup_liger_patches(trainer): + """Clean up liger_kernel patches by reloading the model's specific module""" + try: + # Get the specific module that was used by the trainer's model + module_path = trainer.model.__module__ + reload_module = importlib.import_module(module_path) + importlib.reload(reload_module) + except Exception: + pass # Continue if reload fails + + training_args = SFTConfig( + output_dir=self.tmp_dir, + logging_strategy="no", + report_to="none", + per_device_train_batch_size=2, + max_steps=2, + packing=packing, + max_length=self.max_length, + use_liger_kernel=True, + ) + + trainer = SFTTrainer( + model_name, + args=training_args, + train_dataset=self.train_dataset, + eval_dataset=self.eval_dataset, + ) + + # Ensure cleanup of liger patches after the test + try: + trainer.train() + release_memory(trainer.model, trainer) + finally: + cleanup_liger_patches(trainer) + + @pytest.mark.parametrize("packing", [True, False]) + @pytest.mark.parametrize( + "model_name", + [ + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + ], + ) + @require_torch_accelerator + def test_train_offloading(self, model_name, packing): + """Test that activation offloading works with SFTTrainer.""" + # Initialize the trainer + training_args = SFTConfig( + output_dir=self.tmp_dir, + activation_offloading=True, + report_to="none", + per_device_train_batch_size=2, + max_steps=2, + packing=packing, + max_length=self.max_length, + ) + trainer = SFTTrainer( + model=model_name, args=training_args, train_dataset=self.train_dataset, eval_dataset=self.eval_dataset + ) + + # Save the initial parameters to compare them later + previous_trainable_params = {n: param.clone() for n, param in trainer.model.named_parameters()} + + # Train the model + trainer.train() + + # Check that the training loss is not None + assert trainer.state.log_history[-1]["train_loss"] is not None + + # Check the params have changed + for n, param in previous_trainable_params.items(): + new_param = trainer.model.get_parameter(n) + assert not torch.allclose(param, new_param), f"Parameter {n} has not changed" + + release_memory(trainer.model, trainer) + + +_CHUNKED_CE_MODEL_IDS = [ + "trl-internal-testing/tiny-CohereForCausalLM", + pytest.param( + "trl-internal-testing/tiny-DeepseekV3ForCausalLM", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="DeepseekV3 SDPA attention is broken in transformers < 5.0.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-DeepseekV3ForCausalLM-0528", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="DeepseekV3 SDPA attention is broken in transformers < 5.0.0", + ), + ), + "trl-internal-testing/tiny-Gemma2ForCausalLM", + "trl-internal-testing/tiny-GemmaForCausalLM", + "trl-internal-testing/tiny-Glm4MoeForCausalLM", + "trl-internal-testing/tiny-GptOssForCausalLM", + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-LlamaForCausalLM-3", + "trl-internal-testing/tiny-MistralForCausalLM-0.1", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + "trl-internal-testing/tiny-Phi3ForCausalLM", + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "trl-internal-testing/tiny-Qwen3ForCausalLM", + "trl-internal-testing/tiny-Qwen3MoeForCausalLM", +] + + +class TestChunkedCrossEntropyLoss: + B, S, H, V = 2, 8, 4, 16 + CHUNK_SIZE = 3 # deliberately small to force multiple chunks and a partial final chunk + + def _inputs(self, seed=0, ignore_positions=None, requires_grad=False): + torch.manual_seed(seed) + hidden = torch.randn(self.B, self.S, self.H, dtype=torch.float32, requires_grad=requires_grad) + weight = torch.randn(self.V, self.H, dtype=torch.float32, requires_grad=requires_grad) + labels = torch.randint(0, self.V, (self.B, self.S)) + if ignore_positions is not None: + labels[:, ignore_positions] = -100 + return hidden, weight, labels + + @staticmethod + def _reference(hidden, weight, labels, num_items_in_batch=None): + shift_h = hidden[..., :-1, :].reshape(-1, hidden.size(-1)) + shift_l = labels[..., 1:].reshape(-1) + logits = shift_h.float() @ weight.float().t() + if num_items_in_batch is None: + loss = F.cross_entropy(logits, shift_l, ignore_index=-100, reduction="mean") + else: + loss = F.cross_entropy(logits, shift_l, ignore_index=-100, reduction="sum") + loss = loss / num_items_in_batch + valid = shift_l != -100 + if valid.any(): + log_p = F.log_softmax(logits, dim=-1) + preds = logits.argmax(dim=-1) + accuracy = (preds[valid] == shift_l[valid]).float().mean() + entropy = -(log_p.exp() * log_p).sum(dim=-1)[valid].mean() + else: + accuracy = torch.zeros((), dtype=torch.float32) + entropy = torch.zeros((), dtype=torch.float32) + return loss, accuracy, entropy + + def test_forward_matches_cross_entropy(self): + """With no ignored tokens, chunked loss equals standard mean cross-entropy.""" + hidden, weight, labels = self._inputs() + n_valid = (labels[..., 1:] != -100).sum() + loss_c, correct_c, ent_sum_c = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels) + loss_r, acc_r, ent_r = self._reference(hidden, weight, labels) + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(correct_c / n_valid, acc_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(ent_sum_c / n_valid, ent_r, atol=1e-5, rtol=1e-5) + + def test_forward_ignore_index(self): + """Ignored labels are excluded from loss, accuracy and entropy (matches F.cross_entropy).""" + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + n_valid = (labels[..., 1:] != -100).sum() + loss_c, correct_c, ent_sum_c = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels) + loss_r, acc_r, ent_r = self._reference(hidden, weight, labels) + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(correct_c / n_valid, acc_r, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(ent_sum_c / n_valid, ent_r, atol=1e-5, rtol=1e-5) + + def test_num_items_in_batch_reduction(self): + """When num_items_in_batch is provided, loss is sum / num_items_in_batch.""" + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + num_items = 5 # arbitrary global denominator, != local valid count + loss_c, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels, num_items_in_batch=num_items) + loss_r, *_ = self._reference(hidden, weight, labels, num_items_in_batch=num_items) + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + + def test_num_items_in_batch_tensor(self): + """A tensor `num_items_in_batch` is accepted and produces the same result as the int form.""" + hidden, weight, labels = self._inputs() + num_items_tensor = torch.tensor(7, dtype=torch.float32) + loss_t, *_ = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, labels, num_items_in_batch=num_items_tensor + ) + loss_i, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels, num_items_in_batch=7) + torch.testing.assert_close(loss_t, loss_i, atol=1e-6, rtol=1e-6) + + def test_backward_matches_reference(self): + """Gradients on hidden_states and lm_head weight match the standard CE path.""" + hidden_c, weight_c, labels = self._inputs(ignore_positions=slice(0, 3), requires_grad=True) + hidden_r = hidden_c.detach().clone().requires_grad_(True) + weight_r = weight_c.detach().clone().requires_grad_(True) + + loss_c, *_ = _chunked_cross_entropy_loss(hidden_c, weight_c, self.CHUNK_SIZE, labels) + loss_c.backward() + + loss_r, *_ = self._reference(hidden_r, weight_r, labels) + loss_r.backward() + + torch.testing.assert_close(hidden_c.grad, hidden_r.grad, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(weight_c.grad, weight_r.grad, atol=1e-5, rtol=1e-5) + + def test_all_ignored_returns_zero(self): + """If every label is ignored, loss/correct/entropy_sum are all zero and backward still works. + + Every trainable parameter of the chunked path (hidden_states, lm_head_weight, and lm_head_bias when present) + must receive a gradient — otherwise DDP / FSDP synchronization hangs or errors at the all-reduce step. + """ + hidden, weight, labels = self._inputs(requires_grad=True) + bias = torch.zeros(self.V, dtype=torch.float32, requires_grad=True) + labels[:] = -100 + loss, correct, ent_sum = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, labels, lm_head_bias=bias + ) + assert loss.item() == 0.0 + assert correct.item() == 0.0 + assert ent_sum.item() == 0.0 + assert not torch.isnan(loss) + # Backward must succeed even when n_valid == 0 (can happen with completion-only loss + # + truncation where a whole micro-batch is masked). + loss.backward() + assert hidden.grad is not None and hidden.grad.abs().sum().item() == 0.0 + assert weight.grad is not None and weight.grad.abs().sum().item() == 0.0 + assert bias.grad is not None and bias.grad.abs().sum().item() == 0.0 + + def test_shift_labels_matches_labels(self): + """`shift_labels` path (CP/SP) must match the default `labels` path after external shifting.""" + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + loss_l, correct_l, ent_l = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels) + # Mimic what transformers does under CP/SP: pad labels with -100, then shift. + shift_labels = F.pad(labels, (0, 1), value=-100)[..., 1:].contiguous() + loss_s, correct_s, ent_s = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, shift_labels=shift_labels + ) + torch.testing.assert_close(loss_s, loss_l, atol=1e-6, rtol=1e-6) + torch.testing.assert_close(correct_s, correct_l, atol=1e-6, rtol=1e-6) + torch.testing.assert_close(ent_s, ent_l, atol=1e-6, rtol=1e-6) + + def test_requires_labels_or_shift_labels(self): + """Must provide at least one of `labels` or `shift_labels`.""" + hidden, weight, _ = self._inputs() + with pytest.raises(ValueError, match="At least one"): + _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE) + + def test_shift_labels_wins_when_both_provided(self): + """When both `labels` and `shift_labels` are provided (Ulysses / CP / SP path), `shift_labels` wins.""" + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + shift_labels = F.pad(labels, (0, 1), value=-100)[..., 1:].contiguous() + # Chunked result with both passed in must match the shift_labels-only path. + loss_both, *_ = _chunked_cross_entropy_loss( + hidden, weight, self.CHUNK_SIZE, labels=labels, shift_labels=shift_labels + ) + loss_shift, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, shift_labels=shift_labels) + torch.testing.assert_close(loss_both, loss_shift, atol=1e-6, rtol=1e-6) + + def test_lm_head_bias(self): + """When `lm_head_bias` is provided, chunked loss matches `F.linear(h, w, b)` followed by CE.""" + hidden, weight, labels = self._inputs(ignore_positions=slice(0, 3)) + torch.manual_seed(1) + bias = torch.randn(self.V, dtype=torch.float32) + + loss_c, *_ = _chunked_cross_entropy_loss(hidden, weight, self.CHUNK_SIZE, labels, lm_head_bias=bias) + + # Reference: full F.linear with bias, then CE over non-ignored shifted positions. + logits_ref = F.linear(hidden[..., :-1, :], weight, bias).reshape(-1, self.V) + labels_ref = labels[..., 1:].reshape(-1) + valid = labels_ref != -100 + loss_r = F.cross_entropy(logits_ref[valid], labels_ref[valid], reduction="mean") + torch.testing.assert_close(loss_c, loss_r, atol=1e-5, rtol=1e-5) + + +@require_torch_accelerator +class TestPatchChunkedCELMHead: + """Patched `forward` must be numerically equivalent to the standard HF causal-LM loss path.""" + + CHUNK_SIZE = 5 # small, to exercise the chunk loop + + def _setup(self, model_id): + ref_model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32).to(torch_device) + chunked_model = copy.deepcopy(ref_model) + _patch_chunked_ce_lm_head(chunked_model, chunk_size=self.CHUNK_SIZE) + + B, S = 2, 16 + torch.manual_seed(42) + input_ids = torch.randint(0, ref_model.config.vocab_size, (B, S), device=torch_device) + labels = input_ids.clone() + labels[:, :4] = -100 # prompt-like mask + num_items = int((labels[..., 1:] != -100).sum()) + return ref_model, chunked_model, input_ids, labels, num_items + + @pytest.mark.parametrize("model_id", _CHUNKED_CE_MODEL_IDS) + def test_forward_matches_reference(self, model_id): + ref_model, chunked_model, input_ids, labels, num_items = self._setup(model_id) + + with torch.no_grad(): + ref_out = ref_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + out = chunked_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + + torch.testing.assert_close(out.loss, ref_out.loss, atol=1e-5, rtol=1e-5) + assert out.logits is None + assert out.num_correct_tokens is not None and out.num_correct_tokens.item() >= 0 + assert out.entropy_sum is not None and out.entropy_sum.item() >= 0.0 + + @pytest.mark.parametrize( + "model_id", + [ + "trl-internal-testing/tiny-Qwen3MoeForCausalLM", + "trl-internal-testing/tiny-GptOssForCausalLM", + ], + ) + def test_forward_matches_reference_with_aux_loss(self, model_id): + """MoE models with `output_router_logits=True` add `router_aux_loss_coef * load_balancing_loss` + to the main loss. The chunked path must match the reference loss and expose `aux_loss`.""" + ref_model = AutoModelForCausalLM.from_pretrained( + model_id, torch_dtype=torch.float32, output_router_logits=True + ).to(torch_device) + chunked_model = copy.deepcopy(ref_model) + _patch_chunked_ce_lm_head(chunked_model, chunk_size=self.CHUNK_SIZE) + + B, S = 2, 16 + torch.manual_seed(42) + input_ids = torch.randint(0, ref_model.config.vocab_size, (B, S), device=torch_device) + labels = input_ids.clone() + labels[:, :4] = -100 + num_items = int((labels[..., 1:] != -100).sum()) + + with torch.no_grad(): + ref_out = ref_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + out = chunked_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + + torch.testing.assert_close(out.loss, ref_out.loss, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(out.aux_loss, ref_out.aux_loss, atol=1e-5, rtol=1e-5) + + @pytest.mark.parametrize("model_id", _CHUNKED_CE_MODEL_IDS) + def test_backward_matches_reference(self, model_id): + ref_model, chunked_model, input_ids, labels, num_items = self._setup(model_id) + + ref_out = ref_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + ref_out.loss.backward() + + out = chunked_model(input_ids=input_ids, labels=labels, num_items_in_batch=num_items) + out.loss.backward() + + # lm_head gradient + torch.testing.assert_close( + chunked_model.lm_head.weight.grad, ref_model.lm_head.weight.grad, atol=1e-5, rtol=1e-5 + ) + # Base decoder gradients + for name, ref_param in ref_model.model.named_parameters(): + if ref_param.grad is None: + continue + chunked_param = chunked_model.model.get_parameter(name) + torch.testing.assert_close( + chunked_param.grad, ref_param.grad, atol=1e-5, rtol=1e-5, msg=f"gradient mismatch on model.{name}" + ) + + def test_forward_without_labels_uses_original_path(self): + """With labels=None the patched forward returns real logits (for generation / eval).""" + _, chunked_model, input_ids, _, _ = self._setup("trl-internal-testing/tiny-LlamaForCausalLM-3.2") + with torch.no_grad(): + out = chunked_model(input_ids=input_ids) + assert out.logits is not None + assert out.logits.shape[-1] == chunked_model.config.vocab_size + + def test_forward_without_labels_matches_reference(self): + """labels=None logits must match the unpatched model, including per-model post-processing + (`final_logit_softcapping`, `logit_scale`, ...). This is what makes `.generate()` safe to call on a patched + model.""" + ref_model, chunked_model, input_ids, *_ = self._setup("trl-internal-testing/tiny-CohereForCausalLM") + with torch.no_grad(): + ref_out = ref_model(input_ids=input_ids) + out = chunked_model(input_ids=input_ids) + torch.testing.assert_close(out.logits, ref_out.logits, atol=1e-5, rtol=1e-5) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_skills.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_skills.py new file mode 100644 index 0000000000000000000000000000000000000000..5486226d3ff3ad9ec9f42191e8ed3a42c940eef0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_skills.py @@ -0,0 +1,584 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path + +import pytest + +from trl.skills import install_skill, list_agent_names, list_skills, resolve_target_path, uninstall_skill +from trl.skills.skills import _get_trl_skills_dir + + +class TestGetTrlSkillsDir: + """Tests for _get_trl_skills_dir function.""" + + def test_returns_path_object(self): + """Test that returns a Path object.""" + skills_dir = _get_trl_skills_dir() + assert isinstance(skills_dir, Path) + + def test_directory_exists(self): + """Test that the returned directory exists.""" + skills_dir = _get_trl_skills_dir() + assert skills_dir.exists(), f"Skills directory does not exist: {skills_dir}" + + def test_is_directory(self): + """Test that the returned path is a directory.""" + skills_dir = _get_trl_skills_dir() + assert skills_dir.is_dir(), f"Skills path is not a directory: {skills_dir}" + + def test_contains_skills_module(self): + """Test that the path ends with 'skills' (the module name).""" + skills_dir = _get_trl_skills_dir() + assert skills_dir.name == "skills" + + +class TestListSkills: + """Tests for list_skills function.""" + + def test_returns_list(self): + """Test that list_skills returns a list.""" + skills = list_skills() + assert isinstance(skills, list) + + def test_contains_trl_training(self): + """Test that list_skills includes the trl-training skill.""" + skills = list_skills() + assert "trl-training" in skills + + def test_skills_are_sorted(self): + """Test that skills are returned in sorted order.""" + skills = list_skills() + assert skills == sorted(skills) + + def test_with_custom_directory(self, tmp_path): + """Test list_skills with a custom directory.""" + # Create fake skills + (tmp_path / "skill1").mkdir() + (tmp_path / "skill1" / "SKILL.md").write_text("# Skill 1") + (tmp_path / "skill2").mkdir() + (tmp_path / "skill2" / "SKILL.md").write_text("# Skill 2") + (tmp_path / "not-a-skill").mkdir() # No SKILL.md + + skills = list_skills(tmp_path) + assert skills == ["skill1", "skill2"] + + def test_empty_directory(self, tmp_path): + """Test list_skills with an empty directory.""" + skills = list_skills(tmp_path) + assert skills == [] + + def test_nonexistent_directory(self, tmp_path): + """Test list_skills with a non-existent directory.""" + nonexistent = tmp_path / "nonexistent" + skills = list_skills(nonexistent) + assert skills == [] + + def test_ignores_files(self, tmp_path): + """Test that list_skills ignores files, only returns directories.""" + (tmp_path / "skill1").mkdir() + (tmp_path / "skill1" / "SKILL.md").write_text("# Skill 1") + (tmp_path / "not-a-skill.txt").write_text("Not a skill") + + skills = list_skills(tmp_path) + assert skills == ["skill1"] + + def test_requires_skill_md(self, tmp_path): + """Test that directories without SKILL.md are ignored.""" + (tmp_path / "has-skill-md").mkdir() + (tmp_path / "has-skill-md" / "SKILL.md").write_text("# Valid") + (tmp_path / "no-skill-md").mkdir() + (tmp_path / "no-skill-md" / "readme.md").write_text("# Invalid") + + skills = list_skills(tmp_path) + assert skills == ["has-skill-md"] + + +class TestInstallSkill: + """Tests for install_skill function.""" + + def test_basic_installation(self, tmp_path): + """Test basic skill installation.""" + target_dir = tmp_path / "target" + + result = install_skill("trl-training", target_dir) + + assert result is True + assert (target_dir / "trl-training").exists() + assert (target_dir / "trl-training" / "SKILL.md").exists() + + def test_creates_target_directory(self, tmp_path): + """Test that install_skill creates the target directory if it doesn't exist.""" + target_dir = tmp_path / "nested" / "target" + + install_skill("trl-training", target_dir) + + assert target_dir.exists() + assert (target_dir / "trl-training").exists() + + def test_skill_not_found(self, tmp_path): + """Test that install_skill raises FileNotFoundError for non-existent skill.""" + target_dir = tmp_path / "target" + + with pytest.raises(FileNotFoundError, match="Skill 'nonexistent' not found"): + install_skill("nonexistent", target_dir) + + def test_skill_already_exists_without_force(self, tmp_path): + """Test that install_skill raises FileExistsError if skill exists and force=False.""" + target_dir = tmp_path / "target" + + # Install once + install_skill("trl-training", target_dir) + + # Try to install again without force + with pytest.raises(FileExistsError, match="already installed"): + install_skill("trl-training", target_dir, force=False) + + def test_force_overwrites_existing(self, tmp_path): + """Test that install_skill with force=True overwrites existing skill.""" + target_dir = tmp_path / "target" + + # Install once + install_skill("trl-training", target_dir) + + # Modify the installed skill + marker_file = target_dir / "trl-training" / "marker.txt" + marker_file.write_text("This should be removed") + + # Install again with force + result = install_skill("trl-training", target_dir, force=True) + + assert result is True + assert (target_dir / "trl-training").exists() + assert not marker_file.exists() # Marker should be gone + + def test_force_overwrites_symlink(self, tmp_path): + """Test that install_skill with force=True can overwrite a symlink.""" + target_dir = tmp_path / "target" + target_dir.mkdir() + + # Create a symlink + symlink = target_dir / "trl-training" + symlink.symlink_to(_get_trl_skills_dir() / "trl-training") + + # Install with force should replace symlink with copy + result = install_skill("trl-training", target_dir, force=True) + + assert result is True + assert (target_dir / "trl-training").exists() + assert not (target_dir / "trl-training").is_symlink() + + def test_skill_not_directory(self, tmp_path): + """Test that install_skill raises ValueError if skill is not a directory.""" + source_dir = tmp_path / "source" + source_dir.mkdir() + target_dir = tmp_path / "target" + + # Create a file instead of directory + (source_dir / "fake-skill").write_text("not a directory") + + with pytest.raises(ValueError, match="is not a directory"): + install_skill("fake-skill", target_dir, source=source_dir) + + def test_preserves_directory_structure(self, tmp_path): + """Test that install_skill preserves the skill's directory structure.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create a skill with subdirectories + skill_dir = source_dir / "test-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Test") + (skill_dir / "subdir").mkdir() + (skill_dir / "subdir" / "file.txt").write_text("content") + + install_skill("test-skill", target_dir, source=source_dir) + + assert (target_dir / "test-skill" / "SKILL.md").exists() + assert (target_dir / "test-skill" / "subdir" / "file.txt").exists() + assert (target_dir / "test-skill" / "subdir" / "file.txt").read_text() == "content" + + def test_install_to_same_directory_fails(self, tmp_path): + """Test that installing to the same directory as source is handled correctly.""" + source_dir = tmp_path / "skills" + source_dir.mkdir() + + # Create a skill + skill_dir = source_dir / "test-skill" + skill_dir.mkdir() + (skill_dir / "SKILL.md").write_text("# Test") + + # Try to install to same directory (should fail with exists error) + with pytest.raises(FileExistsError): + install_skill("test-skill", source_dir, source=source_dir, force=False) + + +class TestUninstallSkill: + """Tests for uninstall_skill function.""" + + def test_basic_uninstallation(self, tmp_path): + """Test basic skill uninstallation.""" + target_dir = tmp_path / "target" + + # Install first + install_skill("trl-training", target_dir) + assert (target_dir / "trl-training").exists() + + # Uninstall + result = uninstall_skill("trl-training", target_dir) + + assert result is True + assert not (target_dir / "trl-training").exists() + + def test_skill_not_installed(self, tmp_path): + """Test that uninstall_skill raises FileNotFoundError for non-existent skill.""" + target_dir = tmp_path / "target" + target_dir.mkdir() + + with pytest.raises(FileNotFoundError, match="not installed"): + uninstall_skill("nonexistent", target_dir) + + def test_uninstall_from_nonexistent_directory(self, tmp_path): + """Test uninstall_skill when target directory doesn't exist.""" + target_dir = tmp_path / "nonexistent" + + with pytest.raises(FileNotFoundError, match="not installed"): + uninstall_skill("trl-training", target_dir) + + def test_uninstall_removes_all_contents(self, tmp_path): + """Test that uninstall removes the entire skill directory.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create a skill with multiple files + skill_dir = source_dir / "test-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Test") + (skill_dir / "file1.txt").write_text("content1") + (skill_dir / "subdir").mkdir() + (skill_dir / "subdir" / "file2.txt").write_text("content2") + + # Install and uninstall + install_skill("test-skill", target_dir, source=source_dir) + uninstall_skill("test-skill", target_dir) + + assert not (target_dir / "test-skill").exists() + # Target directory itself should still exist + assert target_dir.exists() + + def test_uninstall_doesnt_affect_other_skills(self, tmp_path): + """Test that uninstalling one skill doesn't affect others.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create two skills + for skill_name in ["skill1", "skill2"]: + skill_dir = source_dir / skill_name + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text(f"# {skill_name}") + + # Install both + install_skill("skill1", target_dir, source=source_dir) + install_skill("skill2", target_dir, source=source_dir) + + # Uninstall one + uninstall_skill("skill1", target_dir) + + # Check that only skill1 is removed + assert not (target_dir / "skill1").exists() + assert (target_dir / "skill2").exists() + + +class TestIntegration: + """Integration tests for skills functions.""" + + def test_full_workflow(self, tmp_path): + """Test complete install -> list -> uninstall workflow.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create skills + for i in range(3): + skill_dir = source_dir / f"skill{i}" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text(f"# Skill {i}") + + # List available skills + available = list_skills(target=source_dir) + assert available == ["skill0", "skill1", "skill2"] + + # Install skills + for skill in available: + install_skill(skill, target_dir, source=source_dir) + + # List installed skills + installed_dirs = [d.name for d in target_dir.iterdir() if d.is_dir()] + assert sorted(installed_dirs) == ["skill0", "skill1", "skill2"] + + # Uninstall one skill + uninstall_skill("skill1", target_dir) + + # Verify + installed_dirs = [d.name for d in target_dir.iterdir() if d.is_dir()] + assert sorted(installed_dirs) == ["skill0", "skill2"] + + def test_install_uninstall_cycle(self, tmp_path): + """Test that we can install and uninstall the same skill multiple times.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create skill + skill_dir = source_dir / "test-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Test") + + # Install -> Uninstall -> Install -> Uninstall + for _ in range(2): + install_skill("test-skill", target_dir, source=source_dir) + assert (target_dir / "test-skill").exists() + + uninstall_skill("test-skill", target_dir) + assert not (target_dir / "test-skill").exists() + + def test_force_reinstall_workflow(self, tmp_path): + """Test the workflow of using force to update an installed skill.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create initial skill version + skill_dir = source_dir / "test-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Version 1") + + # Install + install_skill("test-skill", target_dir, source=source_dir) + assert (target_dir / "test-skill" / "SKILL.md").read_text() == "# Version 1" + + # Update source skill + (skill_dir / "SKILL.md").write_text("# Version 2") + + # Force reinstall + install_skill("test-skill", target_dir, source=source_dir, force=True) + assert (target_dir / "test-skill" / "SKILL.md").read_text() == "# Version 2" + + +class TestEdgeCases: + """Tests for edge cases and special scenarios.""" + + def test_skill_with_special_characters_in_name(self, tmp_path): + """Test handling skills with special characters in names.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create skill with hyphens and underscores (common in skill names) + skill_name = "test-skill_v2" + skill_dir = source_dir / skill_name + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Test") + + # Should work fine + install_skill(skill_name, target_dir, source=source_dir) + assert (target_dir / skill_name).exists() + + uninstall_skill(skill_name, target_dir) + assert not (target_dir / skill_name).exists() + + def test_empty_skill_directory(self, tmp_path): + """Test installing a skill with only SKILL.md (no other files).""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + skill_dir = source_dir / "minimal-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Minimal") + + install_skill("minimal-skill", target_dir, source=source_dir) + + assert (target_dir / "minimal-skill" / "SKILL.md").exists() + # Should only contain SKILL.md + files = list((target_dir / "minimal-skill").iterdir()) + assert len(files) == 1 + assert files[0].name == "SKILL.md" + + def test_skill_with_hidden_files(self, tmp_path): + """Test that hidden files are preserved during installation.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + skill_dir = source_dir / "test-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Test") + (skill_dir / ".hidden").write_text("hidden content") + + install_skill("test-skill", target_dir, source=source_dir) + + assert (target_dir / "test-skill" / ".hidden").exists() + assert (target_dir / "test-skill" / ".hidden").read_text() == "hidden content" + + def test_list_skills_with_symlinks(self, tmp_path): + """Test that list_skills handles symlinked skill directories.""" + source_dir = tmp_path / "source" + skills_dir = tmp_path / "skills" + skills_dir.mkdir() + + # Create a real skill + skill_dir = source_dir / "real-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Real") + + # Create symlink to it + (skills_dir / "linked-skill").symlink_to(skill_dir) + + # list_skills should include symlinked skills if they have SKILL.md + skills = list_skills(target=skills_dir) + assert "linked-skill" in skills + + +class TestListAgentNames: + """Tests for list_agent_names function.""" + + def test_returns_list(self): + """Test that list_agent_names returns a list.""" + agents = list_agent_names() + assert isinstance(agents, list) + + def test_contains_expected_agents(self): + """Test that list includes expected agent names.""" + agents = list_agent_names() + assert "claude" in agents + assert "codex" in agents + assert "opencode" in agents + + def test_agents_are_sorted(self): + """Test that agent names are sorted.""" + agents = list_agent_names() + assert agents == sorted(agents) + + +class TestResolveTargetPath: + """Tests for resolve_target_path function.""" + + def test_resolve_agent_name_project_scope(self): + """Test resolving agent name with project scope.""" + path = resolve_target_path("claude", "project") + assert path == Path("./.claude/skills").expanduser().resolve() + + def test_resolve_agent_name_global_scope(self): + """Test resolving agent name with global scope.""" + path = resolve_target_path("claude", "global") + assert path == Path("~/.claude/skills").expanduser().resolve() + + def test_resolve_custom_path_string(self): + """Test resolving custom path as string.""" + path = resolve_target_path("/custom/path", "project") + assert path == Path("/custom/path").resolve() + + def test_resolve_custom_path_object(self): + """Test resolving Path object.""" + custom = Path("/custom/path") + path = resolve_target_path(custom, "project") + assert path == Path("/custom/path").resolve() + + def test_resolve_path_with_tilde(self): + """Test that tilde expansion works.""" + path = resolve_target_path("~/my/skills", "project") + assert path == Path("~/my/skills").expanduser().resolve() + assert "~" not in str(path) + + def test_all_predefined_agents(self): + """Test that all predefined agents can be resolved.""" + for agent in list_agent_names(): + for scope in ["project", "global"]: + path = resolve_target_path(agent, scope) + assert isinstance(path, Path) + assert path.is_absolute() + + def test_invalid_scope_for_predefined_agent(self): + """Test invalid scope raises ValueError for predefined agents.""" + with pytest.raises(ValueError, match="Invalid scope"): + resolve_target_path("claude", "invalid") + + +class TestHighLevelAPI: + """Tests for the new high-level API (target/scope instead of Path).""" + + def test_list_skills_with_target_string(self, tmp_path): + """Test list_skills with target as string (custom path).""" + # Create skills in target + (tmp_path / "skill1").mkdir() + (tmp_path / "skill1" / "SKILL.md").write_text("# Skill 1") + + skills = list_skills(target=str(tmp_path), scope="project") + assert skills == ["skill1"] + + def test_list_skills_with_target_path(self, tmp_path): + """Test list_skills with target as Path object.""" + (tmp_path / "skill1").mkdir() + (tmp_path / "skill1" / "SKILL.md").write_text("# Skill 1") + + skills = list_skills(target=tmp_path, scope="project") + assert skills == ["skill1"] + + def test_list_skills_without_target(self): + """Test list_skills without target lists TRL's built-in skills.""" + skills = list_skills() + assert isinstance(skills, list) + assert "trl-training" in skills + + def test_install_skill_with_target_string(self, tmp_path): + """Test install_skill with target as string.""" + result = install_skill("trl-training", target=str(tmp_path), scope="project") + assert result is True + assert (tmp_path / "trl-training").exists() + + def test_install_skill_with_target_path(self, tmp_path): + """Test install_skill with target as Path object.""" + result = install_skill("trl-training", target=tmp_path, scope="project") + assert result is True + assert (tmp_path / "trl-training").exists() + + def test_install_skill_with_force(self, tmp_path): + """Test install_skill with force parameter.""" + install_skill("trl-training", target=tmp_path) + # Install again with force + result = install_skill("trl-training", target=tmp_path, force=True) + assert result is True + + def test_uninstall_skill_with_target_string(self, tmp_path): + """Test uninstall_skill with target as string.""" + install_skill("trl-training", target=tmp_path) + result = uninstall_skill("trl-training", target=str(tmp_path), scope="project") + assert result is True + assert not (tmp_path / "trl-training").exists() + + def test_uninstall_skill_with_target_path(self, tmp_path): + """Test uninstall_skill with target as Path object.""" + install_skill("trl-training", target=tmp_path) + result = uninstall_skill("trl-training", target=tmp_path, scope="project") + assert result is True + assert not (tmp_path / "trl-training").exists() + + def test_install_with_custom_source(self, tmp_path): + """Test install_skill with custom source parameter.""" + source_dir = tmp_path / "source" + target_dir = tmp_path / "target" + + # Create custom skill + skill_dir = source_dir / "custom-skill" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text("# Custom") + + result = install_skill("custom-skill", target=target_dir, source=source_dir) + assert result is True + assert (target_dir / "custom-skill").exists() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_skills_cli.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_skills_cli.py new file mode 100644 index 0000000000000000000000000000000000000000..a8b29439800cd8fcabbbc45e3588e920869820ab --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_skills_cli.py @@ -0,0 +1,289 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse + +import pytest + +from trl.skills import install_skill +from trl.skills.cli import add_skills_subcommands, cmd_install, cmd_list, cmd_uninstall + + +class TestCLICommands: + """Tests for CLI command handlers.""" + + def test_cmd_list_without_target(self, capsys): + """Test cmd_list without target (lists TRL skills).""" + args = argparse.Namespace(target=None, scope="project") + + result = cmd_list(args) + + captured = capsys.readouterr() + assert result == 0 + assert "TRL (available for installation)" in captured.out + assert "trl-training" in captured.out + assert "Use 'trl skills install" in captured.out + + def test_cmd_list_with_target(self, tmp_path, capsys): + """Test cmd_list with target (lists installed skills).""" + # Install a skill + install_skill("trl-training", target=tmp_path) + + args = argparse.Namespace(target=str(tmp_path), scope="project") + result = cmd_list(args) + + captured = capsys.readouterr() + assert result == 0 + assert "trl-training" in captured.out + assert str(tmp_path) in captured.out + + def test_cmd_list_empty_target(self, tmp_path, capsys): + """Test cmd_list with empty target directory.""" + args = argparse.Namespace(target=str(tmp_path), scope="project") + + result = cmd_list(args) + + captured = capsys.readouterr() + assert result == 0 + assert "No skills installed" in captured.out + + def test_cmd_install_single_skill(self, tmp_path, capsys): + """Test cmd_install with single skill.""" + args = argparse.Namespace(skill="trl-training", all=False, target=str(tmp_path), scope="project", force=False) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 0 + assert "✓" in captured.out + assert "1/1 skills installed" in captured.out + assert (tmp_path / "trl-training").exists() + + def test_cmd_install_all_skills(self, tmp_path, capsys): + """Test cmd_install with --all flag.""" + args = argparse.Namespace(skill=None, all=True, target=str(tmp_path), scope="project", force=False) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 0 + assert "✓" in captured.out + assert "installed successfully" in captured.out + assert (tmp_path / "trl-training").exists() + + def test_cmd_install_no_skill_or_all(self, capsys): + """Test cmd_install without skill name or --all flag.""" + args = argparse.Namespace(skill=None, all=False, target="/tmp/test", scope="project", force=False) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 1 + assert "Error: Either provide a skill name or use --all" in captured.out + + def test_cmd_install_both_skill_and_all(self, capsys): + """Test cmd_install with both skill name and --all (error).""" + args = argparse.Namespace(skill="trl-training", all=True, target="/tmp/test", scope="project", force=False) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 1 + assert "Cannot specify both" in captured.out + + def test_cmd_install_nonexistent_skill(self, tmp_path, capsys): + """Test cmd_install with non-existent skill.""" + args = argparse.Namespace(skill="nonexistent", all=False, target=str(tmp_path), scope="project", force=False) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 1 + assert "✗" in captured.out + assert "0/1 skills installed" in captured.out + + def test_cmd_install_already_exists(self, tmp_path, capsys): + """Test cmd_install when skill already exists without force.""" + # Install once + install_skill("trl-training", target=tmp_path) + + args = argparse.Namespace(skill="trl-training", all=False, target=str(tmp_path), scope="project", force=False) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 1 + assert "✗" in captured.out + assert "Use --force to overwrite" in captured.out + + def test_cmd_install_with_force(self, tmp_path, capsys): + """Test cmd_install with --force to overwrite.""" + # Install once + install_skill("trl-training", target=tmp_path) + + args = argparse.Namespace(skill="trl-training", all=False, target=str(tmp_path), scope="project", force=True) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 0 + assert "✓" in captured.out + assert "1/1 skills installed" in captured.out + + def test_cmd_uninstall_success(self, tmp_path, capsys): + """Test cmd_uninstall with installed skill.""" + # Install first + install_skill("trl-training", target=tmp_path) + + args = argparse.Namespace(skill="trl-training", target=str(tmp_path), scope="project") + + result = cmd_uninstall(args) + + captured = capsys.readouterr() + assert result == 0 + assert "✓" in captured.out + assert "has been removed" in captured.out + assert not (tmp_path / "trl-training").exists() + + def test_cmd_uninstall_not_installed(self, tmp_path, capsys): + """Test cmd_uninstall when skill is not installed.""" + args = argparse.Namespace(skill="nonexistent", target=str(tmp_path), scope="project") + + result = cmd_uninstall(args) + + captured = capsys.readouterr() + assert result == 1 + assert "✗" in captured.out + assert "Error:" in captured.out + + def test_cmd_install_creates_target_directory(self, tmp_path, capsys): + """Test cmd_install creates target directory if it doesn't exist.""" + # Custom path that doesn't exist yet + target_path = tmp_path / "new_directory" + assert not target_path.exists() + + args = argparse.Namespace( + skill="trl-training", all=False, target=str(target_path), scope="project", force=False + ) + + result = cmd_install(args) + + captured = capsys.readouterr() + assert result == 0 + assert "✓" in captured.out + assert target_path.exists() + + def test_cmd_uninstall_invalid_target(self, capsys): + """Test cmd_uninstall with non-existent path.""" + args = argparse.Namespace(skill="trl-training", target="/nonexistent/invalid/path", scope="project") + + result = cmd_uninstall(args) + + captured = capsys.readouterr() + assert result == 1 + assert "✗" in captured.out + + +class TestCLIArgumentParsing: + """Tests for CLI argument parsing setup.""" + + def test_add_skills_subcommands_creates_parsers(self): + """Test that add_skills_subcommands creates the expected subparsers.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + + add_skills_subcommands(subparsers) + + # Test that we can parse expected commands + args = parser.parse_args(["list"]) + assert args.command == "list" + assert hasattr(args, "func") + + args = parser.parse_args(["install", "trl-training", "--target", "claude"]) + assert args.command == "install" + assert args.skill == "trl-training" + assert args.target == "claude" + + args = parser.parse_args(["uninstall", "trl-training", "--target", "claude"]) + assert args.command == "uninstall" + assert args.skill == "trl-training" + + def test_list_command_optional_target(self): + """Test that list command has optional target.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + add_skills_subcommands(subparsers) + + # Should work without target + args = parser.parse_args(["list"]) + assert args.target is None + + # Should work with target + args = parser.parse_args(["list", "--target", "claude"]) + assert args.target == "claude" + + def test_install_command_requires_target(self): + """Test that install command requires target.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + add_skills_subcommands(subparsers) + + # Should fail without target + with pytest.raises(SystemExit): + parser.parse_args(["install", "trl-training"]) + + def test_scope_choices(self): + """Test that scope parameter accepts valid choices.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + add_skills_subcommands(subparsers) + + # Valid scopes + args = parser.parse_args(["install", "trl-training", "--target", "claude", "--scope", "project"]) + assert args.scope == "project" + + args = parser.parse_args(["install", "trl-training", "--target", "claude", "--scope", "global"]) + assert args.scope == "global" + + # Invalid scope should fail + with pytest.raises(SystemExit): + parser.parse_args(["install", "trl-training", "--target", "claude", "--scope", "invalid"]) + + def test_install_all_flag(self): + """Test install --all flag.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + add_skills_subcommands(subparsers) + + args = parser.parse_args(["install", "--all", "--target", "claude"]) + assert args.all is True + assert args.skill is None + + def test_install_force_flag(self): + """Test install --force flag.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + add_skills_subcommands(subparsers) + + args = parser.parse_args(["install", "trl-training", "--target", "claude", "--force"]) + assert args.force is True + + def test_default_scope_is_project(self): + """Test that default scope is 'project'.""" + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command") + add_skills_subcommands(subparsers) + + args = parser.parse_args(["install", "trl-training", "--target", "claude"]) + assert args.scope == "project" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..093c4e4004f054a4b8a55869da6a19378745c366 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_utils.py @@ -0,0 +1,1284 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +import textwrap +from io import StringIO +from unittest.mock import patch + +import pytest +import torch +import torch.nn as nn +import torch.nn.functional as F +import transformers +from packaging.version import Version +from transformers import AutoModelForCausalLM +from transformers.testing_utils import torch_device +from transformers.utils import is_peft_available + +from trl import ModelConfig +from trl.trainer.utils import ( + RepeatSampler, + _ChunkedLogProbFunction, + entropy_from_logits, + flush_left, + generate_model_card, + get_peft_config, + hash_module, + nanstd, + pad, + patch_chunked_lm_head, + print_prompt_completions_sample, + selective_log_softmax, + shuffle_sequence_dict, + split_pixel_values_by_grid, + split_tensor_dict, + unsplit_pixel_values_by_grid, + use_adapter, +) + +from .testing_utils import TrlTestCase, require_peft, require_rich, require_torch_accelerator + + +if is_peft_available(): + from peft import AutoPeftModelForCausalLM, LoraConfig + + +@require_peft +class TestUseAdapter(TrlTestCase): + def test_disables_on_none(self): + model = AutoPeftModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-PeftModel", adapter_name="my_adapter" + ) + input_ids = torch.tensor([[1, 2, 3], [4, 5, 6]]) + with model.disable_adapter(): + expected = model(input_ids).logits + + with use_adapter(model, None): + output = model(input_ids).logits + + assert torch.equal(output, expected) + + def test_restores_previous_adapter(self): + model = AutoPeftModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-PeftModel", adapter_name="my_adapter" + ) + input_ids = torch.tensor([[1, 2, 3], [4, 5, 6]]) + expected = model(input_ids).logits + with use_adapter(model, "my_adapter"): + pass + output = model(input_ids).logits + assert torch.equal(output, expected) + + with use_adapter(model, None): + pass + output = model(input_ids).logits + assert torch.equal(output, expected) + + def test_with_multiple_adapters(self): + model = AutoPeftModelForCausalLM.from_pretrained( + "trl-internal-testing/tiny-PeftModel", adapter_name="my_adapter_1" + ) + model.load_adapter("trl-internal-testing/tiny-PeftModel-2", "my_adapter_2") + input_ids = torch.tensor([[1, 2, 3], [4, 5, 6]]) + + model.set_adapter("my_adapter_1") # should be a no-op, but let's keep it for clarity + expected_1 = model(input_ids).logits + model.set_adapter("my_adapter_2") + expected_2 = model(input_ids).logits + + with use_adapter(model, "my_adapter_1"): + output_1 = model(input_ids).logits + + with use_adapter(model, "my_adapter_2"): + output_2 = model(input_ids).logits + + assert torch.equal(output_1, expected_1) + assert torch.equal(output_2, expected_2) + + +class TestPad(TrlTestCase): + def test_pad_1_dim_left(self): + x = torch.tensor([1, 2, 3]) + y = torch.tensor([4, 5]) + output = pad((x, y), padding_value=0, padding_side="left") + expected = torch.tensor([[1, 2, 3], [0, 4, 5]]) + assert torch.equal(output, expected) + + def test_pad_1_dim_right(self): + x = torch.tensor([1, 2, 3]) + y = torch.tensor([4, 5]) + output = pad((x, y), padding_value=0, padding_side="right") + expected = torch.tensor([[1, 2, 3], [4, 5, 0]]) + assert torch.equal(output, expected) + + def test_pad_2_dim_left(self): + x = torch.tensor([[1, 2], [3, 4]]) + y = torch.tensor([[5, 6]]) + output = pad((x, y), padding_value=0, padding_side="left") + expected = torch.tensor( + [ + [[1, 2], [3, 4]], + [[0, 0], [5, 6]], + ] + ) + assert torch.equal(output, expected) + + def test_pad_2_dim_right(self): + x = torch.tensor([[1, 2], [3, 4]]) + y = torch.tensor([[5, 6]]) + output = pad((x, y), padding_value=0, padding_side="right") + expected = torch.tensor( + [ + [[1, 2], [3, 4]], + [[5, 6], [0, 0]], + ] + ) + assert torch.equal(output, expected) + + def test_pad_2_dim_right_multidim(self): + x = torch.tensor([[1, 2], [3, 4]]) + y = torch.tensor([[5]]) + output = pad((x, y), padding_value=0, padding_side="right") + expected = torch.tensor( + [ + [[1, 2], [3, 4]], + [[5, 0], [0, 0]], + ] + ) + assert torch.equal(output, expected) + + def test_pad_to_multiple_of_1(self): + x = torch.tensor([1, 2, 3]) + y = torch.tensor([4, 5]) + # Max length is 3, pad to multiple of 4 + output = pad((x, y), padding_value=0, padding_side="right", pad_to_multiple_of=4) + expected = torch.tensor([[1, 2, 3, 0], [4, 5, 0, 0]]) + assert torch.equal(output, expected) + + def test_pad_to_multiple_of_2(self): + x = torch.tensor([1, 2, 3, 4, 5]) + y = torch.tensor([6, 7, 8]) + # Max length is 3, pad to multiple of 4 + output = pad((x, y), padding_value=0, padding_side="right", pad_to_multiple_of=4) + expected = torch.tensor([[1, 2, 3, 4, 5, 0, 0, 0], [6, 7, 8, 0, 0, 0, 0, 0]]) + assert torch.equal(output, expected) + + def test_pad_to_multiple_of_side_left(self): + x = torch.tensor([1, 2, 3, 4, 5]) + y = torch.tensor([6, 7, 8]) + # Max length is 3, pad to multiple of 4 + output = pad((x, y), padding_value=0, padding_side="left", pad_to_multiple_of=4) + expected = torch.tensor([[0, 0, 0, 1, 2, 3, 4, 5], [0, 0, 0, 0, 0, 6, 7, 8]]) + assert torch.equal(output, expected) + + def test_pad_to_multiple_of_no_extra_padding(self): + x = torch.tensor([1, 2, 3, 4]) + y = torch.tensor([5, 6, 7, 8]) + # Already multiple of 4 + output = pad((x, y), padding_value=0, padding_side="left", pad_to_multiple_of=4) + expected = torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]]) + assert torch.equal(output, expected) + + +class TestHashModule(TrlTestCase): + def test_hash_module_deterministic_across_order(self): + class ModAB(torch.nn.Module): + def __init__(self, a: torch.Tensor, b: torch.Tensor): + super().__init__() + self.a = torch.nn.Parameter(a) + self.b = torch.nn.Parameter(b) + + class ModBA(torch.nn.Module): + def __init__(self, a: torch.Tensor, b: torch.Tensor): + super().__init__() + self.b = torch.nn.Parameter(b) + self.a = torch.nn.Parameter(a) + + a = torch.tensor([[1.0, 2.0]]) + b = torch.tensor([3.0]) + assert hash_module(ModAB(a, b)) == hash_module(ModBA(a, b)) + + def test_hash_module_changes_with_value(self): + class Mod(torch.nn.Module): + def __init__(self, value: float): + super().__init__() + self.weight = torch.nn.Parameter(torch.tensor([value, 2.0])) + + assert hash_module(Mod(1.0)) != hash_module(Mod(1.5)) + + def test_hash_module_includes_dtype(self): + class Mod(torch.nn.Module): + def __init__(self, dtype: torch.dtype): + super().__init__() + self.weight = torch.nn.Parameter(torch.tensor([1.0, 2.0], dtype=dtype)) + + assert hash_module(Mod(torch.float32)) != hash_module(Mod(torch.float16)) + + def test_hash_module_tiny_model_twice(self): + model_id = "trl-internal-testing/tiny-GptOssForCausalLM" + model_a = AutoModelForCausalLM.from_pretrained(model_id) + model_b = AutoModelForCausalLM.from_pretrained(model_id) + assert hash_module(model_a) == hash_module(model_b) + + def test_hash_module_tiny_model_change_layer(self): + model_id = "trl-internal-testing/tiny-GptOssForCausalLM" + model = AutoModelForCausalLM.from_pretrained(model_id) + h1 = hash_module(model) + with torch.no_grad(): + model.lm_head.weight.add_(0.01) + h2 = hash_module(model) + assert h1 != h2 + + +@require_peft +class TestGetPEFTConfig(TrlTestCase): + def test_create_peft_config_use_peft_false(self): + """Test that when use_peft is False, the function returns None.""" + model_args = ModelConfig(use_peft=False) + peft_config = get_peft_config(model_args) + assert peft_config is None + + def test_create_peft_config_use_peft_true(self): + """Test that when use_peft is True, the function returns a LoraConfig object.""" + # Provide non-default values to the model config for testing + peft_kwargs = { + "lora_r": 8, + "lora_alpha": 16, + "lora_dropout": 0.1, + "lora_task_type": "SEQ_CLS", + "use_rslora": True, + "lora_target_modules": ["up_proj", "down_proj"], + "lora_modules_to_save": ["up_proj"], + } + model_args = ModelConfig(use_peft=True, **peft_kwargs) + peft_config = get_peft_config(model_args) + assert isinstance(peft_config, LoraConfig) + for arg, value in peft_kwargs.items(): + # Test that lists of modules are converted to sets + if arg == "lora_target_modules": + value = set(value) + # Rename the argument to match the LoraConfig attribute name + if arg in ["lora_r", "lora_task_type", "lora_target_modules", "lora_modules_to_save"]: + arg = arg[len("lora_") :] if arg.startswith("lora_") else arg + + assert getattr(peft_config, arg) == value + + +class TestNanStd(TrlTestCase): + def test_nanstd_ignores_nans(self): + x = torch.tensor([1.0, 2.0, 3.0, float("nan")]) + result = nanstd(x) + torch.testing.assert_close(result, torch.tensor(1.0)) + + def test_nanstd_dim_and_keepdim(self): + x = torch.tensor([[1.0, float("nan")], [3.0, 5.0]]) + result = nanstd(x, dim=1, keepdim=True) + assert torch.isnan(result[0, 0]) + torch.testing.assert_close(result[1, 0], torch.tensor(1.4142135), rtol=1e-5, atol=1e-6) + + def test_nanstd_all_nan(self): + x = torch.tensor([float("nan"), float("nan")]) + result = nanstd(x) + assert torch.isnan(result) + + +class TestGenerateModelCard(TrlTestCase): + def test_full(self): + model_card = generate_model_card( + base_model="username/my_base_model", + model_name="my_model", + hub_model_id="username/my_hub_model", + dataset_name="username/my_dataset", + tags=["trl", "trainer-tag"], + wandb_url="https://wandb.ai/username/project_id/runs/abcd1234", + trackio_url="https://huggingface.co/spaces/username/space_id", + comet_url="https://www.comet.com/username/project_id/experiment_id", + trainer_name="My Trainer", + trainer_citation="@article{my_trainer, ...}", + paper_title="My Paper", + paper_id="1234.56789", + ) + card_text = str(model_card) + assert "[username/my_base_model](https://huggingface.co/username/my_base_model)" in card_text + assert "my_model" in card_text + assert 'pipeline("text-generation", model="username/my_hub_model", device="cuda")' in card_text + assert "datasets: username/my_dataset" in card_text + assert "](https://wandb.ai/username/project_id/runs/abcd1234)" in card_text + assert "](https://huggingface.co/spaces/username/space_id)" in card_text + assert "](https://www.comet.com/username/project_id/experiment_id" in card_text + assert "My Trainer" in card_text + assert "```bibtex\n@article{my_trainer, ...}\n```" in card_text + assert "[My Paper](https://huggingface.co/papers/1234.56789)" in card_text + + def test_val_none(self): + model_card = generate_model_card( + base_model=None, + model_name="my_model", + hub_model_id="username/my_hub_model", + dataset_name=None, + tags=[], + wandb_url=None, + trackio_url=None, + comet_url=None, + trainer_name="My Trainer", + trainer_citation=None, + paper_title=None, + paper_id=None, + ) + card_text = str(model_card) + assert "my_model" in card_text + assert 'pipeline("text-generation", model="username/my_hub_model", device="cuda")' in card_text + assert "My Trainer" in card_text + + +class TestFlushLeft(TrlTestCase): + def test_basic_case(self): + mask = torch.tensor([[0, 0, 1, 1, 1], [0, 1, 1, 0, 0]]) + tensor1 = torch.tensor([[0, 0, 2, 3, 4], [0, 5, 6, 0, 0]]) + tensor2 = torch.tensor([[0, 0, 7, 8, 9], [0, 10, 11, 0, 0]]) + new_mask, new_tensor1, new_tensor2 = flush_left(mask, tensor1, tensor2) + + expected_mask = torch.tensor([[1, 1, 1], [1, 1, 0]]) + expected_tensor1 = torch.tensor([[2, 3, 4], [5, 6, 0]]) + expected_tensor2 = torch.tensor([[7, 8, 9], [10, 11, 0]]) + + assert torch.equal(new_mask, expected_mask) + assert torch.equal(new_tensor1, expected_tensor1) + assert torch.equal(new_tensor2, expected_tensor2) + + def test_single_row(self): + mask = torch.tensor([[0, 0, 1, 1]]) + tensor1 = torch.tensor([[0, 0, 2, 3]]) + new_mask, new_tensor1 = flush_left(mask, tensor1) + + expected_mask = torch.tensor([[1, 1]]) + expected_tensor1 = torch.tensor([[2, 3]]) + + assert torch.equal(new_mask, expected_mask) + assert torch.equal(new_tensor1, expected_tensor1) + + def test_no_shift_needed(self): + mask = torch.tensor([[1, 1, 0, 0], [1, 0, 0, 0]]) + tensor1 = torch.tensor([[5, 6, 0, 0], [7, 0, 0, 0]]) + new_mask, new_tensor1 = flush_left(mask, tensor1) + + expected_mask = torch.tensor([[1, 1], [1, 0]]) + expected_tensor1 = torch.tensor([[5, 6], [7, 0]]) + + assert torch.equal(new_mask, expected_mask) + assert torch.equal(new_tensor1, expected_tensor1) + + def test_no_tensors(self): + mask = torch.tensor([[0, 0, 1, 1, 1], [0, 1, 1, 0, 0]]) + new_mask = flush_left(mask) + expected_mask = torch.tensor([[1, 1, 1], [1, 1, 0]]) + assert torch.equal(new_mask, expected_mask) + + +class TestRepeatRandomSampler(TrlTestCase): + def test_sampler(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=2) + # Should output something like [4, 4, 3, 3, 0, 0, 1, 1, 2, 2, 6, 6, 5, 5] + sampled = list(sampler) + # Check that the length is doubled + assert len(sampled) == 2 * len(dataset) + # Check that all indexes are present + assert set(sampled) == set(range(len(dataset))) + # Check that each element is repeated twice + assert all(sampled[i] == sampled[i + 1] for i in range(0, len(sampled), 2)) + + def test_sampler_no_shuffle(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=2, shuffle=False) + sampled = list(sampler) + expected = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6] + assert sampled == expected + + def test_sampler_no_repeat(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=1) + # Should output something like [4, 3, 0, 1, 2, 6, 5] + sampled = list(sampler) + # Check that the length is the same + assert len(sampled) == len(dataset) + # Check that all indexes are present + assert set(sampled) == set(range(len(dataset))) + + def test_sampler_with_batch_size(self): + dataset = ["a", "b", "c", "d", "e", "f", "g", "h"] + sampler = RepeatSampler(dataset, mini_repeat_count=1, batch_size=2, repeat_count=2) + # Should output something like [4, 3, 4, 3, 0, 1, 0, 1, 2, 6, 2, 6, 5, 7, 5, 7] + sampled = list(sampler) + # Check that the length is doubled + assert len(sampled) == 2 * len(dataset) + # Check that all indexes are present + assert set(sampled) == set(range(len(dataset))) + # Check that each element is repeated as expected + assert all(sampled[i : i + 1] == sampled[i + 2 : i + 3] for i in range(0, len(sampled), 4)) + + def test_sampler_with_batch_size_and_drop(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=1, batch_size=2, repeat_count=2) + # Should output something like [4, 3, 4, 3, 0, 1, 0, 1, 2, 6, 2, 6] + sampled = list(sampler) + # Check that the length is doubled + assert len(sampled) == 2 * ( + len(dataset) - 1 + ) # one element is dropped, because it's not enough to form a batch + assert len(sampler) == len(sampled) # the length should be the same as the sampled length + # Check that the sampled indexes are a subset of the dataset indexes + assert set(sampled).issubset(set(range(len(dataset)))) + # Check that each element is repeated as expected + assert all(sampled[i : i + 1] == sampled[i + 2 : i + 3] for i in range(0, len(sampled), 4)) + + def test_sampler_with_mini_repeat_count_and_batch_size_1(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=2, batch_size=3, repeat_count=2) + # Should output something like [4, 4, 3, 3, 0, 0, 4, 4, 3, 3, 0, 0, + # 1, 1, 2, 2, 6, 6, 1, 1, 2, 2, 6, 6] + sampled = list(sampler) + # Check that the length is quadrupled + assert len(sampled) == 4 * (len(dataset) - 1) # 1 element is dropped, because it's not enough to form a batch + assert len(sampler) == len(sampled) # the length should be the same as the sampled length + # Check that the sampled indexes are a subset of the dataset indexes + assert set(sampled).issubset(set(range(len(dataset)))) + # Check that each element is repeated as expected + assert all(sampled[i] == sampled[i + 1] for i in range(0, len(sampled), 2)) + # Check that the batch is repeated as expected + assert sampled[0:6] == sampled[6:12] + assert sampled[12:18] == sampled[18:24] + + def test_sampler_with_mini_repeat_count_and_batch_size_2(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=3, batch_size=2, repeat_count=2) + # Should output something like [4, 4, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, + # 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, + # 2, 2, 2, 6, 6, 6, 2, 2, 2, 6, 6, 6] + sampled = list(sampler) + # Check that the length is sextupled + assert len(sampled) == 6 * (len(dataset) - 1) # 1 element is dropped, because it's not enough to form a batch + assert len(sampler) == len(sampled) # the length should be the same as the sampled length + # Check that the sampled indexes are a subset of the dataset indexes + assert set(sampled).issubset(set(range(len(dataset)))) + # Check that each element is repeated as expected + assert all(sampled[i] == sampled[i + 1] == sampled[i + 2] for i in range(0, len(sampled), 3)) + # Check that the batch is repeated as expected + assert sampled[0:6] == sampled[6:12] + assert sampled[12:18] == sampled[18:24] + assert sampled[24:30] == sampled[30:36] + + def test_sampler_with_mini_repeat_count_and_batch_size_3(self): + dataset = ["a", "b", "c", "d", "e", "f", "g"] + sampler = RepeatSampler(dataset, mini_repeat_count=2, batch_size=2, repeat_count=3) + # Should output something like [4, 4, 3, 3, 4, 4, 3, 3, 4, 4, 3, 3, + # 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, + # 2, 2, 6, 6, 2, 2, 6, 6, 2, 2, 6, 6] + sampled = list(sampler) + # Check that the length is sextupled + assert len(sampled) == 6 * (len(dataset) - 1) # 1 element is dropped, because it's not enough to form a batch + # Check that the sampled indexes are a subset of the dataset indexes + assert set(sampled).issubset(set(range(len(dataset)))) + # Check that each element is repeated as expected + assert all(sampled[i] == sampled[i + 1] for i in range(0, len(sampled), 2)) + # Check that the batch is repeated as expected + assert sampled[0:4] == sampled[4:8] == sampled[8:12] + assert sampled[12:16] == sampled[16:20] == sampled[20:24] + assert sampled[24:28] == sampled[28:32] == sampled[32:36] + + +class TestEntropyFromLogits(TrlTestCase): + @pytest.mark.parametrize("shape", [(768,), (32, 768), (8, 16, 768), (2, 4, 8, 768)]) + @pytest.mark.parametrize("chunk_size", [1, 16]) + @pytest.mark.parametrize("dtype", [torch.float64, torch.float32, torch.float16, torch.bfloat16]) + def test_entropy_from_logits_2_dims(self, dtype, chunk_size, shape): + logits = torch.randn(*shape, dtype=dtype) + if dtype in (torch.float64, torch.float32): + p = logits.softmax(-1) + entropy = -torch.sum(p * p.log(), dim=-1) + else: + logps = logits.log_softmax(dim=-1) + entropy = -(torch.exp(logps) * logps).sum(-1) + predicted_entropy = entropy_from_logits(logits, chunk_size=chunk_size) + torch.testing.assert_close(predicted_entropy, entropy, rtol=1e-5, atol=1e-5) + + +@require_rich +class TestPrintPromptCompletionsSample(TrlTestCase): + @patch("sys.stdout", new_callable=StringIO) + def test_print_output(self, mock_stdout): + prompts = ["The sky is", "The sun is"] + completions = [" blue.", " in the sky."] + rewards = {"Correctness": [0.123, 0.456], "Format": [0.789, 0.101]} + advantages = [0.987, 0.654] + step = 42 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step) + + output = mock_stdout.getvalue() + + # docstyle-ignore + expected_output = textwrap.dedent("""\ + ╭──────────────────────────── Step 42 ─────────────────────────────╮ + │ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Correctness ┃ Format ┃ Advantage ┃ │ + │ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ The sky is │ blue. │ 0.12 │ 0.79 │ 0.99 │ │ + │ ├────────────┼──────────────┼─────────────┼────────┼───────────┤ │ + │ │ The sun is │ in the sky. │ 0.46 │ 0.10 │ 0.65 │ │ + │ └────────────┴──────────────┴─────────────┴────────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────╯ + """) + + assert output == expected_output + + @patch("sys.stdout", new_callable=StringIO) + def test_extra_columns(self, mock_stdout): + prompts = ["The sky is", "The sun is"] + completions = [" blue.", " in the sky."] + rewards = {"Correctness": [0.123, 0.456], "Format": [0.789, 0.101]} + advantages = [0.987, 0.654] + extra = {"source": ["dataset_A", "dataset_B"]} + step = 42 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step, extra=extra) + + output = mock_stdout.getvalue() + + # docstyle-ignore + expected_output = textwrap.dedent("""\ + ╭────────────────────────────────── Step 42 ───────────────────────────────────╮ + │ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Correctness ┃ Format ┃ Advantage ┃ source ┃ │ + │ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ The sky is │ blue. │ 0.12 │ 0.79 │ 0.99 │ dataset_A │ │ + │ ├────────────┼──────────────┼─────────────┼────────┼───────────┼───────────┤ │ + │ │ The sun is │ in the sky. │ 0.46 │ 0.10 │ 0.65 │ dataset_B │ │ + │ └────────────┴──────────────┴─────────────┴────────┴───────────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────────────────╯ + """) + + assert output == expected_output + + @patch("sys.stdout", new_callable=StringIO) + def test_num_samples(self, mock_stdout): + prompts = ["A", "B"] + completions = ["1", "2"] + rewards = {"Score": [0.1, 0.2]} + advantages = [0.3, 0.4] + step = 10 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step, num_samples=1) + output = mock_stdout.getvalue() + + # docstyle-ignore + possible_outputs = [ + textwrap.dedent("""\ + ╭────────────────── Step 10 ──────────────────╮ + │ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Score ┃ Advantage ┃ │ + │ ┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ A │ 1 │ 0.10 │ 0.30 │ │ + │ └────────┴────────────┴───────┴───────────┘ │ + ╰─────────────────────────────────────────────╯ + """), + # docstyle-ignore + textwrap.dedent("""\ + ╭────────────────── Step 10 ──────────────────╮ + │ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Score ┃ Advantage ┃ │ + │ ┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ B │ 2 │ 0.20 │ 0.40 │ │ + │ └────────┴────────────┴───────┴───────────┘ │ + ╰─────────────────────────────────────────────╯ + """), + ] + assert output in possible_outputs + + @patch("sys.stdout", new_callable=StringIO) + def test_print_messages(self, mock_stdout): + prompts = [ + [ + {"role": "system", "content": "You are an helpful assistant."}, + {"role": "user", "content": "What color is the sky?"}, + ], + [ + {"role": "system", "content": "You are an helpful assistant."}, + {"role": "user", "content": "Where is the sun?"}, + ], + ] + completions = [ + [{"role": "assistant", "content": "It is blue."}], + [{"role": "assistant", "content": "In the sky."}], + ] + rewards = {"Correctness": [0.123, 0.456], "Format": [0.789, 0.101]} + advantages = [0.987, 0.654] + step = 42 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step) + + output = mock_stdout.getvalue() + + # docstyle-ignore + expected_output = textwrap.dedent("""\ + ╭────────────────────────────────── Step 42 ───────────────────────────────────╮ + │ ┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Correctness ┃ Format ┃ Advantage ┃ │ + │ ┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ SYSTEM │ ASSISTANT │ 0.12 │ 0.79 │ 0.99 │ │ + │ │ You are an helpful │ It is blue. │ │ │ │ │ + │ │ assistant. │ │ │ │ │ │ + │ │ │ │ │ │ │ │ + │ │ USER │ │ │ │ │ │ + │ │ What color is the sky? │ │ │ │ │ │ + │ ├─────────────────────────┼─────────────┼─────────────┼────────┼───────────┤ │ + │ │ SYSTEM │ ASSISTANT │ 0.46 │ 0.10 │ 0.65 │ │ + │ │ You are an helpful │ In the sky. │ │ │ │ │ + │ │ assistant. │ │ │ │ │ │ + │ │ │ │ │ │ │ │ + │ │ USER │ │ │ │ │ │ + │ │ Where is the sun? │ │ │ │ │ │ + │ └─────────────────────────┴─────────────┴─────────────┴────────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────────────────╯ + """) + + assert output == expected_output + + @patch("sys.stdout", new_callable=StringIO) + def test_print_messages_with_tools(self, mock_stdout): + prompts = [ + [{"role": "user", "content": "What is the temperature in Paris?"}], + [{"role": "user", "content": "What is the weather in London?"}], + ] + completions = [ + [{"role": "tool", "name": "get_temperature", "args": {"location": "Paris"}}], + [{"role": "tool", "name": "get_weather", "args": {"location": "London"}}], + ] + rewards = {"Correctness": [0.123, 0.456], "Format": [0.789, 0.101]} + advantages = [0.987, 0.654] + step = 42 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step) + + output = mock_stdout.getvalue() + + # docstyle-ignore + expected_output = textwrap.dedent("""\ + ╭────────────────────────────────── Step 42 ───────────────────────────────────╮ + │ ┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Correctness ┃ Format ┃ Advantage ┃ │ + │ ┡━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ USER │ TOOL │ 0.12 │ 0.79 │ 0.99 │ │ + │ │ What is the │ get_temperature(… │ │ │ │ │ + │ │ temperature in │ 'Paris'}) │ │ │ │ │ + │ │ Paris? │ │ │ │ │ │ + │ ├───────────────────┼───────────────────┼─────────────┼────────┼───────────┤ │ + │ │ USER │ TOOL │ 0.46 │ 0.10 │ 0.65 │ │ + │ │ What is the │ get_weather({'lo… │ │ │ │ │ + │ │ weather in │ 'London'}) │ │ │ │ │ + │ │ London? │ │ │ │ │ │ + │ └───────────────────┴───────────────────┴─────────────┴────────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────────────────╯ + """) + + assert output == expected_output + + @patch("sys.stdout", new_callable=StringIO) + def test_print_messages_with_reasoning_content(self, mock_stdout): + prompts = [[{"role": "user", "content": "What color is the sky?"}]] + completions = [[{"role": "assistant", "reasoning_content": "I think it is blue.", "content": "It is blue."}]] + rewards = {"Score": [0.5]} + advantages = [0.9] + step = 1 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step) + + output = mock_stdout.getvalue() + + # docstyle-ignore + expected_output = textwrap.dedent("""\ + ╭─────────────────────────────── Step 1 ───────────────────────────────╮ + │ ┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Score ┃ Advantage ┃ │ + │ ┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ USER │ ASSISTANT │ 0.50 │ 0.90 │ │ + │ │ What color is the sky? │ I think it is blue. │ │ │ │ + │ │ │ It is blue. │ │ │ │ + │ └────────────────────────┴─────────────────────┴───────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────────╯ + """) + + assert output == expected_output + + @patch("sys.stdout", new_callable=StringIO) + def test_print_messages_with_thinking(self, mock_stdout): + prompts = [[{"role": "user", "content": "What color is the sky?"}]] + completions = [[{"role": "assistant", "thinking": "I think it is blue.", "content": "It is blue."}]] + rewards = {"Score": [0.5]} + advantages = [0.9] + step = 1 + + print_prompt_completions_sample(prompts, completions, rewards, advantages, step) + + output = mock_stdout.getvalue() + + # docstyle-ignore + expected_output = textwrap.dedent("""\ + ╭─────────────────────────────── Step 1 ───────────────────────────────╮ + │ ┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Score ┃ Advantage ┃ │ + │ ┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ USER │ ASSISTANT │ 0.50 │ 0.90 │ │ + │ │ What color is the sky? │ I think it is blue. │ │ │ │ + │ │ │ It is blue. │ │ │ │ + │ └────────────────────────┴─────────────────────┴───────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────────╯ + """) + + assert output == expected_output + + +class TestSelectiveLogSoftmax(TrlTestCase): + @pytest.mark.parametrize("dtype", [torch.float64, torch.float32, torch.float16, torch.bfloat16]) + def test_selective_log_softmax(self, dtype): + """Test selective_log_softmax with logits of different dtypes""" + vocab_size = 1024 + batch_size = 4 + seq_len = 32 + + input_ids = torch.randint(low=0, high=vocab_size, size=(batch_size, seq_len)) + logits = torch.randn(batch_size, seq_len, vocab_size, dtype=dtype) + + expected_output = torch.gather(logits.log_softmax(-1), dim=-1, index=input_ids.unsqueeze(-1)).squeeze(-1) + actual_output = selective_log_softmax(logits, input_ids) + + if dtype in [torch.float16, torch.bfloat16]: + # half-precision dtypes fall back to an exact method + assert torch.equal(actual_output, expected_output) + else: + torch.testing.assert_close(actual_output, expected_output, rtol=1e-5, atol=1e-5) + + @pytest.mark.parametrize("dtype", [torch.float64, torch.float32, torch.float16, torch.bfloat16]) + @pytest.mark.parametrize("k", [1, 8]) + def test_selective_log_softmax_multi_index(self, dtype, k): + """Test selective_log_softmax with logits of different dtypes and index widths""" + vocab_size = 1024 + batch_size = 4 + seq_len = 32 + + index = torch.randint(low=0, high=vocab_size, size=(batch_size, seq_len, k)) + logits = torch.randn(batch_size, seq_len, vocab_size, dtype=dtype) + + expected_output = torch.gather(logits.log_softmax(-1), dim=-1, index=index) + actual_output = selective_log_softmax(logits, index) + + assert actual_output.shape == (batch_size, seq_len, k) + if dtype in [torch.float16, torch.bfloat16]: + # half-precision dtypes fall back to an exact method + assert torch.equal(actual_output, expected_output) + else: + torch.testing.assert_close(actual_output, expected_output, rtol=1e-5, atol=1e-5) + + +class TestShuffleSequenceDict(TrlTestCase): + def test_shuffle_preserves_shape(self): + x = torch.arange(6).reshape(3, 2) + y = torch.arange(3).reshape(3, 1) + tensor_dict = {"x": x.clone(), "y": y.clone()} + + shuffled = shuffle_sequence_dict(tensor_dict) + + assert shuffled["x"].shape == x.shape + assert shuffled["y"].shape == y.shape + + def test_shuffle_consistent_across_tensors(self): + # Use known patterns to check alignment + x = torch.tensor([[10, 11], [20, 21], [30, 31]]) + y = torch.tensor([[1], [2], [3]]) + tensor_dict = {"x": x.clone(), "y": y.clone()} + + shuffled = shuffle_sequence_dict(tensor_dict) + + # Build a reverse map from shuffled x rows to y values + for i in range(3): + x_row = shuffled["x"][i] + y_val = shuffled["y"][i].item() + + if torch.equal(x_row, torch.tensor([10, 11])): + assert y_val == 1 + elif torch.equal(x_row, torch.tensor([20, 21])): + assert y_val == 2 + elif torch.equal(x_row, torch.tensor([30, 31])): + assert y_val == 3 + else: + pytest.fail("Unexpected x row in shuffled output.") + + def test_none_tensor_remains_none(self): + x = torch.arange(6).reshape(3, 2) + tensor_dict = {"x": x.clone(), "y": None} + + shuffled = shuffle_sequence_dict(tensor_dict) + + assert shuffled["y"] is None + assert shuffled["x"].shape == x.shape + + def test_shuffle_with_list(self): + x = torch.tensor([[10, 11], [20, 21], [30, 31]]) + y = ["a", "b", "c"] + + sequence_dict = {"x": x.clone(), "y": y} + + shuffled = shuffle_sequence_dict(sequence_dict) + + # Check that the list y is shuffled in the same order as x + for i in range(3): + x_row = shuffled["x"][i] + y_val = shuffled["y"][i] + + if torch.equal(x_row, torch.tensor([10, 11])): + assert y_val == "a" + elif torch.equal(x_row, torch.tensor([20, 21])): + assert y_val == "b" + elif torch.equal(x_row, torch.tensor([30, 31])): + assert y_val == "c" + else: + pytest.fail("Unexpected x row in shuffled output.") + + +class TestSplitTensorDict(TrlTestCase): + def test_split_equal_chunks(self): + x = torch.arange(12).reshape(6, 2) + y = torch.arange(6).reshape(6, 1) + tensor_dict = {"x": x, "y": y} + + result = split_tensor_dict(tensor_dict, 3) + + expected_x_chunks = torch.chunk(x, 3, dim=0) + expected_y_chunks = torch.chunk(y, 3, dim=0) + assert len(result) == 3 + for i in range(3): + assert torch.equal(result[i]["x"], expected_x_chunks[i]) + assert torch.equal(result[i]["y"], expected_y_chunks[i]) + + def test_with_none_tensor(self): + x = torch.arange(12).reshape(6, 2) + tensor_dict = {"x": x, "y": None} + + result = split_tensor_dict(tensor_dict, 2) + + expected_x_chunks = torch.chunk(x, 2, dim=0) + assert len(result) == 2 + for i in range(2): + assert torch.equal(result[i]["x"], expected_x_chunks[i]) + assert result[i]["y"] is None + + def test_with_scalar(self): + x = torch.arange(12).reshape(6, 2) + tensor_dict = {"x": x, "y": torch.tensor(1)} + + result = split_tensor_dict(tensor_dict, 2) + + expected_x_chunks = torch.chunk(x, 2, dim=0) + assert len(result) == 2 + for i in range(2): + assert torch.equal(result[i]["x"], expected_x_chunks[i]) + assert torch.equal(result[i]["y"], torch.tensor(1)) + + +class TestSplitPixelValuesByGrid(TrlTestCase): + def test_split_correctly_0(self): + batch = { + "image_grid_thw": torch.tensor([[1, 2, 2], [1, 2, 2]]), + "num_images": [1, 1], + "pixel_values": torch.arange(8 * 3).reshape(8, 3), # Shape: [8, 3] + } + result = split_pixel_values_by_grid(batch) + assert isinstance(result["pixel_values"], list) + assert len(result["pixel_values"]) == 2 + assert torch.equal(result["pixel_values"][0], batch["pixel_values"][:4]) + assert torch.equal(result["pixel_values"][1], batch["pixel_values"][4:]) + assert isinstance(result["image_grid_thw"], list) + assert len(result["image_grid_thw"]) == 2 + assert torch.equal(result["image_grid_thw"][0], torch.tensor([[1, 2, 2]])) + assert torch.equal(result["image_grid_thw"][1], torch.tensor([[1, 2, 2]])) + + def test_split_correctly_1(self): + batch = { + "image_grid_thw": torch.tensor([[1, 2, 2], [1, 2, 4]]), + "num_images": [1, 1], + "pixel_values": torch.arange(12 * 3).reshape(12, 3), # Shape: [12, 3] + } + result = split_pixel_values_by_grid(batch) + assert isinstance(result["pixel_values"], list) + assert len(result["pixel_values"]) == 2 + assert torch.equal(result["pixel_values"][0], batch["pixel_values"][:4]) + assert torch.equal(result["pixel_values"][1], batch["pixel_values"][4:12]) + assert isinstance(result["image_grid_thw"], list) + assert len(result["image_grid_thw"]) == 2 + assert torch.equal(result["image_grid_thw"][0], torch.tensor([[1, 2, 2]])) + assert torch.equal(result["image_grid_thw"][1], torch.tensor([[1, 2, 4]])) + + def test_missing_keys(self): + batch = {"pixel_values": torch.tensor([1.0])} + result = split_pixel_values_by_grid(batch) + assert result == batch + + def test_mismatched_length(self): + batch = { + "image_grid_thw": torch.tensor([[1, 1, 2], [1, 2, 1]]), # Total = 8 + "num_images": [1, 1], + "pixel_values": torch.randn(3, 5), # Only 3 rows + } + with pytest.raises(ValueError): + split_pixel_values_by_grid(batch) + + def test_multi_images(self): + batch = { + "image_grid_thw": torch.tensor([[1, 1, 2], [1, 2, 2], [1, 2, 1]]), # Total = 8 + "num_images": [1, 2], + "pixel_values": torch.arange(8 * 3).reshape(8, 3), # Shape: [8, 3] + } + result = split_pixel_values_by_grid(batch) + assert isinstance(result["pixel_values"], list) + assert len(result["pixel_values"]) == 2 + assert torch.equal(result["pixel_values"][0], batch["pixel_values"][:2]) + assert torch.equal(result["pixel_values"][1], batch["pixel_values"][2:]) + assert isinstance(result["image_grid_thw"], list) + assert len(result["image_grid_thw"]) == 2 + assert torch.equal(result["image_grid_thw"][0], torch.tensor([[1, 1, 2]])) + assert torch.equal(result["image_grid_thw"][1], torch.tensor([[1, 2, 2], [1, 2, 1]])) + + def test_split_by_image_position_ids(self): + # Gemma-style: no image_grid_thw, split by num_images using image_position_ids + batch = { + "num_images": [1, 2], + "pixel_values": torch.arange(3 * 4).reshape(3, 4), + "image_position_ids": torch.tensor([[0, 1], [2, 3], [4, 5]]), + } + result = split_pixel_values_by_grid(batch) + assert isinstance(result["pixel_values"], list) + assert len(result["pixel_values"]) == 2 + assert torch.equal(result["pixel_values"][0], batch["pixel_values"][:1]) + assert torch.equal(result["pixel_values"][1], batch["pixel_values"][1:]) + assert isinstance(result["image_position_ids"], list) + assert len(result["image_position_ids"]) == 2 + assert torch.equal(result["image_position_ids"][0], batch["image_position_ids"][:1]) + assert torch.equal(result["image_position_ids"][1], batch["image_position_ids"][1:]) + + +class TestUnsplitPixelValuesByGrid(TrlTestCase): + def test_unsplit_correctly(self): + pixel_values = [torch.randn(4, 5), torch.randn(2, 5)] + pixel_values_merged = torch.cat(pixel_values, dim=0) + image_grid_thw = [torch.tensor([[1, 2, 2]]), torch.tensor([[1, 2, 1]])] + image_grid_thw_merged = torch.cat(image_grid_thw, dim=0) + batch = {"pixel_values": pixel_values, "image_grid_thw": image_grid_thw, "other_key": torch.tensor([1])} + result = unsplit_pixel_values_by_grid(batch) + assert isinstance(result["pixel_values"], torch.Tensor) + torch.testing.assert_close(result["pixel_values"], pixel_values_merged) + assert isinstance(result["image_grid_thw"], torch.Tensor) + assert torch.equal(result["image_grid_thw"], image_grid_thw_merged) + assert "other_key" in result + + def test_unsplit_image_position_ids(self): + image_position_ids = [torch.tensor([[0, 1]]), torch.tensor([[2, 3], [4, 5]])] + image_position_ids_merged = torch.cat(image_position_ids, dim=0) + pixel_values = [torch.randn(1, 4), torch.randn(2, 4)] + batch = {"pixel_values": pixel_values, "image_position_ids": image_position_ids} + result = unsplit_pixel_values_by_grid(batch) + assert isinstance(result["image_position_ids"], torch.Tensor) + assert torch.equal(result["image_position_ids"], image_position_ids_merged) + + def test_no_op_if_not_list(self): + original = torch.randn(5, 3) + batch = {"pixel_values": original} + result = unsplit_pixel_values_by_grid(batch) + assert torch.equal(result["pixel_values"], original) + + +class TestChunkedLogProbFunction: + N, H, V = 64, 32, 128 + CHUNK_SIZE = 32 + + def _reference_logprobs_and_entropy(self, hidden, weight, labels, temperature): + logits = (hidden @ weight.t()).to(torch.float32) / temperature # [N, V] + log_p = F.log_softmax(logits, dim=-1) + logprobs = log_p.gather(-1, labels.unsqueeze(-1)).squeeze(-1) + p = torch.softmax(logits, dim=-1) + entropy = -(p * log_p).sum(dim=-1) + return logprobs, entropy + + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_forward(self, temperature): + torch.manual_seed(42) + hidden = torch.randn(self.N, self.H) + weight = torch.randn(self.V, self.H) + labels = torch.randint(0, self.V, (self.N,)) + + logprobs_chunked, entropy_chunked = _ChunkedLogProbFunction.apply( + hidden, weight, labels, temperature, self.CHUNK_SIZE + ) + logprobs_ref, entropy_ref = self._reference_logprobs_and_entropy(hidden, weight, labels, temperature) + + torch.testing.assert_close(logprobs_chunked, logprobs_ref, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(entropy_chunked, entropy_ref, atol=1e-5, rtol=1e-5) + + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_backward(self, temperature): + torch.manual_seed(42) + hidden = torch.randn(self.N, self.H, requires_grad=True) + weight = torch.randn(self.V, self.H, requires_grad=True) + labels = torch.randint(0, self.V, (self.N,)) + + # Chunked backward + logprobs_chunked, _ = _ChunkedLogProbFunction.apply(hidden, weight, labels, temperature, self.CHUNK_SIZE) + logprobs_chunked.sum().backward() + grad_hidden_chunked = hidden.grad.clone() + grad_weight_chunked = weight.grad.clone() + + hidden.grad = None + weight.grad = None + + # Reference backward + logprobs_ref, _ = self._reference_logprobs_and_entropy(hidden, weight, labels, temperature) + logprobs_ref.sum().backward() + + torch.testing.assert_close(grad_hidden_chunked, hidden.grad, atol=1e-5, rtol=1e-5) + torch.testing.assert_close(grad_weight_chunked, weight.grad, atol=1e-5, rtol=1e-5) + + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_backward_bfloat16(self, temperature): + torch.manual_seed(42) + hidden = torch.randn(self.N, self.H, dtype=torch.bfloat16, requires_grad=True) + weight = torch.randn(self.V, self.H, dtype=torch.bfloat16, requires_grad=True) + labels = torch.randint(0, self.V, (self.N,)) + + # Chunked backward + logprobs_chunked, _ = _ChunkedLogProbFunction.apply(hidden, weight, labels, temperature, self.CHUNK_SIZE) + logprobs_chunked.sum().backward() + grad_hidden_chunked = hidden.grad.clone() + grad_weight_chunked = weight.grad.clone() + + hidden.grad = None + weight.grad = None + + # Reference backward + logprobs_ref, _ = self._reference_logprobs_and_entropy(hidden, weight, labels, temperature) + logprobs_ref.sum().backward() + + torch.testing.assert_close(grad_hidden_chunked, hidden.grad, atol=1e-2, rtol=1e-2) + torch.testing.assert_close(grad_weight_chunked, weight.grad, atol=1e-2, rtol=1e-2) + + +class _FakeTransformerModel(nn.Module): + """Minimal stand-in for a transformer body: returns random hidden states of the right shape.""" + + def __init__(self, hidden_size): + super().__init__() + self.hidden_size = hidden_size + self._hidden = None + + def forward(self, input_ids, attention_mask=None, use_cache=False, **kwargs): + b, s = input_ids.shape + if self._hidden is None or self._hidden.shape[:2] != (b, s): + torch.manual_seed(123) + self._hidden = torch.randn(b, s, self.hidden_size, requires_grad=True) + return type("Out", (), {"last_hidden_state": self._hidden})() + + +class _FakeCausalLM(nn.Module): + """Minimal CausalLM with .model and .lm_head, enough for patch_chunked_lm_head.""" + + def __init__(self, hidden_size, vocab_size): + super().__init__() + self.config = type("Config", (), {})() + self.model = _FakeTransformerModel(hidden_size) + self.lm_head = nn.Linear(hidden_size, vocab_size, bias=False) + + def forward(self, input_ids, attention_mask=None, labels=None, **kwargs): + raise NotImplementedError("should be monkey-patched") + + +_CHUNKED_LM_HEAD_MODEL_IDS = [ + "trl-internal-testing/tiny-CohereForCausalLM", + "trl-internal-testing/tiny-Cohere2ForCausalLM", + pytest.param( + "trl-internal-testing/tiny-DeepseekV3ForCausalLM", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="DeepseekV3 SDPA attention is broken in transformers < 5.0.0", + ), + ), + pytest.param( + "trl-internal-testing/tiny-DeepseekV3ForCausalLM-0528", + marks=pytest.mark.skipif( + Version(transformers.__version__) < Version("5.0.0"), + reason="DeepseekV3 SDPA attention is broken in transformers < 5.0.0", + ), + ), + "trl-internal-testing/tiny-Gemma2ForCausalLM", + "trl-internal-testing/tiny-GemmaForCausalLM", + "trl-internal-testing/tiny-Glm4MoeForCausalLM", + "trl-internal-testing/tiny-GptOssForCausalLM", + "trl-internal-testing/tiny-LlamaForCausalLM-3.1", + "trl-internal-testing/tiny-LlamaForCausalLM-3.2", + "trl-internal-testing/tiny-LlamaForCausalLM-3", + "trl-internal-testing/tiny-MistralForCausalLM-0.1", + "trl-internal-testing/tiny-MistralForCausalLM-0.2", + "trl-internal-testing/tiny-Phi3ForCausalLM-3", + "trl-internal-testing/tiny-Phi3ForCausalLM-3.5", + "trl-internal-testing/tiny-Qwen2ForCausalLM-2.5", + "trl-internal-testing/tiny-Qwen3ForCausalLM", +] + + +@require_torch_accelerator +class TestPatchChunkedLMHead: + B, S = 4, 16 # batch size, sequence length (including prompt + completion) + H, V = 32, 128 + CHUNK_SIZE = 32 + + def _build_model_and_inputs(self, temperature=1.0): + torch.manual_seed(42) + model = _FakeCausalLM(self.H, self.V) + patch_chunked_lm_head(model, self.CHUNK_SIZE, temperature) + + input_ids = torch.randint(0, self.V, (self.B, self.S)) + attention_mask = torch.ones(self.B, self.S, dtype=torch.long) + # First half of each sequence is prompt (0), second half is completion (1) + completion_mask = torch.zeros(self.B, self.S, dtype=torch.float32) + completion_mask[:, self.S // 2 :] = 1.0 + return model, input_ids, attention_mask, completion_mask + + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_dummy_model_chunked_forward_with_completion_mask(self, temperature): + """Masked forward matches unmasked forward at completion positions and is zero at prompt positions.""" + model, input_ids, attention_mask, completion_mask = self._build_model_and_inputs(temperature) + + # Run WITHOUT completion_mask (baseline — computes all positions) + out_full = model(input_ids=input_ids, attention_mask=attention_mask, labels=input_ids) + + # Reset hidden state cache so both runs use the same hidden states + model.model._hidden = None + + # Run WITH completion_mask + out_masked = model( + input_ids=input_ids, attention_mask=attention_mask, labels=input_ids, completion_mask=completion_mask + ) + + # shifted completion_mask (matching the shift in _chunked_forward) + shifted_mask = completion_mask[:, 1:].bool() + + # At completion positions, values should match + torch.testing.assert_close( + out_masked["log_probs"][shifted_mask], + out_full["log_probs"][shifted_mask], + atol=1e-5, + rtol=1e-5, + ) + torch.testing.assert_close( + out_masked["entropy"][shifted_mask], + out_full["entropy"][shifted_mask], + atol=1e-5, + rtol=1e-5, + ) + + # At prompt positions, values should be zero + prompt_mask = ~shifted_mask + assert (out_masked["log_probs"][prompt_mask] == 0).all() + assert (out_masked["entropy"][prompt_mask] == 0).all() + + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_dummy_model_chunked_forward_completion_mask_backward(self, temperature): + model, input_ids, attention_mask, completion_mask = self._build_model_and_inputs(temperature) + + # Full forward + backward (mask applied after, as the trainer does) + out_full = model(input_ids=input_ids, attention_mask=attention_mask, labels=input_ids) + shifted_mask = completion_mask[:, 1:] + loss_full = (out_full["log_probs"] * shifted_mask).sum() + loss_full.backward() + grad_weight_full = model.lm_head.weight.grad.clone() + + model.lm_head.weight.grad = None + model.model._hidden = None + + # Masked forward + backward + out_masked = model( + input_ids=input_ids, attention_mask=attention_mask, labels=input_ids, completion_mask=completion_mask + ) + loss_masked = (out_masked["log_probs"] * shifted_mask).sum() + loss_masked.backward() + grad_weight_masked = model.lm_head.weight.grad.clone() + + torch.testing.assert_close(grad_weight_masked, grad_weight_full, atol=1e-5, rtol=1e-5) + + @pytest.mark.parametrize("model_id", _CHUNKED_LM_HEAD_MODEL_IDS) + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_forward(self, model_id, temperature): + model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16).to(torch_device) + if getattr(model.config, "final_logit_softcapping", None) is not None: + pytest.skip("model uses final_logit_softcapping, not supported by chunked LM head") + model.eval() + + B, S, chunk_size = 2, 8, 32 + torch.manual_seed(42) + input_ids = torch.randint(0, model.config.vocab_size, (B, S), device=torch_device) + labels = input_ids.clone() + + # Reference: standard forward → shifted logits → logprobs & entropy + with torch.no_grad(): + ref_logits = model(input_ids=input_ids).logits[:, :-1, :].float() / temperature + shifted_labels = labels[:, 1:] + ref_log_p = F.log_softmax(ref_logits, dim=-1) + ref_logprobs = ref_log_p.gather(-1, shifted_labels.unsqueeze(-1)).squeeze(-1) + ref_p = ref_logits.softmax(dim=-1) + ref_entropy = -(ref_p * ref_log_p).sum(dim=-1) + + # Chunked forward + patch_chunked_lm_head(model, chunk_size, temperature) + with torch.no_grad(): + out = model(input_ids=input_ids, labels=labels) + + torch.testing.assert_close(out["log_probs"], ref_logprobs, atol=5e-3, rtol=5e-3) + torch.testing.assert_close(out["entropy"], ref_entropy, atol=5e-3, rtol=5e-3) + + @pytest.mark.parametrize("model_id", _CHUNKED_LM_HEAD_MODEL_IDS) + @pytest.mark.parametrize("temperature", [1.0, 0.7]) + def test_backward(self, model_id, temperature): + model_ref = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16).to(torch_device) + if getattr(model_ref.config, "final_logit_softcapping", None) is not None: + pytest.skip("model uses final_logit_softcapping, not supported by chunked LM head") + model_chunked = copy.deepcopy(model_ref) + + B, S, chunk_size = 2, 8, 32 + torch.manual_seed(42) + input_ids = torch.randint(0, model_ref.config.vocab_size, (B, S), device=torch_device) + labels = input_ids.clone() + shifted_labels = labels[:, 1:] + + # Reference backward: standard logits → logprobs → backward + ref_logits = model_ref(input_ids=input_ids).logits[:, :-1, :].float() / temperature + ref_log_p = F.log_softmax(ref_logits, dim=-1) + ref_logprobs = ref_log_p.gather(-1, shifted_labels.unsqueeze(-1)).squeeze(-1) + ref_logprobs.sum().backward() + ref_grad = model_ref.lm_head.weight.grad.clone() + + # Chunked backward + patch_chunked_lm_head(model_chunked, chunk_size, temperature) + out = model_chunked(input_ids=input_ids, labels=labels) + out["log_probs"].sum().backward() + chunked_grad = model_chunked.lm_head.weight.grad.clone() + + torch.testing.assert_close(chunked_grad, ref_grad, atol=5e-2, rtol=5e-2) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/test_vllm_client_server.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_vllm_client_server.py new file mode 100644 index 0000000000000000000000000000000000000000..820483a9d7e003316e2204b0e2ed8565495041a2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/test_vllm_client_server.py @@ -0,0 +1,1036 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import subprocess +from types import SimpleNamespace + +import pytest +from packaging.version import Version +from transformers import AutoModelForCausalLM, AutoProcessor, AutoTokenizer +from transformers.testing_utils import torch_device + +from trl.generation.vllm_client import VLLMClient +from trl.generation.vllm_generation import extract_logprobs +from trl.import_utils import is_vllm_available +from trl.scripts.vllm_serve import chunk_list + +from .testing_utils import ( + TrlTestCase, + kill_process, + require_3_accelerators, + require_torch_multi_accelerator, + require_vision, + require_vllm, +) + + +if is_vllm_available(): + import vllm + from vllm import LLM, SamplingParams + + _is_vllm_ge_014 = Version(vllm.__version__) >= Version("0.14.0") +else: + _is_vllm_ge_014 = False + + +class TestChunkList(TrlTestCase): + def test_even_split(self): + assert chunk_list([1, 2, 3, 4, 5, 6], 2) == [[1, 2, 3], [4, 5, 6]] + + def test_uneven_split(self): + assert chunk_list([1, 2, 3, 4, 5, 6], 4) == [[1, 2], [3, 4], [5], [6]] + + def test_more_chunks_than_elements(self): + assert chunk_list([1, 2, 3, 4, 5, 6], 8) == [[1], [2], [3], [4], [5], [6], [], []] + + def test_n_equals_len(self): + assert chunk_list([1, 2, 3], 3) == [[1], [2], [3]] + + def test_n_is_1(self): + assert chunk_list([1, 2, 3], 1) == [[1, 2, 3]] + + def test_single_element_list(self): + assert chunk_list([42], 2) == [[42], []] + + def test_any_dtype(self): + assert chunk_list([1, "two", 3.0, {"four": 4}, ["f", "i", "v", "e"]], 2) == [ + [1, "two", 3.0], + [{"four": 4}, ["f", "i", "v", "e"]], + ] + + +class TestExtractLogprobs(TrlTestCase): + def test_extract_logprobs_sorts_by_rank_and_replaces_nan(self): + all_outputs = [ + SimpleNamespace( + outputs=[ + SimpleNamespace( + logprobs=[ + { + 11: SimpleNamespace(rank=1, logprob=-0.2), + 99: SimpleNamespace(rank=0, logprob=-0.1), + 42: SimpleNamespace(rank=2, logprob=float("nan")), + }, + { + 5: SimpleNamespace(rank=0, logprob=-1.1), + }, + ] + ) + ] + ), + SimpleNamespace( + outputs=[ + SimpleNamespace( + logprobs=[ + { + 3: SimpleNamespace(rank=1, logprob=-0.5), + 7: SimpleNamespace(rank=0, logprob=-0.4), + } + ] + ) + ] + ), + ] + + all_logprobs, all_token_ids = extract_logprobs(all_outputs) + + assert all_token_ids == [ + [[99, 11, 42], [5]], + [[7, 3]], + ] + assert all_logprobs == [ + [[-0.1, -0.2, None], [-1.1]], + [[-0.4, -0.5]], + ] + + def test_extract_logprobs_returns_none_token_ids_when_logprobs_missing(self): + all_outputs = [SimpleNamespace(outputs=[SimpleNamespace(logprobs=None)])] + + all_logprobs, all_token_ids = extract_logprobs(all_outputs) + + assert all_logprobs is None + assert all_token_ids is None + + +@pytest.mark.slow +@require_torch_multi_accelerator +@require_vllm +class TestVLLMClientServer(TrlTestCase): + model_id = "Qwen/Qwen2.5-1.5B" + + @classmethod + def setup_class(cls): + # We want the server to run on accelerator 1, so we set VISIBLE_DEVICES to "1" + env = os.environ.copy() + VISIBLE_DEVICES = "ZE_AFFINITY_MASK" if torch_device == "xpu" else "CUDA_VISIBLE_DEVICES" + env[VISIBLE_DEVICES] = "1" # Restrict to accelerator 1 + + # Start the server process + cls.server_process = subprocess.Popen( + ["trl", "vllm-serve", "--model", cls.model_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env + ) + + # Initialize the client + cls.client = VLLMClient(connection_timeout=240, host="localhost") + cls.client.init_communicator() + + def test_generate(self): + prompts = ["Hello, AI!", "Tell me a joke"] + outputs = self.client.generate(prompts) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_logprobs_none(self): + outputs = self.client.generate(["Hello, AI!"], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat(self): + messages = [[{"role": "user", "content": "Hello, AI!"}], [{"role": "user", "content": "Tell me a joke"}]] + outputs = self.client.chat(messages) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of messages + assert len(prompt_ids) == len(messages) + assert len(completion_ids) == len(messages) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_chat_with_logprobs_none(self): + outputs = self.client.chat([[{"role": "user", "content": "Hello, AI!"}]], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat_with_tools(self): + def multiply(a: int, b: int) -> int: + """ + Multiplies two integers. + + Args: + a: The first integer. + b: The second integer. + + Returns: + The product of the two integers. + """ + return a * b + + messages = [[{"role": "user", "content": "What is 3 multiplied by 4?"}]] + outputs = self.client.chat(messages, tools=[multiply]) + + # Decode prompt and check that "Multiplies two integers." is in the prompt. + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + decoded_prompt = tokenizer.decode(outputs["prompt_ids"][0]) + assert "Multiplies two integers." in decoded_prompt + + def test_generate_with_token_ids(self): + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + prompts = ["Hello, AI!", "Tell me a joke"] + prompt_token_ids = tokenizer(prompts)["input_ids"] + outputs = self.client.generate(prompt_token_ids) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that prompt_ids match the input token IDs + assert prompt_ids == prompt_token_ids + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_params(self): + prompts = ["Hello, AI!", "Tell me a joke"] + completion_ids = self.client.generate(prompts, n=2, repetition_penalty=0.9, temperature=0.8, max_tokens=32)[ + "completion_ids" + ] + + # Check that the output is a list + assert isinstance(completion_ids, list) + + # Check that the number of generated sequences is 2 times the number of prompts + assert len(completion_ids) == 2 * len(prompts) + + # Check that the generated sequences are lists of integers + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + # Check that the length of the generated sequences is less than or equal to 32 + for seq in completion_ids: + assert len(seq) <= 32 + + def test_update_model_params(self): + model = AutoModelForCausalLM.from_pretrained(self.model_id, device_map=torch_device) + self.client.update_model_params(model) + + def test_reset_prefix_cache(self): + # Test resetting the prefix cache + self.client.reset_prefix_cache() + + @pytest.mark.xfail(reason="Importing `bitsandbytes` causes issues, see vllm-project/vllm#32793") + def test_logprobs_match_with_non_default_sampling(self): + prompts = ["Hello, AI!", "Tell me a joke"] + # Use non-default sampling parameters (especially temperature) to ensure vLLM applies logprob processing. With + # default sampling, raw and processed logprobs are identical, so mismatches would not be detected. + temperature = 0.7 + repetition_penalty = 1.05 + top_p = 0.9 + max_tokens = 8 + seed = 1234 + num_logprobs = 5 + + server_outputs = self.client.generate( + prompts, + temperature=temperature, + repetition_penalty=repetition_penalty, + top_p=top_p, + max_tokens=max_tokens, + logprobs=num_logprobs, + generation_kwargs={"seed": seed}, + ) + os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn" + llm = LLM( + model=self.model_id, + tensor_parallel_size=1, + gpu_memory_utilization=0.2, + max_model_len=128, + logprobs_mode="processed_logprobs", + ) + + sampling_params = SamplingParams( + temperature=temperature, + repetition_penalty=repetition_penalty, + top_p=top_p, + max_tokens=max_tokens, + logprobs=num_logprobs, + seed=seed, + ) + colocate_outputs = llm.generate(prompts, sampling_params=sampling_params, use_tqdm=False) + colocate_prompt_ids = [output.prompt_token_ids for output in colocate_outputs] + colocate_completion_ids = [ + list(output.token_ids) for outputs in colocate_outputs for output in outputs.outputs + ] + colocate_logprobs, colocate_logprob_token_ids = extract_logprobs(colocate_outputs) + + # Generation correctness: prompt and completion IDs match between server and colocate + assert server_outputs["prompt_ids"] == colocate_prompt_ids + assert server_outputs["completion_ids"] == colocate_completion_ids + + server_logprobs = server_outputs["logprobs"] + server_logprob_token_ids = server_outputs["logprob_token_ids"] + + # Shape: both should be (num_sequences, seq_len, num_logprobs) with multiple logprobs per token + assert len(server_logprobs) == len(prompts) + assert len(server_logprob_token_ids) == len(prompts) + for seq_lps in server_logprobs: + for token_lps in seq_lps: + assert len(token_lps) > 1, "Expected multiple logprobs per token when logprobs > 0" + + # Value correctness: server extraction matches colocate extraction via extract_logprobs + assert server_logprob_token_ids == colocate_logprob_token_ids + for server_seq, colocate_seq in zip(server_logprobs, colocate_logprobs, strict=True): + assert len(server_seq) == len(colocate_seq) + for server_token_lps, colocate_token_lps in zip(server_seq, colocate_seq, strict=True): + assert server_token_lps == pytest.approx(colocate_token_lps, rel=1e-6, abs=1e-6) + + # Ordering: logprobs at each position should be sorted descending + for seq_lps in server_logprobs: + for token_lps in seq_lps: + assert token_lps == sorted(token_lps, reverse=True), "Logprobs should be sorted descending" + + # Sampled token presence: the actual completion token should appear in the logprob token IDs + for seq_idx, (completion_seq, token_ids_seq) in enumerate( + zip(server_outputs["completion_ids"], server_logprob_token_ids, strict=True) + ): + for pos, (sampled_id, lp_ids) in enumerate(zip(completion_seq, token_ids_seq, strict=True)): + assert sampled_id in lp_ids, ( + f"Sampled token {sampled_id} not found in logprob token IDs {lp_ids} " + f"at sequence {seq_idx}, position {pos}" + ) + + @classmethod + def teardown_class(cls): + # Close the client + cls.client.close_communicator() + + # vLLM x pytest (or Popen) seems not to handle process termination well. To avoid zombie processes, we need to + # kill the server process and its children explicitly. + kill_process(cls.server_process) + + +# Same as above but using base_url to instantiate the client. +@pytest.mark.slow +@require_torch_multi_accelerator +@require_vllm +class TestVLLMClientServerBaseURL(TrlTestCase): + model_id = "Qwen/Qwen2.5-1.5B" + + @classmethod + def setup_class(cls): + # We want the server to run on accelerator 1, so we set VISIBLE_DEVICES to "1" + env = os.environ.copy() + VISIBLE_DEVICES = "ZE_AFFINITY_MASK" if torch_device == "xpu" else "CUDA_VISIBLE_DEVICES" + env[VISIBLE_DEVICES] = "1" # Restrict to accelerator 1 + + # Start the server process + cls.server_process = subprocess.Popen( + ["trl", "vllm-serve", "--model", cls.model_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env + ) + + # Initialize the client + cls.client = VLLMClient(base_url="http://localhost:8000", connection_timeout=240) + cls.client.init_communicator() + + def test_generate(self): + prompts = ["Hello, AI!", "Tell me a joke"] + outputs = self.client.generate(prompts) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_logprobs_none(self): + outputs = self.client.generate(["Hello, AI!"], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat(self): + messages = [[{"role": "user", "content": "Hello, AI!"}], [{"role": "user", "content": "Tell me a joke"}]] + outputs = self.client.chat(messages) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of messages + assert len(prompt_ids) == len(messages) + assert len(completion_ids) == len(messages) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_chat_with_logprobs_none(self): + outputs = self.client.chat([[{"role": "user", "content": "Hello, AI!"}]], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat_with_tools(self): + def multiply(a: int, b: int) -> int: + """ + Multiplies two integers. + + Args: + a: The first integer. + b: The second integer. + + Returns: + The product of the two integers. + """ + return a * b + + messages = [[{"role": "user", "content": "What is 3 multiplied by 4?"}]] + outputs = self.client.chat(messages, tools=[multiply]) + + # Decode prompt and check that "Multiplies two integers." is in the prompt. + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + decoded_prompt = tokenizer.decode(outputs["prompt_ids"][0]) + assert "Multiplies two integers." in decoded_prompt + + def test_generate_with_token_ids(self): + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + prompts = ["Hello, AI!", "Tell me a joke"] + prompt_token_ids = tokenizer(prompts)["input_ids"] + outputs = self.client.generate(prompt_token_ids) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that prompt_ids match the input token IDs + assert prompt_ids == prompt_token_ids + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_params(self): + prompts = ["Hello, AI!", "Tell me a joke"] + completion_ids = self.client.generate(prompts, n=2, repetition_penalty=0.9, temperature=0.8, max_tokens=32)[ + "completion_ids" + ] + + # Check that the output is a list + assert isinstance(completion_ids, list) + + # Check that the number of generated sequences is 2 times the number of prompts + assert len(completion_ids) == 2 * len(prompts) + + # Check that the generated sequences are lists of integers + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + # Check that the length of the generated sequences is less than or equal to 32 + for seq in completion_ids: + assert len(seq) <= 32 + + def test_update_model_params(self): + model = AutoModelForCausalLM.from_pretrained(self.model_id, device_map=torch_device) + self.client.update_model_params(model) + + def test_reset_prefix_cache(self): + # Test resetting the prefix cache + self.client.reset_prefix_cache() + + @classmethod + def teardown_class(cls): + # Close the client + cls.client.close_communicator() + + # vLLM x pytest (or Popen) seems not to handle process termination well. To avoid zombie processes, we need to + # kill the server process and its children explicitly. + kill_process(cls.server_process) + + +@pytest.mark.slow +@require_3_accelerators +@require_vllm +class TestVLLMClientServerTP(TrlTestCase): + model_id = "Qwen/Qwen2.5-1.5B" + + @classmethod + def setup_class(cls): + # We want the server to run on accelerator 1 and 2, so we set VISIBLE_DEVICES to "1,2" + env = os.environ.copy() + VISIBLE_DEVICES = "ZE_AFFINITY_MASK" if torch_device == "xpu" else "CUDA_VISIBLE_DEVICES" + env[VISIBLE_DEVICES] = "1,2" # Restrict to accelerator 1 and 2 + + # Start the server process + cls.server_process = subprocess.Popen( + ["trl", "vllm-serve", "--model", cls.model_id, "--tensor_parallel_size", "2"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, + ) + + # Initialize the client + cls.client = VLLMClient(connection_timeout=240, host="localhost") + cls.client.init_communicator() + + def test_generate(self): + prompts = ["Hello, AI!", "Tell me a joke"] + outputs = self.client.generate(prompts) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_logprobs_none(self): + outputs = self.client.generate(["Hello, AI!"], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat(self): + messages = [[{"role": "user", "content": "Hello, AI!"}], [{"role": "user", "content": "Tell me a joke"}]] + outputs = self.client.chat(messages) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of messages + assert len(prompt_ids) == len(messages) + assert len(completion_ids) == len(messages) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_chat_with_logprobs_none(self): + outputs = self.client.chat([[{"role": "user", "content": "Hello, AI!"}]], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat_with_tools(self): + def multiply(a: int, b: int) -> int: + """ + Multiplies two integers. + + Args: + a: The first integer. + b: The second integer. + + Returns: + The product of the two integers. + """ + return a * b + + messages = [[{"role": "user", "content": "What is 3 multiplied by 4?"}]] + outputs = self.client.chat(messages, tools=[multiply]) + + # Decode prompt and check that "Multiplies two integers." is in the prompt. + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + decoded_prompt = tokenizer.decode(outputs["prompt_ids"][0]) + assert "Multiplies two integers." in decoded_prompt + + def test_generate_with_token_ids(self): + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + prompts = ["Hello, AI!", "Tell me a joke"] + prompt_token_ids = tokenizer(prompts)["input_ids"] + outputs = self.client.generate(prompt_token_ids) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that prompt_ids match the input token IDs + assert prompt_ids == prompt_token_ids + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_params(self): + prompts = ["Hello, AI!", "Tell me a joke"] + completion_ids = self.client.generate(prompts, n=2, repetition_penalty=0.9, temperature=0.8, max_tokens=32)[ + "completion_ids" + ] + + # Check that the output is a list + assert isinstance(completion_ids, list) + + # Check that the number of generated sequences is 2 times the number of prompts + assert len(completion_ids) == 2 * len(prompts) + + # Check that the generated sequences are lists of integers + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + # Check that the length of the generated sequences is less than or equal to 32 + for seq in completion_ids: + assert len(seq) <= 32 + + def test_update_model_params(self): + model = AutoModelForCausalLM.from_pretrained(self.model_id, device_map=torch_device) + self.client.update_model_params(model) + + def test_reset_prefix_cache(self): + # Test resetting the prefix cache + self.client.reset_prefix_cache() + + @classmethod + def teardown_class(cls): + # Close the client + cls.client.close_communicator() + + # vLLM x pytest (or Popen) seems not to handle process termination well. To avoid zombie processes, we need to + # kill the server process and its children explicitly. + kill_process(cls.server_process) + + +@pytest.mark.slow +@pytest.mark.skipif( + _is_vllm_ge_014, + reason="Skipping DP server test for vLLM>=0.14.0 (PR vllm#30739: DP for non-MoE/dense models no longer supported).", +) +@require_3_accelerators +@require_vllm +class TestVLLMClientServerDP(TrlTestCase): + model_id = "Qwen/Qwen2.5-1.5B" + + @classmethod + def setup_class(cls): + # We want the server to run on accelerator 1 and 2, so we set VISIBLE_DEVICES to "1,2" + env = os.environ.copy() + VISIBLE_DEVICES = "ZE_AFFINITY_MASK" if torch_device == "xpu" else "CUDA_VISIBLE_DEVICES" + env[VISIBLE_DEVICES] = "1,2" # Restrict to accelerator 1 and 2 + + # Start the server process + cls.server_process = subprocess.Popen( + ["trl", "vllm-serve", "--model", cls.model_id, "--data_parallel_size", "2"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, + ) + + # Initialize the client + cls.client = VLLMClient(connection_timeout=240, host="localhost") + cls.client.init_communicator() + + def test_generate(self): + prompts = ["Hello, AI!", "Tell me a joke"] + outputs = self.client.generate(prompts) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_logprobs_none(self): + outputs = self.client.generate(["Hello, AI!"], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat(self): + messages = [[{"role": "user", "content": "Hello, AI!"}], [{"role": "user", "content": "Tell me a joke"}]] + outputs = self.client.chat(messages) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of messages + assert len(prompt_ids) == len(messages) + assert len(completion_ids) == len(messages) + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_chat_with_logprobs_none(self): + outputs = self.client.chat([[{"role": "user", "content": "Hello, AI!"}]], logprobs=None) + + assert isinstance(outputs["prompt_ids"], list) + assert isinstance(outputs["completion_ids"], list) + assert outputs["logprobs"] is None + assert outputs["logprob_token_ids"] is None + + def test_chat_with_tools(self): + def multiply(a: int, b: int) -> int: + """ + Multiplies two integers. + + Args: + a: The first integer. + b: The second integer. + + Returns: + The product of the two integers. + """ + return a * b + + messages = [[{"role": "user", "content": "What is 3 multiplied by 4?"}]] + outputs = self.client.chat(messages, tools=[multiply]) + + # Decode prompt and check that "Multiplies two integers." is in the prompt. + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + decoded_prompt = tokenizer.decode(outputs["prompt_ids"][0]) + assert "Multiplies two integers." in decoded_prompt + + def test_generate_with_token_ids(self): + tokenizer = AutoTokenizer.from_pretrained(self.model_id) + prompts = ["Hello, AI!", "Tell me a joke"] + prompt_token_ids = tokenizer(prompts)["input_ids"] + outputs = self.client.generate(prompt_token_ids) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + # Check that the outputs are lists + assert isinstance(prompt_ids, list) + assert isinstance(completion_ids, list) + + # Check that the number of sequences are equal to the number of prompts + assert len(prompt_ids) == len(prompts) + assert len(completion_ids) == len(prompts) + + # Check that prompt_ids match the input token IDs + assert prompt_ids == prompt_token_ids + + # Check that the sequences are lists of integers + for seq in prompt_ids: + assert all(isinstance(tok, int) for tok in seq) + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + def test_generate_with_params(self): + prompts = ["Hello, AI!", "Tell me a joke"] + completion_ids = self.client.generate(prompts, n=2, repetition_penalty=0.9, temperature=0.8, max_tokens=32)[ + "completion_ids" + ] + + # Check that the output is a list + assert isinstance(completion_ids, list) + + # Check that the number of generated sequences is 2 times the number of prompts + assert len(completion_ids) == 2 * len(prompts) + + # Check that the generated sequences are lists of integers + for seq in completion_ids: + assert all(isinstance(tok, int) for tok in seq) + + # Check that the length of the generated sequences is less than or equal to 32 + for seq in completion_ids: + assert len(seq) <= 32 + + def test_update_model_params(self): + model = AutoModelForCausalLM.from_pretrained(self.model_id, device_map=torch_device) + self.client.update_model_params(model) + + def test_reset_prefix_cache(self): + # Test resetting the prefix cache + self.client.reset_prefix_cache() + + @classmethod + def teardown_class(cls): + # Close the client + cls.client.close_communicator() + + # vLLM x pytest (or Popen) seems not to handle process termination well. To avoid zombie processes, we need to + # kill the server process and its children explicitly. + kill_process(cls.server_process) + + +@pytest.mark.slow +@require_torch_multi_accelerator +@require_vllm +class TestVLLMClientServerDeviceParameter(TrlTestCase): + """Test the device parameter functionality in init_communicator.""" + + model_id = "Qwen/Qwen2.5-1.5B" + + @classmethod + def setup_class(cls): + # We want the server to run on accelerator 1, so we set VISIBLE_DEVICES to "1" + env = os.environ.copy() + VISIBLE_DEVICES = "ZE_AFFINITY_MASK" if torch_device == "xpu" else "CUDA_VISIBLE_DEVICES" + env[VISIBLE_DEVICES] = "1" # Restrict to accelerator 1 + + # Start the server process + cls.server_process = subprocess.Popen( + ["trl", "vllm-serve", "--model", cls.model_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env + ) + + def test_init_communicator_with_device_int(self): + """Test init_communicator with integer device parameter.""" + client = VLLMClient(connection_timeout=240, host="localhost") + client.init_communicator(device=0) # Explicitly specify device 0 + + # Test basic functionality + prompts = ["Hello, AI!"] + outputs = client.generate(prompts) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + assert isinstance(prompt_ids, list) + assert len(prompt_ids) == len(prompts) + assert isinstance(completion_ids, list) + assert len(completion_ids) == len(prompts) + + client.close_communicator() + + def test_init_communicator_with_device_string(self): + """Test init_communicator with string device parameter.""" + client = VLLMClient(connection_timeout=240, host="localhost") + client.init_communicator(device=0) # Explicitly specify device as string + + # Test basic functionality + prompts = ["Hello, AI!"] + outputs = client.generate(prompts)["completion_ids"] + assert isinstance(outputs, list) + assert len(outputs) == len(prompts) + + client.close_communicator() + + def test_init_communicator_with_torch_device(self): + """Test init_communicator with torch.device object.""" + import torch + + client = VLLMClient(connection_timeout=240, host="localhost") + device = torch.device(0) + client.init_communicator(device=device) # Explicitly specify torch.device object + + # Test basic functionality + prompts = ["Hello, AI!"] + outputs = client.generate(prompts)["completion_ids"] + assert isinstance(outputs, list) + assert len(outputs) == len(prompts) + + client.close_communicator() + + @classmethod + def teardown_class(cls): + # vLLM x pytest (or Popen) seems not to handle process termination well. To avoid zombie processes, we need to + # kill the server process and its children explicitly. + kill_process(cls.server_process) + + +@pytest.mark.slow +@require_vllm +@require_vision +class TestVLLMClientServerVLM(TrlTestCase): + model_id = "Qwen/Qwen2.5-VL-3B-Instruct" + + @classmethod + def setup_class(cls): + # Start the server process + cls.server_process = subprocess.Popen( + ["trl", "vllm-serve", "--model", cls.model_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + + # Initialize the client (no communicator needed for generation-only tests) + cls.client = VLLMClient(connection_timeout=240, host="localhost") + + def test_generate_with_token_ids_and_image(self): + from PIL import Image + + processor = AutoProcessor.from_pretrained(self.model_id) + image1 = Image.new("RGB", (64, 64), color="red") + image2 = Image.new("RGB", (64, 64), color="blue") + image3 = Image.new("RGB", (64, 64), color="green") + messages = [ + [ + { + "role": "user", + "content": [ + {"type": "image", "image": image1}, + {"type": "image", "image": image2}, + {"type": "text", "text": "What are the differences between these two images?"}, + ], + } + ], + [ + { + "role": "user", + "content": [ + {"type": "image", "image": image3}, + {"type": "text", "text": "What is the color of this image?"}, + ], + } + ], + ] + prompt_token_ids = processor.apply_chat_template( + conversation=messages, tokenize=True, add_generation_prompt=True + ) + outputs = self.client.generate(prompt_token_ids, images=[[image1, image2], [image3]], max_tokens=64) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + assert len(prompt_ids) == 2 + assert len(completion_ids) == 2 + assert all(isinstance(tok, int) for tok in prompt_ids[0]) + assert all(isinstance(tok, int) for tok in completion_ids[0]) + + def test_generate_with_token_ids_mixed_images(self): + """Test a batch where one prompt has an image and the other does not.""" + from PIL import Image + + processor = AutoProcessor.from_pretrained(self.model_id) + image = Image.new("RGB", (64, 64), color="red") + messages = [ + [ + { + "role": "user", + "content": [{"type": "image", "image": image}, {"type": "text", "text": "Describe this image."}], + } + ], + [ + { + "role": "user", + "content": [{"type": "text", "text": "What is 1+1?"}], + } + ], + ] + prompt_token_ids = processor.apply_chat_template( + conversation=messages, tokenize=True, add_generation_prompt=True + ) + outputs = self.client.generate(prompt_token_ids, images=[[image], None], max_tokens=64) + prompt_ids = outputs["prompt_ids"] + completion_ids = outputs["completion_ids"] + + assert len(prompt_ids) == 2 + assert len(completion_ids) == 2 + assert all(isinstance(tok, int) for tok in prompt_ids[0]) + assert all(isinstance(tok, int) for tok in prompt_ids[1]) + assert all(isinstance(tok, int) for tok in completion_ids[0]) + assert all(isinstance(tok, int) for tok in completion_ids[1]) + + @classmethod + def teardown_class(cls): + kill_process(cls.server_process) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/testing_constants.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/testing_constants.py new file mode 100644 index 0000000000000000000000000000000000000000..7589117c85a06be131489b8a7b905f2162b3c14d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/testing_constants.py @@ -0,0 +1,18 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +CI_HUB_USER = "__DUMMY_TRANSFORMERS_USER__" +CI_HUB_USER_FULL_NAME = "Dummy User" + +CI_HUB_ENDPOINT = "https://hub-ci.huggingface.co" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/tests/testing_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/tests/testing_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..aeff14ab634e6781381ec1974d76a8f43526f7eb --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/tests/testing_utils.py @@ -0,0 +1,144 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import functools +import signal +import warnings +from collections.abc import Callable + +import psutil +import pytest +import torch +from transformers import is_bitsandbytes_available, is_comet_available, is_sklearn_available, is_wandb_available +from transformers.testing_utils import backend_device_count, torch_device +from transformers.utils import ( + is_kernels_available, + is_peft_available, + is_rich_available, + is_torch_available, + is_vision_available, +) + +from trl.import_utils import ( + is_jmespath_available, + is_joblib_available, + is_liger_kernel_available, + is_math_verify_available, + is_mergekit_available, + is_vllm_available, +) + + +require_bitsandbytes = pytest.mark.skipif(not is_bitsandbytes_available(), reason="test requires bitsandbytes") +require_comet = pytest.mark.skipif(not is_comet_available(), reason="test requires comet_ml") +require_jmespath = pytest.mark.skipif(not is_jmespath_available(), reason="test requires jmespath") +require_kernels = pytest.mark.skipif(not is_kernels_available(), reason="test requires kernels") +require_liger_kernel = pytest.mark.skipif(not is_liger_kernel_available(), reason="test requires liger-kernel") +require_math_latex = pytest.mark.skipif(not is_math_verify_available(), reason="test requires math_verify") +require_mergekit = pytest.mark.skipif(not is_mergekit_available(), reason="test requires mergekit") +require_peft = pytest.mark.skipif(not is_peft_available(), reason="test requires peft") +require_rich = pytest.mark.skipif(not is_rich_available(), reason="test requires rich") +require_sklearn = pytest.mark.skipif( + not (is_sklearn_available() and is_joblib_available()), reason="test requires sklearn" +) +require_torch_accelerator = pytest.mark.skipif( + torch_device is None or torch_device == "cpu", reason="test requires accelerator" +) +require_torch_multi_accelerator = pytest.mark.skipif( + not is_torch_available() or backend_device_count(torch_device) <= 1, reason="test requires multiple accelerators" +) +require_vision = pytest.mark.skipif(not is_vision_available(), reason="test requires vision") +require_vllm = pytest.mark.skipif(not is_vllm_available(), reason="test requires vllm") +require_wandb = pytest.mark.skipif(not is_wandb_available(), reason="test requires wandb") +require_no_wandb = pytest.mark.skipif(is_wandb_available(), reason="test requires no wandb") +require_3_accelerators = pytest.mark.skipif( + not (getattr(torch, torch_device, torch.cuda).device_count() >= 3), + reason=f"test requires at least 3 {torch_device}s", +) + + +def is_bitsandbytes_multi_backend_available() -> bool: + if is_bitsandbytes_available(): + import bitsandbytes as bnb + + return "multi_backend" in getattr(bnb, "features", set()) + return False + + +# Function ported from transformers.testing_utils before transformers#41283 +require_torch_gpu_if_bnb_not_multi_backend_enabled = pytest.mark.skipif( + not is_bitsandbytes_multi_backend_available() and not torch_device == "cuda", + reason="test requires bitsandbytes multi-backend enabled or 'cuda' torch device", +) + + +def is_ampere_or_newer(device_index=0): + if not torch.cuda.is_available(): + return False + + major, minor = torch.cuda.get_device_capability(device_index) + # Ampere starts at compute capability 8.0 (e.g., A100 = 8.0, RTX 30xx = 8.6) + return (major, minor) >= (8, 0) + + +require_ampere_or_newer = pytest.mark.skipif(not is_ampere_or_newer(), reason="test requires Ampere or newer GPU") + + +class TrlTestCase: + @pytest.fixture(autouse=True) + def set_tmp_dir(self, tmp_path): + self.tmp_dir = str(tmp_path) + + +def ignore_warnings(message: str = None, category: type[Warning] = Warning) -> Callable: + """ + Decorator to ignore warnings with a specific message and/or category. + + Args: + message (`str`, *optional*): + Regex pattern for the warning message to ignore. If `None`, all messages are ignored. + category (`type[Warning]`, *optional*, defaults to `Warning`): + Warning class to ignore. Defaults to `Warning`, which ignores all warnings. + """ + + def decorator(test_func): + @functools.wraps(test_func) + def wrapper(*args, **kwargs): + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message=message, category=category) + return test_func(*args, **kwargs) + + return wrapper + + return decorator + + +def kill_process(process): + parent = psutil.Process(process.pid) + children = parent.children(recursive=True) + for child in children: + try: + child.send_signal(signal.SIGTERM) + child.wait(timeout=5) + except psutil.TimeoutExpired: + child.kill() + except psutil.NoSuchProcess: + pass + try: + process.terminate() + process.wait(timeout=5) + except psutil.TimeoutExpired: + process.kill() + except psutil.NoSuchProcess: + pass diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4947fc16c56e7abf1de978619b878bde579c9d15 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/__init__.py @@ -0,0 +1,132 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from importlib.metadata import PackageNotFoundError, version +from typing import TYPE_CHECKING + +from . import _compat +from ._lazy_module import _LazyModule + + +try: + __version__ = version("trl") +except PackageNotFoundError: + __version__ = "unknown" + +_import_structure = { + "chat_template_utils": [ + "add_response_schema", + "clone_chat_template", + "get_training_chat_template", + "supports_tool_calling", + ], + "data_utils": [ + "apply_chat_template", + "extract_prompt", + "is_conversational", + "is_conversational_from_value", + "maybe_apply_chat_template", + "maybe_convert_to_chatml", + "maybe_extract_prompt", + "maybe_unpair_preference_dataset", + "pack_dataset", + "prepare_multimodal_messages", + "prepare_multimodal_messages_vllm", + "unpair_preference_dataset", + ], + "models": ["create_reference_model"], + "scripts": ["DatasetMixtureConfig", "ScriptArguments", "TrlParser", "get_dataset", "init_zero_verbose"], + "trainer": [ + "BEMACallback", + "DPOConfig", + "DPOTrainer", + "GRPOConfig", + "GRPOTrainer", + "KTOConfig", + "KTOTrainer", + "LogCompletionsCallback", + "ModelConfig", + "RewardConfig", + "RewardTrainer", + "RichProgressCallback", + "RLOOConfig", + "RLOOTrainer", + "SFTConfig", + "SFTTrainer", + "SyncRefModelCallback", + "WeaveCallback", + "get_kbit_device_map", + "get_peft_config", + "get_quantization_config", + ], +} + +if TYPE_CHECKING: + from .chat_template_utils import ( + add_response_schema, + clone_chat_template, + get_training_chat_template, + supports_tool_calling, + ) + from .data_utils import ( + apply_chat_template, + extract_prompt, + is_conversational, + is_conversational_from_value, + maybe_apply_chat_template, + maybe_convert_to_chatml, + maybe_extract_prompt, + maybe_unpair_preference_dataset, + pack_dataset, + prepare_multimodal_messages, + prepare_multimodal_messages_vllm, + unpair_preference_dataset, + ) + from .models import create_reference_model + from .scripts import DatasetMixtureConfig, ScriptArguments, TrlParser, get_dataset, init_zero_verbose + from .trainer import ( + BEMACallback, + DPOConfig, + DPOTrainer, + GRPOConfig, + GRPOTrainer, + KTOConfig, + KTOTrainer, + LogCompletionsCallback, + ModelConfig, + RewardConfig, + RewardTrainer, + RichProgressCallback, + RLOOConfig, + RLOOTrainer, + SFTConfig, + SFTTrainer, + SyncRefModelCallback, + WeaveCallback, + get_kbit_device_map, + get_peft_config, + get_quantization_config, + ) + +else: + import sys + + sys.modules[__name__] = _LazyModule( + __name__, + globals()["__file__"], + _import_structure, + module_spec=__spec__, + extra_objects={"__version__": __version__}, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/_compat.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/_compat.py new file mode 100644 index 0000000000000000000000000000000000000000..31086a2e912cc9926e3fab7d2a8045fa5421c49d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/_compat.py @@ -0,0 +1,164 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Compatibility shims for third-party dependencies. + +This module contains temporary patches to handle version incompatibilities between TRL's dependencies. + +Each patch should be removed when minimum version requirements eliminate the need. +""" + +import warnings + +from packaging.version import Version + +from .import_utils import _is_package_available + + +def _is_package_version_below(package_name: str, version_threshold: str) -> bool: + """ + Check if installed package version is below the given threshold. + + Args: + package_name (str): Package name. + version_threshold (str): Maximum version threshold. + + Returns: + - True if package is installed and version < version_threshold. + - False if package is not installed or version >= version_threshold. + """ + try: + is_available, version = _is_package_available(package_name, return_version=True) + return is_available and Version(version) < Version(version_threshold) + except Exception as e: + warnings.warn( + f"Failed to check {package_name} version against {version_threshold}: {e}. " + f"Compatibility patch may not be applied.", + stacklevel=2, + ) + return False + + +def _is_package_version_at_least(package_name: str, version_threshold: str) -> bool: + """ + Check if installed package version is at least the given threshold. + + Args: + package_name (str): Package name. + version_threshold (str): Minimum version threshold. + + Returns: + - True if package is installed and version >= version_threshold. + - False if package is not installed or version < version_threshold. + """ + try: + is_available, version = _is_package_available(package_name, return_version=True) + return is_available and Version(version) >= Version(version_threshold) + except Exception as e: + warnings.warn( + f"Failed to check {package_name} version against {version_threshold}: {e}. " + f"Compatibility patch may not be applied.", + stacklevel=2, + ) + return False + + +def _patch_vllm_logging() -> None: + """Set vLLM logging level to ERROR by default to reduce noise.""" + if _is_package_available("vllm"): + import os + + os.environ["VLLM_LOGGING_LEVEL"] = os.getenv("VLLM_LOGGING_LEVEL", "ERROR") + + +def _patch_transformers_hybrid_cache() -> None: + """ + Fix HybridCache import for transformers v5 compatibility. + + - Issue: peft import HybridCache from transformers.cache_utils + - HybridCache removed in https://github.com/huggingface/transformers/pull/43168 (transformers>=5.0.0) + - Fixed in peft: https://github.com/huggingface/peft/pull/2735 (released in v0.18.0) + - This can be removed when TRL requires peft>=0.18.0 + """ + if _is_package_version_at_least("transformers", "5.0.0") and _is_package_version_below("peft", "0.18.0"): + try: + import transformers.cache_utils + from transformers.utils.import_utils import _LazyModule + + Cache = transformers.cache_utils.Cache + + # Patch for liger_kernel: Add HybridCache as an alias for Cache in the cache_utils module + transformers.cache_utils.HybridCache = Cache + + # Patch for peft: Patch _LazyModule.__init__ to add HybridCache to transformers' lazy loading structures + _original_lazy_module_init = _LazyModule.__init__ + + def _patched_lazy_module_init(self, name, *args, **kwargs): + _original_lazy_module_init(self, name, *args, **kwargs) + if name == "transformers": + # Update _LazyModule's internal structures + if hasattr(self, "_import_structure") and "cache_utils" in self._import_structure: + if "HybridCache" not in self._import_structure["cache_utils"]: + self._import_structure["cache_utils"].append("HybridCache") + + if hasattr(self, "_class_to_module"): + self._class_to_module["HybridCache"] = "cache_utils" + + if hasattr(self, "__all__") and "HybridCache" not in self.__all__: + self.__all__.append("HybridCache") + + self.HybridCache = Cache + + _LazyModule.__init__ = _patched_lazy_module_init + + except Exception as e: + warnings.warn(f"Failed to patch transformers HybridCache compatibility: {e}", stacklevel=2) + + +def _patch_transformers_parallelism_config() -> None: + """ + Fix ParallelismConfig for transformers compatibility. + + Ensure that ``transformers.training_args`` always defines the symbol `ParallelismConfig` so that Python's + `typing.get_type_hints` can resolve annotations on `transformers.TrainingArguments` without raising a `NameError`. + + This is needed when running with ``accelerate<1.10.1``, where the module ``accelerate.parallelism_config`` did not + exist and therefore the type alias is not imported by Transformers. + + See upstream fix PR in transformers#40818. + + - Issue: transformers imports ParallelismConfig only if accelerate>=1.10.1 and raises NameError if + accelerate<1.10.1 + - Fixed in transformers: https://github.com/huggingface/transformers/pull/40818 (released in v4.57.0) + - This can be removed when TRL requires transformers>=4.57.0 or accelerate>=1.10.1 + """ + if _is_package_version_below("transformers", "4.57.0") and _is_package_version_below("accelerate", "1.10.1"): + try: + from typing import Any + + import transformers.training_args + + if not hasattr(transformers.training_args, "ParallelismConfig"): + transformers.training_args.ParallelismConfig = Any + except Exception as e: + warnings.warn(f"Failed to patch transformers ParallelismConfig compatibility: {e}", stacklevel=2) + + +# Apply vLLM patches +_patch_vllm_logging() + +# Apply transformers patches +_patch_transformers_hybrid_cache() +_patch_transformers_parallelism_config() # before creating HfArgumentParser diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/_lazy_module.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/_lazy_module.py new file mode 100644 index 0000000000000000000000000000000000000000..d030f00df1fdb0fc1f4c136393ea6ce06bb72669 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/_lazy_module.py @@ -0,0 +1,79 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib +import os +from itertools import chain +from types import ModuleType +from typing import Any + + +class _LazyModule(ModuleType): + """ + Module class that surfaces all objects but only performs associated imports when the objects are requested. + """ + + # Very heavily inspired by optuna.integration._IntegrationModule + # https://github.com/optuna/optuna/blob/master/optuna/integration/__init__.py + def __init__(self, name, module_file, import_structure, module_spec=None, extra_objects=None): + super().__init__(name) + self._modules = set(import_structure.keys()) + self._class_to_module = {} + for key, values in import_structure.items(): + for value in values: + self._class_to_module[value] = key + # Needed for autocompletion in an IDE + self.__all__ = list(import_structure.keys()) + list(chain(*import_structure.values())) + self.__file__ = module_file + self.__spec__ = module_spec + self.__path__ = [os.path.dirname(module_file)] + self._objects = {} if extra_objects is None else extra_objects + self._name = name + self._import_structure = import_structure + + # Needed for autocompletion in an IDE + def __dir__(self): + result = super().__dir__() + # The elements of self.__all__ that are submodules may or may not be in the dir already, depending on whether + # they have been accessed or not. So we only add the elements of self.__all__ that are not already in the dir. + for attr in self.__all__: + if attr not in result: + result.append(attr) + return result + + def __getattr__(self, name: str) -> Any: + if name in self._objects: + return self._objects[name] + if name in self._modules: + value = self._get_module(name) + elif name in self._class_to_module.keys(): + module = self._get_module(self._class_to_module[name]) + value = getattr(module, name) + else: + raise AttributeError(f"module {self.__name__} has no attribute {name}") + + setattr(self, name, value) + return value + + def _get_module(self, module_name: str): + try: + return importlib.import_module("." + module_name, self.__name__) + except Exception as e: + raise RuntimeError( + f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its" + f" traceback):\n{e}" + ) from e + + def __reduce__(self): + return (self.__class__, (self._name, self.__file__, self._import_structure)) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/fsdp1.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/fsdp1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c01b0b567bc93bf87ec136ea975b3793d273a45c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/fsdp1.yaml @@ -0,0 +1,28 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: FSDP +downcast_bf16: 'no' +enable_cpu_affinity: false +fsdp_config: + fsdp_activation_checkpointing: false + fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP + fsdp_backward_prefetch: BACKWARD_PRE + fsdp_cpu_ram_efficient_loading: true + fsdp_forward_prefetch: true + fsdp_offload_params: false + fsdp_reshard_after_forward: FULL_SHARD + fsdp_state_dict_type: FULL_STATE_DICT + fsdp_sync_module_states: true + fsdp_use_orig_params: true + fsdp_version: 1 +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/fsdp2.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/fsdp2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af498f3eced9c2434b80113f2f22d40395e0ab8a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/fsdp2.yaml @@ -0,0 +1,25 @@ +# Requires accelerate 1.7.0 or higher +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: FSDP +downcast_bf16: 'no' +enable_cpu_affinity: false +fsdp_config: + fsdp_activation_checkpointing: false + fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP + fsdp_cpu_ram_efficient_loading: true + fsdp_offload_params: false + fsdp_reshard_after_forward: true + fsdp_state_dict_type: FULL_STATE_DICT + fsdp_version: 2 +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/multi_gpu.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/multi_gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..15dad9be3ba44f7c934e1ecab98a93cb83cbc79a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/multi_gpu.yaml @@ -0,0 +1,16 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: MULTI_GPU +downcast_bf16: 'no' +gpu_ids: all +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/single_gpu.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/single_gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ebd00a067118e56f3d63ab0f24827cfea21b24b9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/single_gpu.yaml @@ -0,0 +1,16 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: "NO" +downcast_bf16: 'no' +gpu_ids: all +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero1.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d5b5f782fb30f9fcbcc8fc58262f09eaf2e10368 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero1.yaml @@ -0,0 +1,20 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + gradient_accumulation_steps: 1 + zero3_init_flag: false + zero_stage: 1 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero2.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..239b14ac3a9ae8de73122d1154bf0d71903dc15f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero2.yaml @@ -0,0 +1,21 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + offload_optimizer_device: none + offload_param_device: none + zero3_init_flag: false + zero_stage: 2 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: 'bf16' +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero3.yaml b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero3.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b5a1201f8a2ee8706b63f0f80c664a1fc61a7d9d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/accelerate_configs/zero3.yaml @@ -0,0 +1,22 @@ +compute_environment: LOCAL_MACHINE +debug: false +deepspeed_config: + deepspeed_multinode_launcher: standard + offload_optimizer_device: none + offload_param_device: none + zero3_init_flag: true + zero3_save_16bit_model: true + zero_stage: 3 +distributed_type: DEEPSPEED +downcast_bf16: 'no' +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 +num_machines: 1 +num_processes: 8 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_template_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_template_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..fccb0a578e32971e3d319c2d5f24a55cf190b17d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_template_utils.py @@ -0,0 +1,734 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path +from typing import TypeVar + +from jinja2 import TemplateError +from transformers import AddedToken, AutoTokenizer, PreTrainedModel, PreTrainedTokenizerBase, ProcessorMixin + +from .data_utils import prepare_multimodal_messages + + +_CHAT_TEMPLATES_DIR = Path(__file__).parent / "chat_templates" + + +def clone_chat_template( + model: PreTrainedModel, + tokenizer: PreTrainedTokenizerBase, + source_tokenizer_path: str, + resize_to_multiple_of: int | None = 64, +) -> tuple[PreTrainedModel, PreTrainedTokenizerBase, list[int]]: + """ + Clones a chat template from a source tokenizer to the target tokenizer and updates the model accordingly. + + This function: + - Copies the chat template from a source tokenizer to the target tokenizer. + - Adds any new tokens from the source tokenizer to the target tokenizer. + - Sets and synchronizes the EOS token across the tokenizer and model. + - Resizes the model's token embeddings to match the new vocabulary size, optionally rounding it up to a multiple of + a specified value. In such cases, dummy tokens are added to the tokenizer to ensure the vocabulary size matches + the embedding dimensions. + + Args: + model ([`~transformers.PreTrainedModel`]): + Model to update. + tokenizer ([`~transformers.PreTrainedTokenizerBase`]): + Tokenizer to update. + source_tokenizer_path (`str`): + Path or identifier of the pretrained tokenizer to clone from. + resize_to_multiple_of (`int` or `None`, *optional*, defaults to `64`): + The embedding layer will be resized to the new vocabulary size. If this is not `None`, it will round up the + new vocabulary size to the nearest multiple of this value. + + Returns: + model ([`~transformers.PreTrainedModel`]): + Updated model with resized token embeddings and EOS token configured. + tokenizer ([`~transformers.PreTrainedTokenizerBase`]): + Updated tokenizer with the chat template and special tokens applied. + added_tokens (`list[int]`): + List of tokens that were added to the tokenizer from the source tokenizer. + + Example: + ```python + from transformers import AutoModelForCausalLM, AutoTokenizer + from trl import clone_chat_template + + model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B") + tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B") + model, tokenizer, added_tokens = clone_chat_template(model, tokenizer, "Qwen/Qwen3-0.6B") + ``` + """ + # Load the source tokenizer containing the desired chat template + tokenizer_source = AutoTokenizer.from_pretrained(source_tokenizer_path) + + # Copy the chat template from the source tokenizer + tokenizer.chat_template = tokenizer_source.get_chat_template() + + # Ensure all added tokens from the source are available in the target tokenizer + added_tokens = [ + token for token in tokenizer_source.added_tokens_decoder.values() if token.content not in tokenizer.vocab + ] + tokenizer.add_tokens(added_tokens) + + # Set the EOS token from the source tokenizer (important for generation) + tokenizer.eos_token = tokenizer_source.eos_token + model.config.eos_token_id = tokenizer.eos_token_id + if model.can_generate(): # Non-generative models (e.g. SequenceClassification) may not have a generation_config + model.generation_config.eos_token_id = tokenizer.eos_token_id + + # Resize model embeddings to include any new tokens, optionally rounding up to a multiple + model.resize_token_embeddings( + # After studying many tokenizers, we found that len(tokenizer.vocab) is the most reliable way to get the vocab + # size. Avoid using tokenizer.vocab_size or tokenizer.vocab_size + len(tokenizer.added_tokens_encoder), + # as handling of special and added tokens varies across tokenizers. + new_num_tokens=len(tokenizer.vocab), + pad_to_multiple_of=resize_to_multiple_of if resize_to_multiple_of is not None else None, + ) + + # After resizing, the embedding matrix size may exceed the vocabulary size. Add dummy tokens to the tokenizer to + # ensure vocabulary size matches the embedding matrix dimensions. + idx = 0 + while model.vocab_size > len(tokenizer.vocab): + dummy_token = AddedToken(f"") + is_added = tokenizer.add_tokens(dummy_token) + idx += 1 + if is_added == 1: + added_tokens.append(dummy_token) + + # Verify that vocabulary size now matches embedding dimensions + if len(tokenizer.vocab) != model.vocab_size: + raise RuntimeError( + f"Vocabulary size mismatch after resizing: tokenizer vocab size is {len(tokenizer.vocab)}, but model " + f"embedding size is {model.vocab_size}. This indicates an internal error in the token alignment process." + ) + added_tokens = [token.content for token in added_tokens] + added_tokens = tokenizer.convert_tokens_to_ids(added_tokens) + return model, tokenizer, added_tokens + + +glm4moe_schema = { + "x-regex": r"^(?:\n?\n?(?:(?P.*?\S.*?)\n?|[\s]*)\s*)?(?P.*?)(?:\n(?=))?(?=(?:|$))(?P(?:.+?\s*)+)?$", + "type": "object", + "properties": { + "role": {"const": "assistant"}, + "content": {"type": "string"}, + "reasoning_content": {"type": "string"}, + "tool_calls": { + "type": "array", + "x-regex-iterator": r"\s*(.+?)\s*", + "items": { + "type": "object", + "properties": { + "type": {"const": "function"}, + "function": { + "type": "object", + "properties": { + "name": {"type": "string", "x-regex": r"^(\S+)"}, + "arguments": { + "type": "object", + "x-regex-key-value": r"(?P[^<]+)\s*\n(?P.*?)", + "default": {}, + "additionalProperties": { + "x-parser": "json", + "x-parser-args": {"allow_non_json": True}, + }, + }, + }, + }, + }, + }, + }, + }, +} + +gptoss_schema = { + # Normalize final content to analysis format so both map to the same "content" group. + "x-regex-substitutions": [ + [r"<\|channel\|>final<\|message\|>(.*?)<\|return\|>", r"<|channel|>analysis<|message|>\1<|end|>"], + ], + "x-regex": r"^(?:<\|channel\|>analysis<\|message\|>(?P.*?)<\|end\|>(?:<\|start\|>assistant)?)?\s*(?Pto=functions\.\S+<\|channel\|>commentary json<\|message\|>.*?<\|call\|>)?$", + "type": "object", + "properties": { + "role": {"const": "assistant"}, + "content": {"type": "string"}, + "tool_calls": { + "type": "array", + "x-regex-iterator": r"(to=functions\.\S+<\|channel\|>commentary json<\|message\|>.*?<\|call\|>)", + "items": { + # Convert "to=functions.NAME<|channel|>commentary json<|message|>ARGS<|call|>" + # into '{"name": "NAME", "arguments": ARGS}' so it can be parsed as JSON. + "x-regex-substitutions": [ + [ + r"to=functions\.(\S+)<\|channel\|>commentary json<\|message\|>(.*?)<\|call\|>", + r'{"name": "\1", "arguments": \2}', + ], + ], + "x-parser": "json", + "x-parser-args": {"transform": "{type: 'function', function: @}"}, + "type": "object", + "properties": { + "type": {"const": "function"}, + "function": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "arguments": { + "type": "object", + "additionalProperties": {}, + }, + }, + }, + }, + }, + }, + }, +} + +# Adapted and corrected versions of the schemas from: +# https://github.com/huggingface/transformers/blob/main/tests/utils/test_chat_parsing_utils.py +qwen3_schema = { + "x-regex": r"^(?:\n?(?:(?P.*?\S.*?)\n?|[\s]*)\s*)?(?P.*?)(?:\n(?=))?(?=(?:|<\|im_end\|>|$))(?P(?:.+?\s*)+)?\s*(?:<\|im_end\|>|$)", + "type": "object", + "properties": { + "role": {"const": "assistant"}, + "content": {"type": "string"}, + "reasoning_content": {"type": "string"}, + "tool_calls": { + "type": "array", + "x-regex-iterator": r"\s*(.+?)\s*", + "items": { + "x-parser": "json", + "x-parser-args": {"transform": "{type: 'function', function: @}"}, + "type": "object", + "properties": { + "type": {"const": "function"}, + "function": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "arguments": { + "type": "object", + "additionalProperties": {}, + }, + }, + }, + }, + }, + }, + }, +} + +llama3_schema = { + # Llama 3.1 / 3.2 render a tool call as a single bare JSON object using the key "parameters" instead of + # "arguments": `{"name": "", "parameters": }<|eot_id|>`. There is no surrounding marker, no + # support for content alongside a tool call, and at most one tool call per assistant turn (the template raises + # otherwise). Either we match a tool call (capturing the JSON) or we treat the response as plain content. + "x-regex": r'^(?:(?P\{"name":\s*".+?",\s*"parameters":\s*.+\})|(?P.*?))(?:<\|eot_id\|>|$)', + "type": "object", + "properties": { + "role": {"const": "assistant"}, + "content": {"type": "string"}, + "tool_calls": { + "type": "array", + "x-regex-iterator": r'(\{"name":\s*".+?",\s*"parameters":\s*.+\})', + "items": { + # Rewrite "parameters" → "arguments" so the JSON parses into the standard tool-call shape. Anchored + # on the leading `{"name": "..."` so a stray `"parameters"` inside argument values is not touched. + "x-regex-substitutions": [ + [r'^(\{"name":\s*"[^"]+",\s*)"parameters":', r'\1"arguments":'], + ], + "x-parser": "json", + "x-parser-args": {"transform": "{type: 'function', function: @}"}, + "type": "object", + "properties": { + "type": {"const": "function"}, + "function": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "arguments": { + "type": "object", + "additionalProperties": {}, + }, + }, + }, + }, + }, + }, + }, +} + +qwen3_5_schema = { + "x-regex": r"^(?:(?:\n?)?(?:(?P.*?\S.*?)\n?|[\s]*)\s*)?(?P.*?)(?:\n+(?=))?(?=(?:|<\|im_end\|>|$))(?P(?:.+?\s*)+)?\s*(?:<\|im_end\|>|$)", + "type": "object", + "properties": { + "role": {"const": "assistant"}, + "content": {"type": "string"}, + "reasoning_content": {"type": "string"}, + "tool_calls": { + "type": "array", + "x-regex-iterator": r"\s*(.+?)\s*", + "items": { + "type": "object", + "properties": { + "type": {"const": "function"}, + "function": { + "type": "object", + "properties": { + "name": {"type": "string", "x-regex": r"]+)>"}, + "arguments": { + "type": "object", + "x-regex-key-value": r"[^>\n]+)>\n(?P.*?)\n", + "default": {}, + "additionalProperties": { + "x-parser": "json", + "x-parser-args": {"allow_non_json": True}, + }, + }, + }, + }, + }, + }, + }, + }, +} + + +deepseekv3_chat_template = (_CHAT_TEMPLATES_DIR / "deepseekv3.jinja").read_text() + +gemma_chat_template = (_CHAT_TEMPLATES_DIR / "gemma.jinja").read_text() + +glm4moe_chat_template = (_CHAT_TEMPLATES_DIR / "glm4moe.jinja").read_text() + +gptoss_chat_template = (_CHAT_TEMPLATES_DIR / "gptoss.jinja").read_text() + +llama3_chat_template = (_CHAT_TEMPLATES_DIR / "llama3.jinja").read_text() + +llama3_1_chat_template = (_CHAT_TEMPLATES_DIR / "llama3_1.jinja").read_text() + +llama3_2_chat_template = (_CHAT_TEMPLATES_DIR / "llama3_2.jinja").read_text() + +phi3_chat_template = (_CHAT_TEMPLATES_DIR / "phi3.jinja").read_text() + +qwen2_5_chat_template = (_CHAT_TEMPLATES_DIR / "qwen2_5.jinja").read_text() + +qwen3_chat_template = (_CHAT_TEMPLATES_DIR / "qwen3.jinja").read_text() + +qwen3_vl_chat_template = (_CHAT_TEMPLATES_DIR / "qwen3_vl.jinja").read_text() + +qwen3_5_chat_template_2b_and_below = (_CHAT_TEMPLATES_DIR / "qwen3_5_2b_and_below.jinja").read_text() + +qwen3_5_chat_template_4b_and_above = (_CHAT_TEMPLATES_DIR / "qwen3_5_4b_and_above.jinja").read_text() + +qwen3_6_chat_template = (_CHAT_TEMPLATES_DIR / "qwen3_6.jinja").read_text() + + +ProcessingClassT = TypeVar("ProcessingClassT", PreTrainedTokenizerBase, ProcessorMixin) + + +def add_response_schema(processing_class: ProcessingClassT) -> ProcessingClassT: + r""" + Adds the appropriate response schema to the given tokenizer based on its chat template. + + At the time of initial implementation, most tokenizers do not have built-in support for response schemas. While + waiting for broader adoption, we provide this utility function to manually set the response schema for known chat + templates. + + When given a VLM processor, the schema is set on the inner tokenizer, since `parse_response` is a tokenizer method + and reads `self.response_schema` from the tokenizer instance. + + Args: + processing_class (`PreTrainedTokenizerBase` or `ProcessorMixin`): + Tokenizer or VLM processor to which the response schema will be added. + + Returns: + `PreTrainedTokenizerBase` or `ProcessorMixin`: + The same object that was passed in, with the response schema set on the underlying tokenizer. + + Examples: + + ```python + >>> from trl.chat_template_utils import add_response_schema + >>> from transformers import AutoTokenizer + + >>> tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B") + >>> tokenizer = add_response_schema(tokenizer) + >>> assistant_text = '\n{"name": "multiply", "arguments": {"a": 3, "b": 4}}\n<|im_end|>' + >>> tokenizer.parse_response(assistant_text) + {'role': 'assistant', 'content': '', 'tool_calls': [{'type': 'function', 'function': {'name': 'multiply', 'arguments': {'a': 3, 'b': 4}}}]} + ``` + """ + # For VLM processors, set the schema on the inner tokenizer (where `parse_response` reads it from). + # Match against the top-level chat_template, since that's what was used historically and processors + # may carry their own VLM-specific template separate from the inner tokenizer's. + chat_template = processing_class.chat_template + if isinstance(processing_class, ProcessorMixin): + tokenizer = processing_class.tokenizer + else: + tokenizer = processing_class + if chat_template == glm4moe_chat_template: + tokenizer.response_schema = glm4moe_schema + elif chat_template == gptoss_chat_template: + tokenizer.response_schema = gptoss_schema + elif chat_template in [llama3_1_chat_template, llama3_2_chat_template]: + tokenizer.response_schema = llama3_schema + elif chat_template in [qwen3_chat_template, qwen3_vl_chat_template]: + tokenizer.response_schema = qwen3_schema + elif chat_template in [ + qwen3_5_chat_template_2b_and_below, + qwen3_5_chat_template_4b_and_above, + qwen3_6_chat_template, + ]: + tokenizer.response_schema = qwen3_5_schema + else: + raise ValueError( + "Unrecognized chat template, failed to add response schema. Please manually set the response schema on " + "the tokenizer or processor. See the Transformers " + "[docs](https://huggingface.co/docs/transformers/main/en/chat_response_parsing#response-parsing) for more " + "details on response parsing." + ) + return processing_class + + +def supports_tool_calling(processing_class) -> bool: + """ + Check if the processing class's chat template can render a full tool-calling conversation. + + This tests that (1) the template doesn't error when rendering a conversation with ``user → assistant (with + tool_calls) → tool`` roles, and (2) every part of the tool-calling exchange — the assistant's tool call name, its + arguments, and the tool message content — actually appears in the rendered output. Some templates silently swallow + `tool_calls` (e.g. the basic Llama 3 template, which only reads `message['content']`) or tool messages (e.g. + Cohere2, Phi3); both cases must be rejected. + + For VLMs (processors), the messages are converted to multimodal format via + [`~trl.data_utils.prepare_multimodal_messages`] before rendering. + + Args: + processing_class (`PreTrainedTokenizerBase` or `ProcessorMixin`): + Tokenizer or processor instance to check. + + Returns: + `bool`: + `True` if the chat template supports tool-calling conversations, `False` otherwise. + """ + if processing_class.chat_template is None: + return False + + is_vlm = isinstance(processing_class, ProcessorMixin) + # Distinct sentinels so we can tell which part of the exchange a template drops. + _name_sentinel = "tool_name_a8f3e2b1" + _arg_key_sentinel = "tool_arg_key_b9d4f5c2" + _arg_val_sentinel = "tool_arg_val_d6e7a9f3" + _content_sentinel = "tool_content_c4f9a8e2" + tool_calls = [ + { + "type": "function", + "function": {"name": _name_sentinel, "arguments": {_arg_key_sentinel: _arg_val_sentinel}}, + } + ] + messages = [ + {"role": "user", "content": "hi"}, + {"role": "assistant", "content": "", "tool_calls": tool_calls}, + {"role": "tool", "name": _name_sentinel, "content": _content_sentinel}, + ] + # VLMs expect content as [{"type": "text", "text": "..."}] instead of plain strings + if is_vlm: + messages = prepare_multimodal_messages(messages) + + try: + rendered = processing_class.apply_chat_template(messages, tokenize=False) + except TemplateError: + # TemplateError: template rejects the role sequence (Cohere, FalconMamba, Gemma, Gemma2, Gemma3) + # UndefinedError (subclass): template indexes into content as a list for all roles, including tool + # (Idefics2, Idefics3, LlavaNext, SmolVLM) + return False + except TypeError: + # Best-effort fallback for templates that reject dict args (e.g. DeepSeek-V3). This is a chat template + # bug (see transformers#45419), and the training chat template fixes it to avoid blocking users. + tool_calls[0]["function"]["arguments"] = f'{{"{_arg_key_sentinel}": "{_arg_val_sentinel}"}}' + try: + rendered = processing_class.apply_chat_template(messages, tokenize=False) + except TemplateError: + return False + # All four sentinels must survive: the tool name and arguments (assistant tool_calls) AND the tool message + # content. Templates that silently drop either side (basic Llama 3 drops tool_calls; Cohere2/Phi3 drop tool + # messages) will fail this check. + return all(s in rendered for s in (_name_sentinel, _arg_key_sentinel, _arg_val_sentinel, _content_sentinel)) + + +def is_chat_template_prefix_preserving(processing_class: PreTrainedTokenizerBase | ProcessorMixin) -> bool: + """ + Check whether the chat template preserves prefixes when applied. + + A prefix-preserving chat template renders earlier messages identically regardless of what messages follow. This + property is required by `_get_tool_suffix_ids`, which extracts tool response formatting tokens by comparing + tokenizations with and without tool messages appended. + + Args: + processing_class (`PreTrainedTokenizerBase` or `ProcessorMixin`): + Tokenizer or processor instance to check. + + Returns: + `bool`: + `True` if the chat template preserves prefixes, `False` otherwise. + """ + # Use the same dummy messages as _get_tool_suffix_ids to test the exact property it relies on. + dummy_tool_calls = [{"type": "function", "function": {"name": "dummy", "arguments": {}}}] + messages1 = [ + {"role": "user", "content": "dummy"}, + {"role": "assistant", "content": "", "tool_calls": dummy_tool_calls}, + ] + messages2 = [ + {"role": "user", "content": "dummy"}, + {"role": "assistant", "content": "", "tool_calls": dummy_tool_calls}, + {"role": "tool", "name": "dummy", "content": "dummy"}, + ] + # VLM processors expect structured list-of-blocks content, and image-token expansion only kicks in when an image + # is actually present, so include a dummy image to exercise the real code path. + is_vlm = isinstance(processing_class, ProcessorMixin) + if is_vlm: + from PIL import Image + + dummy_image = Image.new("RGB", (8, 8)) + messages1 = prepare_multimodal_messages(messages1, images=[dummy_image]) + messages2 = prepare_multimodal_messages(messages2, images=[dummy_image]) + + try: + ids1 = processing_class.apply_chat_template(messages1, tokenize=True, return_dict=False) + ids2 = processing_class.apply_chat_template( + messages2, tokenize=True, return_dict=False, add_generation_prompt=True + ) + except TypeError: + # Best-effort fallback for templates that reject dict args (e.g. DeepSeek-V3). This is a chat template + # bug (see transformers#45419), and the training chat template fixes it to avoid blocking users. + dummy_tool_calls = [{"type": "function", "function": {"name": "dummy", "arguments": "{}"}}] + messages1[1]["tool_calls"] = dummy_tool_calls + messages2[1]["tool_calls"] = dummy_tool_calls + ids1 = processing_class.apply_chat_template(messages1, tokenize=True, return_dict=False) + ids2 = processing_class.apply_chat_template( + messages2, tokenize=True, return_dict=False, add_generation_prompt=True + ) + + # VLM processors return batched output (list of lists), unbatch for single conversation + if is_vlm: + ids1 = ids1[0] + ids2 = ids2[0] + + return ids2[: len(ids1)] == ids1 + + +deepseekv3_training_chat_template = (_CHAT_TEMPLATES_DIR / "deepseekv3_training.jinja").read_text() + +gemma_training_chat_template = (_CHAT_TEMPLATES_DIR / "gemma_training.jinja").read_text() + +glm4moe_training_chat_template = (_CHAT_TEMPLATES_DIR / "glm4moe_training.jinja").read_text() + +gptoss_training_chat_template = (_CHAT_TEMPLATES_DIR / "gptoss_training.jinja").read_text() + +llama3_training_chat_template = (_CHAT_TEMPLATES_DIR / "llama3_training.jinja").read_text() + +phi3_training_chat_template = (_CHAT_TEMPLATES_DIR / "phi3_training.jinja").read_text() + +qwen2_5_training_chat_template = (_CHAT_TEMPLATES_DIR / "qwen2_5_training.jinja").read_text() + +qwen3_training_chat_template = (_CHAT_TEMPLATES_DIR / "qwen3_training.jinja").read_text() + +qwen3_6_training_chat_template = (_CHAT_TEMPLATES_DIR / "qwen3_6_training.jinja").read_text() + + +def get_training_chat_template(tokenizer: PreTrainedTokenizerBase) -> str | None: + r""" + Get a training-compatible chat template, if needed. + + Returns a patched chat template that is prefix-preserving and includes `{%% generation %%}` / `{%% endgeneration + %%}` markers for assistant-only loss masking. Returns `None` if the tokenizer's template already satisfies both + requirements. Currently DeepSeek-V3, Gemma, Gemma2, GLM-4-MoE, GPT-OSS, LLaMA 3, Phi-3, Qwen2.5, Qwen3, and Qwen3.6 + are supported. + + Args: + tokenizer (`PreTrainedTokenizerBase`): + Tokenizer instance to check. + + Returns: + `str` or `None`: + Training-compatible chat template, or `None` if no patching is needed. + + Example: + + ```python + >>> from trl.chat_template_utils import get_training_chat_template + >>> from transformers import AutoTokenizer + + >>> tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B") + >>> messages1 = [ + ... {"role": "user", "content": "What is 2 * 3?"}, + ... { + ... "role": "assistant", + ... "content": "", + ... "tool_calls": [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 2, "b": 3}}}], + ... }, + ... ] + >>> messages2 = messages1 + [ + ... {"role": "tool", "name": "multiply", "content": "6"}, + ... ] + >>> tokenizer.apply_chat_template(messages1, tokenize=False) + '<|im_start|>user\nWhat is 2 * 3?<|im_end|>\n<|im_start|>assistant\n\n\n\n\n\n{"name": "multiply", "arguments": {"a": 2, "b": 3}}\n<|im_end|>\n' + + >>> tokenizer.apply_chat_template(messages2, tokenize=False, add_generation_prompt=True) + '<|im_start|>user\nWhat is 2 * 3?<|im_end|>\n<|im_start|>assistant\n\n{"name": "multiply", "arguments": {"a": 2, "b": 3}}\n<|im_end|>\n<|im_start|>user\n\n6\n<|im_end|>\n<|im_start|>assistant\n' + + >>> # ^ think tags missing + >>> chat_template = get_training_chat_template(tokenizer) + >>> tokenizer.apply_chat_template(messages1, tokenize=False, chat_template=chat_template) + '<|im_start|>user\nWhat is 2 * 3?<|im_end|>\n<|im_start|>assistant\n\n\n\n\n\n{"name": "multiply", "arguments": {"a": 2, "b": 3}}\n<|im_end|>\n' + + >>> tokenizer.apply_chat_template( + ... messages2, tokenize=False, add_generation_prompt=True, chat_template=chat_template + ... ) + '<|im_start|>user\nWhat is 2 * 3?<|im_end|>\n<|im_start|>assistant\n\n\n\n\n\n{"name": "multiply", "arguments": {"a": 2, "b": 3}}\n<|im_end|>\n<|im_start|>user\n\n6\n<|im_end|>\n<|im_start|>assistant\n' + ``` + """ + # First check if patching is needed. Prefix-preservation only matters when the template actually supports tools + # (the check itself renders a tool message), so skip it otherwise. + prefix_ok = not supports_tool_calling(tokenizer) or is_chat_template_prefix_preserving(tokenizer) + if prefix_ok and "{% generation %}" in tokenizer.chat_template: + return None # No patching needed + + if tokenizer.chat_template == deepseekv3_chat_template: + return deepseekv3_training_chat_template + + if tokenizer.chat_template == gemma_chat_template: + return gemma_training_chat_template + + if tokenizer.chat_template == glm4moe_chat_template: + return glm4moe_training_chat_template + + if tokenizer.chat_template == gptoss_chat_template: + return gptoss_training_chat_template + + if tokenizer.chat_template == llama3_chat_template: + return llama3_training_chat_template + + if tokenizer.chat_template == phi3_chat_template: + return phi3_training_chat_template + + if tokenizer.chat_template == qwen2_5_chat_template: + return qwen2_5_training_chat_template + + if tokenizer.chat_template == qwen3_chat_template: + return qwen3_training_chat_template + + if tokenizer.chat_template == qwen3_6_chat_template: + return qwen3_6_training_chat_template + + raise ValueError( + "The tokenizer's chat template is not training-compatible (missing prefix-preservation or " + "`{% generation %}` markers) and patching is not supported for this template. " + "Please manually modify the tokenizer's chat template for training." + ) + + +def _validate_tool_calls(tool_calls: list | None) -> None: + """ + Validate tool_calls to ensure all required fields exist with valid values. + + Raises ValueError when the model generates malformed tool calls (e.g., missing 'arguments' field) that are + partially parsed. + + Args: + tool_calls: List of tool call dictionaries, or None. + """ + if tool_calls is None: + return None + if not isinstance(tool_calls, list): + raise ValueError("tool_calls must be a list or None.") + + for idx, tool_call in enumerate(tool_calls): + if not isinstance(tool_call, dict): + raise ValueError(f"tool_calls[{idx}] must be a dict.") + + # Handle nested function structure: {"type": "function", "function": {"name": ..., "arguments": ...}} + if "function" in tool_call: + func = tool_call["function"] + if not isinstance(func, dict): + raise ValueError(f"tool_calls[{idx}]['function'] must be a dict.") + if not isinstance(func.get("name"), str): + raise ValueError(f"tool_calls[{idx}]['function']['name'] must be a string.") + # Some templates (e.g. Qwen3.5) omit arguments for valid no-arg calls; normalize to {}. + if "arguments" not in func or func["arguments"] is None: + func["arguments"] = {} + else: + # Handle flat structure: {"name": ..., "arguments": ...} + if not isinstance(tool_call.get("name"), str): + raise ValueError(f"tool_calls[{idx}]['name'] must be a string.") + # Some templates (e.g. Qwen3.5) omit arguments for valid no-arg calls; normalize to {}. + if "arguments" not in tool_call or tool_call["arguments"] is None: + tool_call["arguments"] = {} + + +def parse_response(processing_class: PreTrainedTokenizerBase | ProcessorMixin, ids: list[int]) -> dict: + r""" + Parse a token sequence into structured response dictionaries with fallback handling. + + Attempts to parse the sequence using `tokenizer.parse_response()`. If parsing fails (e.g., due to malformed tool + calls like `{"type":"function"`), falls back to decoding as plain text. + + Also removes incorrectly appended EOS tokens from tool call content when present, and validates tool_calls to + ensure all required fields exist. + + For VLM processors, automatically uses the inner tokenizer for parsing. + + Args: + processing_class (`PreTrainedTokenizerBase` or VLM processor): + Tokenizer or processor with a `parse_response()` method (directly or via inner tokenizer). + ids (`list[int]`): + List of token sequences. + + Returns: + `dict`: + Response dictionary. + + Example: + ```python + >>> from trl.chat_template_utils import parse_response, add_response_schema + >>> from transformers import AutoTokenizer + + >>> tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B") + >>> tokenizer = add_response_schema(tokenizer) # temporary until built-in support + >>> text = '\n{"name": "multiply", "arguments": {"a": 3, "b": 4}}\n<|im_end|>' + >>> ids = tokenizer(text)["input_ids"] + >>> parse_response(tokenizer, ids) + {'role': 'assistant', 'content': '', 'tool_calls': [{'type': 'function', 'function': {'name': 'multiply', 'arguments': {'a': 3, 'b': 4}}}]} + ``` + """ + # VLM processors don't have parse_response directly; use the inner tokenizer + tokenizer = getattr(processing_class, "tokenizer", processing_class) + try: + parsed = tokenizer.parse_response(ids) + # Hotfix: remove incorrectly appended EOS token from tool calls + # See https://github.com/huggingface/transformers/issues/42249 + if isinstance(parsed.get("content"), str): + parsed["content"] = parsed["content"].removesuffix(tokenizer.eos_token) + # Normalize: ensure content is always a string (some models omit it or set it to None) + if not parsed.get("content"): + parsed["content"] = "" + # Validate tool_calls to prevent Jinja2 Undefined errors when fields are missing + if "tool_calls" in parsed: + _validate_tool_calls(parsed["tool_calls"]) + except (ValueError, TypeError): + # Fallback: decode as plain text if parsing fails. This happens if the model outputs malformed tool calls. + content = tokenizer.decode(ids, skip_special_tokens=True) + parsed = {"role": "assistant", "content": content} + return parsed diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/README.md b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9b9f02430817368f4bb2144da2ae4cc45cd5d76f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/README.md @@ -0,0 +1,145 @@ +# Chat Templates + +Jinja2 chat templates stored here serve two purposes: + +1. **Identity comparison**: detecting which model is being used (by comparing `tokenizer.chat_template` against known templates) to add the appropriate response schema (`add_response_schema`) or swap in a training template (`get_training_chat_template`). +2. **Training patches**: modified templates that fix training-specific issues (prefix-preservation for GRPO, `{% generation %}` markers for SFT assistant-only loss). + +**Why prefix-preserving?** The GRPO tool call loop extracts tool response formatting tokens by comparing tokenizations with and without tool messages appended (`_get_tool_suffix_ids`). This requires the chat template to be *prefix-preserving*: appending messages must not change how earlier messages are rendered. + +**Why generation-tagged?** SFT with `assistant_only_loss=True` requires the chat template to include `{% generation %}` / `{% endgeneration %}` markers around assistant output, so `return_assistant_tokens_mask=True` can produce correct masks. Most model templates don't include these markers natively. + +## Original templates + +Used for identity comparison only. + +### `deepseekv3.jinja` + +Original DeepSeek-V3 chat template. + +### `gemma.jinja` + +Original Gemma chat template. Used by both Gemma (v1) and Gemma2, which ship identical templates. + +### `glm4moe.jinja` + +Original GLM-4-MoE chat template. + +### `gptoss.jinja` + +Original GPT-OSS chat template. + +### `llama3.jinja` + +Original Llama 3 chat template. + +### `llama3_1.jinja` / `llama3_2.jinja` + +Original Llama 3.1 / 3.2 chat templates. Both render tool calls as a single bare JSON object using the key `parameters` (instead of `arguments`) and support at most one tool call per assistant turn. + +### `qwen2_5.jinja` + +Original Qwen2.5 chat template. + +### `qwen3.jinja` + +Original Qwen3 chat template. + +### `qwen3_vl.jinja` + +Original Qwen3-VL chat template. Unlike text-only Qwen3, this template is already prefix-preserving (no conditional thinking blocks), so no training patch is needed. + +### `qwen3_5_2b_and_below.jinja` / `qwen3_5_4b_and_above.jinja` + +Original Qwen3.5 chat templates. + +### `qwen3_6.jinja` + +Original Qwen3.6 chat template (shared across `Qwen3.6-27B`, `Qwen3.6-35B-A3B`, and their FP8 variants). Differs from `qwen3_5_4b_and_above.jinja` by adding a `preserve_thinking` flag and tweaking how non-string tool-call argument values are stringified. + +## Training templates + +Patched templates that fix training-specific issues. Swapped in at init when tools are enabled (GRPO) or when `assistant_only_loss=True` (SFT). + +### `deepseekv3_training.jinja` + +Patched DeepSeek-V3 template. Diff vs `deepseekv3.jinja`: + +- Uses `| tojson` on `tool['function']['arguments']` so that `arguments` can be passed as a `dict` (the documented format per [transformers docs](https://huggingface.co/docs/transformers/en/chat_extras#tool-calling-example)). The original template uses raw string concatenation, which crashes on dict inputs. +- Wraps assistant message output with `{% generation %}` / `{% endgeneration %}` markers for SFT assistant-only loss. + +### `gemma_training.jinja` + +Patched Gemma template, shared by Gemma (v1) and Gemma2 (which ship identical chat templates). Diff vs `gemma.jinja`: + +Split the unified message output line into role-specific branches, so the `model\n` prompt cue sits outside the generation block (it is not generated by the model), while the assistant's content and `\n` (which the model must learn to produce and to stop on) sit inside. Wrap the assistant content with `{% generation %}` / `{% endgeneration %}` so that `return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `glm4moe_training.jinja` + +Patched GLM-4-MoE template. Diff vs `glm4moe.jinja`: + +Require both `` and `` to be present before parsing, to avoid incorrect splitting when the model generates only one tag: + +```diff +- {%- if '' in content %} ++ {%- if '' in content and '' in content %} +``` + +Wrap assistant message output with `{% generation %}` / `{% endgeneration %}` so that `return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `gptoss_training.jinja` + +Patched GPT-OSS template. Diff vs `gptoss.jinja`: + +Wrap assistant message output with `{% generation %}` / `{% endgeneration %}` so that `return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `llama3_training.jinja` + +Patched Llama 3 template. Diff vs `llama3.jinja`: + +Wrap assistant message output with `{% generation %}` / `{% endgeneration %}` so that `return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `phi3_training.jinja` + +Patched Phi-3 template. Diff vs `phi3.jinja`: + +Wrap assistant message output with `{% generation %}` / `{% endgeneration %}` so that +`return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `qwen2_5_training.jinja` + +Patched Qwen2.5 template. Diff vs `qwen2_5.jinja`: + +Wrap assistant message output with `{% generation %}` / `{% endgeneration %}` so that `return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `qwen3_training.jinja` + +Patched Qwen3 template. Diff vs `qwen3.jinja`: + +Require both `` and `` to be present before parsing, to avoid incorrect splitting when the model generates only one tag: + +```diff +- {%- if '' in content %} ++ {%- if '' in content and '' in content %} +``` + +Always include the thinking block regardless of message position. The original conditionally omits it based on `loop.last`, which changes the assistant rendering when a tool message is appended — breaking prefix-preservation: + +```diff +- {%- if loop.index0 > ns.last_query_index %} +- {%- if loop.last or (not loop.last and reasoning_content) %} +- {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} +- {%- else %} +- {{- '<|im_start|>' + message.role + '\n' + content }} +- {%- endif %} +- {%- else %} +- {{- '<|im_start|>' + message.role + '\n' + content }} +- {%- endif %} ++ {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} +``` + +Wrap assistant message output with `{% generation %}` / `{% endgeneration %}` so that `return_assistant_tokens_mask=True` produces correct masks for SFT assistant-only loss. + +### `qwen3_6_training.jinja` + +Patched Qwen3.6 template. Same diff as `qwen3_training.jinja` (require both `` and `` before parsing, drop the `loop.index0 > ns.last_query_index` conditional so the thinking block is always emitted, wrap assistant output in `{% generation %}` / `{% endgeneration %}`), applied to the Qwen3.6 base template. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/deepseekv3.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/deepseekv3.jinja new file mode 100644 index 0000000000000000000000000000000000000000..1f77c0e7a0387150b561306b16531fac17a15ab5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/deepseekv3.jinja @@ -0,0 +1 @@ +{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '\n\n' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' in message %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if message['content'] is none %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<|tool▁call▁end|>'}}{%- else %}{{'<|Assistant|>' + message['content'] + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- endfor %}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' not in message %}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '' in content %}{% set content = content.split('')[-1] %}{% endif %}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|>\n'}}{% endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/deepseekv3_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/deepseekv3_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..6b965f057ec733b867da74e6a1b1d50e108c54f1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/deepseekv3_training.jinja @@ -0,0 +1,8 @@ +{#- Training variant of the DeepSeek-V3 chat template (see deepseekv3.jinja for the original). + Modifications vs the original: + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. + - Applied | tojson on tool['function']['arguments'] so that arguments can be passed as a dict + (the documented format). The original uses raw string concatenation, which crashes on dicts. +-#} +{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '\n\n' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' in message %}{%- set ns.is_tool = false -%}{%- generation %}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if message['content'] is none %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] | tojson + '\n' + '```' + '<|tool▁call▁end|>'}}{%- else %}{{'<|Assistant|>' + message['content'] + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] | tojson + '\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] | tojson + '\n' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- endfor %}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endgeneration %}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' not in message %}{%- if ns.is_tool %}{%- generation %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- endgeneration %}{%- else %}{%- generation %}{% set content = message['content'] %}{% if '' in content %}{% set content = content.split('')[-1] %}{% endif %}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}{%- endgeneration %}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|>\n'}}{% endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gemma.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gemma.jinja new file mode 100644 index 0000000000000000000000000000000000000000..923ec253c8dbefbb41cf084db7251df41d000f6d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gemma.jinja @@ -0,0 +1,4 @@ +{{ bos_token }}{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% endif %}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '' + role + ' +' + message['content'] | trim + ' +' }}{% endfor %}{% if add_generation_prompt %}{{'model +'}}{% endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gemma_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gemma_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..290e63f8ebe2917790b67568cefb231804a08299 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gemma_training.jinja @@ -0,0 +1,29 @@ +{#- Training variant of the Gemma chat template (see gemma.jinja for the original). + This template is shared by Gemma (v1) and Gemma2, which ship identical chat templates. + Modifications vs the original: + - Split the unified output line into role-specific branches so that the + 'model\n' header (a prompt cue, not generated by the model) sits + outside the generation block. + - Added {% generation %} / {% endgeneration %} around assistant message content to + support assistant-only loss masking in SFT training. +-#} +{{- bos_token -}} +{%- if messages[0]['role'] == 'system' -%} + {{- raise_exception('System role not supported') -}} +{%- endif -%} +{%- for message in messages -%} + {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%} + {{- raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') -}} + {%- endif -%} + {%- if message['role'] == 'assistant' -%} + {{- 'model\n' -}} + {%- generation -%} + {{- message['content'] | trim + '\n' -}} + {%- endgeneration -%} + {%- else -%} + {{- '' + message['role'] + '\n' + message['content'] | trim + '\n' -}} + {%- endif -%} +{%- endfor -%} +{%- if add_generation_prompt -%} + {{- 'model\n' -}} +{%- endif -%} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/glm4moe.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/glm4moe.jinja new file mode 100644 index 0000000000000000000000000000000000000000..41478957aca7a04b7321022e7d1f73de5badd995 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/glm4moe.jinja @@ -0,0 +1,103 @@ +[gMASK] +{%- if tools -%} +<|system|> +# Tools + +You may call one or more functions to assist with the user query. + +You are provided with function signatures within XML tags: + +{% for tool in tools %} +{{ tool | tojson(ensure_ascii=False) }} +{% endfor %} + + +For each function call, output the function name and arguments within the following XML format: +{function-name} +{arg-key-1} +{arg-value-1} +{arg-key-2} +{arg-value-2} +... +{%- endif -%} +{%- macro visible_text(content) -%} + {%- if content is string -%} + {{- content }} + {%- elif content is iterable and content is not mapping -%} + {%- for item in content -%} + {%- if item is mapping and item.type == 'text' -%} + {{- item.text }} + {%- elif item is string -%} + {{- item }} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {{- content }} + {%- endif -%} +{%- endmacro -%} +{%- set ns = namespace(last_user_index=-1) %} +{%- for m in messages %} + {%- if m.role == 'user' %} + {% set ns.last_user_index = loop.index0 -%} + {%- endif %} +{%- endfor %} +{% for m in messages %} +{%- if m.role == 'user' -%}<|user|> +{{ visible_text(m.content) }} +{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith("/nothink")) else '' -}} +{%- elif m.role == 'assistant' -%} +<|assistant|> +{%- set reasoning_content = '' %} +{%- set content = visible_text(m.content) %} +{%- if m.reasoning_content is string %} + {%- set reasoning_content = m.reasoning_content %} +{%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} +{%- endif %} +{%- if loop.index0 > ns.last_user_index and reasoning_content -%} +{{ '\n' + reasoning_content.strip() + ''}} +{%- else -%} +{{ '\n' }} +{%- endif -%} +{%- if content.strip() -%} +{{ '\n' + content.strip() }} +{%- endif -%} +{% if m.tool_calls %} +{% for tc in m.tool_calls %} +{%- if tc.function %} + {%- set tc = tc.function %} +{%- endif %} +{{ '\n' + tc.name }} +{% set _args = tc.arguments %} +{% for k, v in _args.items() %} +{{ k }} +{{ v | tojson(ensure_ascii=False) if v is not string else v }} +{% endfor %} +{% endfor %} +{% endif %} +{%- elif m.role == 'tool' -%} +{%- if m.content is string -%} +{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|observation|>' }} +{%- endif %} +{{- '\n\n' }} +{{- m.content }} +{{- '\n' }} +{%- else -%} +<|observation|>{% for tr in m.content %} + + +{{ tr.output if tr.output is defined else tr }} +{% endfor -%} +{% endif -%} +{%- elif m.role == 'system' -%} +<|system|> +{{ visible_text(m.content) }} +{%- endif -%} +{%- endfor -%} +{%- if add_generation_prompt -%} + <|assistant|>{{- '\n' if (enable_thinking is defined and not enable_thinking) else '' -}} +{%- endif -%} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/glm4moe_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/glm4moe_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..7e02685cda7eaa7a70a1ae0df864bed86e97ae82 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/glm4moe_training.jinja @@ -0,0 +1,112 @@ +{#- Training variant of the GLM-4-MoE chat template (see glm4moe.jinja for the original). + Modifications vs the original: + - {%- if '' in content %} → {%- if '' in content and '' in content %} + Always check for both tags to avoid edge cases where the model generates only one tag. + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. +-#} +[gMASK] +{%- if tools -%} +<|system|> +# Tools + +You may call one or more functions to assist with the user query. + +You are provided with function signatures within XML tags: + +{% for tool in tools %} +{{ tool | tojson(ensure_ascii=False) }} +{% endfor %} + + +For each function call, output the function name and arguments within the following XML format: +{function-name} +{arg-key-1} +{arg-value-1} +{arg-key-2} +{arg-value-2} +... +{%- endif -%} +{%- macro visible_text(content) -%} + {%- if content is string -%} + {{- content }} + {%- elif content is iterable and content is not mapping -%} + {%- for item in content -%} + {%- if item is mapping and item.type == 'text' -%} + {{- item.text }} + {%- elif item is string -%} + {{- item }} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {{- content }} + {%- endif -%} +{%- endmacro -%} +{%- set ns = namespace(last_user_index=-1) %} +{%- for m in messages %} + {%- if m.role == 'user' %} + {% set ns.last_user_index = loop.index0 -%} + {%- endif %} +{%- endfor %} +{% for m in messages %} +{%- if m.role == 'user' -%}<|user|> +{{ visible_text(m.content) }} +{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith("/nothink")) else '' -}} +{%- elif m.role == 'assistant' -%} +<|assistant|> +{%- set reasoning_content = '' %} +{%- set content = visible_text(m.content) %} +{%- if m.reasoning_content is string %} + {%- set reasoning_content = m.reasoning_content %} +{%- else %} + {%- if '' in content and '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} +{%- endif %} +{%- generation %} +{%- if loop.index0 > ns.last_user_index and reasoning_content -%} +{{ '\n' + reasoning_content.strip() + ''}} +{%- else -%} +{{ '\n' }} +{%- endif -%} +{%- if content.strip() -%} +{{ '\n' + content.strip() }} +{%- endif -%} +{% if m.tool_calls %} +{% for tc in m.tool_calls %} +{%- if tc.function %} + {%- set tc = tc.function %} +{%- endif %} +{{ '\n' + tc.name }} +{% set _args = tc.arguments %} +{% for k, v in _args.items() %} +{{ k }} +{{ v | tojson(ensure_ascii=False) if v is not string else v }} +{% endfor %} +{% endfor %} +{% endif %} +{%- endgeneration %} +{%- elif m.role == 'tool' -%} +{%- if m.content is string -%} +{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|observation|>' }} +{%- endif %} +{{- '\n\n' }} +{{- m.content }} +{{- '\n' }} +{%- else -%} +<|observation|>{% for tr in m.content %} + + +{{ tr.output if tr.output is defined else tr }} +{% endfor -%} +{% endif -%} +{%- elif m.role == 'system' -%} +<|system|> +{{ visible_text(m.content) }} +{%- endif -%} +{%- endfor -%} +{%- if add_generation_prompt -%} + <|assistant|>{{- '\n' if (enable_thinking is defined and not enable_thinking) else '' -}} +{%- endif -%} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gptoss.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gptoss.jinja new file mode 100644 index 0000000000000000000000000000000000000000..dc7bb11927d29f653ba2740f2db2c688fd77592f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gptoss.jinja @@ -0,0 +1,331 @@ +{#- + In addition to the normal inputs of `messages` and `tools`, this template also accepts the + following kwargs: + - "builtin_tools": A list, can contain "browser" and/or "python". + - "model_identity": A string that optionally describes the model identity. + - "reasoning_effort": A string that describes the reasoning effort, defaults to "medium". + #} + +{#- Tool Definition Rendering ============================================== #} +{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%} + {%- if param_spec.type == "array" -%} + {%- if param_spec['items'] -%} + {%- if param_spec['items']['type'] == "string" -%} + {{- "string[]" }} + {%- elif param_spec['items']['type'] == "number" -%} + {{- "number[]" }} + {%- elif param_spec['items']['type'] == "integer" -%} + {{- "number[]" }} + {%- elif param_spec['items']['type'] == "boolean" -%} + {{- "boolean[]" }} + {%- else -%} + {%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%} + {%- if inner_type == "object | object" or inner_type|length > 50 -%} + {{- "any[]" }} + {%- else -%} + {{- inner_type + "[]" }} + {%- endif -%} + {%- endif -%} + {%- if param_spec.nullable -%} + {{- " | null" }} + {%- endif -%} + {%- else -%} + {{- "any[]" }} + {%- if param_spec.nullable -%} + {{- " | null" }} + {%- endif -%} + {%- endif -%} + {%- elif param_spec.type is defined and param_spec.type is iterable and param_spec.type is not string and param_spec.type is not mapping and param_spec.type[0] is defined -%} + {#- Handle array of types like ["object", "object"] from Union[dict, list] #} + {%- if param_spec.type | length > 1 -%} + {{- param_spec.type | join(" | ") }} + {%- else -%} + {{- param_spec.type[0] }} + {%- endif -%} + {%- elif param_spec.oneOf -%} + {#- Handle oneOf schemas - check for complex unions and fallback to any #} + {%- set has_object_variants = false -%} + {%- for variant in param_spec.oneOf -%} + {%- if variant.type == "object" -%} + {%- set has_object_variants = true -%} + {%- endif -%} + {%- endfor -%} + {%- if has_object_variants and param_spec.oneOf|length > 1 -%} + {{- "any" }} + {%- else -%} + {%- for variant in param_spec.oneOf -%} + {{- render_typescript_type(variant, required_params) -}} + {%- if variant.description %} + {{- "// " + variant.description }} + {%- endif -%} + {%- if variant.default is defined %} + {{ "// default: " + variant.default|tojson }} + {%- endif -%} + {%- if not loop.last %} + {{- " | " }} + {% endif -%} + {%- endfor -%} + {%- endif -%} + {%- elif param_spec.type == "string" -%} + {%- if param_spec.enum -%} + {{- '"' + param_spec.enum|join('" | "') + '"' -}} + {%- else -%} + {{- "string" }} + {%- if param_spec.nullable %} + {{- " | null" }} + {%- endif -%} + {%- endif -%} + {%- elif param_spec.type == "number" -%} + {{- "number" }} + {%- elif param_spec.type == "integer" -%} + {{- "number" }} + {%- elif param_spec.type == "boolean" -%} + {{- "boolean" }} + + {%- elif param_spec.type == "object" -%} + {%- if param_spec.properties -%} + {{- "{\n" }} + {%- for prop_name, prop_spec in param_spec.properties.items() -%} + {{- prop_name -}} + {%- if prop_name not in (param_spec.required or []) -%} + {{- "?" }} + {%- endif -%} + {{- ": " }} + {{ render_typescript_type(prop_spec, param_spec.required or []) }} + {%- if not loop.last -%} + {{-", " }} + {%- endif -%} + {%- endfor -%} + {{- "}" }} + {%- else -%} + {{- "object" }} + {%- endif -%} + {%- else -%} + {{- "any" }} + {%- endif -%} +{%- endmacro -%} + +{%- macro render_tool_namespace(namespace_name, tools) -%} + {{- "## " + namespace_name + "\n\n" }} + {{- "namespace " + namespace_name + " {\n\n" }} + {%- for tool in tools %} + {%- set tool = tool.function %} + {{- "// " + tool.description + "\n" }} + {{- "type "+ tool.name + " = " }} + {%- if tool.parameters and tool.parameters.properties %} + {{- "(_: {\n" }} + {%- for param_name, param_spec in tool.parameters.properties.items() %} + {%- if param_spec.description %} + {{- "// " + param_spec.description + "\n" }} + {%- endif %} + {{- param_name }} + {%- if param_name not in (tool.parameters.required or []) -%} + {{- "?" }} + {%- endif -%} + {{- ": " }} + {{- render_typescript_type(param_spec, tool.parameters.required or []) }} + {%- if param_spec.default is defined -%} + {%- if param_spec.enum %} + {{- ", // default: " + param_spec.default }} + {%- elif param_spec.oneOf %} + {{- "// default: " + param_spec.default }} + {%- else %} + {{- ", // default: " + param_spec.default|tojson }} + {%- endif -%} + {%- endif -%} + {%- if not loop.last %} + {{- ",\n" }} + {%- else %} + {{- ",\n" }} + {%- endif -%} + {%- endfor %} + {{- "}) => any;\n\n" }} + {%- else -%} + {{- "() => any;\n\n" }} + {%- endif -%} + {%- endfor %} + {{- "} // namespace " + namespace_name }} +{%- endmacro -%} + +{%- macro render_builtin_tools(browser_tool, python_tool) -%} + {%- if browser_tool %} + {{- "## browser\n\n" }} + {{- "// Tool for browsing.\n" }} + {{- "// The `cursor` appears in brackets before each browsing display: `[{cursor}]`.\n" }} + {{- "// Cite information from the tool using the following format:\n" }} + {{- "// `【{cursor}†L{line_start}(-L{line_end})?】`, for example: `【6†L9-L11】` or `【8†L3】`.\n" }} + {{- "// Do not quote more than 10 words directly from the tool output.\n" }} + {{- "// sources=web (default: web)\n" }} + {{- "namespace browser {\n\n" }} + {{- "// Searches for information related to `query` and displays `topn` results.\n" }} + {{- "type search = (_: {\n" }} + {{- "query: string,\n" }} + {{- "topn?: number, // default: 10\n" }} + {{- "source?: string,\n" }} + {{- "}) => any;\n\n" }} + {{- "// Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines.\n" }} + {{- "// Valid link ids are displayed with the formatting: `【{id}†.*】`.\n" }} + {{- "// If `cursor` is not provided, the most recent page is implied.\n" }} + {{- "// If `id` is a string, it is treated as a fully qualified URL associated with `source`.\n" }} + {{- "// If `loc` is not provided, the viewport will be positioned at the beginning of the document or centered on the most relevant passage, if available.\n" }} + {{- "// Use this function without `id` to scroll to a new location of an opened page.\n" }} + {{- "type open = (_: {\n" }} + {{- "id?: number | string, // default: -1\n" }} + {{- "cursor?: number, // default: -1\n" }} + {{- "loc?: number, // default: -1\n" }} + {{- "num_lines?: number, // default: -1\n" }} + {{- "view_source?: boolean, // default: false\n" }} + {{- "source?: string,\n" }} + {{- "}) => any;\n\n" }} + {{- "// Finds exact matches of `pattern` in the current page, or the page given by `cursor`.\n" }} + {{- "type find = (_: {\n" }} + {{- "pattern: string,\n" }} + {{- "cursor?: number, // default: -1\n" }} + {{- "}) => any;\n\n" }} + {{- "} // namespace browser\n\n" }} + {%- endif -%} + + {%- if python_tool %} + {{- "## python\n\n" }} + {{- "Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).\n\n" }} + {{- "When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.\n\n" }} + {%- endif -%} +{%- endmacro -%} + +{#- System Message Construction ============================================ #} +{%- macro build_system_message() -%} + {%- if model_identity is not defined %} + {%- set model_identity = "You are ChatGPT, a large language model trained by OpenAI." %} + {%- endif %} + {{- model_identity + "\n" }} + {{- "Knowledge cutoff: 2024-06\n" }} + {{- "Current date: " + strftime_now("%Y-%m-%d") + "\n\n" }} + {%- if reasoning_effort is not defined %} + {%- set reasoning_effort = "medium" %} + {%- endif %} + {{- "Reasoning: " + reasoning_effort + "\n\n" }} + {%- if builtin_tools %} + {{- "# Tools\n\n" }} + {%- set available_builtin_tools = namespace(browser=false, python=false) %} + {%- for tool in builtin_tools %} + {%- if tool == "browser" %} + {%- set available_builtin_tools.browser = true %} + {%- elif tool == "python" %} + {%- set available_builtin_tools.python = true %} + {%- endif %} + {%- endfor %} + {{- render_builtin_tools(available_builtin_tools.browser, available_builtin_tools.python) }} + {%- endif -%} + {{- "# Valid channels: analysis, commentary, final. Channel must be included for every message." }} + {%- if tools -%} + {{- "\nCalls to these tools must go to the commentary channel: 'functions'." }} + {%- endif -%} +{%- endmacro -%} + +{#- Main Template Logic ================================================= #} +{#- Set defaults #} + +{#- Render system message #} +{{- "<|start|>system<|message|>" }} +{{- build_system_message() }} +{{- "<|end|>" }} + +{#- Extract developer message #} +{%- if messages[0].role == "developer" or messages[0].role == "system" %} + {%- set developer_message = messages[0].content %} + {%- set loop_messages = messages[1:] %} +{%- else %} + {%- set developer_message = "" %} + {%- set loop_messages = messages %} +{%- endif %} + +{#- Render developer message #} +{%- if developer_message or tools %} + {{- "<|start|>developer<|message|>" }} + {%- if developer_message %} + {{- "# Instructions\n\n" }} + {{- developer_message }} + {{- "\n\n" }} + {%- endif %} + {%- if tools -%} + {{- "# Tools\n\n" }} + {{- render_tool_namespace("functions", tools) }} + {%- endif -%} + {{- "<|end|>" }} +{%- endif %} + +{#- Render messages #} +{%- set last_tool_call = namespace(name=none) %} +{%- for message in loop_messages -%} + {#- At this point only assistant/user/tool messages should remain #} + {%- if message.role == 'assistant' -%} + {#- Checks to ensure the messages are being passed in the format we expect #} + {%- if "content" in message %} + {%- if "<|channel|>analysis<|message|>" in message.content or "<|channel|>final<|message|>" in message.content %} + {{- raise_exception("You have passed a message containing <|channel|> tags in the content field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.") }} + {%- endif %} + {%- endif %} + {%- if "thinking" in message %} + {%- if "<|channel|>analysis<|message|>" in message.thinking or "<|channel|>final<|message|>" in message.thinking %} + {{- raise_exception("You have passed a message containing <|channel|> tags in the thinking field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.") }} + {%- endif %} + {%- endif %} + {%- if "tool_calls" in message %} + {#- We need very careful handling here - we want to drop the tool call analysis message if the model #} + {#- has output a later <|final|> message, but otherwise we want to retain it. This is the only case #} + {#- when we render CoT/analysis messages in inference. #} + {%- set future_final_message = namespace(found=false) %} + {%- for future_message in loop_messages[loop.index:] %} + {%- if future_message.role == 'assistant' and "tool_calls" not in future_message %} + {%- set future_final_message.found = true %} + {%- endif %} + {%- endfor %} + {#- We assume max 1 tool call per message, and so we infer the tool call name #} + {#- in "tool" messages from the most recent assistant tool call name #} + {%- set tool_call = message.tool_calls[0] %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {%- if message.content and message.thinking %} + {{- raise_exception("Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.") }} + {%- elif message.content and not future_final_message.found %} + {{- "<|start|>assistant<|channel|>analysis<|message|>" + message.content + "<|end|>" }} + {%- elif message.thinking and not future_final_message.found %} + {{- "<|start|>assistant<|channel|>analysis<|message|>" + message.thinking + "<|end|>" }} + {%- endif %} + {{- "<|start|>assistant to=" }} + {{- "functions." + tool_call.name + "<|channel|>commentary " }} + {{- (tool_call.content_type if tool_call.content_type is defined else "json") + "<|message|>" }} + {{- tool_call.arguments|tojson }} + {{- "<|call|>" }} + {%- set last_tool_call.name = tool_call.name %} + {%- elif loop.last and not add_generation_prompt %} + {#- Only render the CoT if the final turn is an assistant turn and add_generation_prompt is false #} + {#- This is a situation that should only occur in training, never in inference. #} + {%- if "thinking" in message %} + {{- "<|start|>assistant<|channel|>analysis<|message|>" + message.thinking + "<|end|>" }} + {%- endif %} + {#- <|return|> indicates the end of generation, but <|end|> does not #} + {#- <|return|> should never be an input to the model, but we include it as the final token #} + {#- when training, so the model learns to emit it. #} + {{- "<|start|>assistant<|channel|>final<|message|>" + message.content + "<|return|>" }} + {%- else %} + {#- CoT is dropped during all previous turns, so we never render it for inference #} + {{- "<|start|>assistant<|channel|>final<|message|>" + message.content + "<|end|>" }} + {%- set last_tool_call.name = none %} + {%- endif %} + {%- elif message.role == 'tool' -%} + {%- if last_tool_call.name is none %} + {{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }} + {%- endif %} + {{- "<|start|>functions." + last_tool_call.name }} + {{- " to=assistant<|channel|>commentary<|message|>" + message.content|tojson + "<|end|>" }} + {%- elif message.role == 'user' -%} + {{- "<|start|>user<|message|>" + message.content + "<|end|>" }} + {%- endif -%} +{%- endfor -%} + +{#- Generation prompt #} +{%- if add_generation_prompt -%} +<|start|>assistant +{%- endif -%} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gptoss_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gptoss_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..f635725a0d0c36d1efedda8fe51bf9c4e7f75739 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/gptoss_training.jinja @@ -0,0 +1,338 @@ +{#- + Training variant of the GPT-OSS chat template (see gptoss.jinja for the original). + Modifications vs the original: + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. + + In addition to the normal inputs of `messages` and `tools`, this template also accepts the + following kwargs: + - "builtin_tools": A list, can contain "browser" and/or "python". + - "model_identity": A string that optionally describes the model identity. + - "reasoning_effort": A string that describes the reasoning effort, defaults to "medium". + #} + +{#- Tool Definition Rendering ============================================== #} +{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%} + {%- if param_spec.type == "array" -%} + {%- if param_spec['items'] -%} + {%- if param_spec['items']['type'] == "string" -%} + {{- "string[]" }} + {%- elif param_spec['items']['type'] == "number" -%} + {{- "number[]" }} + {%- elif param_spec['items']['type'] == "integer" -%} + {{- "number[]" }} + {%- elif param_spec['items']['type'] == "boolean" -%} + {{- "boolean[]" }} + {%- else -%} + {%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%} + {%- if inner_type == "object | object" or inner_type|length > 50 -%} + {{- "any[]" }} + {%- else -%} + {{- inner_type + "[]" }} + {%- endif -%} + {%- endif -%} + {%- if param_spec.nullable -%} + {{- " | null" }} + {%- endif -%} + {%- else -%} + {{- "any[]" }} + {%- if param_spec.nullable -%} + {{- " | null" }} + {%- endif -%} + {%- endif -%} + {%- elif param_spec.type is defined and param_spec.type is iterable and param_spec.type is not string and param_spec.type is not mapping and param_spec.type[0] is defined -%} + {#- Handle array of types like ["object", "object"] from Union[dict, list] #} + {%- if param_spec.type | length > 1 -%} + {{- param_spec.type | join(" | ") }} + {%- else -%} + {{- param_spec.type[0] }} + {%- endif -%} + {%- elif param_spec.oneOf -%} + {#- Handle oneOf schemas - check for complex unions and fallback to any #} + {%- set has_object_variants = false -%} + {%- for variant in param_spec.oneOf -%} + {%- if variant.type == "object" -%} + {%- set has_object_variants = true -%} + {%- endif -%} + {%- endfor -%} + {%- if has_object_variants and param_spec.oneOf|length > 1 -%} + {{- "any" }} + {%- else -%} + {%- for variant in param_spec.oneOf -%} + {{- render_typescript_type(variant, required_params) -}} + {%- if variant.description %} + {{- "// " + variant.description }} + {%- endif -%} + {%- if variant.default is defined %} + {{ "// default: " + variant.default|tojson }} + {%- endif -%} + {%- if not loop.last %} + {{- " | " }} + {% endif -%} + {%- endfor -%} + {%- endif -%} + {%- elif param_spec.type == "string" -%} + {%- if param_spec.enum -%} + {{- '"' + param_spec.enum|join('" | "') + '"' -}} + {%- else -%} + {{- "string" }} + {%- if param_spec.nullable %} + {{- " | null" }} + {%- endif -%} + {%- endif -%} + {%- elif param_spec.type == "number" -%} + {{- "number" }} + {%- elif param_spec.type == "integer" -%} + {{- "number" }} + {%- elif param_spec.type == "boolean" -%} + {{- "boolean" }} + + {%- elif param_spec.type == "object" -%} + {%- if param_spec.properties -%} + {{- "{\n" }} + {%- for prop_name, prop_spec in param_spec.properties.items() -%} + {{- prop_name -}} + {%- if prop_name not in (param_spec.required or []) -%} + {{- "?" }} + {%- endif -%} + {{- ": " }} + {{ render_typescript_type(prop_spec, param_spec.required or []) }} + {%- if not loop.last -%} + {{-", " }} + {%- endif -%} + {%- endfor -%} + {{- "}" }} + {%- else -%} + {{- "object" }} + {%- endif -%} + {%- else -%} + {{- "any" }} + {%- endif -%} +{%- endmacro -%} + +{%- macro render_tool_namespace(namespace_name, tools) -%} + {{- "## " + namespace_name + "\n\n" }} + {{- "namespace " + namespace_name + " {\n\n" }} + {%- for tool in tools %} + {%- set tool = tool.function %} + {{- "// " + tool.description + "\n" }} + {{- "type "+ tool.name + " = " }} + {%- if tool.parameters and tool.parameters.properties %} + {{- "(_: {\n" }} + {%- for param_name, param_spec in tool.parameters.properties.items() %} + {%- if param_spec.description %} + {{- "// " + param_spec.description + "\n" }} + {%- endif %} + {{- param_name }} + {%- if param_name not in (tool.parameters.required or []) -%} + {{- "?" }} + {%- endif -%} + {{- ": " }} + {{- render_typescript_type(param_spec, tool.parameters.required or []) }} + {%- if param_spec.default is defined -%} + {%- if param_spec.enum %} + {{- ", // default: " + param_spec.default }} + {%- elif param_spec.oneOf %} + {{- "// default: " + param_spec.default }} + {%- else %} + {{- ", // default: " + param_spec.default|tojson }} + {%- endif -%} + {%- endif -%} + {%- if not loop.last %} + {{- ",\n" }} + {%- else %} + {{- ",\n" }} + {%- endif -%} + {%- endfor %} + {{- "}) => any;\n\n" }} + {%- else -%} + {{- "() => any;\n\n" }} + {%- endif -%} + {%- endfor %} + {{- "} // namespace " + namespace_name }} +{%- endmacro -%} + +{%- macro render_builtin_tools(browser_tool, python_tool) -%} + {%- if browser_tool %} + {{- "## browser\n\n" }} + {{- "// Tool for browsing.\n" }} + {{- "// The `cursor` appears in brackets before each browsing display: `[{cursor}]`.\n" }} + {{- "// Cite information from the tool using the following format:\n" }} + {{- "// `【{cursor}†L{line_start}(-L{line_end})?】`, for example: `【6†L9-L11】` or `【8†L3】`.\n" }} + {{- "// Do not quote more than 10 words directly from the tool output.\n" }} + {{- "// sources=web (default: web)\n" }} + {{- "namespace browser {\n\n" }} + {{- "// Searches for information related to `query` and displays `topn` results.\n" }} + {{- "type search = (_: {\n" }} + {{- "query: string,\n" }} + {{- "topn?: number, // default: 10\n" }} + {{- "source?: string,\n" }} + {{- "}) => any;\n\n" }} + {{- "// Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines.\n" }} + {{- "// Valid link ids are displayed with the formatting: `【{id}†.*】`.\n" }} + {{- "// If `cursor` is not provided, the most recent page is implied.\n" }} + {{- "// If `id` is a string, it is treated as a fully qualified URL associated with `source`.\n" }} + {{- "// If `loc` is not provided, the viewport will be positioned at the beginning of the document or centered on the most relevant passage, if available.\n" }} + {{- "// Use this function without `id` to scroll to a new location of an opened page.\n" }} + {{- "type open = (_: {\n" }} + {{- "id?: number | string, // default: -1\n" }} + {{- "cursor?: number, // default: -1\n" }} + {{- "loc?: number, // default: -1\n" }} + {{- "num_lines?: number, // default: -1\n" }} + {{- "view_source?: boolean, // default: false\n" }} + {{- "source?: string,\n" }} + {{- "}) => any;\n\n" }} + {{- "// Finds exact matches of `pattern` in the current page, or the page given by `cursor`.\n" }} + {{- "type find = (_: {\n" }} + {{- "pattern: string,\n" }} + {{- "cursor?: number, // default: -1\n" }} + {{- "}) => any;\n\n" }} + {{- "} // namespace browser\n\n" }} + {%- endif -%} + + {%- if python_tool %} + {{- "## python\n\n" }} + {{- "Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).\n\n" }} + {{- "When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.\n\n" }} + {%- endif -%} +{%- endmacro -%} + +{#- System Message Construction ============================================ #} +{%- macro build_system_message() -%} + {%- if model_identity is not defined %} + {%- set model_identity = "You are ChatGPT, a large language model trained by OpenAI." %} + {%- endif %} + {{- model_identity + "\n" }} + {{- "Knowledge cutoff: 2024-06\n" }} + {{- "Current date: " + strftime_now("%Y-%m-%d") + "\n\n" }} + {%- if reasoning_effort is not defined %} + {%- set reasoning_effort = "medium" %} + {%- endif %} + {{- "Reasoning: " + reasoning_effort + "\n\n" }} + {%- if builtin_tools %} + {{- "# Tools\n\n" }} + {%- set available_builtin_tools = namespace(browser=false, python=false) %} + {%- for tool in builtin_tools %} + {%- if tool == "browser" %} + {%- set available_builtin_tools.browser = true %} + {%- elif tool == "python" %} + {%- set available_builtin_tools.python = true %} + {%- endif %} + {%- endfor %} + {{- render_builtin_tools(available_builtin_tools.browser, available_builtin_tools.python) }} + {%- endif -%} + {{- "# Valid channels: analysis, commentary, final. Channel must be included for every message." }} + {%- if tools -%} + {{- "\nCalls to these tools must go to the commentary channel: 'functions'." }} + {%- endif -%} +{%- endmacro -%} + +{#- Main Template Logic ================================================= #} +{#- Set defaults #} + +{#- Render system message #} +{{- "<|start|>system<|message|>" }} +{{- build_system_message() }} +{{- "<|end|>" }} + +{#- Extract developer message #} +{%- if messages[0].role == "developer" or messages[0].role == "system" %} + {%- set developer_message = messages[0].content %} + {%- set loop_messages = messages[1:] %} +{%- else %} + {%- set developer_message = "" %} + {%- set loop_messages = messages %} +{%- endif %} + +{#- Render developer message #} +{%- if developer_message or tools %} + {{- "<|start|>developer<|message|>" }} + {%- if developer_message %} + {{- "# Instructions\n\n" }} + {{- developer_message }} + {{- "\n\n" }} + {%- endif %} + {%- if tools -%} + {{- "# Tools\n\n" }} + {{- render_tool_namespace("functions", tools) }} + {%- endif -%} + {{- "<|end|>" }} +{%- endif %} + +{#- Render messages #} +{%- set last_tool_call = namespace(name=none) %} +{%- for message in loop_messages -%} + {#- At this point only assistant/user/tool messages should remain #} + {%- if message.role == 'assistant' -%} + {#- Checks to ensure the messages are being passed in the format we expect #} + {%- if "content" in message %} + {%- if "<|channel|>analysis<|message|>" in message.content or "<|channel|>final<|message|>" in message.content %} + {{- raise_exception("You have passed a message containing <|channel|> tags in the content field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.") }} + {%- endif %} + {%- endif %} + {%- if "thinking" in message %} + {%- if "<|channel|>analysis<|message|>" in message.thinking or "<|channel|>final<|message|>" in message.thinking %} + {{- raise_exception("You have passed a message containing <|channel|> tags in the thinking field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.") }} + {%- endif %} + {%- endif %} + {%- generation %} + {%- if "tool_calls" in message %} + {#- We need very careful handling here - we want to drop the tool call analysis message if the model #} + {#- has output a later <|final|> message, but otherwise we want to retain it. This is the only case #} + {#- when we render CoT/analysis messages in inference. #} + {%- set future_final_message = namespace(found=false) %} + {%- for future_message in loop_messages[loop.index:] %} + {%- if future_message.role == 'assistant' and "tool_calls" not in future_message %} + {%- set future_final_message.found = true %} + {%- endif %} + {%- endfor %} + {#- We assume max 1 tool call per message, and so we infer the tool call name #} + {#- in "tool" messages from the most recent assistant tool call name #} + {%- set tool_call = message.tool_calls[0] %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {%- if message.content and message.thinking %} + {{- raise_exception("Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.") }} + {%- elif message.content and not future_final_message.found %} + {{- "<|start|>assistant<|channel|>analysis<|message|>" + message.content + "<|end|>" }} + {%- elif message.thinking and not future_final_message.found %} + {{- "<|start|>assistant<|channel|>analysis<|message|>" + message.thinking + "<|end|>" }} + {%- endif %} + {{- "<|start|>assistant to=" }} + {{- "functions." + tool_call.name + "<|channel|>commentary " }} + {{- (tool_call.content_type if tool_call.content_type is defined else "json") + "<|message|>" }} + {{- tool_call.arguments|tojson }} + {{- "<|call|>" }} + {%- set last_tool_call.name = tool_call.name %} + {%- elif loop.last and not add_generation_prompt %} + {#- Only render the CoT if the final turn is an assistant turn and add_generation_prompt is false #} + {#- This is a situation that should only occur in training, never in inference. #} + {%- if "thinking" in message %} + {{- "<|start|>assistant<|channel|>analysis<|message|>" + message.thinking + "<|end|>" }} + {%- endif %} + {#- <|return|> indicates the end of generation, but <|end|> does not #} + {#- <|return|> should never be an input to the model, but we include it as the final token #} + {#- when training, so the model learns to emit it. #} + {{- "<|start|>assistant<|channel|>final<|message|>" + message.content + "<|return|>" }} + {%- else %} + {#- CoT is dropped during all previous turns, so we never render it for inference #} + {{- "<|start|>assistant<|channel|>final<|message|>" + message.content + "<|end|>" }} + {%- set last_tool_call.name = none %} + {%- endif %} + {%- endgeneration %} + {%- elif message.role == 'tool' -%} + {%- if last_tool_call.name is none %} + {{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }} + {%- endif %} + {{- "<|start|>functions." + last_tool_call.name }} + {{- " to=assistant<|channel|>commentary<|message|>" + message.content|tojson + "<|end|>" }} + {%- elif message.role == 'user' -%} + {{- "<|start|>user<|message|>" + message.content + "<|end|>" }} + {%- endif -%} +{%- endfor -%} + +{#- Generation prompt #} +{%- if add_generation_prompt -%} +<|start|>assistant +{%- endif -%} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3.jinja new file mode 100644 index 0000000000000000000000000000000000000000..39bd0c9f7fe30aea14eda194fee17703da4a4dbf --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3.jinja @@ -0,0 +1,5 @@ +{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|> + +'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|> + +' }}{% endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_1.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_1.jinja new file mode 100644 index 0000000000000000000000000000000000000000..33089ace1be88f22a10fe861ad49718d5d886090 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_1.jinja @@ -0,0 +1,109 @@ +{{- bos_token }} +{%- if custom_tools is defined %} + {%- set tools = custom_tools %} +{%- endif %} +{%- if not tools_in_user_message is defined %} + {%- set tools_in_user_message = true %} +{%- endif %} +{%- if not date_string is defined %} + {%- set date_string = "26 Jul 2024" %} +{%- endif %} +{%- if not tools is defined %} + {%- set tools = none %} +{%- endif %} + +{#- This block extracts the system message, so we can slot it into the right place. #} +{%- if messages[0]['role'] == 'system' %} + {%- set system_message = messages[0]['content']|trim %} + {%- set messages = messages[1:] %} +{%- else %} + {%- set system_message = "" %} +{%- endif %} + +{#- System message + builtin tools #} +{{- "<|start_header_id|>system<|end_header_id|>\n\n" }} +{%- if builtin_tools is defined or tools is not none %} + {{- "Environment: ipython\n" }} +{%- endif %} +{%- if builtin_tools is defined %} + {{- "Tools: " + builtin_tools | reject('equalto', 'code_interpreter') | join(", ") + "\n\n"}} +{%- endif %} +{{- "Cutting Knowledge Date: December 2023\n" }} +{{- "Today Date: " + date_string + "\n\n" }} +{%- if tools is not none and not tools_in_user_message %} + {{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }} + {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }} + {{- "Do not use variables.\n\n" }} + {%- for t in tools %} + {{- t | tojson(indent=4) }} + {{- "\n\n" }} + {%- endfor %} +{%- endif %} +{{- system_message }} +{{- "<|eot_id|>" }} + +{#- Custom tools are passed in a user message with some extra guidance #} +{%- if tools_in_user_message and not tools is none %} + {#- Extract the first user message so we can plug it in here #} + {%- if messages | length != 0 %} + {%- set first_user_message = messages[0]['content']|trim %} + {%- set messages = messages[1:] %} + {%- else %} + {{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }} +{%- endif %} + {{- '<|start_header_id|>user<|end_header_id|>\n\n' -}} + {{- "Given the following functions, please respond with a JSON for a function call " }} + {{- "with its proper arguments that best answers the given prompt.\n\n" }} + {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }} + {{- "Do not use variables.\n\n" }} + {%- for t in tools %} + {{- t | tojson(indent=4) }} + {{- "\n\n" }} + {%- endfor %} + {{- first_user_message + "<|eot_id|>"}} +{%- endif %} + +{%- for message in messages %} + {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %} + {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }} + {%- elif 'tool_calls' in message %} + {%- if not message.tool_calls|length == 1 %} + {{- raise_exception("This model only supports single tool-calls at once!") }} + {%- endif %} + {%- set tool_call = message.tool_calls[0].function %} + {%- if builtin_tools is defined and tool_call.name in builtin_tools %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}} + {{- "<|python_tag|>" + tool_call.name + ".call(" }} + {%- for arg_name, arg_val in tool_call.arguments | items %} + {{- arg_name + '="' + arg_val + '"' }} + {%- if not loop.last %} + {{- ", " }} + {%- endif %} + {%- endfor %} + {{- ")" }} + {%- else %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}} + {{- '{"name": "' + tool_call.name + '", ' }} + {{- '"parameters": ' }} + {{- tool_call.arguments | tojson }} + {{- "}" }} + {%- endif %} + {%- if builtin_tools is defined %} + {#- This means we're in ipython mode #} + {{- "<|eom_id|>" }} + {%- else %} + {{- "<|eot_id|>" }} + {%- endif %} + {%- elif message.role == "tool" or message.role == "ipython" %} + {{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }} + {%- if message.content is mapping or message.content is iterable %} + {{- message.content | tojson }} + {%- else %} + {{- message.content }} + {%- endif %} + {{- "<|eot_id|>" }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_2.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_2.jinja new file mode 100644 index 0000000000000000000000000000000000000000..1bad6a0f648dccdbec523ca79ba90fbcfc806af0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_2.jinja @@ -0,0 +1,93 @@ +{{- bos_token }} +{%- if custom_tools is defined %} + {%- set tools = custom_tools %} +{%- endif %} +{%- if not tools_in_user_message is defined %} + {%- set tools_in_user_message = true %} +{%- endif %} +{%- if not date_string is defined %} + {%- if strftime_now is defined %} + {%- set date_string = strftime_now("%d %b %Y") %} + {%- else %} + {%- set date_string = "26 Jul 2024" %} + {%- endif %} +{%- endif %} +{%- if not tools is defined %} + {%- set tools = none %} +{%- endif %} + +{#- This block extracts the system message, so we can slot it into the right place. #} +{%- if messages[0]['role'] == 'system' %} + {%- set system_message = messages[0]['content']|trim %} + {%- set messages = messages[1:] %} +{%- else %} + {%- set system_message = "" %} +{%- endif %} + +{#- System message #} +{{- "<|start_header_id|>system<|end_header_id|>\n\n" }} +{%- if tools is not none %} + {{- "Environment: ipython\n" }} +{%- endif %} +{{- "Cutting Knowledge Date: December 2023\n" }} +{{- "Today Date: " + date_string + "\n\n" }} +{%- if tools is not none and not tools_in_user_message %} + {{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }} + {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }} + {{- "Do not use variables.\n\n" }} + {%- for t in tools %} + {{- t | tojson(indent=4) }} + {{- "\n\n" }} + {%- endfor %} +{%- endif %} +{{- system_message }} +{{- "<|eot_id|>" }} + +{#- Custom tools are passed in a user message with some extra guidance #} +{%- if tools_in_user_message and not tools is none %} + {#- Extract the first user message so we can plug it in here #} + {%- if messages | length != 0 %} + {%- set first_user_message = messages[0]['content']|trim %} + {%- set messages = messages[1:] %} + {%- else %} + {{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }} +{%- endif %} + {{- '<|start_header_id|>user<|end_header_id|>\n\n' -}} + {{- "Given the following functions, please respond with a JSON for a function call " }} + {{- "with its proper arguments that best answers the given prompt.\n\n" }} + {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }} + {{- "Do not use variables.\n\n" }} + {%- for t in tools %} + {{- t | tojson(indent=4) }} + {{- "\n\n" }} + {%- endfor %} + {{- first_user_message + "<|eot_id|>"}} +{%- endif %} + +{%- for message in messages %} + {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %} + {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }} + {%- elif 'tool_calls' in message %} + {%- if not message.tool_calls|length == 1 %} + {{- raise_exception("This model only supports single tool-calls at once!") }} + {%- endif %} + {%- set tool_call = message.tool_calls[0].function %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}} + {{- '{"name": "' + tool_call.name + '", ' }} + {{- '"parameters": ' }} + {{- tool_call.arguments | tojson }} + {{- "}" }} + {{- "<|eot_id|>" }} + {%- elif message.role == "tool" or message.role == "ipython" %} + {{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }} + {%- if message.content is mapping or message.content is iterable %} + {{- message.content | tojson }} + {%- else %} + {{- message.content }} + {%- endif %} + {{- "<|eot_id|>" }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..85dafd3d877c69b48fcebae678a5ba367909afd1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/llama3_training.jinja @@ -0,0 +1,19 @@ +{#- Training variant of the Llama 3 chat template (see llama3.jinja for the original). + Modifications vs the original: + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. +-#} +{%- for message in messages %} + {%- if loop.index0 == 0 %}{{- bos_token }}{%- endif %} + {%- if message['role'] == 'assistant' %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }} + {%- generation %} + {{- message['content'] | trim + '<|eot_id|>' }} + {%- endgeneration %} + {%- else %} + {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/phi3.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/phi3.jinja new file mode 100644 index 0000000000000000000000000000000000000000..ddb5006baa8ee6aa317c5d84827e6993469c2073 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/phi3.jinja @@ -0,0 +1,8 @@ +{% for message in messages %}{% if message['role'] == 'system' %}{{'<|system|> +' + message['content'] + '<|end|> +'}}{% elif message['role'] == 'user' %}{{'<|user|> +' + message['content'] + '<|end|> +'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|> +' + message['content'] + '<|end|> +'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|> +' }}{% else %}{{ eos_token }}{% endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/phi3_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/phi3_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..1536d152f7de385ed29917e463bb0aba66977eb3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/phi3_training.jinja @@ -0,0 +1,26 @@ +{#- Training variant of the Phi-3 chat template (see phi3.jinja for the original). + Modifications vs the original: + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. +-#} +{%- for message in messages %} + {%- if message['role'] == 'system' %} + {{- '<|system|>\n' + message['content'] + '<|end|>\n' }} + {%- elif message['role'] == 'user' %} + {{- '<|user|>\n' + message['content'] + '<|end|>\n' }} + {%- elif message['role'] == 'assistant' %} + {{- '<|assistant|>\n' }} + {%- generation %} + {{- message['content'] + '<|end|>\n' }} + {%- endgeneration %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|assistant|>\n' }} +{%- elif messages[-1]['role'] == 'assistant' %} + {%- generation %} + {{- eos_token }} + {%- endgeneration %} +{%- else %} + {{- eos_token }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen2_5.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen2_5.jinja new file mode 100644 index 0000000000000000000000000000000000000000..bdf7919a96cfe43d50914a007b9c0877bd0ec27e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen2_5.jinja @@ -0,0 +1,54 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0]['role'] == 'system' %} + {{- messages[0]['content'] }} + {%- else %} + {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }} + {%- endif %} + {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0]['role'] == 'system' %} + {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }} + {%- else %} + {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- for message in messages %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %} + {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {{- '<|im_start|>' + message.role }} + {%- if message.content %} + {{- '\n' + message.content }} + {%- endif %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {{- tool_call.arguments | tojson }} + {{- '}\n' }} + {%- endfor %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- message.content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen2_5_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen2_5_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..fd7258ece606cb8b6b59a3fb28904282f6004ac4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen2_5_training.jinja @@ -0,0 +1,65 @@ +{#- Training variant of the Qwen2.5 chat template (see qwen2_5.jinja for the original). + Modifications vs the original: + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. +-#} +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0]['role'] == 'system' %} + {{- messages[0]['content'] }} + {%- else %} + {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }} + {%- endif %} + {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0]['role'] == 'system' %} + {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }} + {%- else %} + {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- for message in messages %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {{- '<|im_start|>assistant' }} + {%- generation %} + {%- if not message.tool_calls %} + {{- '\n' + message.content + '<|im_end|>\n' }} + {%- else %} + {%- if message.content %} + {{- '\n' + message.content }} + {%- endif %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {{- tool_call.arguments | tojson }} + {{- '}\n' }} + {%- endfor %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endgeneration %} + {%- elif message.role == "tool" %} + {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- message.content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3.jinja new file mode 100644 index 0000000000000000000000000000000000000000..01be9b307daa2d425f7c168c9fb145a286e0afb4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3.jinja @@ -0,0 +1,89 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].role == 'system' %} + {{- messages[0].content + '\n\n' }} + {%- endif %} + {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('') and message.content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} +{%- endfor %} +{%- for message in messages %} + {%- if message.content is string %} + {%- set content = message.content %} + {%- else %} + {%- set content = '' %} + {%- endif %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- if loop.index0 > ns.last_query_index %} + {%- if loop.last or (not loop.last and reasoning_content) %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if (loop.first and content) or (not loop.first) %} + {{- '\n' }} + {%- endif %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {%- if tool_call.arguments is string %} + {{- tool_call.arguments }} + {%- else %} + {{- tool_call.arguments | tojson }} + {%- endif %} + {{- '}\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_5_2b_and_below.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_5_2b_and_below.jinja new file mode 100644 index 0000000000000000000000000000000000000000..0ef09f214eaa6d9bca297988afc1454b5827b2c7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_5_2b_and_below.jinja @@ -0,0 +1,154 @@ +{%- set image_count = namespace(value=0) %} +{%- set video_count = namespace(value=0) %} +{%- macro render_content(content, do_vision_count, is_system_content=false) %} + {%- if content is string %} + {{- content }} + {%- elif content is iterable and content is not mapping %} + {%- for item in content %} + {%- if 'image' in item or 'image_url' in item or item.type == 'image' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain images.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set image_count.value = image_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Picture ' ~ image_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|image_pad|><|vision_end|>' }} + {%- elif 'video' in item or item.type == 'video' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain videos.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set video_count.value = video_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Video ' ~ video_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|video_pad|><|vision_end|>' }} + {%- elif 'text' in item %} + {{- item.text }} + {%- else %} + {{- raise_exception('Unexpected item type in content.') }} + {%- endif %} + {%- endfor %} + {%- elif content is none or content is undefined %} + {{- '' }} + {%- else %} + {{- raise_exception('Unexpected content type.') }} + {%- endif %} +{%- endmacro %} +{%- if not messages %} + {{- raise_exception('No messages provided.') }} +{%- endif %} +{%- if tools and tools is iterable and tools is not mapping %} + {{- '<|im_start|>system\n' }} + {{- "# Tools\n\nYou have access to the following functions:\n\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n" }} + {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n\n\n\nvalue_1\n\n\nThis is the value for the second parameter\nthat can span\nmultiple lines\n\n\n\n\n\nReminder:\n- Function calls MUST follow the specified format: an inner block must be nested within XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n' }} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {%- if content %} + {{- '\n\n' + content }} + {%- endif %} + {%- endif %} + {{- '<|im_end|>\n' }} +{%- else %} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" %} + {%- set content = render_content(message.content, false)|trim %} + {%- if not(content.startswith('') and content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if ns.multi_step_tool %} + {{- raise_exception('No user query found in messages.') }} +{%- endif %} +{%- for message in messages %} + {%- set content = render_content(message.content, true)|trim %} + {%- if message.role == "system" %} + {%- if not loop.first %} + {{- raise_exception('System message must be at the beginning.') }} + {%- endif %} + {%- elif message.role == "user" %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- set reasoning_content = reasoning_content|trim %} + {%- if loop.index0 > ns.last_query_index %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content + '\n\n\n' + content }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {%- if loop.first %} + {%- if content|trim %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n\n' }} + {%- endif %} + {%- else %} + {{- '\n\n\n' }} + {%- endif %} + {%- if tool_call.arguments is defined %} + {%- for args_name, args_value in tool_call.arguments|items %} + {{- '\n' }} + {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} + {{- args_value }} + {{- '\n\n' }} + {%- endfor %} + {%- endif %} + {{- '\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.previtem and loop.previtem.role != "tool" %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if not loop.last and loop.nextitem.role != "tool" %} + {{- '<|im_end|>\n' }} + {%- elif loop.last %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- else %} + {{- raise_exception('Unexpected message role.') }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is true %} + {{- '\n' }} + {%- else %} + {{- '\n\n\n\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_5_4b_and_above.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_5_4b_and_above.jinja new file mode 100644 index 0000000000000000000000000000000000000000..a585dec894e63da457d9440ec6aa7caa16d20860 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_5_4b_and_above.jinja @@ -0,0 +1,154 @@ +{%- set image_count = namespace(value=0) %} +{%- set video_count = namespace(value=0) %} +{%- macro render_content(content, do_vision_count, is_system_content=false) %} + {%- if content is string %} + {{- content }} + {%- elif content is iterable and content is not mapping %} + {%- for item in content %} + {%- if 'image' in item or 'image_url' in item or item.type == 'image' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain images.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set image_count.value = image_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Picture ' ~ image_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|image_pad|><|vision_end|>' }} + {%- elif 'video' in item or item.type == 'video' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain videos.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set video_count.value = video_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Video ' ~ video_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|video_pad|><|vision_end|>' }} + {%- elif 'text' in item %} + {{- item.text }} + {%- else %} + {{- raise_exception('Unexpected item type in content.') }} + {%- endif %} + {%- endfor %} + {%- elif content is none or content is undefined %} + {{- '' }} + {%- else %} + {{- raise_exception('Unexpected content type.') }} + {%- endif %} +{%- endmacro %} +{%- if not messages %} + {{- raise_exception('No messages provided.') }} +{%- endif %} +{%- if tools and tools is iterable and tools is not mapping %} + {{- '<|im_start|>system\n' }} + {{- "# Tools\n\nYou have access to the following functions:\n\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n" }} + {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n\n\n\nvalue_1\n\n\nThis is the value for the second parameter\nthat can span\nmultiple lines\n\n\n\n\n\nReminder:\n- Function calls MUST follow the specified format: an inner block must be nested within XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n' }} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {%- if content %} + {{- '\n\n' + content }} + {%- endif %} + {%- endif %} + {{- '<|im_end|>\n' }} +{%- else %} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" %} + {%- set content = render_content(message.content, false)|trim %} + {%- if not(content.startswith('') and content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if ns.multi_step_tool %} + {{- raise_exception('No user query found in messages.') }} +{%- endif %} +{%- for message in messages %} + {%- set content = render_content(message.content, true)|trim %} + {%- if message.role == "system" %} + {%- if not loop.first %} + {{- raise_exception('System message must be at the beginning.') }} + {%- endif %} + {%- elif message.role == "user" %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- set reasoning_content = reasoning_content|trim %} + {%- if loop.index0 > ns.last_query_index %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content + '\n\n\n' + content }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {%- if loop.first %} + {%- if content|trim %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n\n' }} + {%- endif %} + {%- else %} + {{- '\n\n\n' }} + {%- endif %} + {%- if tool_call.arguments is defined %} + {%- for args_name, args_value in tool_call.arguments|items %} + {{- '\n' }} + {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} + {{- args_value }} + {{- '\n\n' }} + {%- endfor %} + {%- endif %} + {{- '\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.previtem and loop.previtem.role != "tool" %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if not loop.last and loop.nextitem.role != "tool" %} + {{- '<|im_end|>\n' }} + {%- elif loop.last %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- else %} + {{- raise_exception('Unexpected message role.') }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_6.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_6.jinja new file mode 100644 index 0000000000000000000000000000000000000000..a8755d827c0a7b614c246c4060dfd58ab352a8ff --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_6.jinja @@ -0,0 +1,154 @@ +{%- set image_count = namespace(value=0) %} +{%- set video_count = namespace(value=0) %} +{%- macro render_content(content, do_vision_count, is_system_content=false) %} + {%- if content is string %} + {{- content }} + {%- elif content is iterable and content is not mapping %} + {%- for item in content %} + {%- if 'image' in item or 'image_url' in item or item.type == 'image' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain images.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set image_count.value = image_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Picture ' ~ image_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|image_pad|><|vision_end|>' }} + {%- elif 'video' in item or item.type == 'video' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain videos.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set video_count.value = video_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Video ' ~ video_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|video_pad|><|vision_end|>' }} + {%- elif 'text' in item %} + {{- item.text }} + {%- else %} + {{- raise_exception('Unexpected item type in content.') }} + {%- endif %} + {%- endfor %} + {%- elif content is none or content is undefined %} + {{- '' }} + {%- else %} + {{- raise_exception('Unexpected content type.') }} + {%- endif %} +{%- endmacro %} +{%- if not messages %} + {{- raise_exception('No messages provided.') }} +{%- endif %} +{%- if tools and tools is iterable and tools is not mapping %} + {{- '<|im_start|>system\n' }} + {{- "# Tools\n\nYou have access to the following functions:\n\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n" }} + {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n\n\n\nvalue_1\n\n\nThis is the value for the second parameter\nthat can span\nmultiple lines\n\n\n\n\n\nReminder:\n- Function calls MUST follow the specified format: an inner block must be nested within XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n' }} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {%- if content %} + {{- '\n\n' + content }} + {%- endif %} + {%- endif %} + {{- '<|im_end|>\n' }} +{%- else %} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" %} + {%- set content = render_content(message.content, false)|trim %} + {%- if not(content.startswith('') and content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if ns.multi_step_tool %} + {{- raise_exception('No user query found in messages.') }} +{%- endif %} +{%- for message in messages %} + {%- set content = render_content(message.content, true)|trim %} + {%- if message.role == "system" %} + {%- if not loop.first %} + {{- raise_exception('System message must be at the beginning.') }} + {%- endif %} + {%- elif message.role == "user" %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- set reasoning_content = reasoning_content|trim %} + {%- if (preserve_thinking is defined and preserve_thinking is true) or (loop.index0 > ns.last_query_index) %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content + '\n\n\n' + content }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {%- if loop.first %} + {%- if content|trim %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n\n' }} + {%- endif %} + {%- else %} + {{- '\n\n\n' }} + {%- endif %} + {%- if tool_call.arguments is defined %} + {%- for args_name, args_value in tool_call.arguments|items %} + {{- '\n' }} + {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %} + {{- args_value }} + {{- '\n\n' }} + {%- endfor %} + {%- endif %} + {{- '\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.previtem and loop.previtem.role != "tool" %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if not loop.last and loop.nextitem.role != "tool" %} + {{- '<|im_end|>\n' }} + {%- elif loop.last %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- else %} + {{- raise_exception('Unexpected message role.') }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_6_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_6_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..e4e705768d7d62e8149f7c28da77c93b57f6d041 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_6_training.jinja @@ -0,0 +1,162 @@ +{#- Training variant of the Qwen3.6 chat template (see qwen3_6.jinja for the original). + Modifications vs the original: + - {%- if '' in content %} → {%- if '' in content and '' in content %} + Always check for both tags to avoid edge cases where the model generates only one tag. + - Removed the loop.index0 > ns.last_query_index conditional; always include thinking block. + This makes the template prefix-preserving for the [user, assistant] → [user, assistant, tool] transition. + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. +-#} +{%- set image_count = namespace(value=0) %} +{%- set video_count = namespace(value=0) %} +{%- macro render_content(content, do_vision_count, is_system_content=false) %} + {%- if content is string %} + {{- content }} + {%- elif content is iterable and content is not mapping %} + {%- for item in content %} + {%- if 'image' in item or 'image_url' in item or item.type == 'image' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain images.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set image_count.value = image_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Picture ' ~ image_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|image_pad|><|vision_end|>' }} + {%- elif 'video' in item or item.type == 'video' %} + {%- if is_system_content %} + {{- raise_exception('System message cannot contain videos.') }} + {%- endif %} + {%- if do_vision_count %} + {%- set video_count.value = video_count.value + 1 %} + {%- endif %} + {%- if add_vision_id %} + {{- 'Video ' ~ video_count.value ~ ': ' }} + {%- endif %} + {{- '<|vision_start|><|video_pad|><|vision_end|>' }} + {%- elif 'text' in item %} + {{- item.text }} + {%- else %} + {{- raise_exception('Unexpected item type in content.') }} + {%- endif %} + {%- endfor %} + {%- elif content is none or content is undefined %} + {{- '' }} + {%- else %} + {{- raise_exception('Unexpected content type.') }} + {%- endif %} +{%- endmacro %} +{%- if not messages %} + {{- raise_exception('No messages provided.') }} +{%- endif %} +{%- if tools and tools is iterable and tools is not mapping %} + {{- '<|im_start|>system\n' }} + {{- "# Tools\n\nYou have access to the following functions:\n\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n" }} + {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n\n\n\nvalue_1\n\n\nThis is the value for the second parameter\nthat can span\nmultiple lines\n\n\n\n\n\nReminder:\n- Function calls MUST follow the specified format: an inner block must be nested within XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n' }} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {%- if content %} + {{- '\n\n' + content }} + {%- endif %} + {%- endif %} + {{- '<|im_end|>\n' }} +{%- else %} + {%- if messages[0].role == 'system' %} + {%- set content = render_content(messages[0].content, false, true)|trim %} + {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" %} + {%- set content = render_content(message.content, false)|trim %} + {%- if not(content.startswith('') and content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if ns.multi_step_tool %} + {{- raise_exception('No user query found in messages.') }} +{%- endif %} +{%- for message in messages %} + {%- set content = render_content(message.content, true)|trim %} + {%- if message.role == "system" %} + {%- if not loop.first %} + {{- raise_exception('System message must be at the beginning.') }} + {%- endif %} + {%- elif message.role == "user" %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content and '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- set reasoning_content = reasoning_content|trim %} + {{- '<|im_start|>' + message.role + '\n' }} + {%- generation %} + {{- '\n' + reasoning_content + '\n\n\n' + content }} + {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {%- if loop.first %} + {%- if content|trim %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n\n' }} + {%- endif %} + {%- else %} + {{- '\n\n\n' }} + {%- endif %} + {%- if tool_call.arguments is defined %} + {%- for args_name, args_value in tool_call.arguments|items %} + {{- '\n' }} + {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %} + {{- args_value }} + {{- '\n\n' }} + {%- endfor %} + {%- endif %} + {{- '\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- endgeneration %} + {%- elif message.role == "tool" %} + {%- if loop.previtem and loop.previtem.role != "tool" %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if not loop.last and loop.nextitem.role != "tool" %} + {{- '<|im_end|>\n' }} + {%- elif loop.last %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- else %} + {{- raise_exception('Unexpected message role.') }} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- else %} + {{- '\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_training.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_training.jinja new file mode 100644 index 0000000000000000000000000000000000000000..decc48dc6b6fecb761d045d4a318b92c1c489d0b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_training.jinja @@ -0,0 +1,93 @@ +{#- Training variant of the Qwen3 chat template (see qwen3.jinja for the original). + Modifications vs the original: + - {%- if '' in content %} → {%- if '' in content and '' in content %} + Always check for both tags to avoid edge cases where the model generates only one tag. + - Removed the loop.index0 > ns.last_query_index conditional; always include thinking block. + This makes the template prefix-preserving for the [user, assistant] → [user, assistant, tool] transition. + - Added {% generation %} / {% endgeneration %} around assistant message output to support + assistant-only loss masking in SFT training. +-#} +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].role == 'system' %} + {{- messages[0].content + '\n\n' }} + {%- endif %} + {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('') and message.content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} +{%- endfor %} +{%- for message in messages %} + {%- if message.content is string %} + {%- set content = message.content %} + {%- else %} + {%- set content = '' %} + {%- endif %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content and '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {{- '<|im_start|>' + message.role + '\n' }} + {%- generation %} + {{- '\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if (loop.first and content) or (not loop.first) %} + {{- '\n' }} + {%- endif %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {%- if tool_call.arguments is string %} + {{- tool_call.arguments }} + {%- else %} + {{- tool_call.arguments | tojson }} + {%- endif %} + {{- '}\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- endgeneration %} + {%- elif message.role == "tool" %} + {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_vl.jinja b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_vl.jinja new file mode 100644 index 0000000000000000000000000000000000000000..124386803f142761528f710e77ae483f5f8c4fc4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/chat_templates/qwen3_vl.jinja @@ -0,0 +1,120 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].role == 'system' %} + {%- if messages[0].content is string %} + {{- messages[0].content }} + {%- else %} + {%- for content in messages[0].content %} + {%- if 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {{- '\n\n' }} + {%- endif %} + {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].content is string %} + {{- messages[0].content }} + {%- else %} + {%- for content in messages[0].content %} + {%- if 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set image_count = namespace(value=0) %} +{%- set video_count = namespace(value=0) %} +{%- for message in messages %} + {%- if message.role == "user" %} + {{- '<|im_start|>' + message.role + '\n' }} + {%- if message.content is string %} + {{- message.content }} + {%- else %} + {%- for content in message.content %} + {%- if content.type == 'image' or 'image' in content or 'image_url' in content %} + {%- set image_count.value = image_count.value + 1 %} + {%- if add_vision_id %}Picture {{ image_count.value }}: {% endif -%} + <|vision_start|><|image_pad|><|vision_end|> + {%- elif content.type == 'video' or 'video' in content %} + {%- set video_count.value = video_count.value + 1 %} + {%- if add_vision_id %}Video {{ video_count.value }}: {% endif -%} + <|vision_start|><|video_pad|><|vision_end|> + {%- elif 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "assistant" %} + {{- '<|im_start|>' + message.role + '\n' }} + {%- if message.content is string %} + {{- message.content }} + {%- else %} + {%- for content_item in message.content %} + {%- if 'text' in content_item %} + {{- content_item.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if (loop.first and message.content) or (not loop.first) %} + {{- '\n' }} + {%- endif %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {%- if tool_call.arguments is string %} + {{- tool_call.arguments }} + {%- else %} + {{- tool_call.arguments | tojson }} + {%- endif %} + {{- '}\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {%- if message.content is string %} + {{- message.content }} + {%- else %} + {%- for content in message.content %} + {%- if content.type == 'image' or 'image' in content or 'image_url' in content %} + {%- set image_count.value = image_count.value + 1 %} + {%- if add_vision_id %}Picture {{ image_count.value }}: {% endif -%} + <|vision_start|><|image_pad|><|vision_end|> + {%- elif content.type == 'video' or 'video' in content %} + {%- set video_count.value = video_count.value + 1 %} + {%- if add_vision_id %}Video {{ video_count.value }}: {% endif -%} + <|vision_start|><|video_pad|><|vision_end|> + {%- elif 'text' in content %} + {{- content.text }} + {%- endif %} + {%- endfor %} + {%- endif %} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} +{%- endif %} diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..6a1721cba48803210a91d0280eb9ccd35214d74f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .main import main + + +__all__ = ["main"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/accelerate_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/accelerate_config.py new file mode 100644 index 0000000000000000000000000000000000000000..d775fca787f7618a2785d1294beec2c152962e90 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/accelerate_config.py @@ -0,0 +1,47 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib.resources as resources +from pathlib import Path + + +def resolve_accelerate_config_argument(launch_args: list[str]) -> list[str]: + """ + Resolve `--accelerate_config` from CLI arguments into `accelerate --config_file`. + + The function supports either a filesystem path or a predefined config name shipped in `trl/accelerate_configs` + (without the `.yaml` suffix). + """ + if "--accelerate_config" not in launch_args: + return launch_args + + config_index = launch_args.index("--accelerate_config") + if config_index + 1 >= len(launch_args): + raise ValueError("Expected a value after `--accelerate_config`.") + + config_name = launch_args[config_index + 1] + if Path(config_name).is_file(): + accelerate_config_path = config_name + else: + candidate = resources.files("trl.accelerate_configs").joinpath(f"{config_name}.yaml") + if not candidate.exists(): + raise ValueError( + f"Accelerate config {config_name} is neither a file nor a valid config in the `trl` package. " + "Please provide a valid config name or a path to a config file." + ) + accelerate_config_path = candidate + + # Remove '--accelerate_config '. + launch_args = launch_args[:config_index] + launch_args[config_index + 2 :] + return ["--config_file", str(accelerate_config_path)] + launch_args diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/accelerate_launcher.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/accelerate_launcher.py new file mode 100644 index 0000000000000000000000000000000000000000..eceebe1ffe8d49d6cfa4a3bdc5d3037b5dfd9da3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/accelerate_launcher.py @@ -0,0 +1,47 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib.resources as resources +from collections.abc import Callable +from typing import Any + +from accelerate.commands.launch import launch_command, launch_command_parser + + +def launch_training_script( + script_name: str, + launch_args: list[str], + training_script_args: list[str], + *, + launch_command_fn: Callable[[Any], None] = launch_command, + launch_parser_fn: Callable[[], Any] = launch_command_parser, +) -> None: + """ + Launch a TRL training script through `accelerate launch`. + + Parameters: + script_name (`str`): + Script filename in `trl/scripts`, e.g. `"dpo.py"`. + launch_args (`list[str]`): + Arguments consumed by `accelerate launch`. + training_script_args (`list[str]`): + Arguments forwarded to the training script. + launch_command_fn (`Callable[[Any], None]`, *optional*): + Function used to execute accelerate launch. + launch_parser_fn (`Callable[[], Any]`, *optional*): + Factory creating the accelerate launch parser. + """ + training_script = resources.files("trl.scripts").joinpath(script_name) + accelerate_args = launch_parser_fn().parse_args(launch_args + [str(training_script)] + training_script_args) + launch_command_fn(accelerate_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4bafa3ba61879096285ddeca6b48d7fe3292ffeb --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/__init__.py @@ -0,0 +1,37 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .base import Command +from .env import EnvCommand +from .skills import SkillsCommand +from .training import TrainingCommand +from .vllm_serve import VllmServeCommand + + +def get_commands() -> list[Command]: + """Return all registered top-level TRL CLI commands.""" + return [ + TrainingCommand("dpo"), + EnvCommand(), + TrainingCommand("grpo"), + TrainingCommand("kto"), + TrainingCommand("reward"), + TrainingCommand("rloo"), + TrainingCommand("sft"), + SkillsCommand(), + VllmServeCommand(), + ] + + +__all__ = ["Command", "get_commands"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/base.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/base.py new file mode 100644 index 0000000000000000000000000000000000000000..0000b558f26418077c3946519f54dcd1195029cc --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/base.py @@ -0,0 +1,62 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from abc import ABC, abstractmethod +from argparse import Namespace +from dataclasses import dataclass + + +@dataclass(slots=True) +class CommandContext: + """Context shared by CLI commands during execution.""" + + argv: list[str] + + def argv_after(self, token: str) -> list[str]: + """ + Return CLI tokens after the first occurrence of `token`. + + Parameters: + token (`str`): + Subcommand name as it appears in `argv`. + """ + try: + index = self.argv.index(token) + except ValueError: + return [] + return self.argv[index + 1 :] + + +class Command(ABC): + """ + Base command definition for the TRL CLI. + + Parameters: + name (`str`): + Subcommand name exposed by the CLI. + help_text (`str`): + Short description displayed in help output. + """ + + def __init__(self, name: str, help_text: str): + self.name = name + self.help_text = help_text + + @abstractmethod + def register(self, subparsers) -> None: + """Register this command parser in the subparser collection.""" + + @abstractmethod + def run(self, args: Namespace, context: CommandContext) -> int: + """Execute the command.""" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/env.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/env.py new file mode 100644 index 0000000000000000000000000000000000000000..28498ba15cb0ca1998b2f4b937c6393b7fbd1536 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/env.py @@ -0,0 +1,33 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from argparse import Namespace + +from .base import Command, CommandContext + + +class EnvCommand(Command): + """CLI command that prints TRL environment information.""" + + def __init__(self): + super().__init__(name="env", help_text="Print the environment information") + + def register(self, subparsers) -> None: + subparsers.add_parser(self.name, help=self.help_text) + + def run(self, args: Namespace, context: CommandContext) -> int: + from ...scripts.env import print_env + + print_env() + return 0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/skills.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/skills.py new file mode 100644 index 0000000000000000000000000000000000000000..737bf4747276a348042e25f3826e6ad6e3bfa96c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/skills.py @@ -0,0 +1,42 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from argparse import Namespace + +from ...skills.cli import add_skills_subcommands +from .base import Command, CommandContext + + +class SkillsCommand(Command): + """CLI command that manages TRL agent skills.""" + + def __init__(self): + super().__init__(name="skills", help_text="Manage TRL agent skills") + self._skills_parser = None + + def register(self, subparsers) -> None: + self._skills_parser = subparsers.add_parser(self.name, help=self.help_text) + skills_subparsers = self._skills_parser.add_subparsers(dest="skills_command", help="Skills commands") + add_skills_subcommands(skills_subparsers) + + def run(self, args: Namespace, context: CommandContext) -> int: + if getattr(args, "skills_command", None): + if hasattr(args, "func"): + return args.func(args) + print("Error: Unknown skills command") + return 1 + + if self._skills_parser is not None: + self._skills_parser.print_help() + return 0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/training.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/training.py new file mode 100644 index 0000000000000000000000000000000000000000..64f52c73b7ec998d42d420d53890184bd5a40428 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/training.py @@ -0,0 +1,72 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib +from argparse import Namespace + +from .base import Command, CommandContext + + +def _subtract_subsequence(lst: list[str], subseq: list[str]) -> list[str]: + """Return lst with the ordered subsequence subseq removed.""" + sub_iter = iter(subseq) + current = next(sub_iter, None) + result = [] + for item in lst: + if current is not None and item == current: + current = next(sub_iter, None) + else: + result.append(item) + return result + + +class TrainingCommand(Command): + """ + Generic CLI command that launches a training script with accelerate. + + The script `trl/scripts/.py` must expose a `make_parser()` function. + + Parameters: + name (`str`): + CLI subcommand name (e.g. `"dpo"`). + """ + + def __init__(self, name: str): + super().__init__(name=name, help_text=f"Run the {name} training script") + + def register(self, subparsers) -> None: + subparsers.add_parser(self.name, help=self.help_text, add_help=False) + + def run(self, args: Namespace, context: CommandContext) -> int: + from ..accelerate_config import resolve_accelerate_config_argument + from ..accelerate_launcher import launch_training_script + + module = importlib.import_module(f"...scripts.{self.name}", package=__package__) + all_args = context.argv_after(self.name) + parser = module.make_parser(prog=f"trl {self.name}") + + # Handles -h (exits). Returns config_remaining and cli_remaining separately. + # cli_remaining is an ordered subsequence of all_args; config_remaining is not. + *_, config_remaining, cli_remaining = parser.parse_args_and_config( + all_args, return_remaining_strings=True, separate_remaining_strings=True + ) + launch_args = resolve_accelerate_config_argument(config_remaining + cli_remaining) + training_script_args = _subtract_subsequence(all_args, cli_remaining) + + launch_training_script( + script_name=f"{self.name}.py", + launch_args=launch_args, + training_script_args=training_script_args, + ) + return 0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/vllm_serve.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/vllm_serve.py new file mode 100644 index 0000000000000000000000000000000000000000..cc1cea21a5c1fcb8f52d8c2ce46a820e8702be03 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/commands/vllm_serve.py @@ -0,0 +1,36 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from argparse import Namespace + +from .base import Command, CommandContext + + +class VllmServeCommand(Command): + """CLI command for serving TRL models with vLLM.""" + + def __init__(self): + super().__init__(name="vllm-serve", help_text="Serve a model with vLLM") + + def register(self, subparsers) -> None: + subparsers.add_parser(self.name, help=self.help_text, add_help=False) + + def run(self, args: Namespace, context: CommandContext) -> int: + from ...scripts.vllm_serve import main as vllm_serve_main + from ...scripts.vllm_serve import make_parser as make_vllm_serve_parser + + parser = make_vllm_serve_parser(prog="trl vllm-serve") + (script_args,) = parser.parse_args_and_config(args=context.argv_after(self.name)) + vllm_serve_main(script_args) + return 0 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/main.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/main.py new file mode 100644 index 0000000000000000000000000000000000000000..cea99a16d9a6ce250dbc242389cd4ea21f7f75f2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/cli/main.py @@ -0,0 +1,51 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from argparse import ArgumentParser + +from .commands import get_commands +from .commands.base import Command, CommandContext + + +def _build_parser(commands: list[Command]) -> ArgumentParser: + parser = ArgumentParser(prog="trl", allow_abbrev=False) + subparsers = parser.add_subparsers(help="available commands", dest="command") + + for command in commands: + command.register(subparsers) + + return parser + + +def main(argv: list[str] | None = None) -> int: + """Run the TRL CLI.""" + commands = get_commands() + commands_by_name = {command.name: command for command in commands} + parser = _build_parser(commands) + argv = list(sys.argv[1:] if argv is None else argv) + + args, _ = parser.parse_known_args(argv) + command_name = getattr(args, "command", None) + if command_name is None: + parser.print_help() + return 0 + + command = commands_by_name[command_name] + context = CommandContext(argv=argv) + return command.run(args, context) + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/data_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/data_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..c110bb98a1a15ae16a29b1c5764eb4f7c16700e7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/data_utils.py @@ -0,0 +1,969 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +from collections import defaultdict, deque +from collections.abc import Callable, Sequence +from itertools import takewhile +from typing import Any, Literal, TypeVar + +import numpy as np +import pyarrow as pa +import pyarrow.compute as pc +import pyarrow.types +from datasets import Dataset, DatasetDict, IterableDataset, IterableDatasetDict +from transformers import PreTrainedTokenizerBase, ProcessorMixin + + +DatasetType = TypeVar("DatasetType", Dataset, DatasetDict) +IterableDatasetType = TypeVar("IterableDatasetType", IterableDataset, IterableDatasetDict) + + +def prepare_multimodal_messages(messages: list[dict[str, Any]], images: list | None = None) -> list[dict[str, Any]]: + # docstyle-ignore # because is not parsable in the code block + """ + Convert messages into a structured multimodal format and inject the provided images into the message contents. + + Args: + messages (`list[dict[str, Any]]`): + Messages with `"role"`, `"content"` (or `"tool_calls"`). Content may be a raw string before transformation. + List of messages with a `"role"` key (`"system"`, `"user"`, `"assistant"`, or `"tool"`) and a `"content"` key containing + either a string or a list of structured blocks if already prepared. Optionally, the `"content"` might + be `None` or not provided in favour of `"tool_calls"` in the `"assistant"` turns if applicable. + images (`list`, *optional*): + List of image objects to insert in the messages. + + Returns: + `list[dict[str, Any]]`: A new list of messages where every `"content"` value is a list of structured + content blocks, and all `"image"` placeholders are populated with the corresponding image objects. If the + assistant turns contains `"tool_calls"`, then the `"content"` might be empty. + + Notes: + - When the input `messages` isn't already in the structured format, (i.e., all `"content"` values are strings), + the function transforms them into the structured format by wrapping text in `{"type": "text", "text": ...}` + and inserting `{"type": "image"}` placeholders for the images *before* the first user message. + If the number of placeholders does not match the number of provided images, an error is raised. + - Existing image blocks that already include an `"image"` payload are preserved as-is. Only unfilled image + placeholders are counted and populated from `images`. + + Example: + ```python + # Input + [ + {"role": "user", "content": "What's in this image?"}, + {"role": "assistant", "content": "It looks like a cat."}, + ] + + # Output, one image provided + [ + {"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What's in this image?"}]}, + {"role": "assistant", "content": [{"type": "text", "text": "It looks like a cat."}]}, + ] + ``` + """ + images = images or [] + + # First, convert all messages to the structured format if needed, and insert image placeholders if needed. + # Build new message dicts only when transforming string content to avoid modifying the originals. + new_messages = [] + images_included = False + for message in messages: + if message["role"] == "user": + if isinstance(message["content"], str) and not images_included: + image_entries = [{"type": "image"} for _ in range(len(images))] + message = {**message, "content": [*image_entries, {"type": "text", "text": message["content"]}]} + images_included = True + elif isinstance(message["content"], str): + message = {**message, "content": [{"type": "text", "text": message["content"]}]} + elif message["role"] in {"assistant", "system", "tool"}: + if isinstance(message.get("content"), str): + message = {**message, "content": [{"type": "text", "text": message["content"]}]} + else: + raise ValueError( + f"Invalid role in message: {message['role']}. Expected 'system', 'user', 'assistant', or 'tool'." + ) + new_messages.append(message) + + # Then, check that the number of image placeholders matches the number of images provided + num_placeholders = sum( + sum(1 for part in message["content"] if part["type"] == "image" and "image" not in part) + for message in new_messages + if message.get("content") and message["role"] != "tool" + ) + if num_placeholders != len(images): + raise ValueError( + f"Number of images provided ({len(images)}) does not match number of image placeholders ({num_placeholders})." + ) + + # Then, fill in the actual images in the placeholders + if images: + img_idx = 0 + for i, message in enumerate(new_messages): + if not message.get("content") or message["role"] == "tool": + continue + new_content = [] + for part in message["content"]: + if part["type"] == "image" and "image" not in part: + new_content.append({**part, "image": images[img_idx]}) + img_idx += 1 + else: + new_content.append(part) + new_messages[i] = {**message, "content": new_content} + + return new_messages + + +def prepare_multimodal_messages_vllm(messages: list[dict[str, Any]]) -> list[dict[str, Any]]: + # docstyle-ignore # because is not parsable in the code block + """ + Convert structured multimodal messages into a format compatible with vLLM. Replaces `"type": "image"` blocks with + `"type": "image_pil"` blocks, and `"image": Image` with `"image_pil": Image`. + + Args: + messages (`list[dict[str, Any]]`): + Messages with `"role"` and `"content"`. Content is expected to be a list of structured blocks. + + Returns: + `list[dict[str, Any]]`: + A deep-copied list of messages compatible with vLLM's expected input format. + + Example: + ```python + # Input + [{"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What's in this image?"}]}] + + # Output + [{"role": "user", "content": [{"type": "image_pil", "image_pil": }, {"type": "text", "text": "What's in this image?"}]}] + ``` + """ + messages = copy.deepcopy(messages) # avoid modifying the original messages + for message in messages: + if isinstance(message["content"], list): + for part in message["content"]: + if part["type"] == "image": + part["type"] = "image_pil" # vLLM expects 'image_pil' key for images + part["image_pil"] = part.pop("image") + return messages + + +def is_conversational(example: dict[str, Any]) -> bool: + r""" + Check if the example is in a conversational format. + + Args: + example (`dict[str, Any]`): + A single data entry of a dataset. The example can have different keys depending on the dataset type. + + Returns: + `bool`: + `True` if the data is in a conversational format, `False` otherwise. + + Examples: + + ```python + >>> example = {"prompt": [{"role": "user", "content": "What color is the sky?"}]} + >>> is_conversational(example) + True + + >>> example = {"prompt": "The sky is"} + >>> is_conversational(example) + False + ``` + """ + supported_keys = ["prompt", "chosen", "rejected", "completion", "messages"] + example_keys = {key for key in example.keys() if key in supported_keys} + + # It must have one of the supported keys + if example_keys: + key = example_keys.pop() # take the first supported key + maybe_messages = example[key] + # It must be a list of messages + if isinstance(maybe_messages, list): + maybe_message = maybe_messages[0] + # Each message must a list of dictionaries with keys "role" and "content" + if isinstance(maybe_message, dict) and "role" in maybe_message: + return True + + return False + + +def apply_chat_template( + example: dict[str, list[dict[str, str]]], + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + tools: list[dict | Callable] | None = None, + **template_kwargs, +) -> dict[str, str]: + r""" + Apply a chat template to a conversational example along with the schema for a list of functions in `tools`. + + For more details, see [`maybe_apply_chat_template`]. + """ + tools = tools or None # `or None`: Llama bug: it renders tool boilerplate for tools=[] + # Check that the example has the correct keys + supported_keys = ["prompt", "chosen", "rejected", "completion", "messages", "label"] + example_keys = {key for key in example.keys() if key in supported_keys} + if example_keys not in [ + {"messages"}, # language modeling + {"prompt"}, # prompt-only + {"prompt", "completion"}, # prompt-completion + {"prompt", "chosen", "rejected"}, # preference + {"chosen", "rejected"}, # preference with implicit prompt + {"prompt", "completion", "label"}, # unpaired preference + ]: + raise KeyError(f"Invalid keys in the example: {example_keys}") + + # Apply the chat template to the whole conversation + if "messages" in example: + messages = processing_class.apply_chat_template( + example["messages"], + tools=tools, + tokenize=False, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + + # Apply the chat template to the prompt, adding the generation prompt + if "prompt" in example: + last_role = example["prompt"][-1]["role"] + if last_role in ["user", "tool"]: + add_generation_prompt = True + continue_final_message = False + elif last_role == "assistant": + add_generation_prompt = False + continue_final_message = True + else: + raise ValueError(f"Invalid role in the last message: {last_role}") + prompt = processing_class.apply_chat_template( + example["prompt"], + tools=tools, + continue_final_message=continue_final_message, + tokenize=False, + add_generation_prompt=add_generation_prompt, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + + # Apply the chat template to the entire prompt + completion + if "prompt" in example: # explicit prompt and prompt-completion case + if "chosen" in example: + prompt_chosen = processing_class.apply_chat_template( + example["prompt"] + example["chosen"], + tools=tools, + tokenize=False, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + # DeepSeek-R1 inserts a token when using `add_generation_prompt`, which can cause discrepancies + # between the prompt alone and the combined prompt+completion. To ensure consistency, we extract the + # common prefix between the two. In most cases, this is a no-op. + prompt = "".join(x for x, _ in takewhile(lambda x: x[0] == x[1], zip(prompt, prompt_chosen, strict=False))) + + chosen = prompt_chosen[len(prompt) :] + if "rejected" in example and "prompt" in example: # explicit prompt + prompt_rejected = processing_class.apply_chat_template( + example["prompt"] + example["rejected"], + tools=tools, + tokenize=False, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + # Handle DeepSeek-R1 token, see the above comment for details + prompt = "".join( + x for x, _ in takewhile(lambda x: x[0] == x[1], zip(prompt, prompt_rejected, strict=False)) + ) + rejected = prompt_rejected[len(prompt) :] + if "completion" in example: + prompt_completion = processing_class.apply_chat_template( + example["prompt"] + example["completion"], + tools=tools, + tokenize=False, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + # Handle DeepSeek-R1 token, see the above comment for details + prompt = "".join( + x for x, _ in takewhile(lambda x: x[0] == x[1], zip(prompt, prompt_completion, strict=False)) + ) + completion = prompt_completion[len(prompt) :] + else: # implicit prompt case + if "chosen" in example: + chosen = processing_class.apply_chat_template( + example["chosen"], + tools=tools, + tokenize=False, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + if "rejected" in example: + rejected = processing_class.apply_chat_template( + example["rejected"], + tools=tools, + tokenize=False, + **example.get("chat_template_kwargs", {}), + **template_kwargs, + ) + + # Extract the completion by removing the prompt part from the prompt-completion string + output = {} + if "messages" in example: + output["text"] = messages + if "prompt" in example: + output["prompt"] = prompt + if "chosen" in example: + output["chosen"] = chosen + if "rejected" in example: + output["rejected"] = rejected + if "completion" in example: + output["completion"] = completion + if "label" in example: + output["label"] = example["label"] + + return output + + +def maybe_apply_chat_template( + example: dict[str, list[dict[str, str]]], + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + tools: list[dict | Callable] | None = None, + **template_kwargs: Any, +) -> dict[str, str]: + r""" + If the example is in a conversational format, apply a chat template to it. + + Args: + example (`dict[str, list[dict[str, str]]`): + Dictionary representing a single data entry of a conversational dataset. Each data entry can have different + keys depending on the dataset type. The supported dataset types are: + + - Language modeling dataset: `"messages"`. + - Prompt-only dataset: `"prompt"`. + - Prompt-completion dataset: `"prompt"` and `"completion"`. + - Preference dataset: `"prompt"`, `"chosen"`, and `"rejected"`. + - Preference dataset with implicit prompt: `"chosen"` and `"rejected"`. + - Unpaired preference dataset: `"prompt"`, `"completion"`, and `"label"`. + + For keys `"messages"`, `"prompt"`, `"chosen"`, `"rejected"`, and `"completion"`, the values are lists of + messages, where each message is a dictionary with keys `"role"` and `"content"`. Additionally, the example + may contain a `"chat_template_kwargs"` key, which is a dictionary of additional keyword arguments to pass + to the chat template renderer. + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`]): + Tokenizer to apply the chat template with. + tools (`list[dict | Callable]`, *optional*): + A list of tools (callable functions) that will be accessible to the model. If the template does not support + function calling, this argument will have no effect. + **template_kwargs (`Any`, *optional*): + Additional kwargs to pass to the template renderer. Will be accessible by the chat template. + + Returns: + `dict[str, str]`: + Formatted example with the chat template applied. + + Notes: + - This function does not alter the keys, except for Language modeling dataset, where `"messages"` is replaced + by `"text"`. + + - In case of prompt-only data, if the last role is `"user"`, the generation prompt is added to the prompt. + Else, if the last role is `"assistant"`, the final message is continued. + + Example: + + ```python + >>> from transformers import AutoTokenizer + + >>> tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-128k-instruct") + >>> example = { + ... "prompt": [{"role": "user", "content": "What color is the sky?"}], + ... "completion": [{"role": "assistant", "content": "It is blue."}], + ... } + >>> apply_chat_template(example, tokenizer) + {'prompt': '<|user|>\nWhat color is the sky?<|end|>\n<|assistant|>\n', 'completion': 'It is blue.<|end|>\n'} + ``` + """ + if is_conversational(example): + return apply_chat_template(example, processing_class, tools, **template_kwargs) + else: + return example + + +def _unpair_row(examples: list[dict[str, list[dict[str, str]]]]) -> list[dict[str, list[dict[str, str]]]]: + batch_size = len(examples["chosen"]) + new_rows = { + "completion": examples["chosen"] + examples["rejected"], + "label": [True] * batch_size + [False] * batch_size, + } + if "prompt" in examples: + new_rows["prompt"] = examples["prompt"] + examples["prompt"] + return new_rows + + +def unpair_preference_dataset( + dataset: DatasetType | IterableDatasetType, **map_kwargs +) -> DatasetType | IterableDatasetType: + # docstyle-ignore + """ + Unpair a preference dataset. + + Args: + dataset ([`~datasets.Dataset`] or [`~datasets.DatasetDict`] or [`~datasets.IterableDataset`] or [`~datasets.IterableDatasetDict`]): + Preference dataset to unpair. The dataset must have columns `"chosen"`, `"rejected"` and optionally + `"prompt"`. + **map_kwargs (`dict`, *optional*): + Additional keyword arguments to pass to the dataset's map method when unpairing preferences. + + Returns: + [`~datasets.Dataset`] or [`~datasets.DatasetDict`] or [`~datasets.IterableDataset`] or [`~datasets.IterableDatasetDict`]: + The unpaired preference dataset. + + Example: + + ```python + >>> from datasets import Dataset + + >>> dataset_dict = { + ... "prompt": ["The sky is", "The sun is"], + ... "chosen": [" blue.", "in the sky."], + ... "rejected": [" green.", " in the sea."], + ... } + >>> dataset = Dataset.from_dict(dataset_dict) + >>> dataset = unpair_preference_dataset(dataset) + >>> dataset + Dataset({ + features: ['prompt', 'completion', 'label'], + num_rows: 4 + }) + + >>> dataset[0] + {'prompt': 'The sky is', 'completion': ' blue.', 'label': True} + ``` + """ + return dataset.map(_unpair_row, batched=True, remove_columns=["chosen", "rejected"], **map_kwargs) + + +def maybe_unpair_preference_dataset( + dataset: DatasetType, num_proc: int | None = None, desc: str | None = None +) -> DatasetType: + r""" + Unpair a preference dataset if it is paired. + + Args: + dataset ([`~datasets.Dataset`] or [`~datasets.DatasetDict`]): + Preference dataset to unpair. The dataset must have columns `"chosen"`, `"rejected"` and optionally + `"prompt"`. + num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + desc (`str`, *optional*): + Meaningful description to be displayed alongside with the progress bar while mapping examples. + + Returns: + [`~datasets.Dataset`] or [`~datasets.DatasetDict`]: The unpaired preference dataset if it was paired, otherwise + the original dataset. + + Example: + + ```python + >>> from datasets import Dataset + + >>> dataset_dict = { + ... "prompt": ["The sky is", "The sun is"], + ... "chosen": [" blue.", "in the sky."], + ... "rejected": [" green.", " in the sea."], + ... } + >>> dataset = Dataset.from_dict(dataset_dict) + >>> dataset = unpair_preference_dataset(dataset) + >>> dataset + Dataset({ + features: ['prompt', 'completion', 'label'], + num_rows: 4 + }) + + >>> dataset[0] + {'prompt': 'The sky is', 'completion': ' blue.', 'label': True} + ``` + """ + if isinstance(dataset, DatasetDict): + column_names = dataset[list(dataset.keys())[0]].column_names + else: + column_names = dataset.column_names + if "chosen" in column_names and "rejected" in column_names: + return unpair_preference_dataset(dataset, num_proc=num_proc, desc=desc) + else: + return dataset + + +def extract_prompt(example: dict[str, Sequence]) -> dict[str, Sequence]: + r""" + Extracts the shared prompt from a preference data example, where the prompt is implicit within both the chosen and + rejected completions. + + The function identifies the longest common sequence (prefix) of conversation turns between the "chosen" and + "rejected" completions and extracts this as the prompt. It then removes this prompt from the respective "chosen" + and "rejected" completions. + + Args: + example (`dict[str, list]`): + A dictionary representing a single data entry in the preference dataset. It must contain the keys + `"chosen"` and `"rejected"`, where each value is either conversational or standard (`str`). + + Returns: + `dict[str, list]`: A dictionary containing: + - `"prompt"`: The longest common prefix between the "chosen" and "rejected" completions. + - `"chosen"`: The remainder of the "chosen" completion, with the prompt removed. + - `"rejected"`: The remainder of the "rejected" completion, with the prompt removed. + + Examples: + + ```python + >>> example = { + ... "chosen": [ + ... {"role": "user", "content": "What color is the sky?"}, + ... {"role": "assistant", "content": "It is blue."}, + ... ], + ... "rejected": [ + ... {"role": "user", "content": "What color is the sky?"}, + ... {"role": "assistant", "content": "It is green."}, + ... ], + ... } + >>> extract_prompt(example) + {'prompt': [{'role': 'user', 'content': 'What color is the sky?'}], + 'chosen': [{'role': 'assistant', 'content': 'It is blue.'}], + 'rejected': [{'role': 'assistant', 'content': 'It is green.'}]} + ``` + + Or, with the `map` method of [`~datasets.Dataset`]: + + ```python + >>> from trl import extract_prompt + >>> from datasets import Dataset + + >>> dataset_dict = { + ... "chosen": [ + ... [ + ... {"role": "user", "content": "What color is the sky?"}, + ... {"role": "assistant", "content": "It is blue."}, + ... ], + ... [ + ... {"role": "user", "content": "Where is the sun?"}, + ... {"role": "assistant", "content": "In the sky."}, + ... ], + ... ], + ... "rejected": [ + ... [ + ... {"role": "user", "content": "What color is the sky?"}, + ... {"role": "assistant", "content": "It is green."}, + ... ], + ... [ + ... {"role": "user", "content": "Where is the sun?"}, + ... {"role": "assistant", "content": "In the sea."}, + ... ], + ... ], + ... } + >>> dataset = Dataset.from_dict(dataset_dict) + >>> dataset = dataset.map(extract_prompt) + >>> dataset[0] + {'prompt': [{'role': 'user', 'content': 'What color is the sky?'}], + 'chosen': [{'role': 'assistant', 'content': 'It is blue.'}], + 'rejected': [{'role': 'assistant', 'content': 'It is green.'}]} + ``` + """ + for idx in range(min(len(example["chosen"]), len(example["rejected"]))): + if example["chosen"][idx] != example["rejected"][idx]: + if example["chosen"][idx - 1] == " ": # remove space before the prompt + idx -= 1 + break + return { + "prompt": example["chosen"][:idx], + "chosen": example["chosen"][idx:], + "rejected": example["rejected"][idx:], + } + + +def maybe_extract_prompt(example: dict[str, list]) -> dict[str, list]: + r""" + Extracts the shared prompt from a preference data example, where the prompt is implicit within both the chosen and + rejected completions. + + If the example already contains a `"prompt"` key, the function returns the example as is. For more details, see + [`extract_prompt`]. + ``` + """ + # Some dataset add a `"prompt"` column, even though the prompt is implicit and included in the "chosen" and + # "rejected" completions. E.g.: + # {"prompt": "What color is the sky?", + # "chosen": [{"role": "user", "content": "What color is the sky?"}, {"role": "assistant", "content": "It is blue."}], + # "rejected": [{"role": "user", "content": "What color is the sky?"}, {"role": "assistant", "content": "It is green."}]} + # That's why we check if the prompt is also conversational before deciding not to extract it. + if "chosen" not in example or "rejected" not in example: # not a preference example + return example + if "prompt" in example: + # Both conversational or both non-conversational + chosen_conv = is_conversational({"chosen": example["chosen"]}) + prompt_conv = is_conversational({"prompt": example["prompt"]}) + if (chosen_conv and prompt_conv) or (not chosen_conv and not prompt_conv): + return example + return extract_prompt({"chosen": example["chosen"], "rejected": example["rejected"]}) + + +def _get_dataset_format(dataset: DatasetType) -> dict[str, Any]: + if isinstance(dataset, (DatasetDict, IterableDatasetDict)): + dataset = dataset[next(iter(dataset))] + if isinstance(dataset, Dataset): + format = dataset.format + else: + format_type = dataset._formatting.format_type if dataset._formatting is not None else None + format = {"type": format_type} + format.update(format.pop("format_kwargs", {})) + return format + + +def _check_if_columns_can_be_packed(columns: list[pa.Array]): + first_column_offsets = None + for idx, column in enumerate(columns): + if not (pyarrow.types.is_list(column.type) or pyarrow.types.is_large_list(column.type)): + raise TypeError("Packing requires all columns to be lists of lists.") + + if idx == 0: + first_column_offsets = column.offsets + elif not first_column_offsets.equals(column.offsets): + raise ValueError("All columns must have values of the same length.") + + +class _SegmentTree: + """ + A segment tree data structure that, when initialized as `_SegmentTree(maxval)`, efficiently finds the next larger + value for a given input within the range [1, maxval]. + + See [Fewer Truncations Improve Language Modeling](https://huggingface.co/papers/2404.10830) for more details. + """ + + def __init__(self, maxval: int): + self.maxval = maxval + # For non-power-of-2 values, we need to round up to the next power of 2 for the tree size + self.tree_size = 1 << (maxval - 1).bit_length() + self.tree = [0] * (2 * self.tree_size) + + def add(self, val): + assert 0 < val <= self.maxval + i = self.tree_size + val - 1 + self.tree[i] = val + while i > 1: + i >>= 1 + left, right = self.tree[i << 1], self.tree[(i << 1) + 1] + # Compare the values using if-else otherwise repeated calls to `builtins.max` become the bottleneck + self.tree[i] = left if left >= right else right + + def remove(self, val): + assert 0 < val <= self.maxval + i = self.tree_size + val - 1 + self.tree[i] = 0 + while i > 1: + i >>= 1 + left, right = self.tree[i << 1], self.tree[(i << 1) + 1] + # Compare the values using if-else otherwise repeated calls to `builtins.max` become the bottleneck + self.tree[i] = left if left >= right else right + + def search(self, val): + assert 0 < val <= self.maxval + i = 1 + while i < self.tree_size: + if self.tree[i << 1] >= val: + i = i << 1 + else: + i = (i << 1) + 1 + return self.tree[i] + + +def _pack_bfd( + examples: pa.Table, seq_length: int, on_seq_length_overflow: Literal["truncate", "split"] = "truncate" +) -> pa.Table: + """Pack sequences in a pyarrow Table using Best Fit Decreasing strategy.""" + columns = [column.chunks[0] for column in examples.combine_chunks().columns] + _check_if_columns_can_be_packed(columns) + assert len(columns) > 0 + + lengths = pc.list_value_length(columns[0]) + + # Filter out empty sequences + non_empty_mask = pc.greater(lengths, 0) + columns = [pc.filter(column, non_empty_mask) for column in columns] + lengths = pc.filter(lengths, non_empty_mask) + + if on_seq_length_overflow == "truncate": + columns = [pc.list_slice(column, 0, seq_length) for column in columns] + elif on_seq_length_overflow == "split": + lengths = lengths.to_numpy() + # Split the sequences longer than `seq_length` into chunks (of length `seq_length` or less) while respecting sequence boundaries + num_fragments = np.ceil(lengths / seq_length).astype(int) + offsets = np.arange(np.sum(num_fragments) + 1, dtype=columns[0].offsets.type.to_pandas_dtype()) * seq_length + # "Left-shift" the offsets to account for the last fragment of each original sequence possibly being shorter than `seq_length` + diff = np.zeros_like(offsets) + diff[np.cumsum(num_fragments)] = -lengths % seq_length + diff = np.cumsum(diff) + offsets -= diff + columns = [ + type(column).from_arrays(offsets.astype(column.offsets.type.to_pandas_dtype()), column.values) + for column in columns + ] + else: + raise ValueError(f"Invalid `on_seq_length_overflow`: {on_seq_length_overflow}. Use 'truncate' or 'split'.") + + examples = pa.Table.from_arrays(columns, names=examples.column_names) + lengths = pc.list_value_length(columns[0]) + examples = examples.append_column("seq_lengths", lengths) # Allows us to later construct `position_ids` + ids = np.arange(len(examples)) + lengths = pc.make_struct(lengths, ids) + lengths = lengths.sort("descending", by=0) + + # Greedy BFD binning using a segment tree to quickly find best-fit remaining space. + segment_tree = _SegmentTree(seq_length) + segment_tree.add(seq_length) # the max, `seq_length` bin is always available + space_to_bin = defaultdict(deque) + + # Bin is represented as a dict (of example ids and sum of their lengths) to allow in-place updates + bins: list[dict] = [] + for length, idx in zip(lengths.field(0).to_numpy(), lengths.field(1).to_numpy(), strict=True): + space = segment_tree.search(length) + + if space < seq_length: + # Use existing bin with exactly this amount of space + bin = space_to_bin[space].popleft() + else: + # Create a new bin + bin = {"ids": [], "length": 0} + bins.append(bin) + + bin["ids"].append(idx) + bin["length"] += length + if space < seq_length and not space_to_bin[space]: + segment_tree.remove(space) + + space = space - length + space_to_bin[space].append(bin) + if space > 0: + segment_tree.add(space) + + examples = pc.take(examples, [id_ for bin in bins for id_ in bin["ids"]]) + offsets = np.cumsum([0] + [bin["length"] for bin in bins]) + + assert all( + column.num_chunks == 1 for column in examples.columns + ) # `pc.take` returns a ChunkedArray with a single chunk + + lengths = examples["seq_lengths"].chunks[0] + examples = examples.drop_columns("seq_lengths") + lengths = pa.ListArray.from_arrays(np.cumsum([0] + [len(bin["ids"]) for bin in bins], dtype=np.int32), lengths) + + columns = [] + for column in examples.columns: + column = column.chunks[0] + assert pa.types.is_list(column.type) or pa.types.is_large_list(column.type) + dtype = column.offsets.type.to_pandas_dtype() + column = type(column).from_arrays(offsets.astype(dtype), column.values) + columns.append(column) + return pa.Table.from_arrays(columns + [lengths], names=examples.column_names + ["seq_lengths"]) + + +def _pack_wrapped(examples: pa.Table, seq_length: int) -> pa.Table: + """Pack sequences in a pyarrow Table using a wrapped strategy.""" + columns = [column.chunks[0] for column in examples.combine_chunks().columns] + _check_if_columns_can_be_packed(columns) + offsets, values = columns[0].offsets, columns[0].values + values = values[offsets[0].as_py() : offsets[-1].as_py()] + num_elements = len(values) + offsets = np.arange(0, num_elements, seq_length, dtype=columns[0].offsets.type.to_pandas_dtype()) + offsets = np.concatenate((offsets, [num_elements])) + columns = [ + type(column).from_arrays(offsets.astype(column.offsets.type.to_pandas_dtype()), column.values) + for column in columns + ] + return pa.Table.from_arrays(columns, names=examples.column_names) + + +def pack_dataset( + dataset: DatasetType, + seq_length: int, + strategy: str = "bfd", + map_kwargs: dict[str, Any] | None = None, +) -> DatasetType: + r""" + Pack sequences in a dataset into chunks of size `seq_length`. + + Args: + dataset ([`~datasets.Dataset`] or [`~datasets.DatasetDict`]): + Dataset to pack + seq_length (`int`): + Target sequence length to pack to. + strategy (`str`, *optional*, defaults to `"bfd"`): + Packing strategy to use. Can be either: + + - `"bfd"` (Best Fit Decreasing): Preserves sequence boundaries and truncates sequences that exceed + `seq_length`, discarding overflow tokens. Ideal for SFT and conversational datasets where maintaining + conversation structure is important. + - `"bfd_split"`: Similar to `"bfd"` but splits overflow sequences for packing into other examples. Prevents + token loss for pre-training or long documents, but may break conversation structure in SFT datasets. + - `"wrapped"`: Faster but more aggressive. Ignores sequence boundaries and will cut sequences in the middle + to completely fill each packed sequence with data. + map_kwargs (`dict`, *optional*): + Additional keyword arguments to pass to the dataset's map method when packing examples. + + Returns: + [`~datasets.Dataset`] or [`~datasets.DatasetDict`]: The dataset with packed sequences. The number of examples + may decrease as sequences are combined. + + Example: + ```python + >>> from datasets import Dataset + >>> from trl import pack_dataset + + >>> examples = { + ... "input_ids": [[1, 2, 3, 4, 5], [6, 7], [8, 9, 10], [11]], + ... "attention_mask": [[1, 1, 1, 0, 0], [1, 0], [1, 1, 0], [1]], + ... } + >>> dataset = Dataset.from_dict(examples) + >>> # Default "bfd" strategy (SFT-friendly): truncates long sequences + >>> packed_dataset = pack_dataset(dataset, seq_length=4, strategy="bfd") + >>> packed_dataset[:] + {'input_ids': [[1, 2, 3, 4], [8, 9, 10, 11], [6, 7]], + 'attention_mask': [[1, 1, 1, 0], [1, 1, 0, 1], [1, 0]], + 'seq_lengths': [[4], [3, 1], [2]]} + + >>> # "bfd_split" strategy: preserves all tokens + >>> packed_dataset = pack_dataset(dataset, seq_length=4, strategy="bfd_split") + >>> packed_dataset[:] + {'input_ids': [[1, 2, 3, 4], [8, 9, 10, 5], [6, 7, 11]], + 'attention_mask': [[1, 1, 1, 0], [1, 1, 0, 0], [1, 0, 1]], + 'seq_lengths': [[4], [3, 1], [2, 1]]} + ``` + """ + if map_kwargs is None: + map_kwargs = {} + + valid_strategies = ("bfd", "bfd_split", "wrapped") + if strategy not in valid_strategies: + raise ValueError(f"Invalid packing strategy '{strategy}', must be one of {valid_strategies}.") + format = _get_dataset_format(dataset) + dataset = dataset.with_format("arrow") + if strategy == "bfd": + dataset = dataset.map( + _pack_bfd, + batched=True, + fn_kwargs={"seq_length": seq_length, "on_seq_length_overflow": "truncate"}, + **map_kwargs, + ) + elif strategy == "bfd_split": + dataset = dataset.map( + _pack_bfd, + batched=True, + fn_kwargs={"seq_length": seq_length, "on_seq_length_overflow": "split"}, + **map_kwargs, + ) + elif strategy == "wrapped": + dataset = dataset.map(_pack_wrapped, batched=True, fn_kwargs={"seq_length": seq_length}, **map_kwargs) + else: + raise ValueError(f"Invalid packing strategy: '{strategy}', must be one of {valid_strategies}.") + + if strategy in {"bfd", "bfd_split"} and "columns" in format: + format["columns"] = format["columns"] + ["seq_lengths"] + + dataset = dataset.with_format(**format) + return dataset + + +def is_conversational_from_value(example: dict[str, Any]) -> bool: + r""" + Check if the example is in a conversational format (from/value). Note that this format isn't recommended. Prefer + the ChatML format (role/content) + + Args: + example (`dict[str, Any]`): + A single data entry of a dataset. The example can have different keys depending on the dataset type. + + Returns: + `bool`: + `True` if the data is in a conversational Chatformat, `False` otherwise. + + Examples: + + ```python + >>> example = {"conversations": [{"from": "user", "value": "What color is the sky?"}]} + >>> is_conversational_from_value(example) + True + + >>> example = {"conversations": [{"role": "user", "content": "What color is the sky?"}]} + >>> is_conversational_from_value(example) + False + + >>> example = {"conversations": "The sky is"} + >>> is_conversational_from_value(example) + False + ``` + """ + maybe_messages = example.get("conversations") + # It must be a list of messages + if isinstance(maybe_messages, list): + maybe_message = maybe_messages[0] + # Each message must a list of dictionaries with keys "from" and "value" + if isinstance(maybe_message, dict) and "from" in maybe_message and "value" in maybe_message: + return True + + return False + + +def maybe_convert_to_chatml(example: dict[str, list]) -> dict[str, list]: + """ + Convert a conversational dataset with fields `from` and `value` to ChatML format. + + This function modifies conversational data to align with OpenAI's ChatML format: + - Replaces the key `"from"` with `"role"` in message dictionaries. + - Replaces the key `"value"` with `"content"` in message dictionaries. + - Renames `"conversations"` to `"messages"` for consistency with ChatML. + + Args: + example (`dict[str, list]`): + A single data entry containing a list of messages. + + Returns: + `dict[str, list]`: + Example reformatted to ChatML style. + + Example: + ```python + >>> from trl import maybe_convert_to_chatml + + >>> example = { + ... "conversations": [ + ... {"from": "user", "value": "What color is the sky?"}, + ... {"from": "assistant", "value": "It is blue."}, + ... ] + ... } + >>> maybe_convert_to_chatml(example) + {'messages': [{'role': 'user', 'content': 'What color is the sky?'}, + {'role': 'assistant', 'content': 'It is blue.'}]} + ``` + """ + # List of possible keys containing message lists + for key in ["prompt", "completion", "chosen", "rejected", "messages", "conversations"]: + if key in example and isinstance(example[key], list): + messages = example[key] + for message in messages: + if isinstance(message, dict): + if "from" in message: + message["role"] = message.pop("from") + if "value" in message: + message["content"] = message.pop("value") + + # Rename "conversations" to "messages" + if "conversations" in example: + example["messages"] = example.pop("conversations") + + return example diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..041a38542a6fbaba81fbdb3d278e737109c95f83 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/__init__.py @@ -0,0 +1,36 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Experimental submodule for TRL. + +This submodule contains unstable or incubating features. Anything here may change (or be removed) in any release +without deprecation. Use at your own risk. + +To silence this notice set environment variable TRL_EXPERIMENTAL_SILENCE=1. +""" + +import os +import warnings + +from ..import_utils import TRLExperimentalWarning + + +if not os.environ.get("TRL_EXPERIMENTAL_SILENCE"): + warnings.warn( + "You are importing from 'trl.experimental'. APIs here are unstable and may change or be removed without " + "notice. Silence this warning by setting environment variable TRL_EXPERIMENTAL_SILENCE=1.", + TRLExperimentalWarning, + stacklevel=2, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3fc30c059a76572f449ca53f59aeff47bd789cf5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .async_grpo_config import AsyncGRPOConfig +from .async_grpo_trainer import AsyncGRPOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_grpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_grpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..2afd760e7fc6dae77e521987a524a42083117d07 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_grpo_config.py @@ -0,0 +1,214 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from trl.trainer.base_config import _BaseConfig + + +@dataclass +class AsyncGRPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`AsyncGRPOTrainer`]. + + This class includes only the parameters that are specific to asynchronous GRPO training. For a full list of + training arguments, please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values + in this class may differ from those in [`~transformers.TrainingArguments`]. + + Parameters: + > Parameters that control generation + + num_generations (`int`, *optional*, defaults to `8`): + Number of generations per prompt to sample. + max_completion_length (`int`, *optional*, defaults to `2048`): + Maximum number of tokens to generate per completion. + temperature (`float`, *optional*, defaults to `1.0`): + Temperature for sampling. The higher the temperature, the more random the completions. + chat_template_kwargs (`dict[str, Any]`, *optional*): + Additional keyword arguments to pass to the `apply_chat_template` function when generating completions. + max_tool_calling_iterations (`int`, *optional*): + Maximum number of tool-calling turns when training an agent. If `None`, there is no limit and generation + stops when the model generates a response turn with no tool calls or when the total response length reaches + `max_completion_length`. + + > Parameters that control the vLLM server + + vllm_server_base_url (`str`, *optional*, defaults to `"http://localhost:8000"`): + Base URL of the vLLM server used for generation (e.g., `"http://localhost:8000"`). + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Total timeout duration in seconds to wait for the vLLM server to be ready. + request_timeout (`int`, *optional*, defaults to `600`): + Timeout in seconds for individual HTTP requests to the vLLM server. + + > Parameters that control the training + + epsilon (`float`, *optional*, defaults to `0.2`): + Lower-bound epsilon value for clipping. + epsilon_high (`float`, *optional*, defaults to `0.2`): + Upper-bound epsilon value for clipping. + + > Parameters that control the async rollout pipeline + + max_inflight_tasks (`int`, *optional*, defaults to `-1`): + Maximum number of concurrent generation tasks sent to the vLLM server. Defaults to `-1` (auto), which + sets it to `max_staleness * per_device_train_batch_size * gradient_accumulation_steps * num_processes`. + If using tool-use environments, you may want to set this manually based on how many parallel environments + you can run. + max_staleness (`int`, *optional*, defaults to `4`): + Maximum number of weight update steps a rollout sample can lag behind the current model version before + being discarded. + queue_maxsize (`int`, *optional*, defaults to `1024`): + Maximum number of rollout samples to buffer in the rollout queue. + weight_sync_steps (`int`, *optional*, defaults to `1`): + Number of training steps between weight synchronizations to the vLLM server. + + > Parameters that control the logging + + log_completions (`bool`, *optional*, defaults to `False`): + Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. + num_completions_to_print (`int`, *optional*, defaults to `3`): + Number of completions to print when `log_completions=True`. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + logging_steps: float = field( + default=1, + metadata={ + "help": "Log every X update steps. Should be an integer or a float in range `[0,1)`. If smaller than 1, " + "will be interpreted as ratio of total training steps." + }, + ) + + # Parameters that control generation + num_generations: int = field( + default=8, + metadata={"help": "Number of generations per prompt to sample."}, + ) + max_completion_length: int = field( + default=2048, + metadata={"help": "Maximum number of tokens to generate per completion."}, + ) + temperature: float = field( + default=1.0, + metadata={"help": "Temperature for sampling. The higher the temperature, the more random the completions."}, + ) + chat_template_kwargs: dict | None = field( + default=None, + metadata={ + "help": "Additional keyword arguments to pass to the `apply_chat_template` function when generating " + "completions." + }, + ) + max_tool_calling_iterations: int | None = field( + default=None, + metadata={ + "help": "Maximum number of tool-calling turns when training an agent. If `None`, there is no limit and " + "generation stops when the model generates a response turn with no tool calls or when the total response " + "length reaches `max_completion_length`." + }, + ) + + # Parameters that control the vLLM server + vllm_server_base_url: str = field( + default="http://localhost:8000", + metadata={"help": "Base URL of the vLLM server used for generation (e.g., 'http://localhost:8000')."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={ + "help": "Total timeout duration in seconds to wait for the vLLM server to be ready. If the server is not " + "up after the timeout, a `TimeoutError` is raised." + }, + ) + request_timeout: int = field( + default=600, + metadata={"help": "Timeout in seconds for individual HTTP requests to the vLLM server."}, + ) + + # Parameters that control the training + epsilon: float = field( + default=0.2, + metadata={"help": "Lower-bound epsilon value for clipping."}, + ) + epsilon_high: float = field( + default=0.2, + metadata={"help": "Upper-bound epsilon value for clipping."}, + ) + + # Parameters that control the async rollout pipeline + max_inflight_tasks: int = field( + default=-1, + metadata={ + "help": "Maximum number of concurrent generation tasks sent to the vLLM server. Defaults to -1 (auto), " + "which sets it to `max_staleness * per_device_train_batch_size * gradient_accumulation_steps * " + "num_processes`. Generating more samples than this is wasteful since they will be discarded as stale " + "before the trainer can consume them. If using tool-use environments, you may want to set this manually " + "based on how many parallel environments you can run." + }, + ) + max_staleness: int = field( + default=4, + metadata={ + "help": "Maximum number of weight update steps a rollout sample can lag behind the current model version " + "before being discarded." + }, + ) + queue_maxsize: int = field( + default=1024, + metadata={"help": "Maximum number of rollout samples to buffer in the rollout queue."}, + ) + weight_sync_steps: int = field( + default=1, + metadata={"help": "Number of training steps between weight synchronizations to the vLLM server."}, + ) + + # Parameters that control the logging + log_completions: bool = field( + default=False, + metadata={ + "help": "Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. If `rich` is " + "installed, it prints the sample. If `wandb` logging is enabled, it logs it to `wandb`." + }, + ) + num_completions_to_print: int = field( + default=3, + metadata={"help": "Number of completions to print when `log_completions=True`."}, + ) + + def __post_init__(self): + super().__post_init__() + + # Accelerator config: required for the async IterableDataset-backed dataloader to work correctly. + # split_batches=True and dispatch_batches=True ensure that the main process drives the dataloader + # and batches are broadcast to other processes rather than each process pulling independently. + if not hasattr(self, "accelerator_config") or self.accelerator_config is None: + self.accelerator_config = {"split_batches": True, "dispatch_batches": True} + elif isinstance(self.accelerator_config, dict): + self.accelerator_config["split_batches"] = True + self.accelerator_config["dispatch_batches"] = True + else: + self.accelerator_config.split_batches = True + self.accelerator_config.dispatch_batches = True diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_grpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_grpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..25cc5082d7c85a30abec3899ef8605fd4d11bf74 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_grpo_trainer.py @@ -0,0 +1,624 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import math +import queue +import textwrap +import time +from collections import defaultdict +from collections.abc import Callable, Iterator +from dataclasses import dataclass +from typing import Any, Protocol + +import torch +from accelerate.logging import get_logger +from datasets import Dataset, IterableDataset +from torch.distributed._tensor import DTensor +from torch.utils.data import DataLoader +from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerBase, TrainerCallback +from transformers.data.data_collator import DataCollatorMixin + +from trl.trainer.base_trainer import _BaseTrainer +from trl.trainer.utils import pad, patch_chunked_lm_head + +from .async_grpo_config import AsyncGRPOConfig +from .async_rollout_worker import AsyncRolloutWorker + + +logger = get_logger(__name__) + +# A reward function is a callable that returns a list of floats (the rewards). The callable receives prompts, +# completions, and additional arguments from the trainer (refer to the trainer's source for details). To ensure forward +# compatibility, it should accept **kwargs. +RewardFunc = Callable[..., list[float]] + + +class _SupportsReset(Protocol): + def reset(self, **kwargs) -> str | None: ... + + +EnvironmentFactory = Callable[[], _SupportsReset] + + +class RolloutWorkerProtocol(Protocol): + rollout_buffer: queue.Queue + + def start(self) -> None: ... + def stop(self) -> None: ... + def pause(self) -> None: ... + def resume(self) -> None: ... + def send_weights(self, iterator: Iterator[tuple[str, torch.Tensor]]) -> None: ... + def update_model_version(self, version: int) -> None: ... + + +class StepIntervalCallback(TrainerCallback): + """ + A callback that calls a function every N optimization steps. + """ + + def __init__(self, fn, every_n_steps: int): + self.fn = fn + self.every_n_steps = every_n_steps + + def on_step_end(self, _args, state, _control, **_kwargs): + if state.global_step % self.every_n_steps == 0: + self.fn() + + +class RolloutQueueDataset(torch.utils.data.IterableDataset): + def __init__(self, rollout_queue, model_version_fn, max_staleness=3, timeout=120.0): + self.queue = rollout_queue + self.model_version_fn = model_version_fn + self.max_staleness = max_staleness + self.timeout = timeout + + def __iter__(self): + while True: + t0 = time.time() + qsize = self.queue.qsize() + if qsize == 0: + logger.info("queue empty, waiting for rollout samples...") + try: + sample = self.queue.get(timeout=self.timeout) + except queue.Empty: + logger.warning(f"Rollout queue empty for {self.timeout}s, stopping epoch") + return # StopIteration ends epoch + queue_wait_time_s = time.time() - t0 + if queue_wait_time_s > 1.0: + logger.info(f"waited {queue_wait_time_s:.1f}s for sample (qsize={self.queue.qsize()})") + + staleness = self.model_version_fn() - sample.model_version + if staleness > self.max_staleness: + logger.info(f"dropping stale sample (staleness={staleness}, max={self.max_staleness})") + continue # drop stale, pull next + + yield { + "input_ids": sample.input_ids, + "completion_mask": sample.completion_mask, + "old_log_probs": sample.old_log_probs, + "advantage": sample.advantage, + "metrics": {**sample.metrics, "queue_wait_time_s": queue_wait_time_s}, + } + + +class _EmptyIterableDataset(torch.utils.data.IterableDataset): + """Placeholder for non-rank-0 processes. Never actually iterated.""" + + def __iter__(self): + return iter([]) + + +@dataclass +class DataCollatorForRollout(DataCollatorMixin): + pad_token_id: int + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + input_ids = [torch.tensor(example["input_ids"], dtype=torch.long) for example in examples] + attention_mask = [torch.ones(len(ids), dtype=torch.long) for ids in input_ids] + completion_mask = [torch.tensor(example["completion_mask"], dtype=torch.float32) for example in examples] + old_log_probs = [torch.tensor(example["old_log_probs"], dtype=torch.float32) for example in examples] + advantages = torch.tensor([example["advantage"] for example in examples], dtype=torch.float32) + + input_ids = pad(input_ids, padding_value=self.pad_token_id) + attention_mask = pad(attention_mask, padding_value=0) + completion_mask = pad(completion_mask, padding_value=0) + old_log_probs = pad(old_log_probs, padding_value=0) + + # Total valid completion tokens across all samples in the full batch. + # Repeated per sample so that DataLoaderDispatcher (dispatch_batches=True) slices correctly on dim=0 + global_n_tokens = completion_mask.sum() + global_n_tokens_repeated = torch.full((len(examples),), global_n_tokens.item(), dtype=torch.float32) + + # Convert per-sample metrics dicts to a dict of 1D tensors so that Accelerate's + # recursive broadcast (dispatch_batches=True) can handle them — it traverses nested + # dicts of tensors but chokes on plain Python floats. + metrics_list = [example["metrics"] for example in examples] + metrics = ( + { + key: torch.tensor([m.get(key, 0.0) for m in metrics_list], dtype=torch.float32) + for key in metrics_list[0] + } + if metrics_list and metrics_list[0] + else {} + ) + + return { + "input_ids": input_ids, + "attention_mask": attention_mask, + "completion_mask": completion_mask, + "old_log_probs": old_log_probs, + "advantages": advantages, + "global_n_tokens": global_n_tokens_repeated, + "metrics": metrics, + } + + +class AsyncGRPOTrainer(_BaseTrainer): + """ + Trainer for the Group Relative Policy Optimization (GRPO) method. This algorithm was initially proposed in the + paper [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language + Models](https://huggingface.co/papers/2402.03300). This trainer is the asynchronous version of GRPO, where + generation is offloaded to an external vLLM server that runs asynchronously alongside training, decoupling rollout + from the gradient update loop. + + Example: + + ```python + from trl.experimental.async_grpo import AsyncGRPOTrainer + from trl.rewards import accuracy_reward + from datasets import load_dataset + + dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + + trainer = AsyncGRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + reward_funcs=accuracy_reward, + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str`): + Model to be trained. Must be a string, being the *model id* of a pretrained model hosted inside a model + repo on huggingface.co, or a path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForCausalLM.from_pretrained`]. The model name is also used to identify the + model on the vLLM server used for generation. + reward_funcs (`RewardFunc | list[RewardFunc]`): + Reward functions to be used for computing the rewards. To compute the rewards, we call all the reward + functions with the prompts and completions and sum the rewards. Can be either: + + - A single reward function: The function is provided with the prompts and the generated completions, plus + any additional columns in the dataset. It should return a list of rewards. Reward functions can be either + synchronous or asynchronous and can also return `None` when the reward is not applicable to those + samples. This is useful for multi-task training where different reward functions apply to different types + of samples. When a reward function returns `None` for a sample, that reward function is excluded from the + reward calculation for that sample. For more details, see [Using a custom reward + function](#using-a-custom-reward-function). + - A list of reward functions, where each item is a reward function as described above. Rewards from all + functions are summed. + args ([`AsyncGRPOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. It must include a column `"prompt"`. Any additional columns in the dataset are + ignored. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + processing_class ([`~transformers.PreTrainedTokenizerBase`], *optional*): + Processing class used to process the data. The padding side must be set to `"left"`. If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoTokenizer.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + tools (list of `Callable`, *optional*): + A list of callable tool functions (sync or async) that the model can invoke during generation. Each tool + should be a standard Python function with properly type-hinted arguments and return values, and a + Google-style docstring describing its purpose, arguments, and return value. For more details, see: + https://huggingface.co/docs/transformers/en/chat_extras#passing-tools. The model uses the function's name, + type hints, and docstring to determine how to call it. Ensure that the model's chat template supports tool + use and that it has been fine-tuned for tool calling. + environment_factory (`EnvironmentFactory`, *optional*): + A callable that creates and returns an environment instance. The environment class should define methods + that can be invoked as tools during generation. Each method should comply with the same requirements as the + `tools` described above. If `environment_factory` is provided, an instance of the environment is created + for each generation in the batch, allowing for parallel and independent interactions. The environment must + also implement a callable `reset` method that can be used to reset state between generations. The `reset` + method should return either `None` or a string: when it returns a string, that string is appended to the + last user message before generation. This feature is experimental and may change or be removed at any time + without prior notice. + """ + + _tag_names = ["trl", "async-grpo"] + _name = "AsyncGRPO" + _paper = { + "title": "DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models", + "id": "2402.03300", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{shao2024deepseekmath, + title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}}, + author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo}, + year = 2024, + eprint = {arXiv:2402.03300}, + }"""), + } + + def __init__( + self, + model: str, + reward_funcs: RewardFunc | list[RewardFunc], + args: AsyncGRPOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + processing_class: PreTrainedTokenizerBase | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + tools: list[Callable] | None = None, + environment_factory: EnvironmentFactory | None = None, + rollout_worker: RolloutWorkerProtocol | None = None, + ): + self.args = args or AsyncGRPOConfig() + + # Training arguments + self.epsilon_low = self.args.epsilon + self.epsilon_high = self.args.epsilon_high + self.temperature = self.args.temperature + + # Model + model_name = model + model = AutoModelForCausalLM.from_pretrained(model, device_map=None, dtype=torch.float32) + + if self.args.use_liger_kernel: + raise NotImplementedError("`use_liger_kernel` is not supported yet.") + + patch_chunked_lm_head(model, chunk_size=8192, temperature=self.temperature) + + # Processing class + if processing_class is None: + processing_class = AutoTokenizer.from_pretrained(model_name) + if processing_class.pad_token is None: + processing_class.pad_token = processing_class.eos_token + + # Reward functions + if not isinstance(reward_funcs, list): + reward_funcs = [reward_funcs] + + # Initialize the Trainer + super().__init__( + model=model, + args=self.args, + train_dataset=train_dataset, + processing_class=processing_class, + callbacks=callbacks, + optimizers=optimizers, + compute_loss_func="non-None value to disable scaling", + ) + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Infer max_steps from dataset size when not explicitly set. This must happen after super().__init__() + # so that self.accelerator.num_processes is available for the correct calculation. + samples_per_step = ( + self.args.per_device_train_batch_size + * self.args.gradient_accumulation_steps + * self.accelerator.num_processes + ) + if self.args.max_steps <= 0 and train_dataset is not None and hasattr(train_dataset, "__len__"): + samples_per_epoch = len(train_dataset) * self.args.num_generations + self.args.max_steps = int(self.args.num_train_epochs * samples_per_epoch / samples_per_step) + + # Infer max_inflight_tasks when not explicitly set. Generating more samples than the trainer can consume + # before they become stale is wasteful. The useful upper bound is max_staleness * samples_per_step. + if self.args.max_inflight_tasks < 0: + self.args.max_inflight_tasks = self.args.max_staleness * samples_per_step + logger.info( + f"max_inflight_tasks set to {self.args.max_inflight_tasks} " + f"(max_staleness={self.args.max_staleness} × samples_per_step={samples_per_step})" + ) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._train_tokens_start_time = None + self.model_version = 0 + # Create worker and queue on rank 0 + if self.accelerator.is_main_process: + if self.train_dataset is None: + raise ValueError("train_dataset is required for AsyncGRPOTrainer") + + if rollout_worker is not None: + # Use the injected worker (e.g. a stub in tests). The queue is owned by the worker. + self.rollout_worker = rollout_worker + else: + # Collect weight metadata once — names/dtypes/shapes are fixed for the lifetime of training. + # DTensor.shape returns the global shape without triggering any all-gather. + weight_names, weight_dtype_names, weight_shapes = [], [], [] + for name, param in model.named_parameters(): + # DDP/FSDP1 wrapping, avoids vllm module not exist error + name = name.removeprefix("module.") + weight_names.append(name) + weight_dtype_names.append(str(param.dtype).split(".")[-1]) + weight_shapes.append(list(param.shape)) + self.rollout_worker = AsyncRolloutWorker( + model_name=model_name, + dataset=train_dataset, + reward_funcs=reward_funcs, + processing_class=processing_class, + tools=tools, + environment_factory=environment_factory, + num_generations=self.args.num_generations, + max_inflight_tasks=self.args.max_inflight_tasks, + queue_maxsize=self.args.queue_maxsize, + vllm_server_url=self.args.vllm_server_base_url, + max_tokens=self.args.max_completion_length, + temperature=self.args.temperature, + request_timeout=self.args.request_timeout, + server_timeout=self.args.vllm_server_timeout, + chat_template_kwargs=self.args.chat_template_kwargs, + max_tool_calling_iterations=self.args.max_tool_calling_iterations, + log_completions=self.args.log_completions, + num_completions_to_print=self.args.num_completions_to_print, + weight_names=weight_names, + weight_dtype_names=weight_dtype_names, + weight_shapes=weight_shapes, + ) + self.rollout_queue = self.rollout_worker.rollout_buffer + else: + self.rollout_queue = None + self.rollout_worker = None + + # Add callbacks + self.add_callback(StepIntervalCallback(self._sync_weight, self.args.weight_sync_steps)) + + def get_train_dataloader(self) -> DataLoader: + if self.accelerator.is_main_process: + dataset = RolloutQueueDataset( + rollout_queue=self.rollout_queue, + model_version_fn=lambda: self.model_version, + max_staleness=self.args.max_staleness, + timeout=self.args.vllm_server_timeout, + ) + else: + dataset = _EmptyIterableDataset() + + return self.accelerator.prepare( + DataLoader( + dataset, + batch_size=self.args.per_device_train_batch_size * self.accelerator.num_processes, + collate_fn=DataCollatorForRollout(self.processing_class.pad_token_id), + num_workers=0, + # NOTE(@aminediro): + # dispatch_batches = True for DataLoader whose underlying dataset is an IterableDataset + # dataloader prepared by the Accelerator is only iterated through on the main process a + ) + ) + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). In AsyncGRPOTrainer, we need additional columns ("completion_mask", "old_log_probs", + # "advantages", "global_n_tokens") to compute the loss, hence the override. + if self._signature_columns is None: + self._signature_columns = [ + "input_ids", + "attention_mask", + "completion_mask", + "old_log_probs", + "advantages", + "global_n_tokens", + "metrics", + ] + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + input_ids = inputs["input_ids"] + attention_mask = inputs["attention_mask"] + completion_mask = inputs["completion_mask"] + old_log_probs = inputs["old_log_probs"] + advantages = inputs["advantages"] + + # The collator pads to the global batch max length (across all ranks). After DataLoaderDispatcher slices and + # sends rows to each rank, the local slice is still padded to that global max. Truncate to the longest real + # sequence in this rank's slice so we don't run the forward pass over pure-padding columns. + local_max_len = attention_mask.sum(dim=1).max() + input_ids = input_ids[:, :local_max_len] + attention_mask = attention_mask[:, :local_max_len] + completion_mask = completion_mask[:, :local_max_len] + old_log_probs = old_log_probs[:, :local_max_len] + + forward_start = time.time() + outputs = model( + input_ids=input_ids, + attention_mask=attention_mask, + labels=input_ids, + completion_mask=completion_mask, + use_cache=False, + ) + log_probs, entropy = outputs["log_probs"], outputs["entropy"] + self._last_forward_time_s = time.time() - forward_start + + completion_mask = completion_mask[:, 1:] + old_log_probs = old_log_probs[:, 1:] + advantages = advantages.unsqueeze(1) + log_ratio = log_probs - old_log_probs + ratio = torch.exp(log_ratio) + clipped = torch.clamp(ratio, 1 - self.epsilon_low, 1 + self.epsilon_high) + per_token_loss = -torch.min(ratio * advantages, clipped * advantages) + + # DDP/FSDP averages gradients across ranks (world_size). + # To get correct per-token normalization we scale by 1/tokens_per_rank + # = world_size / global_n_tokens, so after DDP averaging the effective + loss = (per_token_loss * completion_mask).sum() + global_n_tokens = inputs["global_n_tokens"][0] + world_size = self.accelerator.num_processes + tokens_per_rank = (global_n_tokens / world_size).clamp(min=1.0) + loss = loss / tokens_per_rank.to(torch.float32) + # For DAPO, we would scale like this instead: + # loss = loss / max(per_token_loss.size(0), 1) + loss = loss / self.current_gradient_accumulation_steps + + with torch.no_grad(): + valid_mask = completion_mask > 0 + local_count = valid_mask.sum().float() + + local_ratio_sum = ( + ratio[valid_mask].sum() if valid_mask.any() else torch.zeros((), device=completion_mask.device) + ) + # Approx KL: http://joschu.net/blog/kl-approx.html + local_kl_sum = ( + ((ratio[valid_mask] - 1) - log_ratio[valid_mask]).sum() + if valid_mask.any() + else torch.zeros((), device=completion_mask.device) + ) + + local_entropy_sum = ( + entropy[valid_mask].sum() if valid_mask.any() else torch.zeros((), device=completion_mask.device) + ) + + clipped = (ratio < 1 - self.epsilon_low) | (ratio > 1 + self.epsilon_high) + local_clip_sum = ( + clipped[valid_mask].float().sum() + if valid_mask.any() + else torch.zeros((), device=completion_mask.device) + ) + + # Batch all-reduce: [ratio_sum, kl_sum, entropy_sum, clip_sum, count] + stats = torch.stack([local_ratio_sum, local_kl_sum, local_entropy_sum, local_clip_sum, local_count]) + stats = self.accelerator.reduce(stats, reduction="sum") + global_ratio_sum, global_kl_sum, global_entropy_sum, global_clip_sum, global_count = stats.unbind(0) + self._metrics["train"]["ratio"].append((global_ratio_sum / global_count).item()) + self._metrics["train"]["kl"].append((global_kl_sum / global_count).item()) + self._metrics["train"]["entropy"].append((global_entropy_sum / global_count).item()) + self._metrics["train"]["clip_ratio"].append((global_clip_sum / global_count).item()) + + # Logging metrics from the rollout worker (reward, reward_std, etc.). + # inputs["metrics"] is a dict of 1D tensors keyed by metric name. + sample_metrics = inputs["metrics"] # dict[str, Tensor(shape=[B_local])] + keys = list(sample_metrics.keys()) + device = completion_mask.device + n_samples = torch.tensor(completion_mask.shape[0], dtype=torch.float32, device=device) + if keys: + local_sums = torch.stack([sample_metrics[k].to(device).sum() for k in keys]) + stats = torch.cat([local_sums, n_samples.unsqueeze(0)]) + stats = self.accelerator.reduce(stats, reduction="sum") + global_sums, global_n_samples = stats[:-1], stats[-1] + for k, global_sum in zip(keys, global_sums, strict=True): + self._metrics["train"][k].append((global_sum / global_n_samples).item()) + + completion_length = completion_mask.sum(dim=1).float() + length_stats = torch.stack([completion_length.sum(), n_samples]) + length_stats = self.accelerator.reduce(length_stats, reduction="sum") + self._metrics["train"]["completions/mean_length"].append((length_stats[0] / length_stats[1]).item()) + + # Training throughput: completion tokens consumed by this training step per second. + now = time.time() + if self._train_tokens_start_time is not None: + train_elapsed = now - self._train_tokens_start_time + if train_elapsed > 0: + self._metrics["train"]["training_tok/s"].append(global_n_tokens.item() / train_elapsed) + self._train_tokens_start_time = now + + self._metrics["train"]["forward_time_s"].append(self._last_forward_time_s) + # NOTE: in dynamic mbs setup, we would need to agg across DP ranks. + self._metrics["train"]["train_seq_len"].append(float(local_max_len)) + return loss + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + # Average the metrics + metrics = {} + for key, val in self._metrics[mode].items(): + # Filter out NaN values before averaging. A reward function that returns None for all samples + # in a batch produces NaN for that batch's metric. With logging_steps > 1, a naive sum()/len() + # would let a single NaN contaminate valid data from other batches. Only return None when no + # valid values remain (e.g. JSON loggers crash on float NaN). + valid = [v for v in val if not math.isnan(v)] + metrics[key] = sum(valid) / len(valid) if valid else None + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + def _streaming_iter(self): + # Iterate parameters one at a time. For FSDP2 (DTensor), full_tensor() all-gathers just this parameter across + # FSDP ranks, then frees it once the generator advances — avoiding materializing the full model in memory. + device = self.accelerator.device + for name, param in self.model.named_parameters(): + name = name.removeprefix("module.") # DDP/FSDP1 wrapping + full = param.full_tensor() if isinstance(param, DTensor) else param.detach() + if full.device != device: + full = full.to(device) + yield name, full + + def _sync_weight(self): + t0 = time.time() + logger.info("Weight sync: pausing vLLM...") + if self.accelerator.is_main_process and self.rollout_worker: + self.rollout_worker.pause() + t_pause = time.time() + logger.info(f"Weight sync: pause took {t_pause - t0:.1f}s, waiting for all ranks...") + + self.accelerator.wait_for_everyone() + t_barrier = time.time() + + logger.info(f"Weight sync: transferring weights... (barrier took {t_barrier - t_pause:.1f}s)") + if self.accelerator.is_main_process and self.rollout_worker: + self.rollout_worker.send_weights(self._streaming_iter()) + else: + # Non-rank-0 processes must still participate in full_tensor() collectives for FSDP2. + for _ in self._streaming_iter(): + pass + t_transfer = time.time() + + self.accelerator.wait_for_everyone() + + logger.info(f"Weight sync: resuming vLLM... (transfer took {t_transfer - t_barrier:.1f}s)") + if self.accelerator.is_main_process and self.rollout_worker: + self.rollout_worker.resume() + self.model_version += 1 + self.rollout_worker.update_model_version(self.model_version) + weight_sync_time_s = time.time() - t0 + self._metrics["train"]["weight_sync_time_s"].append(weight_sync_time_s) + logger.info(f"Weight sync: done. Total {weight_sync_time_s:.1f}s") + + def _inner_training_loop(self, *args, **kwargs): + # Start the rollout worker here (not in __init__) so that checkpoint loading in Trainer.train() + # has already restored the model weights. The sequence is: start worker thread → wait for NCCL + # init → sync weights to vLLM → begin generation. This ensures vLLM always uses the current + # policy before producing any samples (matters for resumed runs, harmless for fresh ones). + self._sync_weight() + if self.accelerator.is_main_process and self.rollout_worker: + self.rollout_worker.start() + try: + return super()._inner_training_loop(*args, **kwargs) + finally: + if self.accelerator.is_main_process and self.rollout_worker: + self.rollout_worker.stop() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_rollout_worker.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_rollout_worker.py new file mode 100644 index 0000000000000000000000000000000000000000..5157c87c4ddce7f21acadf5fba938d5542e22ead --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/async_grpo/async_rollout_worker.py @@ -0,0 +1,747 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +import inspect +import queue +import threading +import time +from collections.abc import Callable, Iterator +from dataclasses import dataclass +from typing import Any, TypeAlias + +import aiohttp +import numpy as np +import requests +from accelerate.logging import get_logger +from datasets import Dataset +from transformers import PreTrainedTokenizerBase + +from trl.chat_template_utils import ( + add_response_schema, + get_training_chat_template, + is_chat_template_prefix_preserving, + parse_response, +) +from trl.import_utils import is_vllm_available +from trl.trainer.utils import print_prompt_completions_sample + + +if is_vllm_available(min_version="0.17.1"): + from vllm.distributed.weight_transfer.nccl_engine import NCCLTrainerSendWeightsArgs, NCCLWeightTransferEngine + from vllm.utils.network_utils import get_ip, get_open_port + + +logger = get_logger(__name__) + +Messages: TypeAlias = list[dict[str, str]] + + +@dataclass(slots=True) +class RolloutGroup: + """Single GRPO group for one prompt with multiple completions.""" + + prompt: Messages + prompt_ids: list[int] + reward_kwargs: dict[str, list[Any]] + completions: list[Messages] + completions_ids: list[list[int]] + completions_logprobs: list[list[float]] + tool_mask: list[list[int]] + tool_call_counts: list[int] + tool_failure_counts: list[int] + model_version: int + queued_at: float = 0.0 + + +@dataclass(slots=True) +class RolloutSample: + prompt: Messages + completion: Messages + input_ids: list[int] + completion_mask: list[int] + old_log_probs: list[float] + advantage: float + model_version: int + metrics: dict[str, float] # logging metadata only, not used in loss computation + + +class AsyncRolloutWorker: + """ + Minimal asynchronous actor worker structure. + + Loop: + generate groups -> score groups -> push samples -> repeat + """ + + def __init__( + self, + model_name: str, + dataset: Dataset, + reward_funcs: list[Callable[..., list[float]]], + processing_class: PreTrainedTokenizerBase, + tools: list[Callable] | None = None, + environment_factory: Callable[[], object] | None = None, + num_generations: int = 8, + max_inflight_tasks: int = 128, + queue_maxsize: int = 0, + vllm_server_url: str = "http://localhost:8000", + max_tokens: int = 32, + temperature: float = 1.0, + request_timeout: int = 120, + server_timeout: float = 240.0, + chat_template_kwargs: dict[str, Any] | None = None, + max_tool_calling_iterations: int | None = None, + log_completions: bool = False, + num_completions_to_print: int = 3, + weight_names: list[str] | None = None, + weight_dtype_names: list[str] | None = None, + weight_shapes: list[list[int]] | None = None, + ): + if not is_vllm_available(min_version="0.17.1"): + raise ImportError( + "vLLM >= 0.17.1 is required to use AsyncRolloutWorker. Install it with: pip install 'vllm>=0.17.1'" + ) + self.model_name = model_name + self.max_tool_calling_iterations = max_tool_calling_iterations + self.dataset = dataset + self._dataset_iter = iter(dataset) + self.rollout_buffer: queue.Queue[RolloutSample] = queue.Queue(maxsize=queue_maxsize) + self._loop: asyncio.AbstractEventLoop | None = None + self._stop_event: asyncio.Event | None = None + self._weight_update_info = { + "names": weight_names, + "dtype_names": weight_dtype_names, + "shapes": weight_shapes, + "packed": True, + "is_checkpoint_format": True, + } + + self.reward_funcs = reward_funcs + self.reward_func_names = [f.__name__ for f in reward_funcs] + self.num_generations = num_generations + self.max_inflight_tasks = max_inflight_tasks + self.environments = None + environment_methods = [[] for _ in range(self.max_inflight_tasks)] + if environment_factory is not None: + self.environments = [environment_factory() for _ in range(self.max_inflight_tasks)] + for i, environment in enumerate(self.environments): + has_reset = False + for name, member in inspect.getmembers(environment, predicate=inspect.ismethod): + if name == "reset": + has_reset = True + elif not name.startswith("_"): + environment_methods[i].append(member) + if not has_reset: + raise ValueError( + "Each environment instance returned by `environment_factory` must define `reset`." + ) + + base_tools = tools or [] + self._sync_tool_dicts = [{} for _ in range(self.max_inflight_tasks)] + for i in range(self.max_inflight_tasks): + for tool in base_tools + (environment_methods[i] if self.environments is not None else []): + if inspect.iscoroutinefunction(tool): + raise ValueError("Asynchronous tools are not supported in AsyncRolloutWorker yet.") + self._sync_tool_dicts[i][tool.__name__] = tool + self.tools = base_tools + (environment_methods[0] if self.environments is not None else []) + + self.vllm_server_url = vllm_server_url.rstrip("/") + self.model_update_group = None + self.max_tokens = max_tokens + self.temperature = temperature + self.request_timeout = request_timeout + self.server_timeout = server_timeout + self.chat_template_kwargs = chat_template_kwargs or {} + self.log_completions = log_completions + self.num_completions_to_print = num_completions_to_print + self.tokenizer = processing_class + self.tokenizer = add_response_schema(self.tokenizer) + # In multi-turn training, the chat template *must* be prefix-preserving. If the tokenizer's original template + # isn't, we replace it at initialization with a training-safe, prefix-preserving template. + if self.tools and not is_chat_template_prefix_preserving(self.tokenizer): + self.chat_template = get_training_chat_template(self.tokenizer) + else: + self.chat_template = None + + self._groups_to_score: asyncio.Queue[RolloutGroup | None] = asyncio.Queue(maxsize=16) + self._total_completion_tokens = 0 + self._total_groups_scored = 0 + self._generation_start_time: float | None = None + self.model_version = 0 + self.session = None + + # Wait for the vLLM server and initialize NCCL weight transfer. + self._wait_for_server_ready_sync(timeout_s=self.server_timeout) + self._init_weight_transfer() + + def _wait_for_server_ready_sync(self, timeout_s: float = 240.0, poll_interval_s: float = 2.0) -> None: + """Block until the vLLM server is healthy.""" + logger.info(f"Waiting for vLLM server at {self.vllm_server_url} ...") + start = time.time() + while True: + elapsed = time.time() - start + try: + response = requests.get(f"{self.vllm_server_url}/health", timeout=5) + if response.status_code == 200: + logger.info(f"vLLM server ready after {elapsed:.1f}s") + return + except (requests.ConnectionError, requests.Timeout, OSError): + pass + if elapsed >= timeout_s: + raise TimeoutError( + f"Timed out after {timeout_s:.0f}s waiting for vLLM server at {self.vllm_server_url}. " + "Make sure the vLLM server is running and reachable. If the server needs more time to load " + "the model, increase `vllm_server_timeout` in your AsyncGRPOConfig." + ) + if int(elapsed) % 10 < poll_interval_s: + logger.info(f"Still waiting for vLLM server... ({elapsed:.0f}s)") + time.sleep(poll_interval_s) + + def _init_weight_transfer(self) -> None: + response = requests.get(f"{self.vllm_server_url}/get_world_size") + inference_world_size = response.json()["world_size"] + world_size = inference_world_size + 1 + master_address = get_ip() + master_port = get_open_port() + + init_info = { + "master_address": master_address, + "master_port": master_port, + "rank_offset": 1, + "world_size": world_size, + } + t_init = threading.Thread( + target=requests.post, + args=(f"{self.vllm_server_url}/init_weight_transfer_engine",), + kwargs={"json": {"init_info": init_info}, "timeout": 120}, + ) + t_init.start() + self.model_update_group = NCCLWeightTransferEngine.trainer_init( + { + "master_address": master_address, + "master_port": master_port, + "world_size": world_size, + } + ) + t_init.join() + + logger.info("Init weight sync group with vLLM") + + def update_model_version(self, model_version: int): + self.model_version = model_version + + async def _run_loops(self, stop_event: asyncio.Event) -> None: + async with aiohttp.ClientSession() as session: + self.session = session + logger.info( + f"vllm worker started: num_generations={self.num_generations}, max_inflight_tasks={self.max_inflight_tasks}" + ) + await asyncio.gather( + asyncio.create_task(self._generate_loop(stop_event=stop_event)), + asyncio.create_task(self._score_loop(stop_event=stop_event)), + ) + + def start(self) -> None: + thread = threading.Thread(target=self._run, daemon=True) + thread.start() + + def stop(self) -> None: + logger.info("Stopping worker thread...") + if self._loop and self._loop.is_running(): + try: + self._loop.call_soon_threadsafe(self._stop_event.set) + except RuntimeError: + pass + + def _run(self) -> None: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + self._loop = loop + self._stop_event = asyncio.Event() + try: + loop.run_until_complete(self._run_loops(stop_event=self._stop_event)) + except Exception as e: + logger.exception(f"Worker thread failed: {e}") + raise + finally: + loop.close() + self._destroy_model_update_group() + + def _destroy_model_update_group(self) -> None: + # It's important because otherwise we get errors on exit. + if self.model_update_group is None: + return # happens if weight transfer was never initialized + self.model_update_group.group.store = None + self.model_update_group.group.socket = None + self.model_update_group = None + + def pause(self) -> None: + t0 = time.time() + requests.post(f"{self.vllm_server_url}/pause", params={"mode": "keep"}) + logger.debug(f"[weight_sync] pause HTTP took {time.time() - t0:.1f}s") + + def resume(self) -> None: + t0 = time.time() + requests.post(f"{self.vllm_server_url}/resume") + logger.debug(f"[weight_sync] resume HTTP took {time.time() - t0:.1f}s") + + def send_weights(self, iterator) -> None: + if self.model_update_group is None: + return + t0 = time.time() + t_update = threading.Thread( + target=requests.post, + args=(f"{self.vllm_server_url}/update_weights",), + kwargs={"json": {"update_info": self._weight_update_info}, "timeout": 1800}, + ) + t_update.start() + logger.debug(f"[weight_sync] /update_weights POST sent ({time.time() - t0:.1f}s)") + t_nccl = time.time() + NCCLWeightTransferEngine.trainer_send_weights( + iterator=iterator, + trainer_args=NCCLTrainerSendWeightsArgs(group=self.model_update_group, packed=True), + ) + logger.debug(f"[weight_sync] NCCL transfer took {time.time() - t_nccl:.1f}s") + t_join = time.time() + t_update.join() + logger.debug( + f"[weight_sync] /update_weights join took {time.time() - t_join:.1f}s (total send_weights: {time.time() - t0:.1f}s)" + ) + + async def _generate_loop(self, stop_event: asyncio.Event) -> None: + pending_groups: dict[int, RolloutGroup] = {} + pending_completed: dict[int, int] = {} + inflight_tasks: dict[asyncio.Task, tuple[int, int]] = {} + free_slots = set(range(self.max_inflight_tasks)) + work_iter = self._repeat_iterator() + + self._generation_start_time = time.monotonic() + try: + while True: + while free_slots and not stop_event.is_set(): + group_id, row = next(work_iter) + if group_id not in pending_groups: + prompt = row["prompt"] + prompt_ids = self.tokenizer.apply_chat_template( + prompt, + return_dict=False, + add_generation_prompt=True, + tools=self.tools or None, # `or None`: Llama bug: it renders tool boilerplate for tools=[] + chat_template=self.chat_template, + **self.chat_template_kwargs, + ) + reward_kwargs = { + key: [row[key]] * self.num_generations + for key in row + if key not in {"prompt", "completion", "completion_ids"} + } + pending_groups[group_id] = RolloutGroup( + prompt=prompt, + prompt_ids=prompt_ids, + reward_kwargs=reward_kwargs, + completions=[], + completions_ids=[], + completions_logprobs=[], + tool_mask=[], + tool_call_counts=[], + tool_failure_counts=[], + model_version=self.model_version, + ) + pending_completed[group_id] = 0 + logger.debug(f"Started group {group_id}; pending_groups={len(pending_groups)}") + + slot = free_slots.pop() + if self.environments is not None: + # Current assumption: reset side effects matter, return value is ignored. + self.environments[slot].reset(**row) + + logger.info(f"[slot] assigned slot={slot} group={group_id} free_after={len(free_slots)}") + task = asyncio.create_task( + self._generate_one(pending_groups[group_id].prompt, tool_dict=self._sync_tool_dicts[slot]) + ) + inflight_tasks[task] = (group_id, slot) + + if not inflight_tasks: + if stop_event.is_set(): + return + await asyncio.sleep(0.01) + continue + + done, _ = await asyncio.wait(inflight_tasks, return_when=asyncio.FIRST_COMPLETED, timeout=0.1) + if not done: + if not free_slots: + logger.debug( + f"[generate] all {self.max_inflight_tasks} slots busy, " + f"pending_groups={len(pending_groups)}, waiting for completions..." + ) + continue + + for task in done: + group_id, slot = inflight_tasks.pop(task) + free_slots.add(slot) + logger.debug(f"[slot] freed slot={slot} group={group_id} free_after={len(free_slots)}") + if task.exception() is not None: + raise task.exception() + + ( + completion, + completion_ids, + completion_logprobs, + tool_mask, + tool_call_count, + tool_failure_count, + ) = task.result() + group = pending_groups[group_id] + group.completions.append(completion) + group.completions_ids.append(completion_ids) + group.completions_logprobs.append(completion_logprobs) + group.tool_mask.append(tool_mask) + group.tool_call_counts.append(tool_call_count) + group.tool_failure_counts.append(tool_failure_count) + # TODO: move this in generation task, shouldn't matter but is correct + self._total_completion_tokens += sum(tool_mask) + pending_completed[group_id] += 1 + + if pending_completed[group_id] == self.num_generations: + group.queued_at = time.monotonic() + while True: + try: + self._groups_to_score.put_nowait(group) + break + except asyncio.QueueFull: + if stop_event.is_set(): + return + await asyncio.sleep(0.1) + logger.debug(f"Group {group_id} complete; queued_for_scoring={self._groups_to_score.qsize()}") + del pending_groups[group_id] + del pending_completed[group_id] + finally: + for task in inflight_tasks: + task.cancel() + if inflight_tasks: + await asyncio.gather(*inflight_tasks, return_exceptions=True) + # Use put_nowait: if the queue is full at shutdown, skip the sentinel — + # _score_loop will exit via stop_event check in its outer loop. + try: + self._groups_to_score.put_nowait(None) + except asyncio.QueueFull: + pass + + def _compute_rollout_metrics(self, samples: list[RolloutSample], scoring_time: float, wait_scoring: float) -> None: + assert self._generation_start_time is not None, "generation_start_time init in run()" + elapsed = time.monotonic() - self._generation_start_time + generation_tok_per_sec = self._total_completion_tokens / elapsed if elapsed > 0 else 0.0 + + scoring_time_ms = scoring_time * 1000 + wait_scoring_ms = wait_scoring * 1000 + + for sample in samples: + sample.metrics["generation_tok_per_s"] = generation_tok_per_sec + sample.metrics["scoring_time_ms"] = scoring_time_ms + sample.metrics["wait_scoring_ms"] = wait_scoring_ms + sample.metrics["buffer_qsize"] = self.rollout_buffer.qsize() + + logger.info( + f"[inference] total_completion_tokens={self._total_completion_tokens}, " + f"generation_tok/s={generation_tok_per_sec:.1f}, scoring_time={scoring_time_ms:.1f}ms, " + f"wait_scoring={wait_scoring_ms:.1f}ms" + ) + + async def _score_loop(self, stop_event: asyncio.Event) -> None: + while not stop_event.is_set(): + t_wait = time.monotonic() + try: + group = await asyncio.wait_for(self._groups_to_score.get(), timeout=0.5) + except asyncio.TimeoutError: + continue + if group is None: + return + score_queue_wait = time.monotonic() - t_wait + + wait_scoring = time.monotonic() - group.queued_at + + if score_queue_wait > 0.5: + logger.info(f"[score] waited {score_queue_wait:.1f}s for a group to score") + + t0 = time.monotonic() + samples = await self._score_group(group) + scoring_time = time.monotonic() - t0 + logger.info( + f"[score] scored {len(samples)} samples in {scoring_time:.2f}s, " + f"buffer_qsize={self.rollout_buffer.qsize()}" + ) + + self._compute_rollout_metrics(samples, scoring_time, wait_scoring) + + if self.log_completions and samples: + print_prompt_completions_sample( + prompts=[s.prompt for s in samples], + completions=[s.completion for s in samples], + rewards={"reward": [s.metrics["reward"] for s in samples]}, + advantages=[s.advantage for s in samples], + step=self._total_groups_scored, + num_samples=self.num_completions_to_print, + ) + self._total_groups_scored += 1 + + for sample in samples: + while True: + try: + self.rollout_buffer.put_nowait(sample) + break + except queue.Full: + if stop_event.is_set(): + return + # Wait for trainer to consume loop + logger.info( + f"[score] rollout buffer full (maxsize={self.rollout_buffer.maxsize}), waiting for trainer to consume..." + ) + await asyncio.sleep(0.1) + + logger.debug( + f"Scored group with {len(samples)} samples; rollout_buffer_qsize={self.rollout_buffer.qsize()}" + ) + + def _repeat_iterator(self) -> Iterator[tuple[int, dict[str, Any]]]: + group_id = 0 + while True: + try: + row = next(self._dataset_iter) + except StopIteration: + self._dataset_iter = iter(self.dataset) + row = next(self._dataset_iter) + for _ in range(self.num_generations): + yield group_id, row + group_id += 1 + + async def _generate_one( + self, prompt: Messages, tool_dict: dict[str, Callable] + ) -> tuple[list[dict[str, str]], list[int], list[float], list[int], int, int]: + completion, completion_ids, completion_logprobs, tool_mask = [], [], [], [] + tool_call_count = 0 + tool_failure_count = 0 + iteration_num = 0 + max_iterations = self.max_tool_calling_iterations + prompt_ids = self.tokenizer.apply_chat_template( + prompt, + return_dict=False, + add_generation_prompt=True, + tools=self.tools or None, # `or None`: Llama bug: it renders tool boilerplate for tools=[] + chat_template=self.chat_template, + **self.chat_template_kwargs, + ) + while True: + turn_ids, turn_logprobs = await self._generate_one_turn(prompt_ids) + assistant_message = parse_response(self.tokenizer, turn_ids) + completion.append(assistant_message) + completion_ids.extend(turn_ids) + completion_logprobs.extend(turn_logprobs) + tool_mask.extend([1] * len(turn_ids)) + tool_calls = assistant_message.get("tool_calls") + if tool_calls is None or (max_iterations is not None and iteration_num >= max_iterations): + return completion, completion_ids, completion_logprobs, tool_mask, tool_call_count, tool_failure_count + + tool_messages, n_calls, n_failures = self._execute_tool_calls(tool_calls, tool_dict) + tool_call_count += n_calls + tool_failure_count += n_failures + completion.extend(tool_messages) + suffix_ids = self._get_tool_suffix_ids(tool_messages) + completion_ids.extend(suffix_ids) + completion_logprobs.extend([0.0] * len(suffix_ids)) + tool_mask.extend([0] * len(suffix_ids)) + prompt_ids = prompt_ids + turn_ids + suffix_ids + iteration_num += 1 + + def _get_tool_suffix_ids(self, tool_messages: list[dict[str, Any]]) -> list[int]: + """Get token IDs for tool result formatting by using a minimal dummy conversation.""" + # Use the real tool name instead of a dummy: some templates (e.g. GPT-OSS) derive the tool response + # header from the assistant's tool call name. + dummy_tool_calls = [{"type": "function", "function": {"name": tool_messages[0]["name"], "arguments": {}}}] + dummy_messages = [ + {"role": "user", "content": "dummy"}, + { + "role": "assistant", + # "content" is required here because VLM processors crash on tokenize=True without it + # (KeyError in processing_utils.py). See huggingface/transformers#45290. + "content": "", + "tool_calls": dummy_tool_calls, + }, + ] + prefix_ids = self.tokenizer.apply_chat_template( + dummy_messages, + add_generation_prompt=False, + tokenize=True, + chat_template=self.chat_template, + return_dict=False, + **self.chat_template_kwargs, + ) + full_ids = self.tokenizer.apply_chat_template( + dummy_messages + tool_messages, + add_generation_prompt=True, + tokenize=True, + chat_template=self.chat_template, + return_dict=False, + **self.chat_template_kwargs, + ) + + # Some chat templates (notably Qwen3/Qwen3.5) render "...<|im_end|>\n" after an assistant/tool block. + # When we compute `suffix_ids` by slicing `full_ids`, we must align the slicing boundary to + # EOS (not EOS + newline). Templates that don't use EOS as end-of-turn (e.g. Gemma uses + # ) skip this trimming. + eos_positions = [i for i, tok_id in enumerate(prefix_ids) if tok_id == self.tokenizer.eos_token_id] + if eos_positions: + prefix_ids = prefix_ids[: eos_positions[-1] + 1] + + if full_ids[: len(prefix_ids)] != prefix_ids: + raise ValueError("Unexpected tokenization: the EOS-trimmed prefix IDs are not a prefix of the full IDs.") + + return full_ids[len(prefix_ids) :] + + def _execute_tool_calls( + self, tool_calls: list[dict[str, Any]], tool_dict: dict[str, Callable] + ) -> tuple[list[dict[str, str]], int, int]: + tool_messages = [] + n_calls = 0 + n_failures = 0 + for tool_call in tool_calls: + n_calls += 1 + function = tool_call["function"] + name = function["name"] + try: + arguments = function.get("arguments", {}) + result = tool_dict[name](**arguments) + except Exception as error: + n_failures += 1 + result = {"error": str(error)} + tool_messages.append({"role": "tool", "name": name, "content": str(result)}) + return tool_messages, n_calls, n_failures + + async def _generate_one_turn(self, prompt_ids: list[int]) -> tuple[list[int], list[float]]: + payload = { + "model": self.model_name, + "prompt": prompt_ids, + "max_tokens": self.max_tokens, + "temperature": self.temperature, + "n": 1, + "return_token_ids": True, + "logprobs": 0, + } + while True: + try: + output = await self._post("/v1/completions", payload, self.request_timeout) + break + except (aiohttp.ServerDisconnectedError, aiohttp.ClientConnectionError, aiohttp.ClientResponseError): + # vLLM drops connections or returns 503 during weight sync (/pause). Wait briefly and retry. + logger.debug("Server unavailable (likely weight sync pause), retrying...") + await asyncio.sleep(1.0) + choice = output["choices"][0] + completion_ids = choice["token_ids"] + completion_logprobs = choice["logprobs"]["token_logprobs"] + return completion_ids, completion_logprobs + + async def _score_group(self, group: RolloutGroup) -> list[RolloutSample]: + kwargs = dict( + completions=group.completions, + prompt=group.prompt, + prompts=[group.prompt] * len(group.completions), + completion_ids=group.completions_ids, + **group.reward_kwargs, + ) + all_rewards = await asyncio.gather( + *[ + reward_func(**kwargs) + if inspect.iscoroutinefunction(reward_func) + else asyncio.to_thread(reward_func, **kwargs) + for reward_func in self.reward_funcs + ] + ) + + # Sum rewards across all reward functions. Reward functions may return None for individual + # samples (e.g. accuracy_reward when the gold solution is unparseable). Convert None → nan + # and use nansum so that a None from one function doesn't affect the others, matching TRL. + all_rewards = [[r if r is not None else float("nan") for r in row] for row in all_rewards] + rewards = np.nansum(np.array(all_rewards, dtype=float), axis=0) + advantages = (rewards - rewards.mean()) / (rewards.std() + 1e-8) + reward_mean = float(rewards.mean()) + reward_std = float(rewards.std()) + logger.info(f"Rollout metrics: reward_mean={reward_mean:.4f}, reward_std={reward_std:.4f}") + + # tools/call_frequency: mean calls per completion (matches TRL's total_calls / num_completions) + # tools/failure_frequency: per-completion failure rate; averaged across samples in compute_loss + # (TRL uses total_failures / total_calls, ours weights equally per completion — close enough) + total_calls = sum(group.tool_call_counts) + tool_metrics = ( + [ + { + "tools/call_frequency": float(n_calls), + "tools/failure_frequency": (n_failures / n_calls) if n_calls > 0 else 0.0, + } + for n_calls, n_failures in zip(group.tool_call_counts, group.tool_failure_counts, strict=True) + ] + if total_calls > 0 + else [{}] * len(group.completions) + ) + + per_func_rewards = np.array(all_rewards, dtype=float) # shape (num_funcs, num_completions) + + return [ + RolloutSample( + prompt=group.prompt, + completion=completion, + input_ids=group.prompt_ids + completion_ids, + completion_mask=[0] * len(group.prompt_ids) + tool_mask, + old_log_probs=[0.0] * len(group.prompt_ids) + logprobs, + advantage=advantage, + model_version=group.model_version, + metrics={ + "reward": float(reward), + "reward_std": reward_std, + **{ + f"rewards/{name}": float(func_reward) + for name, func_reward in zip(self.reward_func_names, per_func_rewards[:, i], strict=True) + }, + **tm, + }, + ) + for i, (completion, completion_ids, logprobs, tool_mask, advantage, reward, tm) in enumerate( + zip( + group.completions, + group.completions_ids, + group.completions_logprobs, + group.tool_mask, + advantages, + rewards, + tool_metrics, + strict=True, + ) + ) + ] + + async def _post(self, path: str, payload: dict, timeout: float, max_retries: int = 3) -> dict: + client_timeout = aiohttp.ClientTimeout(total=timeout) + for attempt in range(max_retries): + try: + async with self.session.post( + f"{self.vllm_server_url}{path}", json=payload, timeout=client_timeout + ) as response: + response.raise_for_status() + content = await response.json() + return content if content else {} + except (TimeoutError, asyncio.TimeoutError): + if attempt < max_retries - 1: + logger.warning(f"POST {path} timed out (attempt {attempt + 1}/{max_retries}), retrying...") + await asyncio.sleep(1) + else: + raise diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3a6871ca60e002b21ac74a69e4113ded3391f622 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .bco_config import BCOConfig +from .bco_trainer import BCOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/bco_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/bco_config.py new file mode 100644 index 0000000000000000000000000000000000000000..325ace3e2609d8c12458b26872052ed2c2f8d907 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/bco_config.py @@ -0,0 +1,154 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class BCOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.bco.BCOTrainer`]. + + This class includes only the parameters that are specific to BCO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the sequences (prompt + completion) in the batch. This argument is required if you want + to use the default data collator. + max_completion_length (`int`, *optional*): + Maximum length of the completion. This argument is required if you want to use the default data collator + and your model is an encoder-decoder. + beta (`float`, *optional*, defaults to `0.1`): + Parameter controlling the deviation from the reference model. Higher β means less deviation from the + reference model. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model and reference model. + generate_during_eval (`bool`, *optional*, defaults to `False`): + If `True`, generates and logs completions from both the model and the reference model to W&B or Comet + during evaluation. + is_encoder_decoder (`bool`, *optional*): + When using the `model_init` argument (callable) to instantiate the model instead of the `model` argument, + you need to specify if the model returned by the callable is an encoder-decoder model. + precompute_ref_log_probs (`bool`, *optional*, defaults to `False`): + Whether to precompute reference model log probabilities for training and evaluation datasets. This is + useful when training without the reference model to reduce the total GPU memory needed. + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model and + reference model from strings. + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + prompt_sample_size (`int`, *optional*, defaults to `1024`): + Number of prompts that are fed to density ratio classifier. + min_density_ratio (`float`, *optional*, defaults to `0.5`): + Minimum value of the density ratio. The estimated density ratio is clamped to this value. + max_density_ratio (`float`, *optional*, defaults to `10.0`): + Maximum value of the density ratio. The estimated density ratio is clamped to this value. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `5e-7` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=5e-7, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + max_length: int | None = field( + default=1024, + metadata={ + "help": "Maximum length of the sequences (prompt + completion) in the batch. " + "This argument is required if you want to use the default data collator." + }, + ) + max_completion_length: int | None = field( + default=None, + metadata={ + "help": "Maximum length of the completion. This argument is required if you want to use the " + "default data collator and your model is an encoder-decoder." + }, + ) + beta: float = field( + default=0.1, + metadata={ + "help": "Parameter controlling the deviation from the reference model. " + "Higher β means less deviation from the reference model." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model and reference model."}, + ) + generate_during_eval: bool = field( + default=False, + metadata={ + "help": "If `True`, generates and logs completions from both the model and the reference model " + "to W&B during evaluation." + }, + ) + is_encoder_decoder: bool | None = field( + default=None, + metadata={ + "help": "When using the `model_init` argument (callable) to instantiate the model instead of the " + "`model` argument, you need to specify if the model returned by the callable is an " + "encoder-decoder model." + }, + ) + precompute_ref_log_probs: bool = field( + default=False, + metadata={ + "help": "Whether to precompute reference model log probabilities for training and evaluation datasets. " + "This is useful when training without the reference model to reduce the total GPU memory " + "needed." + }, + ) + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the " + "model from a string." + }, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + prompt_sample_size: int = field( + default=1024, + metadata={"help": "Number of prompts that are fed to density ratio classifier."}, + ) + min_density_ratio: float = field( + default=0.5, + metadata={"help": "Minimum value of the density ratio. The estimated density ratio is clamped to this value."}, + ) + max_density_ratio: float = field( + default=10.0, + metadata={"help": "Maximum value of the density ratio. The estimated density ratio is clamped to this value."}, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/bco_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/bco_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..9cdf47c65ee2fb10e4554eced0bc357c9890f291 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bco/bco_trainer.py @@ -0,0 +1,1544 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import dataclasses +import inspect +import json +import os +import random +import textwrap +from collections import defaultdict +from collections.abc import Callable +from contextlib import contextmanager, nullcontext +from dataclasses import dataclass +from operator import itemgetter +from pathlib import Path +from typing import Any, Literal + +import numpy as np +import pandas as pd +import torch +import torch.nn as nn +import torch.nn.functional as F +import transformers +from accelerate import Accelerator, PartialState, logging +from accelerate.utils import tqdm +from datasets import Dataset +from packaging.version import Version +from torch import autocast +from torch.utils.data import DataLoader, SequentialSampler +from transformers import ( + AutoModelForCausalLM, + BaseImageProcessor, + DataCollator, + FeatureExtractionMixin, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + TrainingArguments, + is_comet_available, + is_sklearn_available, + is_wandb_available, +) +from transformers.trainer_utils import EvalLoopOutput, has_length +from transformers.utils import is_peft_available + +from ...data_utils import maybe_apply_chat_template, maybe_extract_prompt, maybe_unpair_preference_dataset +from ...import_utils import is_joblib_available +from ...models.utils import prepare_deepspeed +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import disable_dropout_in_model, log_table_to_comet_experiment, selective_log_softmax +from ..utils import DPODataCollatorWithPadding, create_reference_model, pad_to_length, peft_module_casting_to_bf16 +from .bco_config import BCOConfig + + +if is_peft_available(): + from peft import PeftModel, get_peft_model, prepare_model_for_kbit_training + +if is_wandb_available(): + import wandb + +if is_sklearn_available(): + from sklearn.linear_model import LogisticRegression + +if is_joblib_available(): + import joblib + +logger = logging.get_logger(__name__) + +RUNNING_NAME = "running.json" +CLF_NAME = "clf.pkl" + + +@torch.no_grad() +def get_global_statistics( + accelerator, xs: torch.Tensor, mask=None, device="cpu" +) -> tuple[torch.Tensor, torch.Tensor, int]: + """ + Computes element-wise mean and variance of the tensor across processes. Reference: + https://github.com/OpenLMLab/MOSS-RLHF/blob/40b91eb2f2b71b16919addede0341d2bef70825d/utils.py#L57C1-L73C75 + """ + xs = xs.to(accelerator.device) + sum_and_count = torch.tensor([xs.sum(), (xs.numel() if mask is None else mask.sum())], device=xs.device) + sum_and_count = accelerator.reduce(sum_and_count) + global_sum, count = sum_and_count + global_mean = global_sum / count + + sum_var = torch.sum(((xs - global_mean) ** 2).mul(1 if mask is None else mask)) + sum_var = accelerator.reduce(sum_var) + global_var = sum_var / count + + return global_mean.to(device), global_var.to(device), count.item() + + +@dataclass +class RunningMoments: + """ + Calculates the running mean and standard deviation of a data stream. Reference: + https://github.com/OpenLMLab/MOSS-RLHF/blob/40b91eb2f2b71b16919addede0341d2bef70825d/utils.py#L75 + """ + + accelerator: Accelerator + mean: float = 0 + std: float = 1 + var: float = 1 + count: float = 1e-24 + + @torch.no_grad() + def update(self, xs: torch.Tensor) -> tuple[float, float]: + """ + Updates running moments from batch's moments computed across ranks + """ + if self.accelerator.use_distributed: + xs_mean, xs_var, xs_count = get_global_statistics(self.accelerator, xs) + else: + xs_count = xs.numel() + xs_var, xs_mean = torch.var_mean(xs, unbiased=False) + xs_mean, xs_var = xs_mean.float(), xs_var.float() + + delta = xs_mean - self.mean + tot_count = self.count + xs_count + + new_sum = xs_var * xs_count + # correct old_sum deviation accounting for the new mean + old_sum = self.var * self.count + delta**2 * self.count * xs_count / tot_count + tot_sum = old_sum + new_sum + + self.mean += (delta * xs_count / tot_count).item() + new_var = tot_sum / tot_count + self.std = (new_var * tot_count / (tot_count - 1)).float().sqrt().item() + self.var = new_var.item() + self.count = tot_count + + return xs_mean.item(), (xs_var * xs_count / (xs_count - 1)).float().sqrt().item() + + def save_to_json(self, json_path: str): + """Save the content of this instance in JSON format inside `json_path`.""" + # save everything except accelerator + if self.accelerator.is_main_process: + save_dict = dataclasses.asdict(self, dict_factory=lambda x: {k: v for (k, v) in x if k != "accelerator"}) + json_string = json.dumps(save_dict, indent=2, sort_keys=True) + "\n" + with open(json_path, "w", encoding="utf-8") as f: + f.write(json_string) + + @classmethod + def load_from_json(cls, accelerator: Accelerator, json_path: str): + """Create an instance from the content of `json_path`.""" + # load everything except accelerator + with open(json_path, encoding="utf-8") as f: + text = f.read() + return cls(accelerator=accelerator, **json.loads(text)) + + +def _tokenize( + batch: dict[str, list[Any]], + tokenizer: PreTrainedTokenizerBase, + embedding_tokenizer: PreTrainedTokenizerBase | None = None, +) -> dict[str, list[Any]]: + """Tokenize a batch from a BCO specific dataset.""" + prompt_tokenized = tokenizer(batch["prompt"], add_special_tokens=False) + prompt_input_ids = prompt_tokenized["input_ids"] + prompt_attention_mask = prompt_tokenized["attention_mask"] + prompt_and_completion = [ + prompt + completion for prompt, completion in zip(batch["prompt"], batch["completion"], strict=True) + ] + full_tokenized = tokenizer(prompt_and_completion, add_special_tokens=False) + full_input_ids = full_tokenized["input_ids"] + full_attention_mask = full_tokenized["attention_mask"] + + answer_input_ids = [f[len(p) :] for f, p in zip(full_input_ids, prompt_input_ids, strict=True)] + answer_attention_mask = [f[len(p) :] for f, p in zip(full_attention_mask, prompt_attention_mask, strict=True)] + + # Concat tokens to form `enc(a) + enc(a + b)[len(enc(a)):]` + full_concat_input_ids = [np.concatenate([p, a]) for p, a in zip(prompt_input_ids, answer_input_ids, strict=True)] + # Prepare input tokens for token by token comparison + full_input_ids = [np.array(f) for f in full_input_ids] + for full, concat in zip(full_input_ids, full_concat_input_ids, strict=True): + if len(full) != len(concat): + raise ValueError( + "The elements in 'full_input_ids' and 'full_concat_input_ids' must have the same pairwise length." + ) + + # On some tokenizers, like Llama-2 tokenizer, there are occasions where tokens + # can be merged together when tokenizing prompt+answer. This could result + # on the last token from the prompt being different when tokenized on its own + # vs when done as prompt+answer. + response_token_ids_start_idx = [len(p) for p in prompt_input_ids] + + # If tokenized prompt is different than both prompt+answer, then it means the + # last token has changed due to merging. + for idx, (p, f, r) in enumerate(zip(prompt_input_ids, full_input_ids, response_token_ids_start_idx, strict=True)): + if not np.array_equal(p, f[:r]): + response_token_ids_start_idx[idx] -= 1 + + prompt_input_ids = [f[:r] for f, r in zip(full_input_ids, response_token_ids_start_idx, strict=True)] + prompt_attention_mask = [f[:r] for f, r in zip(full_attention_mask, response_token_ids_start_idx, strict=True)] + + for p, m in zip(prompt_input_ids, prompt_attention_mask, strict=True): + if len(p) != len(m): + raise ValueError("Prompt input ids and attention mask should have the same length.") + + answer_input_ids = [f[r:] for f, r in zip(full_input_ids, response_token_ids_start_idx, strict=True)] + answer_attention_mask = [f[r:] for f, r in zip(full_attention_mask, response_token_ids_start_idx, strict=True)] + + output = dict( + prompt_input_ids=prompt_input_ids, + prompt_attention_mask=prompt_attention_mask, + answer_input_ids=answer_input_ids, + answer_attention_mask=answer_attention_mask, + ) + + if embedding_tokenizer is not None: + embedding_tokenized = embedding_tokenizer(batch["prompt"], add_special_tokens=False) + + output.update( + { + "embedding_input_ids": embedding_tokenized["input_ids"], + "embedding_attention_mask": embedding_tokenized["attention_mask"], + } + ) + + return output + + +def _process_tokens(example: dict[str, Any], model: "PreTrainedModel" = None, **kwargs) -> dict: + """Process tokens of a BCO specific dataset. + + At this stage, we don't convert to PyTorch tensors yet; we just handle the truncation in case the prompt + + completion responses is/are too long. First we truncate the prompt; if we're still too long, we truncate the + completion. + + We also create the labels for the completion responses, which are of length equal to the sum of the length of the + prompt and the completion response, with `-100` for the prompt tokens. + """ + prompt = example["prompt"] + completion = example["completion"] + + batch = { + f"{kwargs['prefix']}prompt": prompt, + f"{kwargs['prefix']}completion": completion, + f"{kwargs['prefix']}label": example["label"], + } + + if not kwargs["is_encoder_decoder"]: + # Check issues below for more details + # 1. https://github.com/huggingface/trl/issues/907 + # 2. https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257 + # 3. https://github.com/LianjiaTech/BELLE/issues/337 + + if not isinstance(prompt, str): + raise ValueError(f"prompt should be an str but got {type(prompt)}") + + if not isinstance(completion, str): + raise ValueError(f"completion should be an str but got {type(completion)}") + + # keys of format prompt_* refers to just the prompt and answer_* refers to just the answer + all_tokens = { + "prompt_input_ids": example["prompt_input_ids"], + "prompt_attention_mask": example["prompt_attention_mask"], + "answer_input_ids": example["answer_input_ids"], + "answer_attention_mask": example["answer_attention_mask"], + } + + # calculate max length by checking if BOS/EOS is already there + max_length = kwargs["max_length"] + bos_token_id = kwargs["tokenizer"].bos_token_id + eos_token_id = kwargs["tokenizer"].eos_token_id + if bos_token_id != all_tokens["prompt_input_ids"][0]: + max_length -= 1 + if eos_token_id != all_tokens["answer_input_ids"][-1]: + max_length -= 1 + + # if combined sequence is too long (> max_length - 1 for BOS token - 1 for EOS), truncate the response + if len(all_tokens["prompt_input_ids"]) + len(all_tokens["answer_input_ids"]) > max_length: + for k in ["answer_input_ids", "answer_attention_mask"]: + all_tokens[k] = all_tokens[k][: max_length - len(all_tokens["prompt_input_ids"])] + + # all input_ids and attention mask as is. We then check if we need to add BOS/EOS tokens + batch[f"{kwargs['prefix']}prompt_input_ids"] = all_tokens["prompt_input_ids"] + batch[f"{kwargs['prefix']}prompt_attention_mask"] = all_tokens["prompt_attention_mask"] + batch[f"{kwargs['prefix']}completion_input_ids"] = ( + all_tokens["prompt_input_ids"] + all_tokens["answer_input_ids"] + ) + batch[f"{kwargs['prefix']}completion_attention_mask"] = ( + all_tokens["prompt_attention_mask"] + all_tokens["answer_attention_mask"] + ) + + # add BOS, which affects both prompt and the full completion + if bos_token_id is not None: + if len(all_tokens["prompt_input_ids"]) == 0 or bos_token_id != all_tokens["prompt_input_ids"][0]: + batch[f"{kwargs['prefix']}prompt_input_ids"] = [bos_token_id] + batch[ + f"{kwargs['prefix']}prompt_input_ids" + ] + batch[f"{kwargs['prefix']}prompt_attention_mask"] = [1] + batch[ + f"{kwargs['prefix']}prompt_attention_mask" + ] + batch[f"{kwargs['prefix']}completion_input_ids"] = [bos_token_id] + batch[ + f"{kwargs['prefix']}completion_input_ids" + ] + batch[f"{kwargs['prefix']}completion_attention_mask"] = [1] + batch[ + f"{kwargs['prefix']}completion_attention_mask" + ] + # add EOS, which affects only the full completion + if len(all_tokens["answer_input_ids"]) == 0 or eos_token_id != all_tokens["answer_input_ids"][-1]: + batch[f"{kwargs['prefix']}completion_input_ids"] = batch[f"{kwargs['prefix']}completion_input_ids"] + [ + eos_token_id + ] + batch[f"{kwargs['prefix']}completion_attention_mask"] = batch[ + f"{kwargs['prefix']}completion_attention_mask" + ] + [1] + + batch[f"{kwargs['prefix']}completion_labels"] = batch[f"{kwargs['prefix']}completion_input_ids"][:] + batch[f"{kwargs['prefix']}completion_labels"][: len(batch[f"{kwargs['prefix']}prompt_input_ids"])] = [ + -100 + ] * len(batch[f"{kwargs['prefix']}prompt_input_ids"]) + else: + completion_tokens = kwargs["tokenizer"]( + completion, truncation=True, max_length=kwargs["max_completion_length"], add_special_tokens=True + ) + prompt_tokens = kwargs["tokenizer"](prompt, add_special_tokens=True) + + batch[f"{kwargs['prefix']}prompt_input_ids"] = prompt_tokens["input_ids"] + batch[f"{kwargs['prefix']}prompt_attention_mask"] = prompt_tokens["attention_mask"] + + batch[f"{kwargs['prefix']}completion_labels"] = completion_tokens["input_ids"] + batch[f"{kwargs['prefix']}completion_attention_mask"] = completion_tokens["attention_mask"] + if model is not None and hasattr(model, "prepare_decoder_input_ids_from_labels"): + batch[f"{kwargs['prefix']}completion_decoder_input_ids"] = model.prepare_decoder_input_ids_from_labels( + labels=torch.tensor(batch["completion_labels"]) + ) + + return batch + + +class BCOTrainer(_BaseTrainer): + r""" + Initialize BCOTrainer from [BCO](https://huggingface.co/papers/2404.04656) paper. + + Args: + model ([`~transformers.PreTrainedModel`]): + The model to train, preferably an [`~transformers.AutoModelForSequenceClassification`]. + ref_model ([`~transformers.PreTrainedModel`]): + Hugging Face transformer model with a casual language modelling head. Used for implicit reward computation + and loss. If no reference model is provided, the trainer will create a reference model with the same + architecture as the model to be optimized. + args ([`experimental.bco.BCOConfig`]): + The arguments to use for training. + train_dataset ([`~datasets.Dataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`]): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + data_collator ([`~transformers.DataCollator`], *optional*): + The data collator to use for training. If None is specified, the default data collator + ([`experimental.utils.DPODataCollatorWithPadding`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + model_init (`Callable[[], transformers.PreTrainedModel]`): + The model initializer to use for training. If None is specified, the default model initializer will be + used. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + peft_config (`dict`, defaults to `None`): + The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in + a PEFT model. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + model_adapter_name (`str`, defaults to `None`): + Name of the train target PEFT adapter, when using LoRA with multiple adapters. + ref_adapter_name (`str`, defaults to `None`): + Name of the reference PEFT adapter, when using LoRA with multiple adapters. + """ + + _tag_names = ["trl", "bco"] + _name = "BCO" + _paper = { + "title": "Binary Classifier Optimization for Large Language Model Alignment", + "id": "2404.04656", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{jung2024binary, + title = {{Binary Classifier Optimization for Large Language Model Alignment}}, + author = {Seungjae Jung and Gunsoo Han and Daniel Wontae Nam and Kyoung{-}Woon On}, + year = 2024, + eprint = {arXiv:2404.04656} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str = None, + ref_model: PreTrainedModel | nn.Module | str | None = None, + args: BCOConfig = None, + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + data_collator: DataCollator | None = None, + model_init: Callable[[], PreTrainedModel] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: dict | None = None, + compute_metrics: Callable[[EvalLoopOutput], dict] | None = None, + model_adapter_name: str | None = None, + ref_adapter_name: str | None = None, + embedding_func: Callable | None = None, + embedding_tokenizer: PreTrainedTokenizerBase | None = None, + ): + if embedding_func is not None and not (is_sklearn_available() and is_joblib_available()): + raise ImportError( + "BCOTrainer with UDM requires the scikit-learn and joblib libraries. Please install it with `pip install scikit-learn joblib`." + ) + + if type(args) is TrainingArguments: + raise ValueError("Please use `BCOConfig` instead `TrainingArguments`.") + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + + if not isinstance(model, str) and model is not None and ref_model is model: + raise ValueError( + "`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the " + "same as `model`, you must mass a copy of it, or `None` if you use peft." + ) + + if args.model_init_kwargs is None: + model_init_kwargs = {} + elif not isinstance(model, str): + raise ValueError("You passed model_kwargs to the BCOTrainer. But your model is already instantiated.") + else: + model_init_kwargs = args.model_init_kwargs + dtype = model_init_kwargs.get("dtype", "auto") + if dtype is not None: + # Convert to `torch.dtype` if an str is passed + if isinstance(dtype, str) and dtype != "auto": + dtype = getattr(torch, dtype) + if dtype != "auto" and not isinstance(dtype, torch.dtype): + raise ValueError( + f"Invalid `dtype` passed to the BCOConfig. Expected a string with either `torch.dtype` or 'auto', but got {dtype}." + ) + model_init_kwargs["dtype"] = dtype + model_init_kwargs["device_map"] = model_init_kwargs.get("device_map", "auto") + + if isinstance(model, str): + model = AutoModelForCausalLM.from_pretrained(model, **model_init_kwargs) + + if isinstance(ref_model, str): + ref_model = AutoModelForCausalLM.from_pretrained(ref_model, **model_init_kwargs) + + # Initialize this variable to False. This helps tracking the case when `peft_module_casting_to_bf16` + # has been called in order to properly call autocast if needed. + self._peft_has_been_casted_to_bf16 = False + + if not is_peft_available() and peft_config is not None: + raise ValueError( + "PEFT is not installed and you passed a `peft_config` in the trainer's kwargs, please install it with `pip install peft` to use the PEFT models" + ) + elif is_peft_available() and peft_config is not None: + if isinstance(model, PeftModel): + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first " + "merge and unload the existing adapter, save the resulting base model, and then pass that base " + "model along with the new `peft_config` to the trainer." + ) + + if getattr(model, "is_loaded_in_8bit", False) or getattr(model, "is_loaded_in_4bit", False): + _support_gc_kwargs = hasattr( + args, "gradient_checkpointing_kwargs" + ) and "gradient_checkpointing_kwargs" in list( + inspect.signature(prepare_model_for_kbit_training).parameters + ) + + prepare_model_kwargs = {"use_gradient_checkpointing": args.gradient_checkpointing} + + if _support_gc_kwargs: + prepare_model_kwargs["gradient_checkpointing_kwargs"] = args.gradient_checkpointing_kwargs + + model = prepare_model_for_kbit_training(model, **prepare_model_kwargs) + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + # get peft model with the given config + model = get_peft_model(model, peft_config) + if args.bf16 and getattr(model, "is_loaded_in_4bit", False): + peft_module_casting_to_bf16(model) + # If args.bf16 we need to explicitly call `generate` with torch amp autocast context manager + self._peft_has_been_casted_to_bf16 = True + + # For models that use gradient_checkpointing, we need to attach a hook that enables input + # to explicitly have `requires_grad=True`, otherwise training will either silently + # fail or completely fail. + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + if args.generate_during_eval and not (is_wandb_available() or is_comet_available()): + raise ValueError( + "`generate_during_eval=True` requires Weights and Biases or Comet to be installed." + " Please install `wandb` or `comet-ml` to resolve." + ) + + if model is not None: + self.is_encoder_decoder = model.config.is_encoder_decoder + elif args.is_encoder_decoder is None: + raise ValueError("When no model is provided, you need to pass the parameter is_encoder_decoder.") + else: + self.is_encoder_decoder = args.is_encoder_decoder + + self.is_peft_model = is_peft_available() and isinstance(model, PeftModel) + self.model_adapter_name = model_adapter_name + self.ref_adapter_name = ref_adapter_name + + if ref_model: + self.ref_model = ref_model + elif self.is_peft_model or args.precompute_ref_log_probs: + # The `model` with adapters turned off will be used as the reference model + self.ref_model = None + else: + self.ref_model = create_reference_model(model) + + if processing_class is None: + raise ValueError( + "max_length or a processing_class must be specified when using the default DPODataCollatorWithPadding" + ) + if args.max_length is None: + logger.warning( + "When using DPODataCollatorWithPadding, you should set `max_length` in the `BCOConfig`. " + "It will be set to `512` by default, but you should do it yourself in the future.", + ) + max_length = 512 + if args.max_length is not None: + max_length = args.max_length + + max_completion_length = None + if args.max_completion_length is None and self.is_encoder_decoder: + logger.warning( + "When using DPODataCollatorWithPadding with an encoder decoder architecture, you should set `max_completion_length` in the BCOTrainer's init" + " it will be set to `128` by default, but you should do it yourself in the future.", + ) + max_completion_length = 128 + if args.max_completion_length is not None and self.is_encoder_decoder: + max_completion_length = args.max_completion_length + + if data_collator is None: + data_collator = DPODataCollatorWithPadding( + pad_token_id=processing_class.pad_token_id, + is_encoder_decoder=self.is_encoder_decoder, + ) + + if args.remove_unused_columns: + args.remove_unused_columns = False + # warn users + logger.warning( + "When using DPODataCollatorWithPadding, you should set `remove_unused_columns=False` in your BCOConfig" + " we have set it for you, but you should do it yourself in the future.", + ) + + self.use_dpo_data_collator = True + else: + self.use_dpo_data_collator = False + + # Disable dropout in the model and reference model + if args.disable_dropout: + disable_dropout_in_model(model) + if self.ref_model is not None: + disable_dropout_in_model(self.ref_model) + + self.max_length = max_length + self.generate_during_eval = args.generate_during_eval + self.max_completion_length = max_completion_length + self.precompute_ref_log_probs = args.precompute_ref_log_probs + + # Since ref_logs are precomputed on the first call to get_train/eval_dataloader + # keep track of first called to avoid computation of future calls + self._precomputed_train_ref_log_probs = False + self._precomputed_eval_ref_log_probs = False + + # metric + self._stored_metrics = defaultdict(lambda: defaultdict(list)) + + # BCO parameter + self.beta = args.beta + self.aux_loss_enabled = getattr(model.config, "output_router_logits", False) + self.aux_loss_coef = getattr(model.config, "router_aux_loss_coef", 0.0) + if self.aux_loss_enabled and self.aux_loss_coef == 0.0: + logger.warning( + "You set `output_router_logits` to `True` in the model config, but `router_aux_loss_coef` is set to " + "`0.0`, meaning the auxiliary loss will not be used. Either set `router_aux_loss_coef` to a value " + "greater than `0.0`, or set `output_router_logits` to `False` if you don't want to use the auxiliary " + "loss.", + ) + + # Underlying Distribution Matching argument + self.embedding_func = embedding_func + self.embedding_tokenizer = embedding_tokenizer + + with PartialState().main_process_first(): + # Extract the prompt if needed + train_dataset = train_dataset.map( + maybe_extract_prompt, num_proc=args.dataset_num_proc, desc="Extracting prompt from train dataset" + ) + # Unpair the dataset if needed + train_dataset = maybe_unpair_preference_dataset( + train_dataset, args.dataset_num_proc, desc="Unpairing train dataset" + ) + # Apply the chat template if needed + train_dataset = train_dataset.map( + maybe_apply_chat_template, + fn_kwargs={"processing_class": processing_class}, + num_proc=args.dataset_num_proc, + ) + if eval_dataset is not None: + # Extract the prompt if needed + eval_dataset = eval_dataset.map( + maybe_extract_prompt, num_proc=args.dataset_num_proc, desc="Extracting prompt from eval dataset" + ) + # Unpair the dataset if needed + eval_dataset = maybe_unpair_preference_dataset( + eval_dataset, args.dataset_num_proc, desc="Unpairing eval dataset" + ) + eval_dataset = eval_dataset.map( + maybe_apply_chat_template, + fn_kwargs={"processing_class": processing_class}, + num_proc=args.dataset_num_proc, + ) + + # Tokenize and prepare the training datasets + train_dataset = train_dataset.map( + _tokenize, + batched=True, + fn_kwargs={"tokenizer": processing_class, "embedding_tokenizer": self.embedding_tokenizer}, + num_proc=args.dataset_num_proc, + desc="Tokenizing train dataset", + ) + + # Prepare the datasets + fn_kwargs = { + "prefix": "", + "is_encoder_decoder": self.is_encoder_decoder, + "tokenizer": processing_class, + "max_length": self.max_length, + "max_completion_length": self.max_completion_length, + } + train_dataset = train_dataset.map( + _process_tokens, + fn_kwargs=fn_kwargs, + num_proc=args.dataset_num_proc, + desc="Processing tokenized train dataset", + ) + + if eval_dataset is not None: + # Tokenize + eval_dataset = eval_dataset.map( + _tokenize, + fn_kwargs={"tokenizer": processing_class, "embedding_tokenizer": self.embedding_tokenizer}, + batched=True, + num_proc=args.dataset_num_proc, + desc="Tokenizing eval dataset", + ) + + # Process + fn_kwargs = { + "prefix": "", + "is_encoder_decoder": self.is_encoder_decoder, + "tokenizer": processing_class, + "max_length": self.max_length, + "max_completion_length": self.max_completion_length, + } + eval_dataset = eval_dataset.map( + _process_tokens, + fn_kwargs=fn_kwargs, + num_proc=args.dataset_num_proc, + desc="Processing tokenized eval dataset", + ) + + desirable = train_dataset.filter( + lambda x: x["label"], num_proc=args.dataset_num_proc, desc="Filtering desirable examples" + ) + undesirable = train_dataset.filter( + lambda x: not x["label"], num_proc=args.dataset_num_proc, desc="Filtering undesirable examples" + ) + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + model_init=model_init, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Add tags for models that have been loaded with the correct transformers version + if hasattr(self.model, "add_model_tags"): + self.model.add_model_tags(self._tag_names) + + if not hasattr(self, "accelerator"): + raise AttributeError( + "Your `Trainer` does not have an `accelerator` object. Consider upgrading `transformers`." + ) + + # Deepspeed Zero-3 does not support precompute_ref_log_probs + if self.is_deepspeed_enabled: + if self.accelerator.state.deepspeed_plugin.zero_stage == 3 and self.precompute_ref_log_probs: + raise ValueError( + "You cannot use `precompute_ref_log_probs=True` with Deepspeed ZeRO-3. Please set `precompute_ref_log_probs=False`." + ) + + if self.ref_model is None: + if not (self.is_peft_model or self.precompute_ref_log_probs): + raise ValueError( + "No reference model and model is not a Peft model. Try setting `precompute_ref_log_probs=True`" + ) + else: + if self.is_deepspeed_enabled: + self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) + else: + self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) + + self.running = RunningMoments(accelerator=self.accelerator) + + if self.embedding_func is None or args.resume_from_checkpoint: + return + + chosen_embeddings = self._get_sample_prompt_embeddings(desirable, sample_size=self.args.prompt_sample_size) + rejected_embeddings = self._get_sample_prompt_embeddings(undesirable, sample_size=self.args.prompt_sample_size) + + embeddings = torch.cat((chosen_embeddings, rejected_embeddings), dim=0) + labels = torch.cat( + (torch.ones_like(chosen_embeddings[:, 0]), torch.zeros_like(rejected_embeddings[:, 0])), dim=0 + ) + + self.clf = LogisticRegression(class_weight="balanced").fit( + embeddings.cpu().float().numpy(), labels.cpu().numpy() + ) + chosen_mean = self.clf.score( + chosen_embeddings.cpu().float().numpy(), torch.ones_like(chosen_embeddings[:, 0]).cpu().numpy() + ) + rejected_mean = self.clf.score( + rejected_embeddings.cpu().float().numpy(), torch.zeros_like(rejected_embeddings[:, 0]).cpu().numpy() + ) + logger.info(f"UDM classifier training scores: chosen: {chosen_mean}, rejected: {rejected_mean}") + + @property + def match_underlying_distribution(self): + return self.embedding_func is not None and self.embedding_tokenizer is not None + + def _get_chosen_prob(self, prompt_embeddings: torch.FloatTensor) -> torch.FloatTensor: + """ + Calculates the probability if the given prompt embedding is from desirable dataset. This function calculates + the probability in the process and ensemble across processes. + """ + dtype = prompt_embeddings.dtype + device = prompt_embeddings.device + rank = self.accelerator.process_index + + padded_prompt_embeddings = self.accelerator.pad_across_processes( + prompt_embeddings, pad_index=self.embedding_tokenizer.pad_token_id + ) + sample_size = padded_prompt_embeddings.shape[0] + nonzero = padded_prompt_embeddings.mean(dim=1) != self.embedding_tokenizer.pad_token_id + prompt_embeddings = self.accelerator.gather(padded_prompt_embeddings) + + # cannot predict for all empty values + if prompt_embeddings.shape[0] == 0: + return torch.tensor([], device=device, dtype=dtype) + + prob = self.clf.predict_proba(prompt_embeddings.cpu().float().numpy())[:, 1] + prob = torch.as_tensor(prob, dtype=dtype, device=device) + prob = self.accelerator.reduce(prob, reduction="mean") + + prob = prob[sample_size * rank : sample_size * (rank + 1)] + prob = prob[nonzero] + + return prob + + def _vectorize_prompt(self, input_ids: torch.LongTensor, attention_mask: torch.LongTensor) -> torch.FloatTensor: + """ + Replaces processing_class.pad_token_id to embedding_tokenizer.pad_token_id and applies self.embedding_func + """ + input_ids = torch.where( + input_ids == self.processing_class.pad_token_id, + self.embedding_tokenizer.pad_token_id, + input_ids, + ) + + with torch.no_grad(): + embeddings = self.embedding_func( + input_ids=input_ids, + attention_mask=attention_mask, + ) + + return embeddings + + def _get_prompt_embeddings( + self, batch: dict[str, list | torch.LongTensor] + ) -> tuple[torch.FloatTensor, torch.FloatTensor]: + """Extract embeddings from frozen embedding model""" + + if not self.match_underlying_distribution: + return None, None + + embeddings = self._vectorize_prompt( + input_ids=batch["embedding_input_ids"], + attention_mask=batch["embedding_attention_mask"], + ) + + labels = torch.tensor(batch["label"], dtype=torch.bool, device=embeddings.device) + chosen_idx = torch.where(labels)[0] + rejected_idx = torch.where(~labels)[0] + + chosen_embeddings = embeddings[chosen_idx, ...] + rejected_embeddings = embeddings[rejected_idx, ...] + + return (chosen_embeddings, rejected_embeddings) + + def _get_sample_prompt_embeddings(self, dataset: Dataset, sample_size: int = 512) -> torch.FloatTensor: + """ + Sample instances from dataset and get prompt embeddings. Used for density ratio classifier training. + """ + n_samples = min(len(dataset), sample_size) + rand_indices = np.random.choice(len(dataset), size=(n_samples,)) + + embedding_dataset = dataset.select(rand_indices) + + dataloader_params = { + "batch_size": self.args.per_device_train_batch_size, + "collate_fn": self.data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "shuffle": False, + } + + # prepare dataloader + data_loader = self.accelerator.prepare(DataLoader(embedding_dataset, **dataloader_params)) + + with torch.no_grad(): + all_embeddings = torch.empty(0) + for padded_batch in tqdm(iterable=data_loader, desc="Building sample prompt embeddings"): + embeddings = self._vectorize_prompt( + input_ids=padded_batch["embedding_input_ids"], + attention_mask=padded_batch["embedding_attention_mask"], + ) + embeddings = self.accelerator.gather_for_metrics(embeddings) + all_embeddings = torch.cat((all_embeddings, embeddings.cpu())) + + return all_embeddings + + def _save_optimizer_and_scheduler(self, output_dir): + output_dir = output_dir if output_dir is not None else self.args.output_dir + super()._save_optimizer_and_scheduler(output_dir) + + if self.accelerator.is_main_process: + # When saving optimizer and scheduler to checkpoint, save also the running delta object. + self.running.save_to_json(os.path.join(output_dir, RUNNING_NAME)) + + if self.match_underlying_distribution: + joblib.dump(self.clf, os.path.join(output_dir, CLF_NAME), compress=True) + + def _load_optimizer_and_scheduler(self, checkpoint): + if checkpoint is None: + logger.warning_once(f"Missing Checkpoint {checkpoint}") + return + + super()._load_optimizer_and_scheduler(checkpoint) + + # when loading optimizer and scheduler from checkpoint, also load the running delta object. + running_file = os.path.join(checkpoint, RUNNING_NAME) + if os.path.isfile(running_file): + self.running = RunningMoments.load_from_json(self.accelerator, running_file) + + if self.match_underlying_distribution: + clf_file = os.path.join(checkpoint, CLF_NAME) + if os.path.isfile(clf_file): + self.clf = joblib.load(clf_file) + + @contextmanager + def null_ref_context(self): + """Context manager for handling null reference model (that is, peft adapter manipulation).""" + with ( + self.accelerator.unwrap_model(self.model).disable_adapter() + if self.is_peft_model and not self.ref_adapter_name + else nullcontext() + ): + if self.ref_adapter_name: + self.model.set_adapter(self.ref_adapter_name) + yield + if self.ref_adapter_name: + self.model.set_adapter(self.model_adapter_name or "default") + + def get_train_dataloader(self) -> DataLoader: + """ + Returns the training [`~torch.utils.data.DataLoader`]. + + Subclass of transformers.src.transformers.trainer.get_train_dataloader to precompute `ref_log_probs`. + """ + + if self.precompute_ref_log_probs and not self._precomputed_train_ref_log_probs: + dataloader_params = { + "batch_size": self.args.per_device_train_batch_size, + "collate_fn": self.data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "shuffle": False, + } + + # prepare dataloader + data_loader = self.accelerator.prepare(DataLoader(self.train_dataset, **dataloader_params)) + reference_completion_logps = [] + + for padded_batch in tqdm(iterable=data_loader, desc="Train dataset reference log probs"): + reference_completion_logp = self.compute_reference_log_probs(padded_batch) + + reference_completion_logp = self.accelerator.gather_for_metrics(reference_completion_logp) + reference_completion_logps.append(reference_completion_logp.cpu()) + + self.train_dataset = self.train_dataset.add_column( + name="reference_logps", column=torch.cat(reference_completion_logps).float().numpy() + ) + + self._precomputed_train_ref_log_probs = True + + return super().get_train_dataloader() + + def get_eval_dataloader(self, eval_dataset: Dataset | None = None) -> DataLoader: + """ + Returns the evaluation [`~torch.utils.data.DataLoader`]. + + Subclass of transformers.src.transformers.trainer.get_eval_dataloader to precompute `ref_log_probs`. + + Args: + eval_dataset (`torch.utils.data.Dataset`, *optional*): + If provided, will override `self.eval_dataset`. If it is a [`~datasets.Dataset`], columns not accepted + by the `model.forward()` method are automatically removed. It must implement `__len__`. + """ + if eval_dataset is None and self.eval_dataset is None: + raise ValueError("Trainer: evaluation requires an eval_dataset.") + eval_dataset = eval_dataset if eval_dataset is not None else self.eval_dataset + + if self.precompute_ref_log_probs and not self._precomputed_eval_ref_log_probs: + dataloader_params = { + "batch_size": self.args.per_device_eval_batch_size, + "collate_fn": self.data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "shuffle": False, + } + + # prepare dataloader + data_loader = self.accelerator.prepare(DataLoader(eval_dataset, **dataloader_params)) + + reference_completion_logps = [] + + for padded_batch in tqdm(iterable=data_loader, desc="Eval dataset reference log probs"): + reference_completion_logp = self.compute_reference_log_probs(padded_batch) + + reference_completion_logp = self.accelerator.gather_for_metrics(reference_completion_logp) + reference_completion_logps.append(reference_completion_logp.cpu()) + + eval_dataset = eval_dataset.add_column( + name="reference_logps", column=torch.cat(reference_completion_logps).float().numpy() + ) + + # Save calculated reference_chosen_logps and reference_rejected_logps to the eval_dataset for subsequent runs + if self.eval_dataset is not None: + self.eval_dataset = eval_dataset + self._precomputed_eval_ref_log_probs = True + + return super().get_eval_dataloader(eval_dataset=eval_dataset) + + def compute_reference_log_probs(self, padded_batch: dict) -> dict: + """Computes log probabilities of the reference model for a single padded batch of a BCO specific dataset.""" + with torch.no_grad(): + if self.ref_model is None: + with self.null_ref_context(): + if self.is_encoder_decoder: + completion_logits = self.model( + padded_batch["prompt_input_ids"], + attention_mask=padded_batch["prompt_attention_mask"], + decoder_input_ids=padded_batch.get("completion_decoder_input_ids"), + labels=padded_batch["completion_labels"], + ).logits + + else: + completion_logits = self.model( + padded_batch["completion_input_ids"], + attention_mask=padded_batch["completion_attention_mask"], + ).logits + + else: + if self.is_encoder_decoder: + completion_logits = self.ref_model( + padded_batch["prompt_input_ids"], + attention_mask=padded_batch["prompt_attention_mask"], + decoder_input_ids=padded_batch.get("completion_decoder_input_ids"), + labels=padded_batch["completion_labels"], + ).logits + + else: + completion_logits = self.ref_model( + padded_batch["completion_input_ids"], attention_mask=padded_batch["completion_attention_mask"] + ).logits + + completion_logps = self.get_batch_logps( + completion_logits, + padded_batch["completion_labels"], + average_log_prob=False, + is_encoder_decoder=self.is_encoder_decoder, + ) + + return completion_logps + + @staticmethod + def get_batch_logps( + logits: torch.FloatTensor, + labels: torch.LongTensor, + average_log_prob: bool = False, + is_encoder_decoder: bool = False, + ) -> torch.FloatTensor: + """Compute the log probabilities of the given labels under the given logits. + + Args: + logits: Logits of the model (unnormalized). Shape: (batch_size, sequence_length, vocab_size) + labels: + Labels for which to compute the log probabilities. Label tokens with a value of `-100` are ignored. + Shape: (batch_size, sequence_length) + average_log_prob: + If True, return the average log probability per (non-masked) token. Otherwise, return the sum of the + log probabilities of the (non-masked) tokens. + is_encoder_decoder: + Whether the model is an encoder-decoder model. If True, the labels are not shifted, and the logits are + assumed to already be aligned with the labels. If False, the labels are shifted to the right by one + position, and the logits are assumed to be aligned with the shifted labels. + + Returns: + A tensor of shape (batch_size,) containing the average/sum log probabilities of the given labels under the + given logits. + """ + if logits.shape[:-1] != labels.shape: + raise ValueError("Logits (batch and sequence length dim) and labels must have the same shape.") + + if not is_encoder_decoder: + labels = labels[:, 1:].clone() + logits = logits[:, :-1, :] + else: + # Fixes end-dec RuntimeError + labels = labels.clone() + + loss_mask = labels != -100 + + # dummy token; we'll ignore the losses on these tokens later + labels[labels == -100] = 0 + + per_token_logps = selective_log_softmax(logits, labels) + + if average_log_prob: + return (per_token_logps * loss_mask).sum(-1) / loss_mask.sum(-1) + else: + return (per_token_logps * loss_mask).sum(-1) + + def forward( + self, model: nn.Module, batch: dict[str, list | torch.LongTensor] + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + model_kwargs = ( + { + "labels": batch["completion_labels"], + "decoder_input_ids": batch.get("completion_decoder_input_ids"), + } + if self.is_encoder_decoder + else {} + ) + if self.aux_loss_enabled: + model_kwargs["output_router_logits"] = True + + outputs = model( + batch["completion_input_ids"], + attention_mask=batch["completion_attention_mask"], + **model_kwargs, + ) + completion_logits = outputs.logits + + completion_logps = self.get_batch_logps( + completion_logits, + batch["completion_labels"], + average_log_prob=False, + is_encoder_decoder=self.is_encoder_decoder, + ) + + if completion_logps.shape[0] != len(batch["label"]): + raise ValueError( + "There is a mismatch between the number of examples in this batch and the number of " + "examples for which an output sequence was predicted." + ) + + chosen_idx = [i for i in range(completion_logps.shape[0]) if batch["label"][i] is True] + rejected_idx = [i for i in range(completion_logps.shape[0]) if batch["label"][i] is False] + + chosen_logps = completion_logps[chosen_idx, ...] + rejected_logps = completion_logps[rejected_idx, ...] + + chosen_logits = completion_logits[chosen_idx, ...] + rejected_logits = completion_logits[rejected_idx, ...] + + if self.aux_loss_enabled: + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, outputs.aux_loss) + else: + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits) + + def _get_udm_weight(self, rejected_embeddings: torch.FloatTensor) -> torch.FloatTensor: + prob_desirable = self._get_chosen_prob(rejected_embeddings) + min_ratio = self.args.min_density_ratio + max_ratio = self.args.max_density_ratio + + weight = (prob_desirable / (1 - prob_desirable + 1e-8)).clamp(min=min_ratio, max=max_ratio) + + return weight + + def bco_loss( + self, + policy_chosen_logps: torch.FloatTensor, + policy_rejected_logps: torch.FloatTensor, + reference_chosen_logps: torch.FloatTensor, + reference_rejected_logps: torch.FloatTensor, + chosen_embeddings: torch.FloatTensor | None, + rejected_embeddings: torch.FloatTensor | None, + do_train: bool = True, + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + """Compute the BCO loss for a batch of policy and reference model log probabilities. + + Args: + policy_chosen_logps: + Log probabilities of the policy model for the chosen responses. Shape: (num(chosen) in batch_size,) + policy_rejected_logps: + Log probabilities of the policy model for the rejected responses. Shape: (num(rejected) in batch_size,) + reference_chosen_logps: + Log probabilities of the reference model for the chosen responses. Shape: (num(chosen) in batch_size,) + reference_rejected_logps: + Log probabilities of the reference model for the rejected responses. Shape: (num(rejected) in + batch_size,) + chosen_embeddings: embeddings of desirable prompts + rejected_embeddings: embeddings of undesirable prompts + do_train: whether to update the running delta value. Default is True. + + Returns: + A tuple of four tensors: (losses, chosen_rewards, rejected_rewards, delta). The losses tensor contains the + BCO loss for each example in the batch. The chosen_rewards and rejected_rewards tensors contain the rewards + for the chosen and rejected responses, respectively. The delta value contains the moving average of all + implicit rewards. + """ + + chosen_logratios = policy_chosen_logps - reference_chosen_logps + chosen_rewards = self.beta * chosen_logratios + + rejected_logratios = policy_rejected_logps - reference_rejected_logps + rejected_rewards = self.beta * rejected_logratios + + if do_train: + self.running.update(torch.cat((chosen_rewards, rejected_rewards), 0).detach()) + delta = torch.as_tensor(self.running.mean, device=chosen_rewards.device) + + chosen_losses = -F.logsigmoid(chosen_rewards - delta) + rejected_losses = -F.logsigmoid(-(rejected_rewards - delta)) + + if self.match_underlying_distribution: + chosen_weight = torch.ones_like(chosen_losses) + rejected_weight = self._get_udm_weight(rejected_embeddings) + + losses = torch.cat((chosen_weight * chosen_losses, rejected_weight * rejected_losses), dim=0) + else: + losses = torch.cat((chosen_losses, rejected_losses), dim=0) + + return losses, chosen_rewards, rejected_rewards, delta + + def get_batch_loss_metrics( + self, + model, + batch: dict[str, list | torch.LongTensor], + do_train: bool = True, + ): + """Compute the BCO loss and other metrics for the given batch of inputs for train or test.""" + metrics = {} + batch = {k: (v.to(self.accelerator.device) if isinstance(v, torch.Tensor) else v) for k, v in batch.items()} + + forward_output = self.forward(model, batch) + ( + policy_chosen_logps, + policy_rejected_logps, + policy_chosen_logits, + policy_rejected_logits, + ) = forward_output[:4] + if self.aux_loss_enabled: + aux_loss = forward_output[4] + + # if reference_logps in batch use them, otherwise use the reference model + if "reference_logps" in batch: + chosen_idx = [i for i in range(batch["reference_logps"].shape[0]) if batch["label"][i] is True] + rejected_idx = [i for i in range(batch["reference_logps"].shape[0]) if batch["label"][i] is False] + + reference_chosen_logps = batch["reference_logps"][chosen_idx, ...] + reference_rejected_logps = batch["reference_logps"][rejected_idx, ...] + else: + with torch.no_grad(): + if self.ref_model is None: + with self.null_ref_context(): + ( + reference_chosen_logps, + reference_rejected_logps, + _, + _, + ) = self.forward(self.model, batch)[:4] + else: + ( + reference_chosen_logps, + reference_rejected_logps, + _, + _, + ) = self.forward(self.ref_model, batch)[:4] + + chosen_embeddings, rejected_embeddings = self._get_prompt_embeddings(batch) + + losses, chosen_rewards, rejected_rewards, delta = self.bco_loss( + policy_chosen_logps, + policy_rejected_logps, + reference_chosen_logps, + reference_rejected_logps, + chosen_embeddings, + rejected_embeddings, + do_train=do_train, + ) + metrics["delta"] = self.accelerator.gather_for_metrics(delta).mean().item() + + num_chosen = torch.Tensor([len(chosen_rewards)]).to(self.accelerator.device) + num_rejected = torch.Tensor([len(rejected_rewards)]).to(self.accelerator.device) + + all_num_chosen = self.accelerator.gather_for_metrics(num_chosen).sum().item() + all_num_rejected = self.accelerator.gather_for_metrics(num_rejected).sum().item() + + if all_num_chosen > 0: + metrics["rewards/chosen_sum"] = ( + self.accelerator.gather_for_metrics(chosen_rewards.nansum()).nansum().item() + ) + metrics["logps/chosen_sum"] = ( + self.accelerator.gather_for_metrics(policy_chosen_logps.nansum()).nansum().item() + ) + metrics["logits/chosen_sum"] = ( + self.accelerator.gather_for_metrics(policy_chosen_logits.nansum()).nansum().item() + ) + metrics["count/chosen"] = all_num_chosen + + if all_num_rejected > 0: + metrics["rewards/rejected_sum"] = ( + self.accelerator.gather_for_metrics(rejected_rewards.nansum()).nansum().item() + ) + metrics["logps/rejected_sum"] = ( + self.accelerator.gather_for_metrics(policy_rejected_logps.nansum()).nansum().item() + ) + metrics["logits/rejected_sum"] = ( + self.accelerator.gather_for_metrics(policy_rejected_logits.nansum()).nansum().item() + ) + metrics["count/rejected"] = all_num_rejected + + loss = losses.nanmean() + if self.aux_loss_enabled: + loss += self.aux_loss_coef * aux_loss + + return loss, metrics + + def compute_loss( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + return_outputs=False, + num_items_in_batch=None, + ) -> torch.Tensor | tuple[torch.Tensor, dict[str, torch.Tensor]]: + compute_loss_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with compute_loss_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs) + + # Make sure to move the loss to the device the original accumulating loss is at back in the `Trainer` class: + loss = loss.to(self.args.device) + # force log the metrics + if self.accelerator.is_main_process: + self.store_metrics(metrics, train_eval="train") + + if return_outputs: + return (loss, metrics) + return loss + + def store_metrics(self, metrics: dict[str, float], train_eval: Literal["train", "eval"] = "train") -> None: + for key, value in metrics.items(): + self._stored_metrics[train_eval][key].append(value) + + def _get_train_sampler(self, dataset: Dataset | None = None) -> torch.utils.data.Sampler | None: + if dataset is None: + dataset = self.train_dataset + if dataset is None or not has_length(dataset): + return None + return SequentialSampler(dataset) + + def generate_from_model_and_ref(self, model, batch: dict[str, torch.LongTensor]) -> tuple[str, str]: + """Generate samples from the model and reference model for the given batch of inputs.""" + + # If one uses `generate_during_eval` with peft + bf16, we need to explicitly call generate with + # the torch amp context manager as some hidden states are silently casted to full precision. + generate_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + with generate_context_manager: + policy_output = model.generate( + input_ids=batch["prompt_input_ids"], + attention_mask=batch["prompt_attention_mask"], + max_length=self.max_length, + do_sample=True, + pad_token_id=self.processing_class.pad_token_id, + ) + + # if reference_output in batch use that otherwise use the reference model + if "reference_output" in batch: + reference_output = batch["reference_output"] + else: + if self.ref_model is None: + with self.null_ref_context(): + reference_output = self.model.generate( + input_ids=batch["prompt_input_ids"], + attention_mask=batch["prompt_attention_mask"], + max_length=self.max_length, + do_sample=True, + pad_token_id=self.processing_class.pad_token_id, + ) + else: + reference_output = self.ref_model.generate( + input_ids=batch["prompt_input_ids"], + attention_mask=batch["prompt_attention_mask"], + max_length=self.max_length, + do_sample=True, + pad_token_id=self.processing_class.pad_token_id, + ) + + policy_output = pad_to_length(policy_output, self.max_length, self.processing_class.pad_token_id) + policy_output_decoded = self.processing_class.batch_decode(policy_output, skip_special_tokens=True) + + reference_output = pad_to_length(reference_output, self.max_length, self.processing_class.pad_token_id) + reference_output_decoded = self.processing_class.batch_decode(reference_output, skip_special_tokens=True) + + return policy_output_decoded, reference_output_decoded + + def prediction_step( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + prediction_loss_only: bool, + ignore_keys: list[str] | None = None, + ): + if ignore_keys is None: + if hasattr(model, "config"): + ignore_keys = getattr(model.config, "keys_to_ignore_at_inference", []) + else: + ignore_keys = [] + + prediction_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + with torch.no_grad(), prediction_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs, do_train=False) + + # force log the metrics + if self.accelerator.is_main_process: + self.store_metrics(metrics, train_eval="eval") + + if prediction_loss_only: + return (loss.detach(), None, None) + + # logits for the chosen and rejected samples from model + logits_dict = {} + if "logits/chosen_sum" in metrics: + logits_dict["eval_logits/chosen"] = metrics["logits/chosen_sum"] + if "logits/rejected_sum" in metrics: + logits_dict["eval_logits/rejected"] = metrics["logits/rejected_sum"] + logits = [v for k, v in logits_dict.items() if k not in ignore_keys] + logits = torch.tensor(logits, device=self.accelerator.device) + labels = torch.zeros(logits.shape[0], device=self.accelerator.device) + + return (loss.detach(), logits, labels) + + def evaluation_loop( + self, + dataloader: DataLoader, + description: str, + prediction_loss_only: bool | None = None, + ignore_keys: list[str] | None = None, + metric_key_prefix: str = "eval", + ) -> EvalLoopOutput: + """ + Overriding built-in evaluation loop to store metrics for each batch. Prediction/evaluation loop, shared by + `Trainer.evaluate()` and `Trainer.predict()`. + + Works both with or without labels. + """ + + # Sample and save to game log if requested (for one batch to save time) + if self.generate_during_eval: + # Generate random indices within the range of the total number of samples + num_samples = len(dataloader.dataset) + random_indices = random.sample(range(num_samples), k=self.args.eval_batch_size) + + # Use dataloader.dataset.select to get the random batch without iterating over the DataLoader + random_batch_dataset = dataloader.dataset.select(random_indices) + random_batch = self.data_collator(random_batch_dataset) + random_batch = self._prepare_inputs(random_batch) + + target_labels = torch.tensor(random_batch["label"], dtype=torch.bool, device=self.accelerator.device) + target_indices = torch.where(~target_labels)[0] + target_batch = { + "prompt_input_ids": random_batch["prompt_input_ids"][target_indices], + "prompt_attention_mask": random_batch["prompt_attention_mask"][target_indices], + "prompt": itemgetter(*target_indices)(random_batch["prompt"]), + } + policy_output_decoded, ref_output_decoded = self.generate_from_model_and_ref(self.model, target_batch) + + table = pd.DataFrame( + columns=["Prompt", "Policy", "Ref Model"], + data=[ + [prompt, pol[len(prompt) :], ref[len(prompt) :]] + for prompt, pol, ref in zip( + target_batch["prompt"], policy_output_decoded, ref_output_decoded, strict=True + ) + ], + ) + if "wandb" in self.args.report_to: + wandb.log({"game_log": wandb.Table(data=table)}) + + if "comet_ml" in self.args.report_to: + log_table_to_comet_experiment( + name="game_log.csv", + table=table, + ) + + # Base evaluation + initial_output = super().evaluation_loop( + dataloader, description, prediction_loss_only, ignore_keys, metric_key_prefix + ) + + return initial_output + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + """ + Log `logs` on the various objects watching training, including stored metrics. + + Args: + logs (`dict[str, float]`): + The values to log. + start_time (`float`, *optional*): + Start time of the training. + """ + # logs either has 'loss' or 'eval_loss' + train_eval = "train" if "loss" in logs else "eval" + # train metrics should have no prefix, eval should have 'eval_' + prefix = "eval_" if train_eval == "eval" else "" + # accumulate average metrics from sums and lengths + for split in ["chosen", "rejected"]: + if f"count/{split}" in self._stored_metrics[train_eval]: + count_sum = torch.Tensor(self._stored_metrics[train_eval][f"count/{split}"]).sum().item() + for metric in ["rewards", "logps", "logits"]: + logs[f"{prefix}{metric}/{split}"] = ( + torch.Tensor(self._stored_metrics[train_eval][f"{metric}/{split}_sum"]).sum().item() + / count_sum + ) + # delete obsolete metric + del self._stored_metrics[train_eval][f"{metric}/{split}_sum"] + del self._stored_metrics[train_eval][f"count/{split}"] + # calculate reward margin + if f"{prefix}rewards/chosen" in logs and f"{prefix}rewards/rejected" in logs: + logs[f"{prefix}rewards/margins"] = logs[f"{prefix}rewards/chosen"] - logs[f"{prefix}rewards/rejected"] + # Add averaged stored metrics to logs + for key, metrics in self._stored_metrics[train_eval].items(): + logs[f"{prefix}{key}"] = torch.Tensor(metrics).mean().item() + del self._stored_metrics[train_eval] + return super().log(logs, start_time) + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..8d7de0bee7977851b77a803f297a91ed6d170e27 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .callback import BEMACallback +from .dpo_trainer import DPOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/callback.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/callback.py new file mode 100644 index 0000000000000000000000000000000000000000..d030be9fb51c428fe82e6391c2ec64a05345d5d5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/callback.py @@ -0,0 +1,221 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +import torch +from transformers import PreTrainedModel, TrainerControl, TrainerState, TrainingArguments +from transformers.trainer_callback import CallbackHandler + +from ...trainer.callbacks import BEMACallback as _BEMACallback + + +# Logger for module-level logging +logger = logging.getLogger(__name__) + + +class CallbackHandlerWithRefModel(CallbackHandler): + """ + A [`~transformers.CallbackHandler`] that supports passing a reference model to callbacks. + """ + + def __init__(self, callbacks, model, ref_model, processing_class, optimizer, lr_scheduler): + super().__init__(callbacks, model, processing_class, optimizer, lr_scheduler) + self.ref_model = ref_model + + # Copied from CallbackHandler.call_event with the addition of `ref_model` to the callback call. + def call_event(self, event, args, state, control, **kwargs): + for callback in self.callbacks: + result = getattr(callback, event)( + args, + state, + control, + model=self.model, + ref_model=self.ref_model, # <- Added ref_model to the callback call + processing_class=self.processing_class, + optimizer=self.optimizer, + lr_scheduler=self.lr_scheduler, + train_dataloader=self.train_dataloader, + eval_dataloader=self.eval_dataloader, + **kwargs, + ) + # A Callback can skip the return of `control` if it doesn't change it. + if result is not None: + control = result + return control + + +class BEMACallback(_BEMACallback): + # docstyle-ignore + r""" + A [`~transformers.TrainerCallback`] that implements [BEMA](https://huggingface.co/papers/2508.00180) + (Bias-Corrected Exponential Moving Average) by [Adam Block](https://huggingface.co/abblock) and [Cyril + Zhang](https://huggingface.co/cyrilzhang). Code from https://github.com/abblock/bema under MIT license. + + BEMA computes model weights that scale like: + + $$ + \theta_t' = \alpha_t \cdot (\theta_t - \theta_0) + \text{EMA}_t + $$ + + where \\( \theta_t \\) is the current model weights, \\( \theta_0 \\) is a snapshot of the model weights at the + first `update_after` step, \\( \text{EMA}_t \\) is the exponential moving average of the model weights, and + \\( \alpha_t \\) is a scaling factor that decays with the number of steps \\( t \\) as + + $$ + \alpha_t = (\rho + \gamma \cdot t)^{-\eta}. + $$ + + The EMA is computed as: + + $$ + \text{EMA}_t = (1 - \beta_t) \cdot \text{EMA}_{t-1} + \beta_t \cdot \theta_t + $$ + + where \\( \beta_t \\) is a decay factor that decays with the number of steps \\( t \\) as + + $$ + \beta_t = (\rho + \gamma \cdot t)^{-\kappa}. + $$ + + Args: + update_freq (`int`, *optional*, defaults to `400`): + Update the BEMA weights every X steps. Denoted this as \\( \phi \\) in the paper. + ema_power (`float`, *optional*, defaults to `0.5`): + Power for the EMA decay factor. Denoted \\( \kappa \\) in the paper. To disable EMA, set this to `0.0`. + bias_power (`float`, *optional*, defaults to `0.2`): + Power for the BEMA scaling factor. Denoted \\( \eta \\) in the paper. To disable BEMA, set this to `0.0`. + lag (`int`, *optional*, defaults to `10`): + Initial offset in the weight decay schedule that controls early-stage smoothness by acting as a virtual + starting age for the updates. Denoted as \\( \rho \\) in the paper. + update_after (`int`, *optional*, defaults to `0`): + Burn-in time before starting to update the BEMA weights. Denoted \\( \tau \\) in the paper. + multiplier (`float`, *optional*, defaults to `1.0`): + Initial value for the EMA decay factor. Denoted as \\( \gamma \\) in the paper. + min_ema_multiplier (`float`, *optional*, defaults to `0.0`): + Minimum value for the EMA decay factor. + device (`str`, *optional*, defaults to `"cpu"`): + Device to use for the BEMA buffers, e.g. `"cpu"` or `"cuda"`. Note that in most cases, this device SHOULD + BE DIFFERENT from the device used for training in order to avoid OOM. + update_ref_model (`bool`, *optional*, defaults to `False`): + Whether to update the reference model with BEMA weights. This creates a lagged, smoothed version of the + main model as the reference model. + ref_model_update_freq (`int`, *optional*, defaults to `400`): + Update the reference model with BEMA weights every this many steps. + ref_model_update_after (`int`, *optional*, defaults to `0`): + Number of steps to wait before starting to update the reference model. + + Example: + + ```python + from trl import BEMACallback + + trainer = Trainer(..., callbacks=[BEMACallback()]) + ``` + """ + + def __init__( + self, + update_freq: int = 400, + ema_power: float = 0.5, + bias_power: float = 0.2, + lag: int = 10, + update_after: int = 0, + multiplier: float = 1.0, + min_ema_multiplier: float = 0.0, + device: str = "cpu", + update_ref_model: bool = False, + ref_model_update_freq: int = 400, + ref_model_update_after: int = 0, + ): + super().__init__( + update_freq, + ema_power, + bias_power, + lag, + update_after, + multiplier, + min_ema_multiplier, + device, + ) + # Reference model update parameters + self.update_ref_model = update_ref_model + self.ref_model_update_freq = ref_model_update_freq + self.ref_model_update_after = ref_model_update_after + + @torch.no_grad() + def on_step_end( + self, args: TrainingArguments, state: TrainerState, control: TrainerControl, model: PreTrainedModel, **kwargs + ): + super().on_step_end(args, state, control, model, **kwargs) + + step = state.global_step + # Update reference model if enabled + if ( + self.update_ref_model + and step >= self.ref_model_update_after + and (step - self.ref_model_update_after) % self.ref_model_update_freq == 0 + ): + if "ref_model" not in kwargs: + raise ValueError("'ref_model' not found in kwargs.") + + ref_model = kwargs["ref_model"] + + # Get the current BEMA state dict + bema_state_dict = self.running_model.state_dict() + + # Handle the case where ref_model is None (PEFT case) + if ref_model is None: + # In PEFT case, ref_model is None and we need to update the base model of the main model + main_model = self._unwrap_model(model) + if hasattr(main_model, "get_base_model"): + # This is a PEFT model, update the base model + base_model = main_model.get_base_model() + self._update_model_with_bema_weights(base_model, bema_state_dict, is_peft_base=True) + else: + # Regular model, update directly + self._update_model_with_bema_weights(main_model, bema_state_dict, is_peft_base=False) + else: + # ref_model is provided, unwrap it and update + ref_model = self._unwrap_model(ref_model) + if hasattr(ref_model, "get_base_model"): + # This is a PEFT model, update the base model + base_model = ref_model.get_base_model() + self._update_model_with_bema_weights(base_model, bema_state_dict, is_peft_base=True) + else: + # Regular model, update directly + self._update_model_with_bema_weights(ref_model, bema_state_dict, is_peft_base=False) + + logger.info("BEMACallback: Updated reference model with BEMA weights") + + def _update_model_with_bema_weights(self, model, bema_state_dict, is_peft_base=False): + """Helper method to update a model with BEMA weights, handling PEFT and distributed scenarios.""" + if is_peft_base: + # For PEFT base models, filter out adapter parameters + filtered_state_dict = {} + for key, value in bema_state_dict.items(): + # Skip adapter parameters + if not key.startswith("lora_") and not key.startswith("adapter_"): + # Remove 'base_model.' prefix if it exists + if key.startswith("base_model."): + base_key = key[len("base_model.") :] + else: + base_key = key + filtered_state_dict[base_key] = value + + # Update the base model + model.load_state_dict(filtered_state_dict, strict=False) + else: + # Regular model, update directly + model.load_state_dict(bema_state_dict, strict=False) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/dpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/dpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..8c50a232dc38c236dc64d79d32714b799ceeea8d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/bema_for_ref_model/dpo_trainer.py @@ -0,0 +1,30 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ...trainer.dpo_trainer import DPOTrainer as _DPOTrainer +from .callback import CallbackHandlerWithRefModel + + +class DPOTrainer(_DPOTrainer): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Replace with a new one that calls the events with the reference model + self.callback_handler = CallbackHandlerWithRefModel( + self.callback_handler.callbacks, + self.model, + self.ref_model, + self.processing_class, + self.optimizer, + self.lr_scheduler, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..57e151f53f63b9af52f3b7ba9355e1b3e223fc93 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .cpo_config import CPOConfig +from .cpo_trainer import CPOTrainer + + +__all__ = ["CPOConfig", "CPOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/cpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/cpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..74e1c371300614c80aef18d63ec88627ce3776c7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/cpo_config.py @@ -0,0 +1,172 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class CPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.cpo.CPOTrainer`]. + + This class includes only the parameters that are specific to CPO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the sequences (prompt + completion) in the batch. This argument is required if you want + to use the default data collator. + max_completion_length (`int`, *optional*): + Maximum length of the completion. This argument is required if you want to use the default data collator + and your model is an encoder-decoder. + beta (`float`, *optional*, defaults to `0.1`): + Parameter controlling the deviation from the reference model. Higher β means less deviation from the + reference model. For the IPO loss (`loss_type="ipo"`), β is the regularization parameter denoted by τ in + the [paper](https://huggingface.co/papers/2310.12036). + label_smoothing (`float`, *optional*, defaults to `0.0`): + Label smoothing factor. This argument is required if you want to use the default data collator. + loss_type (`str`, *optional*, defaults to `"sigmoid"`): + Type of loss to use. Possible values are: + + - `"sigmoid"`: sigmoid loss from the original [DPO](https://huggingface.co/papers/2305.18290) paper. + - `"hinge"`: hinge loss on the normalized likelihood from the + [SLiC](https://huggingface.co/papers/2305.10425) paper. + - `"ipo"`: IPO loss from the [IPO](https://huggingface.co/papers/2310.12036) paper. + - `"simpo"`: SimPO loss from the [SimPO](https://huggingface.co/papers/2405.14734) paper. + - `"alphapo"`: AlphaPO loss from the [AlphaPO](https://huggingface.co/papers/2501.03884) paper. This + automatically sets `loss_type="simpo"` and `cpo_alpha=0.0`. + + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + cpo_alpha (`float`, *optional*, defaults to `1.0`): + Weight of the BC regularizer in CPO training. + simpo_gamma (`float`, *optional*, defaults to `0.5`): + Target reward margin for the SimPO loss, used only when the `loss_type="simpo"`. + alpha (`float`, *optional*, defaults to `0.0`): + Alpha parameter that controls reward function shape across all loss types. When alpha=0 (default), uses + standard log probability rewards. When `alpha != 0`, applies AlphaPO transformation: `r = (1 - p^(-alpha)) + / alpha` from the [AlphaPO paper](https://huggingface.co/papers/2501.03884). This parameter works with all + loss types. + generate_during_eval (`bool`, *optional*, defaults to `False`): + If `True`, generates and logs completions from the model to W&B or Comet during evaluation. + is_encoder_decoder (`bool`, *optional*): + When using the `model_init` argument (callable) to instantiate the model instead of the `model` argument, + you need to specify if the model returned by the callable is an encoder-decoder model. + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model from a + string. + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + max_length: int | None = field( + default=1024, + metadata={"help": "Maximum length of the sequences (prompt + completion) in the batch."}, + ) + max_completion_length: int | None = field( + default=None, + metadata={ + "help": "Maximum length of the completion. This argument is required if you want to use the default data " + "collator and your model is an encoder-decoder." + }, + ) + beta: float = field( + default=0.1, + metadata={ + "help": "Parameter controlling the deviation from the reference model. Higher β means less deviation from " + "the reference model." + }, + ) + label_smoothing: float = field( + default=0.0, + metadata={"help": "Label smoothing factor."}, + ) + loss_type: str = field( + default="sigmoid", + metadata={ + "help": "Type of loss to use.", + "choices": ["sigmoid", "hinge", "ipo", "simpo", "alphapo"], + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model."}, + ) + cpo_alpha: float = field( + default=1.0, + metadata={"help": "Weight of the BC regularizer in CPO training."}, + ) + simpo_gamma: float = field( + default=0.5, + metadata={"help": "Target reward margin for the SimPO loss, used only when the `loss_type='simpo'`."}, + ) + alpha: float = field( + default=0.0, + metadata={ + "help": "Alpha parameter that controls reward function shape across all loss types. When alpha=0 " + "(default), uses standard log probability rewards. When `alpha != 0`, applies AlphaPO transformation: " + "`r = (1 - p^(-alpha)) / alpha` from the AlphaPO paper. This parameter works with all loss types." + }, + ) + generate_during_eval: bool = field( + default=False, + metadata={"help": "If `True`, generates and logs completions from the model to W&B during evaluation."}, + ) + is_encoder_decoder: bool | None = field( + default=None, + metadata={"help": "Whether the model is an encoder-decoder model."}, + ) + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model " + "from a string." + }, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + + def __post_init__(self): + # Syntactic sugar for AlphaPO: set loss_type to "simpo" and cpo_alpha to 0.0 + if self.loss_type == "alphapo": + self.loss_type = "simpo" + self.cpo_alpha = 0.0 + + super().__post_init__() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/cpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/cpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..f3e0f39920e0d33cd00e7416ee59b3b186bb5d80 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/cpo/cpo_trainer.py @@ -0,0 +1,1061 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import inspect +import random +import textwrap +from collections import defaultdict +from collections.abc import Callable +from contextlib import nullcontext +from pathlib import Path +from typing import Any, Literal + +import numpy as np +import pandas as pd +import torch +import torch.nn as nn +import torch.nn.functional as F +import transformers +from accelerate import PartialState, logging +from datasets import Dataset +from packaging.version import Version +from torch import autocast +from torch.utils.data import DataLoader +from transformers import ( + AutoModelForCausalLM, + BaseImageProcessor, + DataCollator, + FeatureExtractionMixin, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + is_comet_available, + is_wandb_available, +) +from transformers.trainer_utils import EvalLoopOutput +from transformers.utils import is_peft_available, is_torch_fx_proxy + +from ...data_utils import maybe_apply_chat_template, maybe_extract_prompt +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import disable_dropout_in_model, log_table_to_comet_experiment, selective_log_softmax +from ..utils import ( + DPODataCollatorWithPadding, + add_bos_token_if_needed, + add_eos_token_if_needed, + pad_to_length, + peft_module_casting_to_bf16, +) +from .cpo_config import CPOConfig + + +if is_peft_available(): + from peft import PeftModel, get_peft_model, prepare_model_for_kbit_training + + +if is_wandb_available(): + import wandb + + +logger = logging.get_logger(__name__) + + +class CPOTrainer(_BaseTrainer): + r""" + Initialize CPOTrainer. + + Args: + model ([`~transformers.PreTrainedModel`]): + The model to train, preferably an [`~transformers.AutoModelForSequenceClassification`]. + args ([`experimental.cpo.CPOConfig`]): + The CPO config arguments to use for training. + data_collator ([`~transformers.DataCollator`]): + The data collator to use for training. If None is specified, the default data collator + ([`experimental.utils.DPODataCollatorWithPadding`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + train_dataset ([`~datasets.Dataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`]): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + model_init (`Callable[[], transformers.PreTrainedModel]`): + The model initializer to use for training. If None is specified, the default model initializer will be + used. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + peft_config (`dict`, defaults to `None`): + The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in + a PEFT model. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + """ + + _tag_names = ["trl", "cpo"] + _name = "CPO" + _paper = { + "title": "Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation", + "id": "2401.08417", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{xu2024contrastive, + title = {{Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation}}, + author = {Haoran Xu and Amr Sharaf and Yunmo Chen and Weiting Tan and Lingfeng Shen and Benjamin Van Durme and Kenton Murray and Young Jin Kim}, + year = 2024, + booktitle = {Forty-first International Conference on Machine Learning, {ICML} 2024, Vienna, Austria, July 21-27, 2024}, + publisher = {OpenReview.net}, + url = {https://openreview.net/forum?id=51iwkioZpn} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str | None = None, + args: CPOConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + model_init: Callable[[], PreTrainedModel] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: dict | None = None, + compute_metrics: Callable[[EvalLoopOutput], dict] | None = None, + ): + if train_dataset is None: + raise ValueError("`train_dataset` is required") + + if args.model_init_kwargs is None: + model_init_kwargs = {} + elif not isinstance(model, str): + raise ValueError("You passed model_kwargs to the CPOTrainer. But your model is already instantiated.") + else: + model_init_kwargs = args.model_init_kwargs + dtype = model_init_kwargs.get("dtype", "auto") + if dtype is not None: + # Convert to `torch.dtype` if an str is passed + if isinstance(dtype, str) and dtype != "auto": + dtype = getattr(torch, dtype) + if dtype != "auto" and not isinstance(dtype, torch.dtype): + raise ValueError( + f"Invalid `dtype` passed to the CPOConfig. Expected a string with either `torch.dtype` or 'auto', but got {dtype}." + ) + model_init_kwargs["dtype"] = dtype + model_init_kwargs["device_map"] = model_init_kwargs.get("device_map", "auto") + + if isinstance(model, str): + model = AutoModelForCausalLM.from_pretrained(model, **model_init_kwargs) + + # Initialize this variable to False. This helps tracking the case when `peft_module_casting_to_bf16` + # has been called in order to properly call autocast if needed. + self._peft_has_been_casted_to_bf16 = False + + if not is_peft_available() and peft_config is not None: + raise ValueError( + "PEFT is not installed and you passed a `peft_config` in the trainer's kwargs, please install it to use the PEFT models" + ) + elif is_peft_available() and peft_config is not None: + if isinstance(model, PeftModel): + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first " + "merge and unload the existing adapter, save the resulting base model, and then pass that base " + "model along with the new `peft_config` to the trainer." + ) + + if getattr(model, "is_loaded_in_8bit", False) or getattr(model, "is_loaded_in_4bit", False): + _support_gc_kwargs = hasattr( + args, "gradient_checkpointing_kwargs" + ) and "gradient_checkpointing_kwargs" in list( + inspect.signature(prepare_model_for_kbit_training).parameters + ) + + prepare_model_kwargs = {"use_gradient_checkpointing": args.gradient_checkpointing} + + if _support_gc_kwargs: + prepare_model_kwargs["gradient_checkpointing_kwargs"] = args.gradient_checkpointing_kwargs + + model = prepare_model_for_kbit_training(model, **prepare_model_kwargs) + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + # get peft model with the given config + model = get_peft_model(model, peft_config) + if args.bf16 and getattr(model, "is_loaded_in_4bit", False): + peft_module_casting_to_bf16(model) + # If args.bf16 we need to explicitly call `generate` with torch amp autocast context manager + self._peft_has_been_casted_to_bf16 = True + + # For models that use gradient_checkpointing, we need to attach a hook that enables input + # to explicitly have `requires_grad=True`, otherwise training will either silently + # fail or completely fail. + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + if args.generate_during_eval and not (is_wandb_available() or is_comet_available()): + raise ValueError( + "`generate_during_eval=True` requires Weights and Biases or Comet to be installed." + " Please install `wandb` or `comet-ml` to resolve." + ) + + if model is not None: + self.is_encoder_decoder = model.config.is_encoder_decoder + elif args.is_encoder_decoder is None: + raise ValueError("When no model is provided, you need to pass the parameter is_encoder_decoder.") + else: + self.is_encoder_decoder = args.is_encoder_decoder + + if self.is_encoder_decoder: + self.decoder_start_token_id = model.config.decoder_start_token_id + self.pad_token_id = model.config.pad_token_id + + if processing_class is None: + raise ValueError("processing_class must be specified to tokenize a CPO dataset.") + if args.max_length is None: + logger.warning( + "`max_length` is not set in the CPOConfig's init" + " it will default to `512` by default, but you should do it yourself in the future.", + ) + max_length = 512 + else: + max_length = args.max_length + + if args.max_completion_length is None and self.is_encoder_decoder: + logger.warning( + "When using an encoder decoder architecture, you should set `max_completion_length` in the CPOConfig's init" + " it will default to `128` by default, but you should do it yourself in the future.", + ) + max_completion_length = 128 + else: + max_completion_length = args.max_completion_length + + if data_collator is None: + data_collator = DPODataCollatorWithPadding( + pad_token_id=processing_class.pad_token_id, + is_encoder_decoder=self.is_encoder_decoder, + ) + + if args.remove_unused_columns: + args.remove_unused_columns = False + # warn users + logger.warning( + "When using DPODataCollatorWithPadding, you should set `remove_unused_columns=False` in your TrainingArguments" + " we have set it for you, but you should do it yourself in the future.", + ) + + self.use_dpo_data_collator = True + else: + self.use_dpo_data_collator = False + + # Disable dropout in the model + if args.disable_dropout: + disable_dropout_in_model(model) + + self.max_length = max_length + self.generate_during_eval = args.generate_during_eval + self.max_completion_length = max_completion_length + self.processing_class = processing_class + + if processing_class.pad_token is None: + processing_class.pad_token = processing_class.eos_token + self.pad_token_id = processing_class.pad_token_id + + if args.loss_type in ["hinge", "ipo"] and args.label_smoothing > 0: + logger.warning( + f"You are using the {args.loss_type} loss type that does not support label smoothing. The " + "`label_smoothing` parameter will be ignored. Set `label_smoothing` to `0.0` to remove this warning.", + ) + if args.loss_type == "kto_pair": + raise ValueError("Support for kto_pair has been removed in CPOTrainer. Please use KTOTrainer.") + + self.beta = args.beta + self.label_smoothing = args.label_smoothing + self.loss_type = args.loss_type + self.cpo_alpha = args.cpo_alpha + self.aux_loss_enabled = getattr(model.config, "output_router_logits", False) + self.aux_loss_coef = getattr(model.config, "router_aux_loss_coef", 0.0) + if self.aux_loss_enabled and self.aux_loss_coef == 0.0: + logger.warning( + "You set `output_router_logits` to `True` in the model config, but `router_aux_loss_coef` is set to " + "`0.0`, meaning the auxiliary loss will not be used. Either set `router_aux_loss_coef` to a value " + "greater than `0.0`, or set `output_router_logits` to `False` if you don't want to use the auxiliary " + "loss.", + ) + + if args.loss_type == "simpo": + self.simpo_gamma = args.simpo_gamma + + # AlphaPO parameter for reward shaping + self.alpha = args.alpha + + self._stored_metrics = defaultdict(lambda: defaultdict(list)) + + # Compute that only on the main process for faster data processing. + # see: https://github.com/huggingface/trl/pull/1255 + with PartialState().main_process_first(): + # Extract the prompt if needed, and apply the chat template if needed + train_dataset = train_dataset.map(maybe_extract_prompt, num_proc=args.dataset_num_proc) + train_dataset = train_dataset.map( + maybe_apply_chat_template, + fn_kwargs={"processing_class": processing_class}, + num_proc=args.dataset_num_proc, + ) + if eval_dataset is not None: + eval_dataset = eval_dataset.map(maybe_extract_prompt, num_proc=args.dataset_num_proc) + eval_dataset = eval_dataset.map( + maybe_apply_chat_template, + fn_kwargs={"processing_class": processing_class}, + num_proc=args.dataset_num_proc, + ) + + # tokenize the dataset + train_dataset = train_dataset.map(self.tokenize_row, num_proc=args.dataset_num_proc) + if eval_dataset is not None: + eval_dataset = eval_dataset.map(self.tokenize_row, num_proc=args.dataset_num_proc) + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + model_init=model_init, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Add tags for models that have been loaded with the correct transformers version + if hasattr(self.model, "add_model_tags"): + self.model.add_model_tags(self._tag_names) + + if not hasattr(self, "accelerator"): + raise AttributeError( + "Your `Trainer` does not have an `accelerator` object. Consider upgrading `transformers`." + ) + + def build_tokenized_answer(self, prompt, answer): + """ + Llama tokenizer does satisfy `enc(a + b) = enc(a) + enc(b)`. It does ensure `enc(a + b) = enc(a) + enc(a + + b)[len(enc(a)):]`. Reference: + https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257 + """ + + full_tokenized = self.processing_class(prompt + answer, add_special_tokens=False) + prompt_input_ids = self.processing_class(prompt, add_special_tokens=False)["input_ids"] + + answer_input_ids = full_tokenized["input_ids"][len(prompt_input_ids) :] + answer_attention_mask = full_tokenized["attention_mask"][len(prompt_input_ids) :] + + # Concat tokens to form `enc(a) + enc(a + b)[len(enc(a)):]` + full_concat_input_ids = np.concatenate([prompt_input_ids, answer_input_ids]) + + # Prepare input tokens for token by token comparison + full_input_ids = np.array(full_tokenized["input_ids"]) + + if len(full_input_ids) != len(full_concat_input_ids): + raise ValueError("Prompt input ids and answer input ids should have the same length.") + + # On some tokenizers, like Llama-2 tokenizer, there are occasions where tokens + # can be merged together when tokenizing prompt+answer. This could result + # on the last token from the prompt being different when tokenized on its own + # vs when done as prompt+answer. + response_token_ids_start_idx = len(prompt_input_ids) + + # If tokenized prompt is different than both prompt+answer, then it means the + # last token has changed due to merging. + if prompt_input_ids != full_tokenized["input_ids"][:response_token_ids_start_idx]: + response_token_ids_start_idx -= 1 + + prompt_input_ids = full_tokenized["input_ids"][:response_token_ids_start_idx] + prompt_attention_mask = full_tokenized["attention_mask"][:response_token_ids_start_idx] + + if len(prompt_input_ids) != len(prompt_attention_mask): + raise ValueError("Prompt input ids and attention mask should have the same length.") + + answer_input_ids = full_tokenized["input_ids"][response_token_ids_start_idx:] + answer_attention_mask = full_tokenized["attention_mask"][response_token_ids_start_idx:] + + return dict( + prompt_input_ids=prompt_input_ids, + prompt_attention_mask=prompt_attention_mask, + input_ids=answer_input_ids, + attention_mask=answer_attention_mask, + ) + + def tokenize_row(self, feature, model: PreTrainedModel | nn.Module | None = None) -> dict: + """Tokenize a single row from a CPO specific dataset. + + At this stage, we don't convert to PyTorch tensors yet; we just handle the truncation in case the prompt + + chosen or prompt + rejected responses is/are too long. First we truncate the prompt; if we're still too long, + we truncate the chosen/rejected. + + We also create the labels for the chosen/rejected responses, which are of length equal to the sum of the length + of the prompt and the chosen/rejected response, with `-100` for the prompt tokens. + """ + batch = {} + prompt = feature["prompt"] + chosen = feature["chosen"] + rejected = feature["rejected"] + + if not self.is_encoder_decoder: + # Check issues below for more details + # 1. https://github.com/huggingface/trl/issues/907 + # 2. https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257 + # 3. https://github.com/LianjiaTech/BELLE/issues/337 + + if not isinstance(prompt, str): + raise ValueError(f"prompt should be an str but got {type(prompt)}") + prompt_tokens = self.processing_class(prompt, add_special_tokens=False) + prompt_tokens = {f"prompt_{k}": v for k, v in prompt_tokens.items()} + + if not isinstance(chosen, str): + raise ValueError(f"chosen should be an str but got {type(chosen)}") + chosen_tokens = self.build_tokenized_answer(prompt, chosen) + + if not isinstance(rejected, str): + raise ValueError(f"rejected should be an str but got {type(rejected)}") + rejected_tokens = self.build_tokenized_answer(prompt, rejected) + + # Last prompt token might get merged by tokenizer and + # it should not be included for generation if that happens + prompt_len_input_ids = len(prompt_tokens["prompt_input_ids"]) + + chosen_prompt_len_input_ids = len(chosen_tokens["prompt_input_ids"]) + rejected_prompt_len_input_ids = len(rejected_tokens["prompt_input_ids"]) + prompt_len_input_ids = min(chosen_prompt_len_input_ids, rejected_prompt_len_input_ids) + + for k, v in prompt_tokens.items(): + prompt_tokens[k] = v[:prompt_len_input_ids] + + # Make sure prompts only have one different token at most an + # and length only differs by 1 at most + num_diff_tokens = sum( + a != b + for a, b in zip(chosen_tokens["prompt_input_ids"], rejected_tokens["prompt_input_ids"], strict=False) + ) + num_diff_len = abs(chosen_prompt_len_input_ids - rejected_prompt_len_input_ids) + if num_diff_tokens > 1 or num_diff_len > 1: + raise ValueError( + "Chosen and rejected prompt_input_ids might only differ on the " + "last token due to tokenizer merge ops." + ) + + # add BOS token to head of prompt. Avoid adding if it's already there + prompt_tokens, chosen_tokens, rejected_tokens = add_bos_token_if_needed( + self.processing_class.bos_token_id, + prompt_len_input_ids, + prompt_tokens, + chosen_prompt_len_input_ids, + chosen_tokens, + rejected_prompt_len_input_ids, + rejected_tokens, + ) + + # add EOS token to end of answer. Avoid adding if it's already there + chosen_tokens, rejected_tokens = add_eos_token_if_needed( + self.processing_class.eos_token_id, chosen_tokens, rejected_tokens + ) + + longer_response_length = max(len(chosen_tokens["input_ids"]), len(rejected_tokens["input_ids"])) + + # if combined sequence is too long, truncate the response + for answer_tokens in [chosen_tokens, rejected_tokens]: + if len(answer_tokens["prompt_input_ids"]) + longer_response_length > self.max_length: + for k in ["input_ids", "attention_mask"]: + answer_tokens[k] = answer_tokens[k][: self.max_length - longer_response_length] + + # Create labels + chosen_sequence_tokens = { + k: chosen_tokens[f"prompt_{k}"] + chosen_tokens[k] for k in ["input_ids", "attention_mask"] + } + rejected_sequence_tokens = { + k: rejected_tokens[f"prompt_{k}"] + rejected_tokens[k] for k in ["input_ids", "attention_mask"] + } + chosen_sequence_tokens["labels"] = chosen_sequence_tokens["input_ids"][:] + chosen_sequence_tokens["labels"][: len(chosen_tokens["prompt_input_ids"])] = [-100] * len( + chosen_tokens["prompt_input_ids"] + ) + rejected_sequence_tokens["labels"] = rejected_sequence_tokens["input_ids"][:] + rejected_sequence_tokens["labels"][: len(rejected_tokens["prompt_input_ids"])] = [-100] * len( + rejected_tokens["prompt_input_ids"] + ) + + for k, toks in { + "chosen_": chosen_sequence_tokens, + "rejected_": rejected_sequence_tokens, + "": prompt_tokens, + }.items(): + for type_key, tokens in toks.items(): + if type_key == "token_type_ids": + continue + batch[f"{k}{type_key}"] = tokens + + else: + chosen_tokens = self.processing_class( + chosen, truncation=True, max_length=self.max_completion_length, add_special_tokens=True + ) + rejected_tokens = self.processing_class( + rejected, truncation=True, max_length=self.max_completion_length, add_special_tokens=True + ) + prompt_tokens = self.processing_class(prompt, add_special_tokens=True) + + batch["chosen_labels"] = chosen_tokens["input_ids"] + batch["rejected_labels"] = rejected_tokens["input_ids"] + batch["prompt_input_ids"] = prompt_tokens["input_ids"] + batch["prompt_attention_mask"] = prompt_tokens["attention_mask"] + + if model is not None and hasattr(model, "prepare_decoder_input_ids_from_labels"): + batch["rejected_decoder_input_ids"] = model.prepare_decoder_input_ids_from_labels( + labels=torch.tensor(batch["rejected_labels"]) + ) + batch["chosen_decoder_input_ids"] = model.prepare_decoder_input_ids_from_labels( + labels=torch.tensor(batch["chosen_labels"]) + ) + + return batch + + @staticmethod + def concatenated_inputs( + batch: dict[str, list | torch.LongTensor], + is_encoder_decoder: bool = False, + padding_value: int = 0, + device: torch.device | None = None, + ) -> dict[str, torch.LongTensor]: + """Concatenate the chosen and rejected inputs into a single tensor. + + Args: + batch: + A batch of data. Must contain the keys 'chosen_input_ids' and 'rejected_input_ids', which are tensors + of shape (batch_size, sequence_length). + is_encoder_decoder: + Whether the model is an encoder-decoder model. + padding_value: + The padding value to use for the concatenated inputs_ids. + device: + The device for the concatenated inputs. + + Returns: + A dictionary containing the concatenated inputs under the key 'concatenated_input_ids'. + """ + concatenated_batch = {} + + if is_encoder_decoder: + max_length = max(batch["chosen_labels"].shape[1], batch["rejected_labels"].shape[1]) + else: + max_length = max(batch["chosen_input_ids"].shape[1], batch["rejected_input_ids"].shape[1]) + + for k in batch: + if k.startswith("chosen") and isinstance(batch[k], torch.Tensor): + if "labels" in k or is_encoder_decoder: + pad_value = -100 + elif k.endswith("_input_ids"): + pad_value = padding_value + elif k.endswith("_attention_mask"): + pad_value = 0 + concatenated_key = k.replace("chosen", "concatenated") + concatenated_batch[concatenated_key] = pad_to_length(batch[k], max_length, pad_value=pad_value) + for k in batch: + if k.startswith("rejected") and isinstance(batch[k], torch.Tensor): + if "labels" in k or is_encoder_decoder: + pad_value = -100 + elif k.endswith("_input_ids"): + pad_value = padding_value + elif k.endswith("_attention_mask"): + pad_value = 0 + concatenated_key = k.replace("rejected", "concatenated") + concatenated_batch[concatenated_key] = torch.cat( + ( + concatenated_batch[concatenated_key], + pad_to_length(batch[k], max_length, pad_value=pad_value), + ), + dim=0, + ).to(device=device) + + if is_encoder_decoder: + concatenated_batch["concatenated_input_ids"] = batch["prompt_input_ids"].repeat(2, 1).to(device=device) + concatenated_batch["concatenated_attention_mask"] = ( + batch["prompt_attention_mask"].repeat(2, 1).to(device=device) + ) + + return concatenated_batch + + def cpo_loss( + self, + policy_chosen_logps: torch.FloatTensor, + policy_rejected_logps: torch.FloatTensor, + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + """Compute the CPO loss for a batch of policy and reference model log probabilities. + + Args: + policy_chosen_logps: + Log probabilities of the policy model for the chosen responses. Shape: (batch_size,) + policy_rejected_logps: + Log probabilities of the policy model for the rejected responses. Shape: (batch_size,) + + Returns: + A tuple of three tensors: (losses, chosen_rewards, rejected_rewards). The losses tensor contains the CPO + loss for each example in the batch. The chosen_rewards and rejected_rewards tensors contain the rewards for + the chosen and rejected responses, respectively. + """ + # Apply AlphaPO reward transformation if alpha != 0 + if self.alpha != 0.0: + # Compute probabilities + chosen_probs = torch.exp(policy_chosen_logps) + rejected_probs = torch.exp(policy_rejected_logps) + + # Apply AlphaPO transformation: r = (1 - p^(-alpha)) / alpha + policy_chosen_rewards = (1 - chosen_probs.pow(-self.alpha)) / self.alpha + policy_rejected_rewards = (1 - rejected_probs.pow(-self.alpha)) / self.alpha + + logits = (policy_chosen_rewards - policy_rejected_rewards).to(self.accelerator.device) + else: + # Standard log probability rewards when alpha = 0 + logits = (policy_chosen_logps - policy_rejected_logps).to(self.accelerator.device) + + # The beta is a temperature parameter for the CPO loss, typically something in the range of 0.1 to 0.5. + # We ignore the reference model as beta -> 0. The label_smoothing parameter encodes our uncertainty about the labels and + # calculates a conservative CPO loss. + + if self.loss_type == "simpo": + gamma_logratios = self.simpo_gamma / self.beta + logits = logits - gamma_logratios + # This reduces to Equation 3 from the CPO paper when label_smoothing -> 0. + losses = ( + -F.logsigmoid(self.beta * logits) * (1 - self.label_smoothing) + - F.logsigmoid(-self.beta * logits) * self.label_smoothing + ) + elif self.loss_type == "sigmoid": + # This reduces to Equation 3 from the CPO paper when label_smoothing -> 0. + losses = ( + -F.logsigmoid(self.beta * logits) * (1 - self.label_smoothing) + - F.logsigmoid(-self.beta * logits) * self.label_smoothing + ) + elif self.loss_type == "hinge": + losses = torch.relu(1 - self.beta * logits) + elif self.loss_type == "ipo": + # eqn (17) of the paper where beta is the regularization parameter for the IPO loss, denoted by tau in the paper. + losses = (logits - 1 / (2 * self.beta)) ** 2 + else: + raise ValueError( + f"Unknown loss type: {self.loss_type}. Should be one of ['sigmoid', 'hinge', 'ipo', 'simpo']" + ) + + # Calculate rewards for logging + if self.alpha != 0.0: + # When using AlphaPO transformation, use the transformed rewards + chosen_rewards = self.beta * policy_chosen_rewards.to(self.accelerator.device).detach() + rejected_rewards = self.beta * policy_rejected_rewards.to(self.accelerator.device).detach() + else: + # Standard log probability rewards + chosen_rewards = self.beta * (policy_chosen_logps.to(self.accelerator.device)).detach() + rejected_rewards = self.beta * (policy_rejected_logps.to(self.accelerator.device)).detach() + + return losses, chosen_rewards, rejected_rewards + + @staticmethod + def get_batch_logps( + logits: torch.FloatTensor, + labels: torch.LongTensor, + average_log_prob: bool = False, + is_encoder_decoder: bool = False, + ) -> torch.FloatTensor: + """Compute the log probabilities of the given labels under the given logits. + + Args: + logits: Logits of the model (unnormalized). Shape: (batch_size, sequence_length, vocab_size) + labels: + Labels for which to compute the log probabilities. Label tokens with a value of `-100` are ignored. + Shape: (batch_size, sequence_length) + average_log_prob: + If True, return the average log probability per (non-masked) token. Otherwise, return the sum of the + log probabilities of the (non-masked) tokens. + is_encoder_decoder: Whether the model is an encoder-decoder model. + + Returns: + A tensor of shape (batch_size,) containing the average/sum log probabilities of the given labels under the + given logits. + """ + if logits.shape[:-1] != labels.shape: + raise ValueError("Logits (batch and sequence length dim) and labels must have the same shape.") + + if not is_encoder_decoder: + labels = labels[:, 1:].clone() + logits = logits[:, :-1, :] + loss_mask = labels != -100 + + # dummy token; we'll ignore the losses on these tokens later + labels[labels == -100] = 0 + + per_token_logps = selective_log_softmax(logits, labels) + + if average_log_prob: + return (per_token_logps * loss_mask).sum(-1) / loss_mask.sum(-1) + else: + return (per_token_logps * loss_mask).sum(-1) + + def concatenated_forward( + self, model: nn.Module, batch: dict[str, list | torch.LongTensor] + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + """Run the given model on the given batch of inputs, concatenating the chosen and rejected inputs together. + + We do this to avoid doing two forward passes, because it's faster for FSDP. + """ + concatenated_batch = self.concatenated_inputs( + batch, + is_encoder_decoder=self.is_encoder_decoder, + padding_value=self.pad_token_id, + device=self.accelerator.device, + ) + len_chosen = batch["chosen_labels"].shape[0] + + model_kwargs = ( + { + "decoder_input_ids": self._shift_right(concatenated_batch["concatenated_labels"]), + } + if self.is_encoder_decoder + else {} + ) + + if self.aux_loss_enabled: + model_kwargs["output_router_logits"] = True + + outputs = model( + concatenated_batch["concatenated_input_ids"], + attention_mask=concatenated_batch["concatenated_attention_mask"], + use_cache=False, + **model_kwargs, + ) + all_logits = outputs.logits + + def cross_entropy_loss(logits, labels): + if not self.is_encoder_decoder: + # Shift so that tokens < n predict n + logits = logits[..., :-1, :].contiguous() + labels = labels[..., 1:].contiguous() + # Flatten the tokens + loss_fct = nn.CrossEntropyLoss() + logits = logits.view(-1, logits.shape[-1]) + labels = labels.view(-1) + # Enable model parallelism + labels = labels.to(logits.device) + loss = loss_fct(logits, labels) + return loss + + labels = concatenated_batch["concatenated_labels"].clone() + + if self.cpo_alpha == 0: + nll_loss = torch.tensor(0.0).to(self.accelerator.device) + else: + nll_loss = cross_entropy_loss(all_logits[:len_chosen], labels[:len_chosen]) + + all_logps = self.get_batch_logps( + all_logits, + concatenated_batch["concatenated_labels"], + average_log_prob=self.loss_type in ["ipo", "simpo"], + is_encoder_decoder=self.is_encoder_decoder, + ) + + chosen_logps = all_logps[:len_chosen] + rejected_logps = all_logps[len_chosen:] + + chosen_logits = all_logits[:len_chosen] + rejected_logits = all_logits[len_chosen:] + + if self.aux_loss_enabled: + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, nll_loss, outputs.aux_loss) + + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, nll_loss) + + def get_batch_loss_metrics( + self, + model, + batch: dict[str, list | torch.LongTensor], + train_eval: Literal["train", "eval"] = "train", + ): + """Compute the CPO loss and other metrics for the given batch of inputs for train or test.""" + metrics = {} + + forward_output = self.concatenated_forward(model, batch) + ( + policy_chosen_logps, + policy_rejected_logps, + policy_chosen_logits, + policy_rejected_logits, + policy_nll_loss, + ) = forward_output[:5] + if self.aux_loss_enabled: + aux_loss = forward_output[5] + + losses, chosen_rewards, rejected_rewards = self.cpo_loss( + policy_chosen_logps, + policy_rejected_logps, + ) + + loss = losses.mean() + self.cpo_alpha * policy_nll_loss + reward_accuracies = (chosen_rewards > rejected_rewards).float() + + prefix = "eval_" if train_eval == "eval" else "" + metrics[f"{prefix}rewards/chosen"] = self.accelerator.gather_for_metrics(chosen_rewards).mean().item() + metrics[f"{prefix}rewards/rejected"] = self.accelerator.gather_for_metrics(rejected_rewards).mean().item() + metrics[f"{prefix}rewards/accuracies"] = self.accelerator.gather_for_metrics(reward_accuracies).mean().item() + metrics[f"{prefix}rewards/margins"] = ( + self.accelerator.gather_for_metrics(chosen_rewards - rejected_rewards).mean().item() + ) + metrics[f"{prefix}logps/rejected"] = ( + self.accelerator.gather_for_metrics(policy_rejected_logps).detach().mean().item() + ) + metrics[f"{prefix}logps/chosen"] = ( + self.accelerator.gather_for_metrics(policy_chosen_logps).detach().mean().item() + ) + metrics[f"{prefix}logits/rejected"] = ( + self.accelerator.gather_for_metrics(policy_rejected_logits.detach().mean()).mean().item() + ) + metrics[f"{prefix}logits/chosen"] = ( + self.accelerator.gather_for_metrics(policy_chosen_logits.detach().mean()).mean().item() + ) + metrics[f"{prefix}nll_loss"] = self.accelerator.gather_for_metrics(policy_nll_loss).detach().mean().item() + + if self.aux_loss_enabled: + loss += self.aux_loss_coef * aux_loss + + return loss, metrics + + def compute_loss( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + return_outputs=False, + num_items_in_batch=None, + ) -> torch.Tensor | tuple[torch.Tensor, dict[str, torch.Tensor]]: + compute_loss_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with compute_loss_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs, train_eval="train") + + # force log the metrics + self.store_metrics(metrics, train_eval="train") + + if return_outputs: + return (loss, metrics) + return loss + + def generate_from_model(self, model, batch: dict[str, torch.LongTensor]) -> str: + """Generate samples from the model and reference model for the given batch of inputs.""" + + # If one uses `generate_during_eval` with peft + bf16, we need to explicitly call generate with + # the torch amp context manager as some hidden states are silently casted to full precision. + generate_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with generate_context_manager: + policy_output = model.generate( + input_ids=batch["prompt_input_ids"], + attention_mask=batch["prompt_attention_mask"], + max_length=self.max_length, + do_sample=True, + pad_token_id=self.processing_class.pad_token_id, + ) + + policy_output = pad_to_length(policy_output, self.max_length, self.processing_class.pad_token_id) + policy_output_decoded = self.processing_class.batch_decode(policy_output, skip_special_tokens=True) + + return policy_output_decoded + + def prediction_step( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + prediction_loss_only: bool, + ignore_keys: list[str] | None = None, + ): + if ignore_keys is None: + if hasattr(model, "config"): + ignore_keys = getattr(model.config, "keys_to_ignore_at_inference", []) + else: + ignore_keys = [] + + prediction_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with torch.no_grad(), prediction_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs, train_eval="eval") + + # force log the metrics + self.store_metrics(metrics, train_eval="eval") + + if prediction_loss_only: + return (loss.detach(), None, None) + + # logits for the chosen and rejected samples from model + logits_dict = { + "eval_logits/chosen": metrics["eval_logits/chosen"], + "eval_logits/rejected": metrics["eval_logits/rejected"], + } + logits = [v for k, v in logits_dict.items() if k not in ignore_keys] + logits = torch.tensor(logits, device=self.accelerator.device) + labels = torch.zeros(logits.shape[0], device=self.accelerator.device) + + return (loss.detach(), logits, labels) + + def store_metrics(self, metrics: dict[str, float], train_eval: Literal["train", "eval"] = "train") -> None: + for key, value in metrics.items(): + self._stored_metrics[train_eval][key].append(value) + + def evaluation_loop( + self, + dataloader: DataLoader, + description: str, + prediction_loss_only: bool | None = None, + ignore_keys: list[str] | None = None, + metric_key_prefix: str = "eval", + ) -> EvalLoopOutput: + """ + Overriding built-in evaluation loop to store metrics for each batch. Prediction/evaluation loop, shared by + `Trainer.evaluate()` and `Trainer.predict()`. + + Works both with or without labels. + """ + + # Sample and save to game log if requested (for one batch to save time) + if self.generate_during_eval: + # Generate random indices within the range of the total number of samples + num_samples = len(dataloader.dataset) + random_indices = random.sample(range(num_samples), k=self.args.eval_batch_size) + + # Use dataloader.dataset.select to get the random batch without iterating over the DataLoader + random_batch_dataset = dataloader.dataset.select(random_indices) + random_batch = self.data_collator(random_batch_dataset) + random_batch = self._prepare_inputs(random_batch) + + policy_output_decoded = self.generate_from_model(self.model, random_batch) + + table = pd.DataFrame( + columns=["Prompt", "Policy"], + data=[ + [prompt, pol[len(prompt) :]] + for prompt, pol in zip(random_batch["prompt"], policy_output_decoded, strict=True) + ], + ) + if "wandb" in self.args.report_to: + wandb.log({"game_log": wandb.Table(data=table)}) + + if "comet_ml" in self.args.report_to: + log_table_to_comet_experiment( + name="game_log.csv", + table=table, + ) + + # Base evaluation + initial_output = super().evaluation_loop( + dataloader, description, prediction_loss_only, ignore_keys, metric_key_prefix + ) + + return initial_output + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + """ + Log `logs` on the various objects watching training, including stored metrics. + + Args: + logs (`dict[str, float]`): + The values to log. + start_time (`float`, *optional*): + Start time of the training. + """ + # logs either has 'loss' or 'eval_loss' + train_eval = "train" if "loss" in logs else "eval" + # Add averaged stored metrics to logs + for key, metrics in self._stored_metrics[train_eval].items(): + logs[key] = torch.tensor(metrics).mean().item() + del self._stored_metrics[train_eval] + return super().log(logs, start_time) + + def _shift_right(self, input_ids): + if self.decoder_start_token_id is None: + raise ValueError( + "model.config.decoder_start_token_id has to be defined. It is usually set to the pad_token_id." + ) + + # shift inputs to the right + if is_torch_fx_proxy(input_ids): + # Item assignment is not supported natively for proxies. + shifted_input_ids = torch.full(input_ids.shape[:-1] + (1,), self.decoder_start_token_id) + shifted_input_ids = torch.cat([shifted_input_ids, input_ids[..., :-1]], dim=-1) + else: + shifted_input_ids = input_ids.new_zeros(input_ids.shape) + shifted_input_ids[..., 1:] = input_ids[..., :-1].clone() + shifted_input_ids[..., 0] = self.decoder_start_token_id + + if self.pad_token_id is None: + raise ValueError("model.config.pad_token_id has to be defined.") + # replace possible -100 values in labels by `pad_token_id` + shifted_input_ids.masked_fill_(shifted_input_ids == -100, self.pad_token_id) + + return shifted_input_ids + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..894333c1d01c23f82964cd651ee45a7c3d652e65 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .distillation_config import DistillationConfig +from .distillation_trainer import DistillationTrainer + + +__all__ = ["DistillationConfig", "DistillationTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation.py new file mode 100644 index 0000000000000000000000000000000000000000..368cf4ed03e247c406eed7974239dac5e741d2f5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation.py @@ -0,0 +1,179 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +# docstyle-ignore +""" +# Full training (off-policy only, lmbda=0): +``` +python trl/experimental/distillation/distillation.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2.5-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-5 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --lmbda 0.0 \ + --output_dir distilled-model \ + --num_train_epochs 1 +``` + +# Mixed on/off-policy (lmbda=0.5): +``` +python trl/experimental/distillation/distillation.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2.5-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-5 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --lmbda 0.5 \ + --beta 0.5 \ + --output_dir distilled-model \ + --num_train_epochs 1 +``` + +# LoRA: +``` +python trl/experimental/distillation/distillation.py \ + --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2.5-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-4 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --lmbda 0.0 \ + --output_dir distilled-model \ + --num_train_epochs 1 \ + --use_peft \ + --lora_r 64 \ + --lora_alpha 16 +``` +""" + +import argparse +import os + + +# Enable logging in a Hugging Face Space +os.environ.setdefault("TRACKIO_SPACE_ID", "trl-trackio") + + +def main(script_args, training_args, model_args): + from datasets import load_dataset + from transformers import GenerationConfig + + from trl import ( + LogCompletionsCallback, + get_kbit_device_map, + get_peft_config, + get_quantization_config, + ) + from trl.experimental.distillation import DistillationTrainer + + ################ + # Model init kwargs + ################ + quantization_config = get_quantization_config(model_args) + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + torch_dtype=model_args.dtype, + use_cache=False if training_args.gradient_checkpointing else True, + device_map=get_kbit_device_map() if quantization_config is not None else None, + quantization_config=quantization_config, + ) + training_args.model_init_kwargs = model_kwargs + + teacher_model_kwargs = dict( + revision=training_args.teacher_model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + torch_dtype=model_args.dtype, + use_cache=True, + device_map=get_kbit_device_map() if quantization_config is not None else None, + quantization_config=quantization_config, + ) + if training_args.teacher_model_init_kwargs is not None: + teacher_model_kwargs.update(training_args.teacher_model_init_kwargs) + training_args.teacher_model_init_kwargs = teacher_model_kwargs + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ################ + # Training + ################ + eval_dataset = None + if training_args.eval_strategy != "no": + if script_args.dataset_test_split in dataset: + eval_dataset = dataset[script_args.dataset_test_split] + elif "validation" in dataset: + eval_dataset = dataset["validation"] + elif "dev" in dataset: + eval_dataset = dataset["dev"] + + trainer = DistillationTrainer( + model=model_args.model_name_or_path, + teacher_model=training_args.teacher_model_name_or_path, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + ) + + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_completion_length, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import ModelConfig, ScriptArguments, TrlParser + from trl.experimental.distillation import DistillationConfig + + dataclass_types = (ScriptArguments, DistillationConfig, ModelConfig) + if subparsers is not None: + parser = subparsers.add_parser( + "distillation", help="Run the distillation training script", dataclass_types=dataclass_types + ) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation_config.py new file mode 100644 index 0000000000000000000000000000000000000000..074da155ef87d704569e6e6c33db36fe2633b964 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation_config.py @@ -0,0 +1,451 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class DistillationConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`DistillationTrainer`]. + + Extends [`~transformers.TrainingArguments`] with parameters specific to knowledge distillation. This config is + independent of [`SFTConfig`] — all necessary fields are declared here. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument of the + trainer is provided as a string. + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum total sequence length (prompt + completion) for tokenization and truncation. + + > Parameters that control the distillation + + temperature (`float`, *optional*, defaults to `1.0`): + Temperature for sampling during generation and for computing the distillation loss. Higher values produce + softer probability distributions. + lmbda (`float`, *optional*, defaults to `1.0`): + Probability of using on-policy (student-generated) data for each gradient accumulation slice. A value of + `0.0` means fully off-policy (dataset completions only), `1.0` means fully on-policy. + beta (`float`, *optional*, defaults to `1.0`): + Interpolation coefficient for the Generalized Jensen-Shannon Divergence loss. When `0.0`, the loss is the + forward KL divergence. When `1.0`, the loss is the reverse KL divergence. When `0.5`, it is the standard + JSD. + reverse_kl_top_1_mode (`str`, *optional*, defaults to `"sampled"`): + Selection rule for the reverse-KL top-1 token when `beta > 0` and `loss_top_k == 1`. `"sampled"` uses the + actual completion token in the batch. `"argmax"` uses the student's highest-probability token. This + setting does not affect the forward-KL support, which always uses the teacher's top-1 token. Ignored when + `beta == 0` or `loss_top_k != 1`. + max_completion_length (`int`, *optional*, defaults to `512`): + Maximum number of tokens to generate per completion during on-policy generation. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the student model during training. + + > Parameters that control the teacher model + + teacher_model_name_or_path (`str` or `None`, *optional*): + Model name or path for the teacher model. Used when the teacher is loaded locally. + teacher_model_revision (`str` or `None`, *optional*): + Model revision of the teacher model (e.g., branch name, tag, or commit hash). + teacher_model_init_kwargs (`dict[str, Any]` or `None`, *optional*): + Keyword arguments passed to `AutoModelForCausalLM.from_pretrained` when instantiating the teacher model + from a string. + use_teacher_server (`bool`, *optional*, defaults to `False`): + Whether to use an external vLLM teacher server instead of a local teacher model. + teacher_model_server_url (`str` or `None`, *optional*): + Base URL of a vLLM server hosting the teacher model (e.g., `"http://localhost:8000"`). When set, teacher + logprobs are fetched from the server instead of running a local forward pass when `use_teacher_server=True`. + loss_top_k (`int`, *optional*, defaults to `1`): + Number of top tokens to use when computing the JSD/KL loss. Both student and teacher distributions are + restricted to these K tokens and re-normalized before computing divergence. If 0, the full vocabulary + is used. For local teachers, the general support rule is teacher top-k for forward KL, student top-k for + reverse KL, and the union for mixed JSD. When `beta > 0` and `loss_top_k == 1`, the forward support still + uses the teacher's top-1 token, while the reverse top-1 token is controlled by `reverse_kl_top_1_mode`. + When `use_teacher_server=True`, the pure forward path (`beta=0`) requires this to be positive and uses the + teacher's top-k logprobs for the forward term. When `beta > 0`, server-backed distillation requires + `loss_top_k == 1` and only supports `"sampled"` reverse top-1 tokens. + loss_add_tail (`bool`, *optional*, defaults to `True`): + Whether to append a tail bucket that represents the remaining probability mass outside the selected top-k + support when computing the loss. + + > Parameters that control on-policy generation + + num_generations (`int`, *optional*, defaults to `1`): + Number of completions to generate per prompt during on-policy generation. + generation_batch_size (`int` or `None`, *optional*): + Number of unique prompts per worker per optimizer step. If `None`, computed from + `(per_device_train_batch_size * gradient_accumulation_steps) // num_generations`. + top_p (`float`, *optional*, defaults to `0.95`): + Top-p (nucleus) sampling parameter for on-policy generation. + top_k (`int`, *optional*, defaults to `0`): + Top-k sampling parameter for on-policy generation. `0` disables top-k filtering. + + > Parameters that control vLLM for student generation + + use_vllm (`bool`, *optional*, defaults to `False`): + Whether to use vLLM for generating on-policy completions from the student model. + vllm_mode (`str`, *optional*, defaults to `"colocate"`): + Mode for student vLLM integration. Either `"server"` or `"colocate"`. + vllm_server_base_url (`str` or `None`, *optional*): + Base URL for the student vLLM server. If provided, `vllm_server_host` and `vllm_server_port` are ignored. + vllm_server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the student vLLM server. + vllm_server_port (`int`, *optional*, defaults to `8001`): + Port of the student vLLM server. + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Timeout for connecting to the student vLLM server. + vllm_group_port (`int`, *optional*, defaults to `51216`): + Port for the vLLM weight-update group (NCCL communicator). + vllm_gpu_memory_utilization (`float`, *optional*, defaults to `0.3`): + GPU memory utilization for the colocated student vLLM engine. + vllm_tensor_parallel_size (`int`, *optional*, defaults to `1`): + Tensor parallel size for the colocated student vLLM engine. + vllm_max_model_length (`int` or `None`, *optional*): + Maximum model sequence length for the colocated vLLM engine. + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation backend for vLLM. Use `"vllm"` or `"transformers"`. + vllm_structured_outputs_regex (`str` or `None`, *optional*): + Regex pattern for vLLM structured outputs. + vllm_sync_frequency (`int`, *optional*, defaults to `1`): + Frequency (in training steps) to synchronize student model weights to the vLLM engine. + vllm_enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Enable vLLM sleep mode to offload student weights during the optimizer step. + + > Parameters that control logging + + log_completions (`bool`, *optional*, defaults to `False`): + Whether to log a sample of (prompt, completion) pairs every `log_completions_steps` steps. If `rich` is + installed, it prints the sample. If `wandb` and/or `trackio` logging is enabled, it logs it to `wandb` + and/or `trackio`. + log_completions_steps (`int`, *optional*, defaults to `100`): + Number of steps between logging completions. Only used if `log_completions` is `True`. + num_completions_to_print (`int` or `None`, *optional*): + Number of completions to print. If `None`, all completions are logged. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs", "teacher_model_init_kwargs"] + + # Model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument " + "of the trainer is provided as a string." + }, + ) + max_length: int | None = field( + default=1024, + metadata={"help": "Maximum total sequence length (prompt + completion) for tokenization and truncation."}, + ) + + # Overridden defaults + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Distillation core + temperature: float = field( + default=1.0, + metadata={ + "help": "Temperature for sampling and loss computation. Higher values produce softer distributions." + }, + ) + lmbda: float = field( + default=1.0, + metadata={ + "help": "Probability of using on-policy (student-generated) data per gradient accumulation slice. " + "0.0 = fully off-policy, 1.0 = fully on-policy." + }, + ) + beta: float = field( + default=1.0, + metadata={ + "help": "Interpolation coefficient for the Generalized JSD loss. " + "0.0 = forward KL, 0.5 = JSD, 1.0 = reverse KL." + }, + ) + reverse_kl_top_1_mode: str = field( + default="sampled", + metadata={ + "help": "Reverse-KL top-1 token selection when beta > 0 and loss_top_k == 1. " + "Use 'sampled' for the actual completion token or 'argmax' for the student's top-1 token. " + "The forward-KL support always uses the teacher's top-1 token. Ignored when beta == 0 or loss_top_k != 1." + }, + ) + max_completion_length: int = field( + default=512, + metadata={"help": "Maximum number of tokens to generate per completion."}, + ) + max_prompt_length: int | None = field( + default=None, + metadata={ + "help": "Maximum number of tokens for the prompt. If None, auto-computed as " + "max_length - max_completion_length. Prompts are truncated according to the " + "tokenizer's truncation_side setting." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the student model during training."}, + ) + + # Teacher model (local) + teacher_model_name_or_path: str | None = field( + default=None, + metadata={"help": "Model name or path for the teacher model."}, + ) + teacher_model_revision: str | None = field( + default=None, + metadata={"help": "Model revision of the teacher model (e.g., branch name, tag, or commit hash)."}, + ) + teacher_model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained` when instantiating the teacher." + }, + ) + + # Teacher model (external vLLM server) + use_teacher_server: bool = field( + default=False, + metadata={"help": "Whether to use an external vLLM teacher server instead of a local teacher model."}, + ) + teacher_model_server_url: str | None = field( + default=None, + metadata={ + "help": 'Base URL of a vLLM server hosting the teacher model (e.g., "http://localhost:8000"). ' + "Required when use_teacher_server=True." + }, + ) + loss_top_k: int = field( + default=1, + metadata={ + "help": "Number of top tokens to use when computing the JSD/KL loss. " + "Both student and teacher distributions are restricted to these K tokens " + "(selected based on beta: teacher's top-k for forward KL, student's top-k for reverse KL, " + "union of both for JSD) and re-normalized before computing divergence. " + "If 0, the full vocabulary is used (slower but exact). " + "When beta > 0 and loss_top_k == 1, the forward support still uses the teacher's top-1 token, " + "while the reverse top-1 token is controlled by reverse_kl_top_1_mode. " + "When use_teacher_server=True, beta=0 requires loss_top_k > 0 and uses the teacher's top-k " + "logprobs for the forward term. When beta > 0, server-backed distillation requires loss_top_k == 1 " + "and only supports 'sampled' reverse top-1 tokens." + }, + ) + loss_add_tail: bool = field( + default=True, + metadata={ + "help": "Whether to append a tail bucket representing the remaining probability mass outside the selected top-k support." + }, + ) + + # On-policy generation + num_generations: int = field( + default=1, + metadata={"help": "Number of completions to generate per prompt during on-policy generation."}, + ) + generation_batch_size: int | None = field( + default=None, + metadata={ + "help": "Number of unique prompts per worker per optimizer step. " + "If None, computed from (per_device_train_batch_size * gradient_accumulation_steps) // num_generations." + }, + ) + top_p: float = field( + default=0.95, + metadata={"help": "Top-p (nucleus) sampling parameter for on-policy generation."}, + ) + top_k: int = field( + default=0, + metadata={"help": "Top-k sampling parameter for on-policy generation. 0 disables top-k filtering."}, + ) + + # vLLM for student generation + use_vllm: bool = field( + default=False, + metadata={"help": "Whether to use vLLM for generating on-policy completions from the student model."}, + ) + vllm_mode: str = field( + default="colocate", + metadata={"help": 'Mode for student vLLM integration. Either "server" or "colocate".'}, + ) + vllm_server_base_url: str | None = field( + default=None, + metadata={"help": "Base URL for the student vLLM server."}, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": "Host of the student vLLM server."}, + ) + vllm_server_port: int = field( + default=8001, + metadata={"help": "Port of the student vLLM server."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={"help": "Timeout for connecting to the student vLLM server."}, + ) + vllm_group_port: int = field( + default=51216, + metadata={"help": "Port for the vLLM weight-update group (NCCL communicator)."}, + ) + vllm_gpu_memory_utilization: float = field( + default=0.3, + metadata={"help": "GPU memory utilization for the colocated student vLLM engine."}, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={"help": "Tensor parallel size for the colocated student vLLM engine."}, + ) + vllm_max_model_length: int | None = field( + default=None, + metadata={"help": "Maximum model sequence length for the colocated vLLM engine."}, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={"help": 'Model implementation backend for vLLM. Use "vllm" or "transformers".'}, + ) + vllm_structured_outputs_regex: str | None = field( + default=None, + metadata={"help": "Regex pattern for vLLM structured outputs."}, + ) + vllm_sync_frequency: int = field( + default=1, + metadata={"help": "Frequency (in training steps) to synchronize student weights to the vLLM engine."}, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={"help": "Enable vLLM sleep mode to offload student weights during the optimizer step."}, + ) + + # W&B + wandb_entity: str | None = field( + default=None, + metadata={"help": "The W&B entity to store runs under."}, + ) + wandb_project: str | None = field( + default=None, + metadata={"help": "The W&B project to store runs under."}, + ) + wandb_run_group: str | None = field( + default=None, + metadata={"help": "The W&B group to store runs under."}, + ) + + # Logging + log_completions: bool = field( + default=False, + metadata={ + "help": "Whether to log a sample of (prompt, completion) pairs every `log_completions_steps` steps. If `rich` is " + "installed, it prints the sample. If `wandb` and/or `trackio` logging is enabled, it logs it to `wandb` " + "and/or `trackio`." + }, + ) + log_completions_steps: int = field( + default=100, + metadata={"help": "Number of steps between logging completions."}, + ) + num_completions_to_print: int | None = field( + default=None, + metadata={"help": "Number of completions to print. If None, all completions are logged."}, + ) + + def __post_init__(self): + super().__post_init__() + + if self.lmbda < 0.0 or self.lmbda > 1.0: + raise ValueError(f"lmbda must be in [0.0, 1.0], got {self.lmbda}.") + if self.beta < 0.0 or self.beta > 1.0: + raise ValueError(f"beta must be in [0.0, 1.0], got {self.beta}.") + if self.reverse_kl_top_1_mode not in {"sampled", "argmax"}: + raise ValueError("reverse_kl_top_1_mode must be one of: 'sampled', 'argmax'") + + if self.max_length is not None and self.max_completion_length >= self.max_length: + raise ValueError( + f"max_completion_length ({self.max_completion_length}) must be smaller than " + f"max_length ({self.max_length}) to leave room for the prompt." + ) + + if self.max_prompt_length is None and self.max_length is not None: + self.max_prompt_length = self.max_length - self.max_completion_length + + if self.num_generations < 1: + raise ValueError(f"num_generations must be at least 1, got {self.num_generations}.") + + local_sequence_batch_size = self.per_device_train_batch_size * self.gradient_accumulation_steps + if self.generation_batch_size is None: + self.generation_batch_size = local_sequence_batch_size // self.num_generations + if self.generation_batch_size < 1: + raise ValueError(f"generation_batch_size must be at least 1, got {self.generation_batch_size}.") + if self.generation_batch_size * self.num_generations != local_sequence_batch_size: + raise ValueError( + "generation_batch_size * num_generations must equal per_device_train_batch_size * " + f"gradient_accumulation_steps. Got {self.generation_batch_size} * {self.num_generations} != " + f"{self.per_device_train_batch_size} * {self.gradient_accumulation_steps}." + ) + + if self.use_teacher_server and self.use_liger_kernel: + raise ValueError( + "use_liger_kernel=True is not supported with use_teacher_server=True because the Liger loss path " + "requires a local teacher model." + ) + if self.use_teacher_server and ( + self.teacher_model_server_url is None or not self.teacher_model_server_url.strip() + ): + raise ValueError("teacher_model_server_url must be set when use_teacher_server=True.") + + if self.use_teacher_server and self.beta == 0 and self.loss_top_k < 1: + raise ValueError( + f"loss_top_k must be positive when using use_teacher_server=True with beta=0 " + f"(got loss_top_k={self.loss_top_k}). The pure forward server path only has access to the " + f"teacher's top-k logprobs, so it cannot compute the exact full-vocabulary loss when loss_top_k=0." + ) + if self.use_teacher_server and self.reverse_kl_top_1_mode == "argmax": + raise ValueError( + "reverse_kl_top_1_mode='argmax' is not supported with use_teacher_server=True because the server " + "cannot provide teacher logprobs for arbitrary student-selected tokens." + ) + if self.use_teacher_server and self.beta > 0 and self.loss_top_k != 1: + raise ValueError( + f"loss_top_k must be 1 when using use_teacher_server=True with beta>0 " + f"(got loss_top_k={self.loss_top_k}). Mixed forward/reverse distillation with an external teacher " + "is only implemented for top-1 support." + ) + if self.reverse_kl_top_1_mode != "sampled" and (self.beta == 0 or self.loss_top_k != 1): + warnings.warn( + f"reverse_kl_top_1_mode='{self.reverse_kl_top_1_mode}' has no effect when beta={self.beta} " + f"and loss_top_k={self.loss_top_k}. It only applies when beta > 0 and loss_top_k == 1.", + UserWarning, + stacklevel=2, + ) + + if self.num_generations > 1 and self.lmbda < 1.0: + warnings.warn( + f"num_generations={self.num_generations} with lmbda={self.lmbda} means off-policy batches include " + f"{self.num_generations} copies of each sample. Consider lmbda=1.0 when num_generations > 1.", + UserWarning, + stacklevel=2, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..77dbcc6c08ea5a569174348cbcadf14e079cd016 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/distillation/distillation_trainer.py @@ -0,0 +1,1690 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import random +import textwrap +import warnings +from collections import defaultdict +from collections.abc import Callable +from contextlib import nullcontext +from functools import partial +from typing import Any, Optional + +import torch +import torch.distributed as dist +import torch.nn as nn +import torch.nn.functional as F +from accelerate.utils import DistributedType, broadcast_object_list, gather_object +from datasets import Dataset +from torch.utils.data import DataLoader +from transformers import AutoTokenizer, TrainerCallback, is_trackio_available, is_wandb_available +from transformers.data.data_collator import DataCollator +from transformers.feature_extraction_utils import FeatureExtractionMixin +from transformers.generation.configuration_utils import GenerationConfig +from transformers.image_processing_utils import BaseImageProcessor +from transformers.modeling_utils import PreTrainedModel +from transformers.processing_utils import ProcessorMixin +from transformers.tokenization_utils_base import PreTrainedTokenizerBase +from transformers.trainer_utils import EvalPrediction, seed_worker +from transformers.utils import is_liger_kernel_available, is_peft_available, is_rich_available + +from ...extras.profiling import profiling_decorator +from ...generation.vllm_generation import VLLMGeneration +from ...import_utils import is_vllm_available +from ...models import prepare_deepspeed +from ...models.utils import unwrap_model_for_generation +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + pad, + split_tensor_dict, +) +from .distillation_config import DistillationConfig + + +if is_peft_available(): + from peft import PeftConfig, get_peft_model + +if is_liger_kernel_available(): + from liger_kernel.chunked_loss import LigerFusedLinearJSDLoss + +if is_wandb_available(): + import wandb + +if is_trackio_available(): + import trackio + +if is_rich_available(): + from rich.console import Console + from rich.panel import Panel + from rich.table import Table + from rich.text import Text + + +def _print_completions_sample(prompts: list[str], completions: list[str], step: int, num_samples: int = None) -> None: + """Print a sample of prompt-completion pairs using rich.""" + if not is_rich_available(): + return + + console = Console() + table = Table(show_header=True, header_style="bold white", expand=True) + table.add_column("Prompt", style="bright_yellow") + table.add_column("Completion", style="bright_green") + + if num_samples is not None: + if num_samples >= len(prompts): + num_samples = None + elif num_samples <= 0: + return + + if num_samples is not None: + indices = random.sample(range(len(prompts)), num_samples) + prompts = [prompts[i] for i in indices] + completions = [completions[i] for i in indices] + + for prompt, completion in zip(prompts, completions, strict=True): + table.add_row(Text(prompt), Text(completion)) + table.add_section() + + panel = Panel(table, expand=False, title=f"Step {step}", border_style="bold white") + console.print(panel) + + +def _add_tail_bucket(log_probs, valid_mask): + """Append a (K+1)-th tail element: log(1 - sum(exp(top_k_logps))). + + This creates a proper probability distribution over K+1 elements, preventing trivial zero loss when top_k is small + (especially top_k=1). + """ + log_sum = torch.logsumexp(log_probs, dim=-1, keepdim=True) + log_sum = torch.clamp(log_sum, max=-1e-7) # ensure sum < 1 + tail = torch.log(-torch.expm1(log_sum)) # log(1 - exp(log_sum)) + tail_mask = torch.ones_like(valid_mask[..., :1], dtype=torch.bool) + return torch.cat([log_probs, tail], dim=-1), torch.cat([valid_mask, tail_mask], dim=-1) + + +def _jsd_divergence(student_log_probs, teacher_log_probs, beta, support_mask=None): + """Compute JSD (or forward/reverse KL) from log-probability tensors. + + When *support_mask* is not None, uses manual computation with masked positions zeroed. When None, uses + ``F.kl_div``. + """ + if support_mask is not None: + safe_student = torch.where(support_mask, student_log_probs, torch.zeros_like(student_log_probs)) + safe_teacher = torch.where(support_mask, teacher_log_probs, torch.zeros_like(teacher_log_probs)) + student_probs = torch.where(support_mask, student_log_probs.exp(), torch.zeros_like(student_log_probs)) + teacher_probs = torch.where(support_mask, teacher_log_probs.exp(), torch.zeros_like(teacher_log_probs)) + + if beta == 0: + return torch.nan_to_num(teacher_probs * (safe_teacher - safe_student), nan=0.0) + elif beta == 1: + return torch.nan_to_num(student_probs * (safe_student - safe_teacher), nan=0.0) + else: + beta_t = torch.tensor(beta, dtype=student_log_probs.dtype, device=student_log_probs.device) + tiny = torch.finfo(student_probs.dtype).tiny + mixture_probs = (1 - beta_t) * student_probs + beta_t * teacher_probs + safe_mixture = torch.where( + support_mask, + torch.log(mixture_probs.clamp_min(tiny)), + torch.zeros_like(student_log_probs), + ) + kl_teacher = torch.nan_to_num(teacher_probs * (safe_teacher - safe_mixture), nan=0.0) + kl_student = torch.nan_to_num(student_probs * (safe_student - safe_mixture), nan=0.0) + return beta_t * kl_teacher + (1 - beta_t) * kl_student + else: + if beta == 0: + return F.kl_div(student_log_probs, teacher_log_probs, reduction="none", log_target=True) + elif beta == 1: + return F.kl_div(teacher_log_probs, student_log_probs, reduction="none", log_target=True) + else: + beta_t = torch.tensor(beta, dtype=student_log_probs.dtype, device=student_log_probs.device) + mixture_log_probs = torch.logsumexp( + torch.stack([student_log_probs + torch.log1p(-beta_t), teacher_log_probs + torch.log(beta_t)]), + dim=0, + ) + kl_teacher = F.kl_div(mixture_log_probs, teacher_log_probs, reduction="none", log_target=True) + kl_student = F.kl_div(mixture_log_probs, student_log_probs, reduction="none", log_target=True) + return beta_t * kl_teacher + (1 - beta_t) * kl_student + + +def build_teacher_request_inputs( + input_ids: torch.Tensor, + attention_mask: torch.Tensor, + prompt_attention_mask: torch.Tensor | None = None, + labels: torch.Tensor | None = None, +) -> tuple[list[list[int]], list[int], list[int]]: + """Trim padded batch tensors into per-sample sequences for teacher-server requests.""" + + if input_ids.shape != attention_mask.shape: + raise ValueError( + f"input_ids and attention_mask must have the same shape, got {input_ids.shape} and {attention_mask.shape}." + ) + + input_ids_cpu = input_ids.detach().cpu() + attention_mask_cpu = attention_mask.detach().cpu().bool() + + if prompt_attention_mask is not None: + prompt_lengths = prompt_attention_mask.detach().cpu().sum(dim=1).to(torch.long) + else: + if labels is None: + raise ValueError("labels are required when prompt_attention_mask is not provided.") + if labels.shape != input_ids.shape: + raise ValueError(f"labels must match input_ids shape, got {labels.shape} and {input_ids.shape}.") + full_lengths = attention_mask_cpu.sum(dim=1).to(torch.long) + completion_lengths = (labels.detach().cpu() != -100).sum(dim=1).to(torch.long) + prompt_lengths = full_lengths - completion_lengths + + trimmed_input_ids: list[list[int]] = [] + prompt_lengths_list: list[int] = [] + completion_lengths_list: list[int] = [] + + for row, mask, prompt_length in zip(input_ids_cpu, attention_mask_cpu, prompt_lengths, strict=True): + trimmed_row = row[mask] + prompt_len = int(prompt_length.item()) + if prompt_len < 0 or prompt_len > trimmed_row.numel(): + raise ValueError( + f"Invalid prompt length {prompt_len} for trimmed sequence of length {trimmed_row.numel()}." + ) + trimmed_input_ids.append(trimmed_row.tolist()) + prompt_lengths_list.append(prompt_len) + completion_lengths_list.append(int(trimmed_row.numel()) - prompt_len) + + return trimmed_input_ids, prompt_lengths_list, completion_lengths_list + + +class _DistillationCollator: + """Data collator for the distillation trainer with independent prompt/completion budgets. + + Unlike ``DataCollatorForChatML``, this collator tokenizes prompts and completions separately so that long + completions can never truncate the prompt to empty. It also handles prompt-only data (no assistant completions) for + pure on-policy distillation (``lmbda=1``). + """ + + def __init__( + self, + tokenizer: "PreTrainedTokenizerBase", + max_length: int, + max_prompt_length: int, + messages_key: str = "messages", + ignore_index: int = -100, + ): + self.tokenizer = tokenizer + self.max_length = max_length + self.max_prompt_length = max_prompt_length + self.messages_key = messages_key + self.ignore_index = ignore_index + + if tokenizer.pad_token_id is None: + raise ValueError("The tokenizer does not have a pad token. Please set `pad_token_id` in the tokenizer.") + + def __call__(self, examples: list[dict[str, Any]]) -> dict[str, torch.Tensor]: + all_input_ids: list[list[int]] = [] + all_labels: list[list[int]] = [] + all_prompt_ids: list[list[int]] = [] + + for example in examples: + messages = example[self.messages_key] + + # Split: prompt = everything before the last assistant turn, completion = last assistant turn + has_completion = len(messages) > 1 and messages[-1].get("role") == "assistant" + prompt_messages = messages[:-1] if has_completion else messages + + # Tokenize prompt with its own budget using the tokenizer's truncation side + formatted_prompt = self.tokenizer.apply_chat_template( + prompt_messages, tokenize=False, add_generation_prompt=True + ) + prompt_ids = self.tokenizer( + formatted_prompt, + truncation=True, + max_length=self.max_prompt_length, + padding=False, + add_special_tokens=False, + )["input_ids"] + + if has_completion: + # Tokenize the full message (prompt + completion) without truncation first + formatted_full = self.tokenizer.apply_chat_template( + messages, tokenize=False, add_generation_prompt=False + ) + full_ids = self.tokenizer(formatted_full, truncation=False, padding=False, add_special_tokens=False)[ + "input_ids" + ] + + # Identify completion tokens: everything after the prompt in the full sequence. + # Use the un-truncated prompt length as the split point. + formatted_prompt_ids = self.tokenizer( + formatted_prompt, truncation=False, padding=False, add_special_tokens=False + )["input_ids"] + completion_ids = full_ids[len(formatted_prompt_ids) :] + + # Trim completion so prompt + completion <= max_length + max_comp = self.max_length - len(prompt_ids) + if max_comp > 0 and len(completion_ids) > max_comp: + completion_ids = completion_ids[:max_comp] + elif max_comp <= 0: + completion_ids = [] + + input_ids = prompt_ids + completion_ids + labels = [self.ignore_index] * len(prompt_ids) + list(completion_ids) + else: + # Prompt-only: no completion to train on (on-policy will generate one) + input_ids = list(prompt_ids) + labels = [self.ignore_index] * len(prompt_ids) + + all_input_ids.append(input_ids) + all_labels.append(labels) + all_prompt_ids.append(list(prompt_ids)) + + # Convert to tensors and left-pad + pad_id = self.tokenizer.pad_token_id + input_ids_t = pad( + [torch.tensor(ids, dtype=torch.long) for ids in all_input_ids], + padding_side="left", + padding_value=pad_id, + ) + attention_mask_t = pad( + [torch.ones(len(ids), dtype=torch.long) for ids in all_input_ids], + padding_side="left", + padding_value=0, + ) + labels_t = pad( + [torch.tensor(lab, dtype=torch.long) for lab in all_labels], + padding_side="left", + padding_value=self.ignore_index, + ) + prompts_t = pad( + [torch.tensor(ids, dtype=torch.long) for ids in all_prompt_ids], + padding_side="left", + padding_value=pad_id, + ) + prompt_mask_t = pad( + [torch.ones(len(ids), dtype=torch.long) for ids in all_prompt_ids], + padding_side="left", + padding_value=0, + ) + + return { + "input_ids": input_ids_t, + "attention_mask": attention_mask_t, + "labels": labels_t, + "prompts": prompts_t, + "prompt_attention_mask": prompt_mask_t, + } + + +class _RepeatBatchDataLoader: + """Repeats each collated batch ``repeat_count`` times without re-collation. + + ``RepeatSampler`` with ``repeat_count > 1`` causes the DataLoader to re-collate (re-tokenize) the same examples on + every repeat, which is wasteful. This wrapper instead keeps ``repeat_count=1`` in the sampler and repeats the + already-collated tensor dict, avoiding redundant tokenization. + """ + + def __init__(self, dataloader, repeat_count: int): + self.dataloader = dataloader + self.repeat_count = repeat_count + + def __iter__(self): + for batch in self.dataloader: + for _ in range(self.repeat_count): + yield batch + + def __len__(self): + return len(self.dataloader) * self.repeat_count + + def set_epoch(self, epoch: int): + if hasattr(self.dataloader, "set_epoch"): + self.dataloader.set_epoch(epoch) + + def __getattr__(self, attr): + return getattr(self.dataloader, attr) + + +class DistillationTrainer(_BaseTrainer): + """ + Trainer for knowledge distillation from a teacher model to a student model. + + Supports: + - Generalized JSD loss (forward KL, reverse KL, or interpolated JSD via `beta`) + - On-policy / off-policy mixing via `lmbda` (buffered across gradient accumulation) + - Local teacher model or external teacher via vLLM server + - Student on-policy generation via vLLM or model.generate() + - Liger kernel for memory-efficient fused JSD loss + """ + + _tag_names = ["trl", "distillation"] + _name = "Distillation" + _paper = { + "title": "On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes", + "id": "2306.13649", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{agarwal2024on-policy, + title = {{On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes}}, + author = {Rishabh Agarwal and Nino Vieillard and Yongchao Zhou and Piotr Stanczyk and Sabela Ramos Garea and Matthieu Geist and Olivier Bachem}, + year = 2024, + booktitle = {The Twelfth International Conference on Learning Representations, {ICLR} 2024, Vienna, Austria, May 7-11, 2024}, + publisher = {OpenReview.net}, + url = {https://openreview.net/forum?id=3zKtaqxLhW}, + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str | None = None, + teacher_model: PreTrainedModel | nn.Module | str = None, + args: DistillationConfig | None = None, + data_collator: DataCollator | None = None, # type: ignore + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: Optional["PeftConfig"] = None, + ): + if args is None: + args = DistillationConfig(output_dir="tmp_distillation") + + # ── Student model loading ── + model_init_kwargs = args.model_init_kwargs or {} + if isinstance(model_init_kwargs, str): + import json + + model_init_kwargs = json.loads(model_init_kwargs) + teacher_model_init_kwargs = args.teacher_model_init_kwargs or {} + if isinstance(teacher_model_init_kwargs, str): + import json + + teacher_model_init_kwargs = json.loads(teacher_model_init_kwargs) + if isinstance(model, str): + model_name_or_path = model + model = create_model_from_path(model, **model_init_kwargs) + else: + model_name_or_path = model.config._name_or_path if model is not None else None + + # ── Processing class (tokenizer) ── + if processing_class is None and model_name_or_path is not None: + processing_class = AutoTokenizer.from_pretrained(model_name_or_path) + if processing_class is not None: + if getattr(processing_class, "pad_token", None) is None: + processing_class.pad_token = processing_class.eos_token + + # ── PEFT ── + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # ── Data collator ── + if data_collator is None: + data_collator = _DistillationCollator( + tokenizer=processing_class, + max_length=args.max_length, + max_prompt_length=args.max_prompt_length, + ) + + # ── Liger fused JSD loss ── + self.use_liger_loss = False + if args.use_liger_kernel: + self.liger_jsd_loss = LigerFusedLinearJSDLoss( + beta=args.beta, + ignore_index=-100, + temperature=args.temperature, + compiled=False, + weight_hard_loss=0.0, + weight_soft_loss=1.0, + ) + self.use_liger_loss = True + + # ── Teacher model setup ── + self.teacher_client = None + self.use_teacher_server = args.use_teacher_server + self.teacher_model_server_url = args.teacher_model_server_url + self._local_teacher_tokenizer_matches_student = True + if self.use_teacher_server: + from ...generation.vllm_client import VLLMClient + + self.teacher_client = VLLMClient(base_url=self.teacher_model_server_url, connection_timeout=60.0) + teacher_model = None + elif teacher_model is not None: + if args.teacher_model_init_kwargs is not None and not isinstance(teacher_model, str): + raise ValueError( + "You passed teacher_model_init_kwargs to the config, but your teacher_model is already " + "instantiated." + ) + + teacher_model_name_or_path = ( + teacher_model + if isinstance(teacher_model, str) + else getattr(getattr(teacher_model, "config", None), "_name_or_path", None) + ) + if teacher_model_name_or_path is None: + raise ValueError( + "DistillationTrainer requires a local teacher model with `config._name_or_path` set so its " + "tokenizer can be validated against the student tokenizer." + ) + + teacher_tokenizer_kwargs = {} + teacher_revision = teacher_model_init_kwargs.get("revision", args.teacher_model_revision) + if teacher_revision is not None: + teacher_tokenizer_kwargs["revision"] = teacher_revision + if teacher_model_init_kwargs.get("trust_remote_code") is not None: + teacher_tokenizer_kwargs["trust_remote_code"] = teacher_model_init_kwargs["trust_remote_code"] + teacher_processing_class = AutoTokenizer.from_pretrained( + teacher_model_name_or_path, **teacher_tokenizer_kwargs + ) + if getattr(teacher_processing_class, "pad_token", None) is None: + teacher_processing_class.pad_token = teacher_processing_class.eos_token + self._local_teacher_tokenizer_matches_student = self._local_teacher_tokenizers_match( + processing_class, teacher_processing_class + ) + if not self._local_teacher_tokenizer_matches_student: + warnings.warn( + "DistillationTrainer's built-in local-teacher loss assumes the student and teacher share the " + "same tokenizer. The loaded local teacher tokenizer does not match the student tokenizer, so " + "the teacher weights will be left unchanged for subclass overrides. Direct use of the base " + "DistillationTrainer with this local teacher remains unsupported.", + UserWarning, + stacklevel=2, + ) + + if isinstance(teacher_model, str): + torch_dtype = teacher_model_init_kwargs.get("torch_dtype") + teacher_model_init_kwargs["torch_dtype"] = ( + torch_dtype if torch_dtype in ["auto", None] else getattr(torch, torch_dtype) + ) + + if isinstance(teacher_model, str): + init_kwargs = dict(teacher_model_init_kwargs) + if args.teacher_model_revision is not None: + init_kwargs.setdefault("revision", args.teacher_model_revision) + if "torch_dtype" in init_kwargs and "dtype" not in init_kwargs: + init_kwargs["dtype"] = init_kwargs.pop("torch_dtype") + teacher_model = create_model_from_path(teacher_model, **init_kwargs) + + # Trainer does not need to remove unused columns — the collator handles raw data + args.remove_unused_columns = False + + # ── Call _BaseTrainer.__init__ (which is transformers.Trainer.__init__) ── + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # ── Prepare teacher model (after super().__init__ so accelerator is ready) ── + if teacher_model is not None: + if self._local_teacher_tokenizer_matches_student: + teacher_model.resize_token_embeddings(self.model.config.vocab_size) + if self.is_deepspeed_enabled: + self.teacher_model = prepare_deepspeed(teacher_model, self.accelerator) + else: + self.teacher_model = self.accelerator.prepare_model(teacher_model, evaluation_mode=True) + else: + self.teacher_model = None + + if args.disable_dropout: + disable_dropout_in_model(self.model) + + # ── Store config values ── + self.lmbda = args.lmbda + self.beta = args.beta + self.temperature = args.temperature + self.top_p = args.top_p + self.num_generations = args.num_generations + self.reverse_kl_top_1_mode = args.reverse_kl_top_1_mode + self.loss_top_k = args.loss_top_k + self.loss_add_tail = args.loss_add_tail + + # ── Buffer state ── + self._buffered_inputs = None + self._buffered_on_policy_flags = None + self._buffered_text_logs = None + self._buffer_step = 0 + + # ── Loss tracking ── + self._on_policy_loss_total = 0.0 + self._off_policy_loss_total = 0.0 + self._on_policy_step_equiv = 0.0 + self._off_policy_step_equiv = 0.0 + + # ── Generation config ── + generation_kwargs = { + "max_new_tokens": args.max_completion_length, + "temperature": args.temperature, + "top_p": args.top_p, + "do_sample": True, + "top_k": args.top_k, + "pad_token_id": self.processing_class.pad_token_id, + } + self.generation_config = GenerationConfig(**generation_kwargs) + self.generation_kwargs = generation_kwargs + if ( + hasattr(self.model.generation_config, "eos_token_id") + and self.model.generation_config.eos_token_id is not None + ): + self.generation_config.eos_token_id = self.model.generation_config.eos_token_id + + # ── Metrics & Logging ── + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + self.log_completions = args.log_completions + self.log_completions_steps = args.log_completions_steps + self.num_completions_to_print = args.num_completions_to_print + + self._textual_logs = { + "prompt": [], + "completion": [], + } + + # ── vLLM for student generation ── + self.use_vllm = args.use_vllm + if self.use_vllm: + if not is_vllm_available(): + raise ImportError( + "vLLM is not available and use_vllm is set to True. Please install vLLM with " + "`pip install vllm` to use it." + ) + self.vllm_generation = VLLMGeneration( + model=self.model, + accelerator=self.accelerator, + is_fsdp_enabled=self.is_fsdp_enabled, + processing_class=self.processing_class, + mode=args.vllm_mode, + structured_outputs_regex=args.vllm_structured_outputs_regex, + server_base_url=args.vllm_server_base_url, + server_host=args.vllm_server_host, + server_port=args.vllm_server_port, + group_port=args.vllm_group_port, + server_timeout=args.vllm_server_timeout, + tensor_parallel_size=args.vllm_tensor_parallel_size, + gpu_memory_utilization=args.vllm_gpu_memory_utilization, + max_model_length=args.vllm_max_model_length, + max_num_seqs=args.per_device_train_batch_size * args.gradient_accumulation_steps, + enable_sleep_mode=args.vllm_enable_sleep_mode, + model_impl=args.vllm_model_impl, + temperature=args.temperature, + top_p=args.top_p, + top_k=args.top_k, + max_completion_length=args.max_completion_length, + logprobs=None, + ) + self.vllm_sync_frequency = args.vllm_sync_frequency + self._last_vllm_sync_step = -1 + + @staticmethod + def _local_teacher_tokenizers_match( + student_processing_class: PreTrainedTokenizerBase, + teacher_processing_class: PreTrainedTokenizerBase, + ) -> bool: + """Check whether the student and local teacher tokenizers share the same vocabulary.""" + return student_processing_class.get_vocab() == teacher_processing_class.get_vocab() + + def _raise_if_local_teacher_tokenizer_mismatch(self) -> None: + """Guard the base local-teacher JSD path, while still allowing subclass overrides.""" + if self.teacher_model is not None and not self._local_teacher_tokenizer_matches_student: + raise ValueError( + "DistillationTrainer's built-in local-teacher loss only supports student/teacher pairs that use " + "the same tokenizer. Use a same-tokenizer local teacher, set `use_teacher_server=True`, or " + "override the local teacher loss path in a subclass." + ) + + def _compute_prompt_length(self, inputs: dict[str, torch.Tensor | Any]) -> int: + """Compute the earliest prompt boundary that still includes every completion token in the batch.""" + if inputs.get("labels") is not None: + attention_mask = inputs["attention_mask"] + labels = inputs["labels"] + full_lengths = attention_mask.sum(dim=1) + completion_lengths = (labels != -100).sum(dim=1) + return int((full_lengths - completion_lengths).min().item()) + return inputs["prompts"].shape[1] + + def _get_completion_lengths(self, generated_tokens: torch.Tensor, prompt_width: int) -> torch.Tensor: + """Infer per-sample completion lengths from generated tokens.""" + completion_tokens = generated_tokens[:, prompt_width:] + pad_token_id = self.processing_class.pad_token_id + eos_token_id = self.generation_config.eos_token_id + if eos_token_id is None: + eos_token_ids = set() + elif isinstance(eos_token_id, int): + eos_token_ids = {eos_token_id} + else: + eos_token_ids = set(eos_token_id) + pad_equals_eos = pad_token_id is not None and pad_token_id in eos_token_ids + + completion_lengths = [] + for row in completion_tokens.tolist(): + if pad_equals_eos and eos_token_ids: + completion_length = len(row) + for idx, token_id in enumerate(row): + if token_id in eos_token_ids: + completion_length = idx + 1 + break + elif pad_token_id is not None: + completion_length = len(row) + while completion_length > 0 and row[completion_length - 1] == pad_token_id: + completion_length -= 1 + else: + completion_length = len(row) + completion_lengths.append(completion_length) + + return torch.tensor(completion_lengths, device=generated_tokens.device, dtype=torch.long) + + # ────────────────────────────────────────────────────────────────────── + # Dataset / Dataloader + # ────────────────────────────────────────────────────────────────────── + + def _set_signature_columns_if_needed(self): + super()._set_signature_columns_if_needed() + extra_columns = ["prompts", "prompt_attention_mask", "messages", "chat_template_kwargs", "tools"] + if self._signature_columns is None: + self._signature_columns = extra_columns + else: + for col in extra_columns: + if col not in self._signature_columns: + self._signature_columns.append(col) + + def _get_train_sampler(self, dataset=None): + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size * self.accelerator.num_processes, + repeat_count=1, + shuffle=True, + seed=self.args.seed, + ) + + def get_train_dataloader(self): + """ + Override to load one generation batch per optimizer window. + + The dataloader yields batches of size `per_device_train_batch_size * gradient_accumulation_steps`. + RepeatSampler ensures each generation batch is repeated `gradient_accumulation_steps` times so the Trainer's + loop iterates the correct number of times. + """ + if self.train_dataset is None: + raise ValueError("Trainer: training requires a train_dataset.") + + train_dataset = self.train_dataset + data_collator = self.data_collator + + dataloader_params = { + "batch_size": self._train_batch_size * self.args.gradient_accumulation_steps, + "collate_fn": data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "persistent_workers": self.args.dataloader_persistent_workers, + } + + if not isinstance(train_dataset, torch.utils.data.IterableDataset): + dataloader_params["sampler"] = self._get_train_sampler() + dataloader_params["drop_last"] = self.args.dataloader_drop_last + dataloader_params["worker_init_fn"] = partial( + seed_worker, + num_workers=self.args.dataloader_num_workers, + rank=self.args.process_index, + ) + if self.args.dataloader_num_workers > 0: + dataloader_params["prefetch_factor"] = self.args.dataloader_prefetch_factor + + base_dataloader = self.accelerator.prepare(DataLoader(train_dataset, **dataloader_params)) + return _RepeatBatchDataLoader(base_dataloader, repeat_count=self.args.gradient_accumulation_steps) + + # ────────────────────────────────────────────────────────────────────── + # Buffering: on/off-policy mixing across gradient accumulation steps + # ────────────────────────────────────────────────────────────────────── + + @profiling_decorator + def _prepare_inputs(self, generation_batch: dict[str, torch.Tensor | Any]) -> dict[str, torch.Tensor | Any]: + if not self.model.training: + return generation_batch + + buffer_steps = self.args.gradient_accumulation_steps + if self._buffer_step % buffer_steps == 0 or self._buffered_inputs is None: + self._fill_buffer(generation_batch, buffer_steps) + + slice_idx = self._buffer_step % buffer_steps + inputs = self._buffered_inputs[slice_idx] + self._buffer_step += 1 + return inputs + + @profiling_decorator + def _fill_buffer(self, generation_batch: dict[str, torch.Tensor | Any], buffer_steps: int): + """Split batch into slices and decide which are on-policy (student-generated) vs off-policy.""" + slices = split_tensor_dict(generation_batch, buffer_steps) + + # Decide on-policy flags (synchronized across processes) + if self.accelerator.is_main_process: + on_policy_flags = [random.random() <= self.lmbda for _ in range(buffer_steps)] + else: + on_policy_flags = [False] * buffer_steps + on_policy_flags = broadcast_object_list(on_policy_flags, from_process=0) + + self._buffered_inputs = [None] * buffer_steps + self._buffered_on_policy_flags = on_policy_flags + self._buffered_text_logs = [None] * buffer_steps + + # Store off-policy slices directly + on_policy_indices = [] + for i, is_on_policy in enumerate(on_policy_flags): + if is_on_policy: + on_policy_indices.append(i) + else: + self._buffered_inputs[i] = slices[i] + + # Generate student completions for on-policy slices + if on_policy_indices: + self._generate_student_completions(slices, on_policy_indices) + + # Gather on-policy text logs once per optimizer step (all processes must participate) + if self.log_completions: + on_policy_prompts = [] + on_policy_completions = [] + for i in on_policy_indices: + if self._buffered_text_logs[i] is not None: + prompts, completions = self._buffered_text_logs[i] + on_policy_prompts.extend(prompts) + on_policy_completions.extend(completions) + self._textual_logs["prompt"].extend(gather_object(on_policy_prompts)) + self._textual_logs["completion"].extend(gather_object(on_policy_completions)) + + @profiling_decorator + def _generate_student_completions(self, slices: list[dict[str, torch.Tensor | Any]], on_policy_indices: list[int]): + """Generate completions from the student model for on-policy training.""" + if not self.use_vllm: + self._generate_with_model(slices, on_policy_indices) + return + + # Collect all prompts across on-policy slices, stripping left-padding so vLLM + # receives only real prompt token IDs (like GRPO trainer). + local_prompts = [] + local_slice_indices = [] + pad_token_id = self.processing_class.pad_token_id + for slice_idx in on_policy_indices: + prompt_mask = slices[slice_idx].get("prompt_attention_mask") + for i, prompt in enumerate(slices[slice_idx]["prompts"]): + if prompt_mask is not None: + prompt = prompt[prompt_mask[i].bool()] + elif pad_token_id is not None: + first_non_pad = (prompt != pad_token_id).nonzero(as_tuple=True)[0] + if len(first_non_pad) > 0: + prompt = prompt[first_non_pad[0] :] + local_prompts.append(prompt) + local_slice_indices.append(slice_idx) + + # Sync student weights to vLLM if needed + if ( + self.state.global_step != self._last_vllm_sync_step + and self.state.global_step % self.vllm_sync_frequency == 0 + ): + self.vllm_generation.sync_weights() + self._last_vllm_sync_step = self.state.global_step + + # Generate completions — pass token IDs directly, no text decoding + prompt_ids_list = [p.tolist() for p in local_prompts] + _, completion_ids, _, _ = self.vllm_generation.generate( + prompts=prompt_ids_list, images=None, num_generations=self.num_generations + ) + + # Process completions into the buffer + self._store_completions_in_buffer( + slices, on_policy_indices, local_slice_indices, local_prompts, completion_ids + ) + + def _generate_with_model(self, slices: list[dict[str, torch.Tensor | Any]], on_policy_indices: list[int]): + """Fallback generation using model.generate() (no vLLM).""" + with unwrap_model_for_generation( + self.model, self.accelerator, generation_kwargs=self.generation_kwargs + ) as unwrapped_model: + for slice_idx in on_policy_indices: + slice_inputs = slices[slice_idx] + generated_outputs = unwrapped_model.generate( + input_ids=slice_inputs["prompts"], + attention_mask=slice_inputs.get("prompt_attention_mask", None), + generation_config=self.generation_config, + return_dict_in_generate=True, + ) + generated_tokens = generated_outputs.sequences + batch_size = generated_tokens.size(0) + device = generated_tokens.device + pad_token_id = self.processing_class.pad_token_id + prompt_width = slice_inputs["prompts"].shape[1] + prompt_mask = slice_inputs.get("prompt_attention_mask") + if prompt_mask is not None: + prompt_token_lengths = prompt_mask.sum(dim=1) + else: + prompt_token_lengths = torch.full((batch_size,), prompt_width, dtype=torch.long, device=device) + completion_lengths = self._get_completion_lengths(generated_tokens, prompt_width) + new_attention_mask, new_labels = self._build_sequence_batch( + generated_tokens, prompt_width, prompt_token_lengths, completion_lengths + ) + + # Decode for logging + prompt_texts = [] + completion_texts = [] + for idx in range(batch_size): + prompt_tokens = slice_inputs["prompts"][idx] + if prompt_mask is not None: + prompt_tokens = prompt_tokens[prompt_mask[idx].bool()] + elif pad_token_id is not None: + prompt_tokens = prompt_tokens[prompt_tokens != pad_token_id] + prompt_texts.append( + self.processing_class.decode(prompt_tokens.tolist(), skip_special_tokens=False) + ) + length = prompt_width + completion_length = int(completion_lengths[idx].item()) + completion_texts.append( + self.processing_class.decode( + generated_tokens[idx, length : length + completion_length].tolist(), + skip_special_tokens=False, + ) + ) + + updated = dict(slice_inputs) + updated["input_ids"] = generated_tokens + updated["attention_mask"] = new_attention_mask + updated["labels"] = new_labels + + self._buffered_inputs[slice_idx] = updated + self._buffered_text_logs[slice_idx] = (prompt_texts, completion_texts) + + def _store_completions_in_buffer( + self, + slices: list[dict[str, torch.Tensor | Any]], + on_policy_indices: list[int], + local_slice_indices: list[int], + local_prompts: list[torch.Tensor], + completion_ids: list, + ): + """Process vLLM completions and store them in the buffer. + + Uses original prompt token IDs directly (no decode/re-encode roundtrip), following the same approach as + GRPOTrainer. + """ + device = self.accelerator.device + pad_token_id = self.processing_class.pad_token_id if self.processing_class.pad_token_id is not None else 0 + max_completion_length = self.generation_config.max_new_tokens + + # Group completions and prompt token IDs by slice + slice_completions = {idx: [] for idx in on_policy_indices} + slice_prompt_ids = {idx: [] for idx in on_policy_indices} + for i, slice_idx in enumerate(local_slice_indices): + slice_completions[slice_idx].append(completion_ids[i]) + slice_prompt_ids[slice_idx].append(local_prompts[i]) + + for slice_idx in on_policy_indices: + slice_inputs = slices[slice_idx] + prompt_id_tensors = slice_prompt_ids[slice_idx] + prompt_width = max(len(p) for p in prompt_id_tensors) + prompt_token_lengths = torch.tensor([len(p) for p in prompt_id_tensors], device=device, dtype=torch.long) + prompt_attention_mask = ( + torch.arange(prompt_width, device=device).unsqueeze(0) + >= (prompt_width - prompt_token_lengths).unsqueeze(1) + ).long() + + # Left-pad prompt token IDs to the longest prompt in this slice + prompt_ids = torch.stack( + [F.pad(p, (prompt_width - len(p), 0), value=pad_token_id) for p in prompt_id_tensors] + ).to(device) + + # Pad/truncate completions (right-pad to max_completion_length) + completion_tensors = [] + completion_ids_for_text = [] + completion_lengths = [] + for comp_ids in slice_completions[slice_idx]: + t = torch.tensor(comp_ids, device=device) + if len(t) > max_completion_length: + t = t[:max_completion_length] + completion_ids_for_text.append(t.tolist()) + completion_lengths.append(len(t)) + if len(t) < max_completion_length: + padding = torch.full((max_completion_length - len(t),), pad_token_id, device=device, dtype=t.dtype) + t = torch.cat([t, padding]) + completion_tensors.append(t) + + completion_ids_padded = torch.stack(completion_tensors) + new_input_ids = torch.cat([prompt_ids, completion_ids_padded], dim=1) + completion_lengths = torch.tensor(completion_lengths, device=device, dtype=torch.long) + new_attention_mask, new_labels = self._build_sequence_batch( + new_input_ids, prompt_width, prompt_token_lengths, completion_lengths + ) + + # Decode for logging only + prompt_texts = self.processing_class.batch_decode( + prompt_id_tensors, skip_special_tokens=False, clean_up_tokenization_spaces=False + ) + completion_texts = self.processing_class.batch_decode( + completion_ids_for_text, skip_special_tokens=False, clean_up_tokenization_spaces=False + ) + + updated = dict(slice_inputs) + updated["input_ids"] = new_input_ids + updated["attention_mask"] = new_attention_mask + updated["labels"] = new_labels + # Update prompts to match the new padding width so prompt_length is consistent + updated["prompts"] = prompt_ids + updated["prompt_attention_mask"] = prompt_attention_mask + + self._buffered_inputs[slice_idx] = updated + self._buffered_text_logs[slice_idx] = (prompt_texts, completion_texts) + + @staticmethod + def _build_sequence_batch( + new_input_ids: torch.Tensor, + prompt_width: int, + prompt_token_lengths: torch.Tensor, + completion_lengths: torch.Tensor, + ) -> tuple[torch.Tensor, torch.Tensor]: + """Build attention mask and labels from prompt/completion lengths.""" + prompt_token_lengths = prompt_token_lengths.to(device=new_input_ids.device, dtype=torch.long) + completion_lengths = completion_lengths.to(device=new_input_ids.device, dtype=torch.long) + positions = torch.arange(new_input_ids.shape[1], device=new_input_ids.device).unsqueeze(0) + prompt_mask = (positions < prompt_width) & (positions >= (prompt_width - prompt_token_lengths).unsqueeze(1)) + completion_mask = (positions >= prompt_width) & (positions < (prompt_width + completion_lengths).unsqueeze(1)) + new_attention_mask = (prompt_mask | completion_mask).long() + + new_labels = torch.full_like(new_input_ids, -100) + new_labels[completion_mask] = new_input_ids[completion_mask] + + return new_attention_mask, new_labels + + # ────────────────────────────────────────────────────────────────────── + # Loss computation + # ────────────────────────────────────────────────────────────────────── + + @staticmethod + def _reduce_divergence_loss(jsd, labels=None, reduction="batchmean"): + """Reduce a per-token divergence tensor using the trainer's label mask semantics.""" + mask = None + if labels is not None: + mask = labels != -100 + jsd = jsd[mask] + + if reduction == "batchmean": + if labels is not None: + num_tokens = mask.sum() + if num_tokens == 0: + return jsd.sum() * 0.0 # no completion tokens — return zero-grad scalar + return jsd.sum() / num_tokens + return jsd.sum() / jsd.size(0) + elif reduction == "sum": + return jsd.sum() + elif reduction == "mean": + return jsd.mean() + else: + return jsd + + @staticmethod + def generalized_jsd_loss( + student_logits, + teacher_logits, + labels=None, + beta=0.5, + temperature=1.0, + reduction="batchmean", + top_k=0, + add_tail=True, + ): + """ + Compute the generalized Jensen-Shannon Divergence loss for knowledge distillation. + + Args: + student_logits: Tensor of shape (batch_size, sequence_length, vocab_size). + teacher_logits: Tensor of shape (batch_size, sequence_length, vocab_size). + labels: Tensor of shape (batch_size, sequence_length) with -100 for positions to ignore. + beta: Interpolation coefficient. 0.0 = forward KL, 1.0 = reverse KL. + temperature: Softmax temperature. + reduction: 'batchmean', 'sum', 'mean', or 'none'. + top_k: Number of top tokens to restrict the loss to. The support set depends on beta: + beta=0 (forward KL) uses teacher's top-k, beta=1 (reverse KL) uses student's top-k, 0 0 and student_logits.size(-1) > top_k: + neg_inf = torch.full((), float("-inf"), dtype=student_logits.dtype, device=student_logits.device) + student_log_probs_full = F.log_softmax(student_logits, dim=-1) + teacher_log_probs_full = F.log_softmax(teacher_logits, dim=-1) + + if beta == 0: + # Forward KL: teacher-selected support + _, support = teacher_logits.topk(top_k, dim=-1) + support_mask = torch.ones_like(support, dtype=torch.bool) + elif beta == 1: + # Reverse KL: student-selected support + _, support = student_logits.topk(top_k, dim=-1) + support_mask = torch.ones_like(support, dtype=torch.bool) + else: + # JSD: union of both supports (concatenate + deduplicate) + _, student_top = student_logits.topk(top_k, dim=-1) + _, teacher_top = teacher_logits.topk(top_k, dim=-1) + support = torch.cat([teacher_top, student_top], dim=-1) + support_mask = torch.ones(support.shape, dtype=torch.bool, device=support.device) + for i in range(1, support.shape[-1]): + prev_matches = support[..., i : i + 1] == support[..., :i] + prev_valid = support_mask[..., :i] + support_mask[..., i] &= ~(prev_matches & prev_valid).any(dim=-1) + support = torch.where(support_mask, support, torch.zeros_like(support)) + + student_support_logps = student_log_probs_full.gather(-1, support) + teacher_support_logps = teacher_log_probs_full.gather(-1, support) + + # Mask invalid (duplicate) positions with -inf + student_topk_logps = torch.where(support_mask, student_support_logps, neg_inf) + teacher_topk_logps = torch.where(support_mask, teacher_support_logps, neg_inf) + + if add_tail: + # Add tail bucket: append log(1 - sum(exp(top_k_logps))) to preserve + # the remaining probability mass outside the top-k. This prevents trivial + # zero loss when top_k is small (especially top_k=1). + base_support_mask = support_mask + student_log_probs, support_mask = _add_tail_bucket(student_topk_logps, base_support_mask) + teacher_log_probs, _ = _add_tail_bucket(teacher_topk_logps, base_support_mask) + else: + student_log_probs = student_topk_logps - torch.logsumexp(student_topk_logps, dim=-1, keepdim=True) + teacher_log_probs = teacher_topk_logps - torch.logsumexp(teacher_topk_logps, dim=-1, keepdim=True) + else: + student_log_probs = F.log_softmax(student_logits, dim=-1) + teacher_log_probs = F.log_softmax(teacher_logits, dim=-1) + + jsd = _jsd_divergence(student_log_probs, teacher_log_probs, beta, support_mask) + return DistillationTrainer._reduce_divergence_loss(jsd, labels=labels, reduction=reduction) + + def _get_reverse_kl_top_1_tokens( + self, student_scores: torch.Tensor, completion_tokens: torch.Tensor + ) -> torch.Tensor: + """Return the reverse-KL top-1 token IDs for the mixed top-1 loss path. + + Args: + student_scores: Any (B, T, V) tensor whose argmax selects the student's top token + (logits or log-probs — both are order-preserving). + completion_tokens: (B, T) actual token IDs in the completion. + """ + if self.reverse_kl_top_1_mode == "argmax": + return student_scores.argmax(dim=-1) + return completion_tokens + + def _compute_sparse_top_1_divergence_loss( + self, + student_log_probs: torch.Tensor, + teacher_top1_token_ids: torch.Tensor, + teacher_top1_logprobs: torch.Tensor, + reverse_token_ids: torch.Tensor, + reverse_teacher_logprobs: torch.Tensor, + labels: torch.Tensor, + ) -> torch.Tensor: + """Compute exact generalized JSD/KL on top-1 support for the mixed beta>0 path.""" + neg_inf = torch.full((), float("-inf"), dtype=student_log_probs.dtype, device=student_log_probs.device) + + if self.beta == 1: + support = reverse_token_ids.unsqueeze(-1) + support_mask = torch.ones_like(support, dtype=torch.bool) + teacher_support_logprobs = reverse_teacher_logprobs.unsqueeze(-1) + else: + teacher_support = teacher_top1_token_ids.unsqueeze(-1) + reverse_support = reverse_token_ids.unsqueeze(-1) + support = torch.cat([teacher_support, reverse_support], dim=-1) + support_mask = torch.ones_like(support, dtype=torch.bool) + support_mask[..., 1] = support[..., 1] != support[..., 0] + teacher_support_logprobs = torch.stack([teacher_top1_logprobs, reverse_teacher_logprobs], dim=-1) + support = torch.where(support_mask, support, torch.zeros_like(support)) + + student_support_logprobs = student_log_probs.gather(-1, support) + student_support_logprobs = torch.where(support_mask, student_support_logprobs, neg_inf) + teacher_support_logprobs = torch.where(support_mask, teacher_support_logprobs, neg_inf) + + if self.loss_add_tail: + base_support_mask = support_mask + student_sparse_log_probs, support_mask = _add_tail_bucket(student_support_logprobs, base_support_mask) + teacher_sparse_log_probs, _ = _add_tail_bucket(teacher_support_logprobs, base_support_mask) + else: + student_sparse_log_probs = student_support_logprobs - torch.logsumexp( + student_support_logprobs, dim=-1, keepdim=True + ) + teacher_sparse_log_probs = teacher_support_logprobs - torch.logsumexp( + teacher_support_logprobs, dim=-1, keepdim=True + ) + + jsd = _jsd_divergence(student_sparse_log_probs, teacher_sparse_log_probs, self.beta, support_mask) + return self._reduce_divergence_loss(jsd, labels=labels, reduction="batchmean") + + def _compute_local_sparse_top_1_divergence_loss( + self, + student_logits: torch.Tensor, + teacher_logits: torch.Tensor, + completion_tokens: torch.Tensor, + labels: torch.Tensor, + ) -> torch.Tensor: + """Compute the mixed top-1 loss for a local teacher using gathered full-logit probabilities.""" + student_log_probs = F.log_softmax(student_logits / self.temperature, dim=-1) + teacher_log_probs = F.log_softmax(teacher_logits / self.temperature, dim=-1) + + teacher_top1_token_ids = teacher_logits.argmax(dim=-1) + teacher_top1_logprobs = teacher_log_probs.gather(dim=-1, index=teacher_top1_token_ids.unsqueeze(-1)).squeeze( + -1 + ) + reverse_token_ids = self._get_reverse_kl_top_1_tokens(student_logits, completion_tokens) + reverse_teacher_logprobs = teacher_log_probs.gather(dim=-1, index=reverse_token_ids.unsqueeze(-1)).squeeze(-1) + + return self._compute_sparse_top_1_divergence_loss( + student_log_probs=student_log_probs, + teacher_top1_token_ids=teacher_top1_token_ids, + teacher_top1_logprobs=teacher_top1_logprobs, + reverse_token_ids=reverse_token_ids, + reverse_teacher_logprobs=reverse_teacher_logprobs, + labels=labels, + ) + + def _get_teacher_logits(self, inputs: dict[str, torch.Tensor | Any]) -> torch.Tensor: + """Get teacher logits — dispatches between local model and external server.""" + if self.teacher_model is not None: + self.teacher_model.eval() + with torch.no_grad(): + return self.teacher_model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + ).logits + elif self.use_teacher_server: + raise NotImplementedError( + "Fetching full teacher logits with use_teacher_server=True is not supported. " + "Server-backed distillation only supports per-token logprobs via " + "`_get_teacher_token_logprobs_from_server`." + ) + else: + raise ValueError("No teacher model or teacher server configured.") + + def _get_teacher_token_logprobs_from_server( + self, + inputs: dict[str, torch.Tensor | Any], + aligned_prompt_length: int, + ) -> dict[str, torch.Tensor]: + """Fetch per-token teacher logprobs from an external vLLM server. + + Returns a dict with: + ``actual_logprobs`` – (batch, completion_length) teacher log-prob for the actual + token at each position (for reverse KL). + ``topk_logprobs`` – (batch, completion_length, K) teacher top-k sorted logprobs + (for forward KL). + ``topk_token_ids`` – (batch, completion_length, K) corresponding token IDs. + """ + import numpy as np + + input_ids = inputs["input_ids"] + batch_size = input_ids.shape[0] + sequences, prompt_lengths, completion_lengths = build_teacher_request_inputs( + input_ids, + inputs["attention_mask"], + prompt_attention_mask=inputs.get("prompt_attention_mask"), + labels=inputs.get("labels"), + ) + + # The pure forward server path can use the requested teacher top-k support. + # When beta > 0, config validation restricts the server-backed path to top-1. + requested_top_k = self.loss_top_k + result = self.teacher_client.get_sequence_logprobs( + sequences=sequences, + prompt_lengths=prompt_lengths, + top_logprobs=requested_top_k, + temperature=self.temperature, + ) + K = requested_top_k + + device = input_ids.device + labels = inputs.get("labels") + if labels is None: + raise ValueError("labels are required to align teacher-server logprobs with the student loss tensors.") + + # The student loss slices tensors in padded-sequence coordinates starting at `aligned_prompt_length`. + # Place each teacher completion into that same coordinate system by locating the first non-masked completion + # token in `labels`. This works for both left-padded off-policy batches and on-policy batches where + # completions are right-padded after a fixed-width prompt block. + completion_offsets = [] + label_mask = labels != -100 + for sample_mask, comp_len in zip(label_mask, completion_lengths, strict=True): + if comp_len == 0: + completion_offsets.append(0) + continue + completion_start = int(torch.nonzero(sample_mask, as_tuple=False)[0].item()) + completion_offsets.append(completion_start - aligned_prompt_length) + + # Size the output tensors to tightly fit the teacher logprobs. Using the full padded + # sequence length would include padding positions with -inf teacher logprobs, producing + # inf in the forward pass and NaN gradients in the backward pass (0 * inf = NaN). + completion_length = max( + (offset + len(lps) for offset, lps in zip(completion_offsets, result["logprobs"], strict=True)), + default=0, + ) + + # actual_logprobs: (B, T) — teacher logprob for the actual token + def _actual_to_tensor(key): + arr = np.full((batch_size, completion_length), float("-inf"), dtype=np.float32) + for i, (offset, seq_lps) in enumerate(zip(completion_offsets, result[key], strict=True)): + if seq_lps: + vals = np.array(seq_lps, dtype=np.float32) # (comp_len_i, 1) + arr[i, offset : offset + vals.shape[0]] = vals[:, 0] + return torch.from_numpy(arr).to(device) + + # topk: (B, T, K) + def _topk_to_tensor(key, k, np_dtype, fill): + arr = np.full((batch_size, completion_length, k), fill, dtype=np_dtype) + for i, (offset, seq_vals) in enumerate(zip(completion_offsets, result[key], strict=True)): + if seq_vals: + vals = np.array(seq_vals, dtype=np_dtype) # (comp_len_i, k) + arr[i, offset : offset + vals.shape[0], :] = vals + return torch.from_numpy(arr).to(device) + + return { + "actual_logprobs": _actual_to_tensor("actual_logprobs"), + "topk_logprobs": _topk_to_tensor("logprobs", K, np.float32, float("-inf")), + "topk_token_ids": _topk_to_tensor("logprob_token_ids", K, np.int64, 0), + } + + def _compute_server_sparse_top_1_divergence_loss( + self, + teacher_result: dict[str, torch.Tensor], + student_log_probs: torch.Tensor, + completion_tokens: torch.Tensor, + labels: torch.Tensor, + ) -> torch.Tensor: + """Compute exact sparse top-1 generalized JSD/KL from server-provided teacher logprobs. + + Args: + teacher_result: dict with ``actual_logprobs`` (B, T), ``topk_logprobs`` (B, T, K), + ``topk_token_ids`` (B, T, K). + student_log_probs: (B, T, V) student log-softmax over vocabulary. + completion_tokens: (B, T) actual token IDs in the completion. + labels: (B, T) with -100 for positions to ignore. + """ + topk_teacher_lps = teacher_result["topk_logprobs"] # (B, T, 1) + topk_token_ids = teacher_result["topk_token_ids"] # (B, T, 1) + actual_teacher_lps = teacher_result["actual_logprobs"] # (B, T) + required = labels != -100 + + missing_actual = required & ~torch.isfinite(actual_teacher_lps) + if missing_actual.any(): + missing_count = int(missing_actual.sum().item()) + total_required = int(required.sum().item()) + raise ValueError( + "Teacher server is missing actual-token logprobs for required reverse-KL positions: " + f"{missing_count}/{total_required}." + ) + if self.beta < 1: + teacher_top1_logprobs = topk_teacher_lps.squeeze(-1) + missing_top1 = required & ~torch.isfinite(teacher_top1_logprobs) + if missing_top1.any(): + missing_count = int(missing_top1.sum().item()) + total_required = int(required.sum().item()) + raise ValueError( + "Teacher server is missing top-1 logprobs for required forward-KL positions: " + f"{missing_count}/{total_required}." + ) + + # Server path only supports "sampled" mode — config validation enforces this, but we guard + # explicitly so future relaxations of the config check don't silently change behaviour. + reverse_token_ids = self._get_reverse_kl_top_1_tokens(student_log_probs, completion_tokens) + return self._compute_sparse_top_1_divergence_loss( + student_log_probs=student_log_probs, + teacher_top1_token_ids=topk_token_ids.squeeze(-1), + teacher_top1_logprobs=topk_teacher_lps.squeeze(-1), + reverse_token_ids=reverse_token_ids, + reverse_teacher_logprobs=actual_teacher_lps, + labels=labels, + ) + + def _compute_server_forward_kl_loss( + self, + teacher_result: dict[str, torch.Tensor], + student_log_probs: torch.Tensor, + labels: torch.Tensor, + ) -> torch.Tensor: + """Compute sparse forward KL from server-provided teacher top-k logprobs (beta==0 path). + + Args: + teacher_result: dict with ``topk_logprobs`` (B, T, K) and ``topk_token_ids`` (B, T, K). + student_log_probs: (B, T, V) student log-softmax over vocabulary. + labels: (B, T) with -100 for positions to ignore. + """ + teacher_topk_logprobs = teacher_result["topk_logprobs"] + teacher_topk_token_ids = teacher_result["topk_token_ids"] + valid = teacher_topk_logprobs > float("-inf") + neg_inf = torch.full((), float("-inf"), dtype=student_log_probs.dtype, device=student_log_probs.device) + student_topk_logprobs = student_log_probs.gather(dim=-1, index=teacher_topk_token_ids) + student_topk_logprobs = torch.where(valid, student_topk_logprobs, neg_inf) + teacher_topk_logprobs = torch.where(valid, teacher_topk_logprobs, neg_inf) + + if self.loss_add_tail: + base_support_mask = valid + student_sparse_log_probs, support_mask = _add_tail_bucket(student_topk_logprobs, base_support_mask) + teacher_sparse_log_probs, _ = _add_tail_bucket(teacher_topk_logprobs, base_support_mask) + else: + support_mask = valid + student_sparse_log_probs = student_topk_logprobs - torch.logsumexp( + student_topk_logprobs, dim=-1, keepdim=True + ) + teacher_sparse_log_probs = teacher_topk_logprobs - torch.logsumexp( + teacher_topk_logprobs, dim=-1, keepdim=True + ) + + jsd = _jsd_divergence( + student_sparse_log_probs, + teacher_sparse_log_probs, + beta=0.0, + support_mask=support_mask, + ) + return self._reduce_divergence_loss(jsd, labels=labels, reduction="batchmean") + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + self._raise_if_local_teacher_tokenizer_mismatch() + + if self.use_liger_loss: + loss = self._compute_liger_loss(model, inputs) + return (loss, None) if return_outputs else loss + + # Student forward pass + student_outputs = model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + ) + prompt_length = self._compute_prompt_length(inputs) + labels = inputs["labels"][:, prompt_length:] + completion_tokens = inputs["input_ids"][:, prompt_length:] + + if self.use_teacher_server: + # Server path: token-level divergence using teacher logprobs. + # The server returns: + # actual_logprobs – (B, T) teacher log p(x_actual) (for reverse KL) + # topk_logprobs – (B, T, K) teacher top-k sorted logprobs (for forward KL) + # topk_token_ids – (B, T, K) corresponding token IDs + teacher_result = self._get_teacher_token_logprobs_from_server(inputs, prompt_length) + + student_logits = student_outputs.logits[:, prompt_length - 1 : -1, :] + student_log_probs = F.log_softmax(student_logits / self.temperature, dim=-1) + + comp_len = teacher_result["actual_logprobs"].shape[1] + completion_tokens = completion_tokens[:, :comp_len] + trimmed_labels = labels[:, :comp_len] + + if self.beta > 0: + loss = self._compute_server_sparse_top_1_divergence_loss( + teacher_result=teacher_result, + student_log_probs=student_log_probs[:, :comp_len, :], + completion_tokens=completion_tokens, + labels=trimmed_labels, + ) + else: + loss = self._compute_server_forward_kl_loss( + teacher_result=teacher_result, + student_log_probs=student_log_probs[:, :comp_len, :], + labels=trimmed_labels, + ) + else: + # Local teacher: exact full-vocabulary loss except for the shared mixed top-1 path. + teacher_logits = self._get_teacher_logits(inputs) + student_logits = student_outputs.logits[:, prompt_length - 1 : -1, :] + teacher_logits = teacher_logits[:, prompt_length - 1 : -1, :] + if self.beta > 0 and self.loss_top_k == 1: + loss = self._compute_local_sparse_top_1_divergence_loss( + student_logits=student_logits, + teacher_logits=teacher_logits, + completion_tokens=completion_tokens, + labels=labels, + ) + else: + loss = self.generalized_jsd_loss( + student_logits=student_logits, + teacher_logits=teacher_logits, + labels=labels, + beta=self.beta, + temperature=self.temperature, + top_k=self.loss_top_k, + add_tail=self.loss_add_tail, + ) + + return (loss, student_outputs) if return_outputs else loss + + def _compute_liger_loss(self, model, inputs): + """Memory-efficient JSD using Liger kernel (operates on hidden states, not full logits).""" + unwrapped_student = self.accelerator.unwrap_model(model) + if hasattr(unwrapped_student, "get_decoder") and unwrapped_student.get_decoder() is not None: + base_student = unwrapped_student.get_decoder() + else: + base_student = getattr( + unwrapped_student, getattr(unwrapped_student, "base_model_prefix", "model"), unwrapped_student + ) + + student_outputs = base_student( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + self.teacher_model.eval() + unwrapped_teacher = self.accelerator.unwrap_model(self.teacher_model) + if hasattr(unwrapped_teacher, "get_decoder") and unwrapped_teacher.get_decoder() is not None: + base_teacher = unwrapped_teacher.get_decoder() + else: + base_teacher = getattr( + unwrapped_teacher, getattr(unwrapped_teacher, "base_model_prefix", "model"), unwrapped_teacher + ) + with torch.no_grad(): + teacher_outputs = base_teacher( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + student_hidden = student_outputs.last_hidden_state[:, :-1] + teacher_hidden = teacher_outputs.last_hidden_state[:, :-1] + del student_outputs, teacher_outputs + + student_hidden = student_hidden.reshape(-1, student_hidden.shape[-1]) + teacher_hidden = teacher_hidden.reshape(-1, teacher_hidden.shape[-1]) + + labels_mask = inputs["labels"] != -100 + masked_input_ids = torch.where(labels_mask, inputs["input_ids"], torch.full_like(inputs["input_ids"], -100)) + true_labels = masked_input_ids[:, 1:].contiguous().reshape(-1) + + student_head = unwrapped_student.get_output_embeddings() + teacher_head = unwrapped_teacher.get_output_embeddings() + + loss = self.liger_jsd_loss( + student_input=student_hidden, + student_weight=student_head.weight, + teacher_input=teacher_hidden, + teacher_weight=teacher_head.weight, + true_labels=true_labels, + student_bias=getattr(student_head, "bias", None), + teacher_bias=getattr(teacher_head, "bias", None), + ) + + del student_hidden, teacher_hidden, true_labels + return loss + + def _get_liger_zero3_lm_head_gather_ctx(self, model: nn.Module): + """Context manager for gathering lm_head parameters under Liger + ZeRO-3.""" + if not self.use_liger_loss: + return nullcontext() + + deepspeed_plugin = self.accelerator.state.deepspeed_plugin + if deepspeed_plugin is None or deepspeed_plugin.zero_stage != 3: + return nullcontext() + + import deepspeed + + unwrapped_student = self.accelerator.unwrap_model(model) + unwrapped_teacher = self.accelerator.unwrap_model(self.teacher_model) + student_head = unwrapped_student.get_output_embeddings() + teacher_head = unwrapped_teacher.get_output_embeddings() + params = [student_head.weight, teacher_head.weight] + if student_head.bias is not None: + params.append(student_head.bias) + if teacher_head.bias is not None: + params.append(teacher_head.bias) + return deepspeed.zero.GatheredParameters(params, modifier_rank=None) + + # ────────────────────────────────────────────────────────────────────── + # Training step & Logging + # ────────────────────────────────────────────────────────────────────── + + @profiling_decorator + def training_step( + self, model: nn.Module, inputs: dict[str, torch.Tensor | Any], num_items_in_batch: int | None = None + ) -> torch.Tensor: + """Training step with on/off-policy loss tracking and completion stats.""" + buffer_steps = self.args.gradient_accumulation_steps + + with self._get_liger_zero3_lm_head_gather_ctx(model): + loss = super().training_step(model, inputs, num_items_in_batch) + + slice_idx = (self._buffer_step - 1) % buffer_steps + + # Determine if this slice is on-policy + is_on_policy = False + if self._buffered_on_policy_flags is not None and slice_idx < len(self._buffered_on_policy_flags): + is_on_policy = self._buffered_on_policy_flags[slice_idx] + + # Track completion length stats — read from buffered inputs (which reflect on-policy generation) + actual_inputs = self._buffered_inputs[slice_idx] if self._buffered_inputs is not None else inputs + labels = actual_inputs.get("labels") + if labels is not None: + completion_lengths = (labels != -100).sum(dim=1).float() + gathered_lengths = self.accelerator.gather(completion_lengths) + mode = "train" + prefix = "on_policy" if is_on_policy else "off_policy" + self._metrics[mode][f"completions/{prefix}_mean_length"].append(gathered_lengths.mean().item()) + self._metrics[mode][f"completions/{prefix}_max_length"].append(gathered_lengths.max().item()) + self._metrics[mode][f"completions/{prefix}_min_length"].append(gathered_lengths.min().item()) + + # Log fraction of completions that hit max_completion_length (truncated) + max_comp_len = getattr(self.generation_config, "max_new_tokens", None) + if is_on_policy and max_comp_len is not None: + truncated_frac = (gathered_lengths >= max_comp_len).float().mean().item() + self._metrics[mode]["completions/truncated_fraction"].append(truncated_frac) + + # Track loss per policy type + loss_scalar = float(loss.detach()) + step_equiv = 1.0 / self.args.gradient_accumulation_steps + if is_on_policy: + self._on_policy_loss_total += loss_scalar + self._on_policy_step_equiv += step_equiv + else: + self._off_policy_loss_total += loss_scalar + self._off_policy_step_equiv += step_equiv + + return loss + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + metrics = {key: sum(val) / len(val) for key, val in self._metrics[mode].items()} + + if mode == "train": + # Aggregate on/off-policy losses across distributed processes + device = self.accelerator.device if hasattr(self.accelerator, "device") else torch.device("cpu") + vec = torch.tensor( + [ + self._on_policy_loss_total, + self._off_policy_loss_total, + self._on_policy_step_equiv, + self._off_policy_step_equiv, + ], + dtype=torch.float64, + device=device, + ) + + if ( + getattr(self.accelerator, "distributed_type", DistributedType.NO) != DistributedType.NO + and dist.is_available() + and dist.is_initialized() + ): + dist.all_reduce(vec, op=dist.ReduceOp.SUM) + + on_sum, off_sum, on_eq, off_eq = vec.tolist() + if on_eq > 0: + logs["on_policy_loss"] = round(on_sum / on_eq, 4) + if off_eq > 0: + logs["off_policy_loss"] = round(off_sum / off_eq, 4) + + self._on_policy_loss_total = self._off_policy_loss_total = 0.0 + self._on_policy_step_equiv = self._off_policy_step_equiv = 0.0 + + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + # Log completions to console, wandb, and trackio + should_log_completions = ( + self.log_completions + and self.state.global_step > 0 + and self.state.global_step % self.log_completions_steps == 0 + ) + + if should_log_completions and self.accelerator.is_main_process: + prompts = list(self._textual_logs["prompt"]) + completions = list(self._textual_logs["completion"]) + + if prompts: + _print_completions_sample(prompts, completions, self.state.global_step, self.num_completions_to_print) + + logging_backends = [] + if self.args.report_to and "wandb" in self.args.report_to and wandb.run is not None: + logging_backends.append(wandb) + if self.args.report_to and "trackio" in self.args.report_to: + logging_backends.append(trackio) + + if logging_backends: + import pandas as pd + + table_data = { + "step": [str(self.state.global_step)] * len(prompts), + "prompt": prompts, + "completion": completions, + } + df = pd.DataFrame(table_data) + if self.num_completions_to_print and len(df) > self.num_completions_to_print: + df = df.sample(n=self.num_completions_to_print, random_state=42) + + for logging_backend in logging_backends: + logging_backend.log({"completions": logging_backend.Table(dataframe=df)}) + + # Clear text logs on all processes after the logging interval + if should_log_completions: + self._textual_logs["prompt"].clear() + self._textual_logs["completion"].clear() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..0ce3ffeae4fc9c790f3249ba48a958567c66d35f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from .dppo_config import DPPOConfig +from .dppo_trainer import DPPOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/dppo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/dppo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..92736aac144ad648aeb4b52973535744330963c6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/dppo_config.py @@ -0,0 +1,115 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Literal + +from ...trainer.grpo_config import GRPOConfig + + +@dataclass +class DPPOConfig(GRPOConfig): + """ + Configuration class for DPPOTrainer. + + DPPO (Divergence Proximal Policy Optimization) replaces PPO/GRPO's heuristic ratio-clipping with a principled trust + region based on direct policy divergence estimates. + + Paper: "Rethinking the Trust Region in LLM Reinforcement Learning" (arXiv:2602.04879) + + Args: + divergence_type (`Literal["binary_tv", "binary_kl", "topk_tv", "topk_kl"]`, *optional*, defaults to `"binary_tv"`): + Divergence approximation used for the trust-region mask. Binary variants use only per-token log-probs; + top-K variants require storing top-K token IDs and log-probs during rollout generation plus full logits + during training. + + divergence_topk (`int`, *optional*, defaults to `20`): + K for top-K divergence approximations. Only used when `divergence_type` is `"topk_tv"` or `"topk_kl"`. + + clip_ratio_c (`float`, *optional*, defaults to `20.0`): + Upper bound on the importance-sampling ratio for stability. The IS ratio is clamped to [0, clip_ratio_c]. + + epsilon (`float`, inherited from GRPOConfig, default overridden to `0.15`): + Divergence threshold δ_low. Tokens whose divergence exceeds this when the policy moves in the + advantage-decreasing direction are masked. The paper recommends 0.15 for TV divergence and 0.05 for KL + divergence. + + epsilon_high (`float`, inherited from GRPOConfig, default overridden to `0.15`): + Divergence threshold δ_high. Tokens whose divergence exceeds this when the policy moves in the + advantage-increasing direction are masked. The paper recommends 0.15 for TV divergence and 0.05 for KL + divergence. + """ + + divergence_type: Literal["binary_tv", "binary_kl", "topk_tv", "topk_kl"] = field( + default="binary_tv", + metadata={ + "help": "Divergence approximation used for the trust-region mask. Binary variants use only per-token " + "log-probs; top-K variants require storing top-K token IDs and log-probs during rollout generation plus " + "full logits during training." + }, + ) + divergence_topk: int = field( + default=20, + metadata={ + "help": "K for top-K divergence approximations. Only used when `divergence_type` is `'topk_tv'` or " + "`'topk_kl'`." + }, + ) + clip_ratio_c: float = field( + default=20.0, + metadata={ + "help": "Upper bound on the importance-sampling ratio for stability. The IS ratio is clamped to " + "[0, clip_ratio_c]." + }, + ) + epsilon: float = field( + default=0.15, + metadata={ + "help": "Divergence threshold δ_low. Tokens whose divergence exceeds this when the policy moves in the " + "advantage-decreasing direction are masked. The paper recommends 0.15 for TV divergence and 0.05 for KL " + "divergence." + }, + ) + epsilon_high: float = field( + default=0.15, + metadata={ + "help": "Divergence threshold δ_high. Tokens whose divergence exceeds this when the policy moves in the " + "advantage-increasing direction are masked. The paper recommends 0.15 for TV divergence and 0.05 for KL " + "divergence." + }, + ) + + def __post_init__(self): + super().__post_init__() + + if self.divergence_type not in ("binary_tv", "binary_kl", "topk_tv", "topk_kl"): + raise ValueError( + f"divergence_type must be one of 'binary_tv', 'binary_kl', 'topk_tv', 'topk_kl', " + f"got {self.divergence_type!r}" + ) + + if self.divergence_topk < 1: + raise ValueError(f"divergence_topk must be >= 1, got {self.divergence_topk}") + + if self.clip_ratio_c <= 0: + raise ValueError(f"clip_ratio_c must be > 0, got {self.clip_ratio_c}") + + if self.loss_type != "dapo": + raise ValueError(f"loss_type {self.loss_type} is not supported for DPPO") + + if self.top_entropy_quantile != 1.0: + raise ValueError("top_entropy_quantile is not supported for DPPO") + + if self.off_policy_mask_threshold is not None: + raise ValueError("off_policy_mask_threshold is not supported for DPPO") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/dppo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/dppo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..fb566d2234be7b242be2e459945ed29844b48578 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/dppo/dppo_trainer.py @@ -0,0 +1,1387 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +import copy +import math +import textwrap +from collections.abc import Callable +from contextlib import nullcontext +from copy import copy as shallow_copy +from typing import Any + +import numpy as np +import torch +import transformers +from accelerate.utils import gather_object +from datasets import Dataset, IterableDataset +from packaging.version import Version +from torch.distributed.fsdp import FullyShardedDataParallel as FSDP +from transformers import ( + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + Trainer, + TrainerCallback, +) +from transformers.utils import is_peft_available + +from ...chat_template_utils import parse_response +from ...data_utils import ( + apply_chat_template, + is_conversational, + prepare_multimodal_messages, +) +from ...extras.profiling import profiling_context, profiling_decorator +from ...models import unwrap_model_for_generation +from ...models.utils import disable_gradient_checkpointing +from ...trainer.grpo_trainer import EnvironmentFactory, GRPOTrainer, RewardFunc, RolloutFunc +from ...trainer.utils import ( + entropy_from_logits, + nanstd, + pad, + selective_log_softmax, + use_adapter, +) +from .dppo_config import DPPOConfig + + +if is_peft_available(): + from peft import PeftConfig, PeftModel + +SAFETY_CLAMP_MAX = 20 + + +def _strip_padding(tensor: torch.Tensor, mask: torch.Tensor) -> list[list]: + """Remove padding from a batched tensor using a mask, returning a ragged list-of-lists.""" + return [row[m].tolist() for row, m in zip(tensor, mask.bool(), strict=True)] + + +class DPPOTrainer(GRPOTrainer): + """ + Trainer for Divergence Proximal Policy Optimization (DPPO). + + DPPO replaces PPO/GRPO's heuristic ratio-clipping with a principled trust region based on direct policy divergence + estimates. PPO-style clipping masks tokens based on probability ratio π/μ, which over-penalizes low-probability + tokens and under-penalizes high-probability tokens. In contrast, DPPO masks based on direct approximation of policy + divergence (e.g TV or KL) ensuring updates stay within a theoretically grounded trust region. + + + Four divergence approximations are supported: + - `binary_tv`: Absolute probability difference |π(a) - μ(a)| (simplest) + - `binary_kl`: Bernoulli KL divergence between old and new token probabilities + - `topk_tv`: Total variation over the top-K tokens of the distribution + - `topk_kl`: KL divergence over the top-K tokens of the distribution + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + reward_funcs (`RewardFunc | list[RewardFunc]`): + Reward functions to be used for computing the rewards. To compute the rewards, we call all the reward + functions with the prompts and completions and sum the rewards. Can be either: + + - A single reward function, such as: + - A string: The *model ID* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForSequenceClassification.from_pretrained`] with `num_labels=1` and the + keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object: Only sequence classification models are supported. + - A custom reward function: The function is provided with the prompts and the generated completions, + plus any additional columns in the dataset. It should return a list of rewards. Custom reward + functions can be either synchronous or asynchronous and can also return `None` when the reward is + not applicable to those samples. This is useful for multi-task training where different reward + functions apply to different types of samples. When a reward function returns `None` for a sample, + that reward function is excluded from the reward calculation for that sample. For more details, see + [Using a custom reward + function](#using-a-custom-reward-function). + + The trainer's state is also passed to the reward function. The trainer's state is an instance of + [`~transformers.TrainerState`] and can be accessed by accessing the `trainer_state` argument to the + reward function's signature. + - A list of reward functions, where each item can independently be any of the above types. Mixing different + types within the list (e.g., a string model ID and a custom reward function) is allowed. + args ([`DPPOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. It must include a column `"prompt"`. Any additional columns in the dataset is + ignored. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. The padding side must be set to "left". If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoProcessor.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + reward_processing_classes ([`~transformers.PreTrainedTokenizerBase`] or `list[PreTrainedTokenizerBase]`, *optional*): + Processing classes corresponding to the reward functions specified in `reward_funcs`. Can be either: + + - A single processing class: Used when `reward_funcs` contains only one reward function. + - A list of processing classes: Must match the order and length of the reward functions in `reward_funcs`. + If set to `None`, or if an element of the list corresponding to a [`~transformers.PreTrainedModel`] is + `None`, the tokenizer for the model is automatically loaded using + [`~transformers.AutoTokenizer.from_pretrained`]. For elements in `reward_funcs` that are custom reward + functions (not [`~transformers.PreTrainedModel`]), the corresponding entries in `reward_processing_classes` + are ignored. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + tools (list of `Callable`, *optional*): + A list of callable tool functions (sync or async) that the model can invoke during generation. Each tool + should be a standard Python function with properly type-hinted arguments and return values, and a + Google-style docstring describing its purpose, arguments, and return value. For more details, see: + https://huggingface.co/docs/transformers/en/chat_extras#passing-tools. The model uses the function's name, + type hints, and docstring to determine how to call it. Ensure that the model's chat template supports tool + use and that it has been fine-tuned for tool calling. + rollout_func (`RolloutFunc`, *optional*): + Function to use for generating completions. It receives the list of prompts allocated to the current + process and the trainer instance. It must return a dict with `"prompt_ids"`, `"completion_ids"`, and + `"logprobs"` fields. Any other fields are forwarded to the reward functions. This feature is experimental + and may change or be removed at any time without prior notice. + """ + + _tag_names = ["trl", "dppo"] + _name = "DPPO" + _paper = { + "title": "Rethinking the Trust Region in LLM Reinforcement Learning", + "id": "2602.04879", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{qi2026rethinking, + title = {{Rethinking the Trust Region in LLM Reinforcement Learning}}, + author = {Qi, Penghui and Zhou, Xiangxin and Liu, Zichen and Pang, Tianyu and Du, Chao and Lin, Min and Lee, Wee Sun}, + journal = {arXiv preprint arXiv:2602.04879}, + year = {2026} + }"""), + } + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + reward_funcs: RewardFunc | list[RewardFunc], + args: DPPOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: "PeftConfig | None" = None, + tools: list[Callable] | None = None, + rollout_func: RolloutFunc | None = None, + environment_factory: EnvironmentFactory | None = None, + ): + if args is None: + model_name = model if isinstance(model, str) else model.config._name_or_path + model_name = model_name.split("/")[-1] + args = DPPOConfig(f"{model_name}-DPPO") + + self.divergence_type = args.divergence_type + self.divergence_topk = args.divergence_topk + self.clip_ratio_c = args.clip_ratio_c + + super().__init__( + model=model, + reward_funcs=reward_funcs, + args=args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=reward_processing_classes, + callbacks=callbacks, + optimizers=optimizers, + peft_config=peft_config, + tools=tools, + rollout_func=rollout_func, + environment_factory=environment_factory, + ) + + if self.divergence_type in ["topk_tv", "topk_kl"] and self.use_vllm: + self.vllm_generation.logprobs = self.divergence_topk + + def _tokenize_prompts(self, prompts: list): + """Tokenize prompts and extract images/multimodal fields for generation.""" + if is_conversational({"prompt": prompts[0]}): + images = [] + has_images = False + for prompt in prompts: + prompt_images = [] + for message in prompt: + if isinstance(message["content"], list): + for part in message["content"]: + if part["type"] == "image": + prompt_images.append(part["image"]) + has_images = True + images.append(prompt_images if prompt_images else None) + images = images if has_images else None + + # Workaround for a bug in transformers 5.3.0 where some processors (e.g. Qwen2.5-VL) crash on + # batched unpadded input (transformers#44514). + # Fixed in transformers 5.4.0 (transformers#44563). + needs_padding_workaround = Version("5.3.0") <= Version(transformers.__version__) < Version("5.4.0") + tokenized = self.processing_class.apply_chat_template( + conversation=prompts, + tools=self.tools or None, # `or None`: Llama bug: it renders tool boilerplate for tools=[] + chat_template=self.chat_template, + add_generation_prompt=True, + tokenize=True, + return_dict=True, + **({"padding": True} if needs_padding_workaround else {}), + **self.chat_template_kwargs, + ) + if needs_padding_workaround: + # Unpad input_ids: remove padding tokens using attention_mask to get per-sequence lists + prompt_ids = [ + [tok for tok, m in zip(ids, mask, strict=True) if m] + for ids, mask in zip(tokenized["input_ids"], tokenized["attention_mask"], strict=True) + ] + else: + prompt_ids = tokenized["input_ids"] + multimodal_fields = {k: v for k, v in tokenized.items() if k not in ("input_ids", "attention_mask")} + else: + prompt_ids = self.processing_class(text=prompts)["input_ids"] + images = None + multimodal_fields = {} + return prompt_ids, images, multimodal_fields + + def _generate_single_turn(self, prompt_ids, images, multimodal_fields): + """Generate completions, always extracting sampled token logprobs. + + Returns: + 5-tuple of (prompt_ids, completion_ids, logprobs, topk_logprobs, topk_token_ids). topk_logprobs and + topk_token_ids are None when divergence_type is not topk. + """ + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + needs_topk = self.divergence_type in ["topk_tv", "topk_kl"] + K = self.divergence_topk + + if self.use_vllm: + if self.state.global_step != self._last_loaded_step: + with profiling_context(self, "sync_weights"): + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + prompt_ids, completion_ids, logprobs, logprob_token_ids = self.vllm_generation.generate( + prompts=prompt_ids, + images=images, + num_generations=num_generations, + profiler=profiling_context(self, "vLLM.generate"), + ) + + if needs_topk: + # vLLM returns up to K+1 entries sorted by rank (most probable first). + # The sampled token is always included but may be at any position. + # Per the paper, A'_t = TopK(μ, K) ∪ {a_t}. We keep exactly K slots: if the + # sampled token a_t is not in the top-K, it replaces the K-th ranked entry. + topk_logprobs = [] + topk_token_ids = [] + sampled_logprobs = [] + for seq_lps, seq_tids, seq_cids in zip(logprobs, logprob_token_ids, completion_ids, strict=True): + seq_topk_lps, seq_topk_tids, seq_sampled = [], [], [] + for step_lps, step_tids, sampled_tid in zip(seq_lps, seq_tids, seq_cids, strict=True): + idx = step_tids.index(sampled_tid) + seq_sampled.append(step_lps[idx]) + # Take top-K entries, then ensure sampled token is present + tk_lps = step_lps[:K] + tk_tids = step_tids[:K] + if sampled_tid not in tk_tids: + tk_lps[-1] = step_lps[idx] + tk_tids[-1] = sampled_tid + seq_topk_lps.append(tk_lps) + seq_topk_tids.append(tk_tids) + topk_logprobs.append(seq_topk_lps) + topk_token_ids.append(seq_topk_tids) + sampled_logprobs.append(seq_sampled) + else: + sampled_logprobs = [[step_lps[0] for step_lps in seq_lps] for seq_lps in logprobs] + topk_logprobs = None + topk_token_ids = None + + return prompt_ids, completion_ids, sampled_logprobs, topk_logprobs, topk_token_ids + else: + prompt_tensors = [torch.tensor(ids) for ids in prompt_ids] + padded_ids = pad(prompt_tensors, padding_value=self._tokenizer.pad_token_id, padding_side="left") + attention_mask = pad([torch.ones_like(t) for t in prompt_tensors], padding_value=0, padding_side="left") + generate_inputs = {"input_ids": padded_ids, "attention_mask": attention_mask} + for key, value in multimodal_fields.items(): + if isinstance(value, torch.Tensor): + generate_inputs[key] = value + elif isinstance(value, list) and value and isinstance(value[0], list): + generate_inputs[key] = pad([torch.tensor(x) for x in value], padding_value=0, padding_side="left") + else: + generate_inputs[key] = torch.tensor(np.array(value)) + generate_inputs = Trainer._prepare_inputs(self, generate_inputs) + + gen_config = shallow_copy(self.generation_config) + gen_config.output_logits = True + gen_config.return_dict_in_generate = True + + with ( + profiling_context(self, "transformers.generate"), + unwrap_model_for_generation( + self.model_wrapped, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + generation_kwargs=self.generation_kwargs, + ) as unwrapped_model, + torch.no_grad(), + FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), + ): + gen_output = unwrapped_model.generate(**generate_inputs, generation_config=gen_config) + + prompt_ids_tensor, prompt_mask = generate_inputs["input_ids"], generate_inputs["attention_mask"] + prompt_length = prompt_ids_tensor.size(1) + completion_ids = gen_output.sequences[:, prompt_length:] + + sampled_chunks = [] + topk_logps_chunks = [] if needs_topk else None + topk_ids_chunks = [] if needs_topk else None + + for t, logits_t in enumerate(gen_output.logits): + # logits_t: (B, V) + logits_t = logits_t / self.temperature + + # exact sampled-token logprob without allocating (B, V) log_softmax output + logZ_t = torch.logsumexp(logits_t, dim=-1, keepdim=True) + sampled_ids_t = completion_ids[:, t : t + 1] + sampled_lp_t = logits_t.gather(-1, sampled_ids_t) - logZ_t + sampled_chunks.append(sampled_lp_t.cpu()) + + if needs_topk: + topk_logits_t, topk_ids_t = torch.topk(logits_t, k=K, dim=-1) # (B, K), (B, K) + topk_lp_t = topk_logits_t - logZ_t + + # Ensure sampled token is included in A'_t = TopK ∪ {a_t} + missing = ~(topk_ids_t == sampled_ids_t).any(dim=-1) + if missing.any(): + topk_ids_t = topk_ids_t.clone() + topk_lp_t = topk_lp_t.clone() + topk_ids_t[missing, -1] = sampled_ids_t[missing, 0] + topk_lp_t[missing, -1] = sampled_lp_t[missing, 0] + + topk_ids_chunks.append(topk_ids_t.cpu()) + topk_logps_chunks.append(topk_lp_t.cpu()) + + # Mask everything after the first EOS token + is_eos = completion_ids == self._tokenizer.eos_token_id + has_eos = is_eos.any(dim=1) + eos_idx = torch.full((is_eos.size(0),), is_eos.size(1), dtype=torch.long, device=device) + eos_idx[has_eos] = is_eos.int().argmax(dim=1)[has_eos] + sequence_indices = torch.arange(is_eos.size(1), device=device).expand(is_eos.size(0), -1) + completion_mask = (sequence_indices <= eos_idx.unsqueeze(1)).int() + prompt_mask_cpu = prompt_mask.bool().cpu() + completion_mask_cpu = completion_mask.bool().cpu() + + prompt_ids_out = _strip_padding(prompt_ids_tensor.cpu(), prompt_mask_cpu) + completion_ids_out = _strip_padding(completion_ids.cpu(), completion_mask_cpu) + logprobs_out = _strip_padding(torch.cat(sampled_chunks, dim=1), completion_mask_cpu) + if needs_topk: + topk_logprobs = _strip_padding(torch.stack(topk_logps_chunks, dim=1), completion_mask_cpu) + topk_token_ids = _strip_padding(torch.stack(topk_ids_chunks, dim=1), completion_mask_cpu) + else: + topk_logprobs = None + topk_token_ids = None + + return prompt_ids_out, completion_ids_out, logprobs_out, topk_logprobs, topk_token_ids + + def _tool_call_loop( + self, prompts, prompt_ids, completion_ids, completions, logprobs, topk_logprobs, topk_token_ids + ): + """Tool execution loop that also threads top-K logprob data alongside logprobs. + + Mirrors GRPOTrainer._tool_call_loop but additionally concatenates topk_logprobs and topk_token_ids the same way + logprobs is concatenated: real data for model-generated tokens, zero-padding for tool-result tokens. When topk + data is None (binary divergence), behaves identically to the parent. + """ + K = self.divergence_topk + has_topk = topk_logprobs is not None + + tool_calls = [completion[0].get("tool_calls") for completion in completions] + idxs_with_tool = [idx for idx, tool_call in enumerate(tool_calls) if tool_call] + tool_calls = [tool_calls[idx] for idx in idxs_with_tool] + tool_mask = [[1] * len(ids) for ids in completion_ids] + tool_call_count = 0 + tool_failure_count = 0 + iteration_num = 0 + while idxs_with_tool and iteration_num < self.max_tool_calling_iterations: + prompt_completion_tools = [prompts[i] for i in idxs_with_tool] + + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + tool_call_list = tool_calls[idx] + prompt_completion_tool = prompt_completion_tools[idx] + sync_tool_dict = self._sync_tool_dicts[idx_with_tool] + async_tool_dict = self._async_tool_dicts[idx_with_tool] + prompt_completion_tool.append(completions[idx_with_tool][-1]) + async_coros = [] + tool_call_results = [] + for tool_call in tool_call_list: + tool_call_count += 1 + if tool_call["type"] == "function": + function = tool_call["function"] + name = function["name"] + try: + if name in sync_tool_dict: + tool_call_results.append((name, sync_tool_dict[name](**function["arguments"]))) + elif name in async_tool_dict: + async_coros.append((name, async_tool_dict[name](**function["arguments"]))) + else: + raise ValueError(f"Tool {name} not found.") + except Exception as err: + tool_failure_count += 1 + tool_call_results.append((name, {"error": str(err)})) + else: + tool_failure_count += 1 + name = tool_call.get("name", "unknown") + tool_call_results.append((name, {"error": f"Unsupported tool call type: {tool_call['type']}"})) + + if async_coros: + + async def _run_async_tools(async_coros): + coros = [coro for _, coro in async_coros] + results = await asyncio.gather(*coros, return_exceptions=True) + return [(name, result) for (name, _), result in zip(async_coros, results, strict=False)] + + async_results = asyncio.run_coroutine_threadsafe( + _run_async_tools(async_coros), self.async_loop + ).result() + + for name, result in async_results: + if isinstance(result, Exception): + tool_failure_count += 1 + tool_call_results.append((name, {"error": str(result)})) + else: + tool_call_results.append((name, result)) + + for name, result in tool_call_results: + tool_message = {"role": "tool", "name": name, "content": str(result)} + prompt_completion_tool.append(tool_message) + completions[idx_with_tool].append(tool_message) + + # Tokenize and filter samples whose length exceeds max allowed length + pct_ids = self.processing_class.apply_chat_template( + prompt_completion_tools, + tools=self.tools or None, # `or None`: Llama bug: it renders tool boilerplate for tools=[] + chat_template=self.chat_template, + add_generation_prompt=True, + tokenize=True, + return_dict=False, + **self.chat_template_kwargs, + ) + if self.use_vllm and self.vllm_mode == "colocate": + max_model_len = self.vllm_generation.llm.llm_engine.model_config.max_model_len + elif not self.use_vllm: + max_model_len = self.model.config.max_position_embeddings + else: + raise NotImplementedError( + f"Unsupported mode detected: use_vllm={self.use_vllm}, vllm_mode={self.vllm_mode}" + ) + overlong = [len(pct) >= max_model_len for pct in pct_ids] + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + if overlong[idx]: + prompt_length = len(prompt_ids[idx_with_tool]) + ct = pct_ids[idx][prompt_length : prompt_length + self.max_completion_length] + completion_ids[idx_with_tool] = ct + tool_mask[idx_with_tool] += [1] * (len(ct) - len(tool_mask[idx_with_tool])) + if logprobs is not None: + logprobs[idx_with_tool] += [0.0] * (len(ct) - len(logprobs[idx_with_tool])) + if has_topk: + topk_logprobs[idx_with_tool] += [[0.0] * K] * (len(ct) - len(topk_logprobs[idx_with_tool])) + topk_token_ids[idx_with_tool] += [[0] * K] * (len(ct) - len(topk_token_ids[idx_with_tool])) + + idxs_with_tool = [idx for idx, o in zip(idxs_with_tool, overlong, strict=True) if not o] + prompt_completion_tools = [pct for pct, o in zip(prompt_completion_tools, overlong, strict=True) if not o] + if not idxs_with_tool: + break + + # Generate new completions after tool execution + pct_prompt_ids, pct_images, pct_multimodal_fields = self._tokenize_prompts(prompt_completion_tools) + ( + prompt_completion_tool_ids, + post_tool_ids, + post_tool_logprobs, + post_tool_topk_logprobs, + post_tool_topk_token_ids, + ) = self._generate_single_turn(pct_prompt_ids, pct_images, pct_multimodal_fields) + + # Sanity check: chat template must be prefix-preserving + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + pct = prompt_completion_tool_ids[idx] + if prompt_ids[idx_with_tool] != pct[: len(prompt_ids[idx_with_tool])]: + raise ValueError( + "The chat template is not prefix-preserving. Please update it to use a prefix-preserving " + "format." + ) + + # Truncate so that pct[len(prompt_ids[idx]):] + post_tool does not exceed max_completion_length + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + prompt_len = len(prompt_ids[idx_with_tool]) + completion_tool_ids = prompt_completion_tool_ids[idx][prompt_len:] + excess_length = len(completion_tool_ids) + len(post_tool_ids[idx]) - self.max_completion_length + if excess_length > 0: + post_tool_ids[idx] = post_tool_ids[idx][:-excess_length] + if logprobs is not None: + post_tool_logprobs[idx] = post_tool_logprobs[idx][:-excess_length] + if has_topk and post_tool_topk_logprobs is not None: + post_tool_topk_logprobs[idx] = post_tool_topk_logprobs[idx][:-excess_length] + post_tool_topk_token_ids[idx] = post_tool_topk_token_ids[idx][:-excess_length] + excess_length = len(completion_tool_ids) + len(post_tool_ids[idx]) - self.max_completion_length + if excess_length > 0: + prompt_completion_tool_ids[idx] = prompt_completion_tool_ids[idx][:-excess_length] + + # Update tool_mask and logprobs: tool result tokens get 0/0.0, post-tool model tokens get 1/real values + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + prompt_completion_tool_length = len(prompt_completion_tool_ids[idx]) + prompt_length = len(prompt_ids[idx_with_tool]) + completion_length = len(completion_ids[idx_with_tool]) + post_tool_length = len(post_tool_ids[idx]) + tool_length = prompt_completion_tool_length - prompt_length - completion_length + tool_mask[idx_with_tool] += [0] * tool_length + [1] * post_tool_length + if logprobs is not None: + logprobs[idx_with_tool] += [0.0] * tool_length + post_tool_logprobs[idx] + if has_topk: + topk_pad = [[0.0] * K] * tool_length + tid_pad = [[0] * K] * tool_length + post_topk_lp = post_tool_topk_logprobs[idx] if post_tool_topk_logprobs is not None else [] + post_topk_tid = post_tool_topk_token_ids[idx] if post_tool_topk_token_ids is not None else [] + topk_logprobs[idx_with_tool] += topk_pad + post_topk_lp + topk_token_ids[idx_with_tool] += tid_pad + post_topk_tid + + # Update completion_ids with the new completions (after tool execution) + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + prompt_length = len(prompt_ids[idx_with_tool]) + pct = prompt_completion_tool_ids[idx] + completion_ids[idx_with_tool] = pct[prompt_length:] + post_tool_ids[idx] + + # Decode post-tool completions + post_tool_completions = [parse_response(self._tokenizer, ids) if ids else {} for ids in post_tool_ids] + + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + if post_tool_completions[idx]: + completions[idx_with_tool].append(post_tool_completions[idx]) + + # Check for further tool calls + tool_calls = [completion.get("tool_calls") for completion in post_tool_completions] + idxs_with_tool = [idx for idx, tool_call in zip(idxs_with_tool, tool_calls, strict=True) if tool_call] + tool_calls = [tool_call for tool_call in tool_calls if tool_call] + iteration_num += 1 + + return ( + tool_mask, + completions, + completion_ids, + logprobs, + topk_logprobs, + topk_token_ids, + tool_call_count, + tool_failure_count, + ) + + def _generate(self, prompts: list): + """Generate completions, handling tool calls, and thread top-K logprob data through the full pipeline. + + Returns: + 9-tuple of (prompt_ids, completion_ids, tool_mask, completions, total_completion_tokens, logprobs, + topk_logprobs, topk_token_ids, extra_fields). + """ + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + needs_topk = self.divergence_type in ["topk_tv", "topk_kl"] + + # Copy the prompts to avoid modifying the original list + prompts = copy.deepcopy(prompts) + + if self.rollout_func is not None: + # Keep vLLM weights in sync for custom rollouts that rely on vLLM utilities. + if self.use_vllm and self.state.global_step != self._last_loaded_step: + with profiling_context(self, "sync_weights"): + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + # Pass prompts to rollout_func preserving structured messages. + # Chat templating must happen inside rollout_func, at the backend boundary, so that + # multimodal content (images, typed content blocks) is not lost before rollout logic runs. + output = self.rollout_func(prompts, self) + required_keys = {"prompt_ids", "completion_ids", "logprobs"} + missing_keys = required_keys - output.keys() + if missing_keys: + missing_keys_list = sorted(missing_keys) + raise ValueError(f"rollout_func must return keys {missing_keys_list} in its output dict.") + extra_fields = {k: v for k, v in output.items() if k not in required_keys} + prompt_ids = output["prompt_ids"] + completion_ids = output["completion_ids"] + logprobs = output["logprobs"] + topk_logprobs = extra_fields.pop("topk_logprobs", None) + topk_token_ids = extra_fields.pop("topk_token_ids", None) + if needs_topk and (topk_logprobs is None or topk_token_ids is None): + raise ValueError( + "rollout_func must return keys ['topk_logprobs', 'topk_token_ids'] when divergence_type is " + f"{self.divergence_type!r}." + ) + else: + prompt_ids, images, multimodal_fields = self._tokenize_prompts(prompts) + prompt_ids, completion_ids, logprobs, topk_logprobs, topk_token_ids = self._generate_single_turn( + prompt_ids, images, multimodal_fields + ) + extra_fields = {} + + # Decode completions. It's important to use `parse_response` when possible, because it handles tool calls. + if is_conversational({"prompt": prompts[0]}): + if ( + Version(transformers.__version__) >= Version("5.0.0") # parse_response added in v5 + and hasattr(self._tokenizer, "response_schema") # attribute not set by default for now + and self._tokenizer.response_schema is not None # only works if the tokenizer has a schema + ): + completions = [[parse_response(self._tokenizer, ids)] for ids in completion_ids] + else: + contents = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + completions = [[{"role": "assistant", "content": content}] for content in contents] + else: + completions = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Extract tool calls from the completions and (possibly) execute them + if self.tools: + ( + tool_mask, + completions, + completion_ids, + logprobs, + topk_logprobs, + topk_token_ids, + tool_call_count, + tool_failure_count, + ) = self._tool_call_loop( + prompts, prompt_ids, completion_ids, completions, logprobs, topk_logprobs, topk_token_ids + ) + else: + tool_mask = extra_fields.pop("env_mask", None) + + # Get completion length per sequence, used for logging + prompt_lengths = torch.tensor([len(ids) for ids in prompt_ids], device=device) + if tool_mask is not None: + completion_lengths = torch.tensor([sum(mask) for mask in tool_mask], device=device) + else: + completion_lengths = torch.tensor([len(ids) for ids in completion_ids], device=device) + agg_prompt_lengths = self.accelerator.gather(prompt_lengths) + agg_completion_lengths = self.accelerator.gather(completion_lengths) + total_prompt_tokens = agg_prompt_lengths.sum() + total_completion_tokens = agg_completion_lengths.sum() + + if mode == "train": + self.state.num_input_tokens_seen += (total_prompt_tokens + total_completion_tokens).item() + self._metrics[mode]["num_tokens"] = [self.state.num_input_tokens_seen] + + self._metrics[mode]["completions/mean_length"].append(agg_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_length"].append(agg_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_length"].append(agg_completion_lengths.float().max().item()) + + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids], device=device) + agg_is_truncated = self.accelerator.gather(is_truncated) + self._metrics[mode]["completions/clipped_ratio"].append(agg_is_truncated.float().mean().item()) + term_completion_lengths = agg_completion_lengths[~agg_is_truncated] + if len(term_completion_lengths) == 0: + term_completion_lengths = torch.zeros(1, device=device) + self._metrics[mode]["completions/mean_terminated_length"].append(term_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_terminated_length"].append(term_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_terminated_length"].append(term_completion_lengths.float().max().item()) + + if self.tools: + agg_tool_call_count = self.accelerator.gather(torch.tensor(tool_call_count, device=device)).sum() + tool_call_frequency = (agg_tool_call_count / len(agg_prompt_lengths)).item() + self._metrics[mode]["tools/call_frequency"].append(tool_call_frequency) + agg_tool_failure_count = self.accelerator.gather(torch.tensor(tool_failure_count, device=device)).sum() + failure_frequency = ( + (agg_tool_failure_count / agg_tool_call_count).item() if agg_tool_call_count > 0 else 0.0 + ) + self._metrics[mode]["tools/failure_frequency"].append(failure_frequency) + + return ( + prompt_ids, + completion_ids, + tool_mask, + completions, + total_completion_tokens, + logprobs, + topk_logprobs, + topk_token_ids, + extra_fields, + ) + + @profiling_decorator + def _get_per_token_logps_with_topk( + self, + model, + input_ids, + attention_mask, + logits_to_keep, + topk_token_ids, + batch_size=None, + compute_entropy=False, + pixel_values=None, + image_grid_thw=None, + num_images=None, + pixel_attention_mask=None, + image_sizes=None, + token_type_ids=None, + mm_token_type_ids=None, + ) -> tuple[torch.Tensor, torch.Tensor | None, torch.Tensor]: + """Compute per-token log-probs, (optionally) entropies, and top-K log-probs in one forward pass. + + Evaluates the current policy's log-probs at the rollout's top-K token IDs from the same forward pass used for + per_token_logps, avoiding an extra model call. + + Args: + topk_token_ids: Rollout policy's top-K token IDs, shape (B, T, K). The current policy's + log-probs are evaluated at these positions. + + Returns: + Tuple of (per_token_logps, entropies, current_topk_logps). + """ + batch_size = batch_size or input_ids.size(0) + all_logps = [] + all_entropies = [] + all_topk_logps = [] + + for start in range(0, input_ids.size(0), batch_size): + end = start + batch_size + input_ids_batch = input_ids[start:end] + attention_mask_batch = attention_mask[start:end] + + model_inputs = {"input_ids": input_ids_batch, "attention_mask": attention_mask_batch} + if image_grid_thw is not None and pixel_values is not None: + rows_per_image = image_grid_thw.prod(dim=-1) + rows_per_sample = torch.split(rows_per_image, num_images) + rows_per_sample = torch.stack([s.sum() for s in rows_per_sample]) + cum_rows = torch.cat([torch.tensor([0], device=rows_per_sample.device), rows_per_sample.cumsum(0)]) + row_start, row_end = cum_rows[start].item(), cum_rows[end].item() + model_inputs["pixel_values"] = pixel_values[row_start:row_end] + cum_imgs = torch.tensor([0] + num_images).cumsum(0) + img_start, img_end = cum_imgs[start], cum_imgs[end] + model_inputs["image_grid_thw"] = image_grid_thw[img_start:img_end] + elif pixel_values is not None: + model_inputs["pixel_values"] = pixel_values[start:end] + if pixel_attention_mask is not None: + model_inputs["pixel_attention_mask"] = pixel_attention_mask[start:end] + if image_sizes is not None: + model_inputs["image_sizes"] = image_sizes[start:end] + if token_type_ids is not None: + model_inputs["token_type_ids"] = token_type_ids[start:end] + if mm_token_type_ids is not None: + model_inputs["mm_token_type_ids"] = mm_token_type_ids[start:end] + + if "logits_to_keep" in self.model_kwarg_keys: + model_inputs["logits_to_keep"] = logits_to_keep + 1 + + model_inputs["use_cache"] = False + + logits = model(**model_inputs).logits + logits = logits[:, :-1, :] + logits = logits[:, -logits_to_keep:, :] + logits = logits / self.temperature + + completion_ids = input_ids_batch[:, -logits_to_keep:] + logps = selective_log_softmax(logits, completion_ids) + all_logps.append(logps) + + if compute_entropy: + with torch.no_grad(): + entropies = entropy_from_logits(logits) + all_entropies.append(entropies) + + with torch.no_grad(): + topk_logps = selective_log_softmax(logits, topk_token_ids[start:end]) + all_topk_logps.append(topk_logps) + + logps = torch.cat(all_logps, dim=0) + entropies = torch.cat(all_entropies, dim=0) if compute_entropy else None + topk_logps = torch.cat(all_topk_logps, dim=0) + return logps, entropies, topk_logps + + def _generate_and_score_completions( + self, inputs: list[dict[str, torch.Tensor | Any]] + ) -> dict[str, torch.Tensor | Any]: + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + prompts = [x["prompt"] for x in inputs] + + if self.environments: + for prompt, environment, reset_kwargs in zip(prompts, self.environments, inputs, strict=True): + observation = environment.reset(**reset_kwargs) + if observation is None: + continue + prompt[-1]["content"] += observation + + if "images" in inputs[0]: + images = [example.get("images") for example in inputs] + elif "image" in inputs[0]: + images = [[example.get("image")] if example.get("image") is not None else None for example in inputs] + else: + images = None + # Transformers requires at least one image in the batch, otherwise it throws an error + if images is not None and all(img_list == [] for img_list in images): + images = None + + # If the prompts are conversational and the inputs contain images, we need to convert the prompts from + # [{"role": "user", "content": "What color is the sky?"}] to + # [{"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What color is the sky?"}]}] + if images is not None: + if not is_conversational(inputs[0]): + raise ValueError( + "Multimodal training requires conversational prompts. It looks like the dataset contains " + "non-conversational inputs, likely because a chat template was applied before passing the dataset " + "to the trainer. Please provide the raw conversational prompts and let the trainer apply the chat " + "template internally." + ) + prompts = [ + prepare_multimodal_messages(prompt, images=image_list) + for prompt, image_list in zip(prompts, images, strict=True) + ] + + ( + prompt_ids_list, + completion_ids_list, + tool_mask_list, + completions, + num_items_in_batch, + sampling_per_token_logps_list, + topk_logprobs_list, + topk_token_ids_list, + extra_fields, + ) = self._generate(prompts) + + # Convert lists of token IDs to padded tensors + prompt_ids = [torch.tensor(ids) for ids in prompt_ids_list] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + prompt_ids = pad( + prompt_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + prompt_mask = pad( + prompt_mask, padding_value=0, padding_side="left", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + completion_ids = [torch.tensor(ids) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + completion_ids = pad( + completion_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_mask = pad( + completion_mask, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + sampling_per_token_logps = [torch.tensor(logps) for logps in sampling_per_token_logps_list] + sampling_per_token_logps = pad( + sampling_per_token_logps, + padding_value=0.0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + if tool_mask_list is not None: + tool_mask = [torch.tensor(mask) for mask in tool_mask_list] + tool_mask = pad( + tool_mask, padding_value=1, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + else: + tool_mask = None + if topk_logprobs_list is not None: + sampling_topk_logps = [torch.tensor(lp) for lp in topk_logprobs_list] + sampling_topk_logps = pad( + sampling_topk_logps, + padding_value=0.0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + sampling_topk_token_ids = [torch.tensor(tid, dtype=torch.long) for tid in topk_token_ids_list] + sampling_topk_token_ids = pad( + sampling_topk_token_ids, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + else: + sampling_topk_logps = None + sampling_topk_token_ids = None + + # If mask_truncated_completions is enabled, zero out truncated completions for attention and loss masking + if self.mask_truncated_completions: + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + # Mask completion_mask for attention masking + completion_mask = completion_mask * (~is_truncated).unsqueeze(1).int() + # Also mask tool_mask for consistency in multi-turn training + if tool_mask is not None: + tool_mask = tool_mask * (~is_truncated).unsqueeze(1).int() + + # Concatenate prompt_mask with completion_mask for logit computation + prompt_completion_ids = torch.cat([prompt_ids, completion_ids], dim=1) # (B, P+C) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) # (B, P+C) + + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_size + + num_images = [len(img_list) for img_list in images] if images is not None else None + + # Get forward_kwargs for models with multimodal inputs + if images is not None: + prompts_text = [ + apply_chat_template( + {"prompt": prompt}, self.processing_class, tools=self.tools, **self.chat_template_kwargs + )["prompt"] + for prompt in prompts + ] + prompt_inputs = self.processing_class(images=images, text=prompts_text, padding=True, return_tensors="pt") + prompt_inputs = Trainer._prepare_inputs(self, prompt_inputs) + forward_kwargs = {k: v for k, v in prompt_inputs.items() if k not in ["input_ids", "attention_mask"]} + else: + forward_kwargs = {} + + # If token_type_ids are used, extend them with zeros for the completion part + if "token_type_ids" in forward_kwargs: + token_type_ids = forward_kwargs["token_type_ids"] + if self.pad_to_multiple_of is not None: + padding_size = prompt_ids.size(1) - token_type_ids.size(1) + if padding_size > 0: + token_type_ids = torch.cat( + [token_type_ids.new_zeros((token_type_ids.size(0), padding_size)), token_type_ids], dim=1 + ) + forward_kwargs["token_type_ids"] = torch.cat( + [token_type_ids, token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + # If mm_token_type_ids are used, extend them with zeros for the completion part + if "mm_token_type_ids" in forward_kwargs: + mm_token_type_ids = forward_kwargs["mm_token_type_ids"] + if self.pad_to_multiple_of is not None: + padding_size = prompt_ids.size(1) - mm_token_type_ids.size(1) + if padding_size > 0: + mm_token_type_ids = torch.cat( + [mm_token_type_ids.new_zeros((mm_token_type_ids.size(0), padding_size)), mm_token_type_ids], + dim=1, + ) + forward_kwargs["mm_token_type_ids"] = torch.cat( + [mm_token_type_ids, mm_token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + + # When gradient checkpointing is enabled with use_reentrant=True (non default), calling the model inside a + # torch.no_grad() block triggers a harmless PyTorch warning ("None of the inputs have requires_grad=True"). + # Temporarily disable checkpointing to avoid this warning during inference. + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + # Compute the per-token log probabilities for the reference model + if self.beta != 0.0: + if self.ref_model is not None: + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.ref_model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + # When training a PEFT adapter, how we obtain the reference depends on the setup: + # - New adapter: disabling adapters yields the base model. + # - Re-training an existing adapter: an initial copy is loaded under the name "ref". + model = self.accelerator.unwrap_model(self.model) + with use_adapter(model, adapter_name="ref" if "ref" in model.peft_config else None): + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + ref_per_token_logps = None + + # Decode + prompts_text = self.processing_class.batch_decode(prompt_ids, skip_special_tokens=True) + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Merge extra_fields from rollout_func into inputs for reward functions + if extra_fields: + for i, inp in enumerate(inputs): + for key, values in extra_fields.items(): + if isinstance(values, list) and i < len(values): + inp[key] = values[i] + elif not isinstance(values, list): + inp[key] = values + + # Calculate rewards for each reward function. rewards_per_func aggregates rewards across all processes. This is + # important because rewards will be normalized per group, and completions are distributed. We will later slice + # rewards_per_func to extract each process's subset. + rewards_per_func = self._calculate_rewards(inputs, prompts, completions, completion_ids_list) + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + + if self.multi_objective_aggregation == "sum_then_normalize": + # Apply weights to each reward function's output and sum + rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + mean_grouped_rewards = rewards.view(-1, num_generations).mean(dim=1) + mean_grouped_rewards = mean_grouped_rewards.repeat_interleave(num_generations, dim=0) + if self.scale_rewards in ["group", "none"]: + # If self.scale_rewards = "none", we'll only use std_rewards to check for zero std for logging + if num_generations > 1: + std_rewards = rewards.view(-1, num_generations).std(dim=1) + std_rewards = std_rewards.repeat_interleave(num_generations, dim=0) + else: # doesn't occur during training, but could occur in eval when num_generations_eval=1 + std_rewards = torch.zeros_like(rewards) + elif self.scale_rewards == "batch": + # Compute global std + if rewards.numel() > 1: + std_rewards = rewards.std().expand_as(rewards) + else: # doesn't occur during training, but could occur in eval when num_generations_eval=batch_size=1 + std_rewards = torch.zeros_like(rewards) + else: + raise ValueError( + f"Invalid value for scale_rewards: {self.scale_rewards}. Must be one of 'batch', 'group', or 'none'." + ) + + advantages = rewards - mean_grouped_rewards + if self.scale_rewards != "none": + advantages = advantages / (std_rewards + 1e-4) + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) # for logging + + elif self.multi_objective_aggregation == "normalize_then_sum": + grouped = rewards_per_func.view(-1, num_generations, len(self.reward_funcs)) + mean_k = torch.nanmean(grouped, dim=1, keepdim=True) + std_k = nanstd(grouped, dim=1, keepdim=True) if num_generations > 1 else torch.zeros_like(mean_k) + reward_k = (grouped - mean_k) / (std_k + 1e-4) + reward_k = reward_k.view(-1, len(self.reward_funcs)) + rewards = (reward_k * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + std_rewards = rewards.std().expand_as(rewards) if rewards.numel() > 1 else torch.zeros_like(rewards) + advantages = (rewards - rewards.mean()) / (std_rewards + 1e-4) + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) # for logging + + else: + raise ValueError( + f"Invalid multi_objective_aggregation: {self.multi_objective_aggregation}. Must be " + "'sum_then_normalize' or 'normalize_then_sum'." + ) + + # Slice to keep only the local part of the data + process_slice = slice( + self.accelerator.process_index * len(prompts), + (self.accelerator.process_index + 1) * len(prompts), + ) + all_process_advantages = advantages.clone() # keep the aggregated advantages for logging + advantages = advantages[process_slice] + + # Calculate mean reward per function, but only for samples where the function was applied (non-NaN values) + for i, reward_func_name in enumerate(self.reward_func_names): + mean_rewards = torch.nanmean(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/mean"].append(mean_rewards) + std_func_rewards = nanstd(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/std"].append(std_func_rewards) + rewards = (rewards_per_func * self.reward_weights.to(rewards_per_func.device).unsqueeze(0)).nansum(dim=1) + self._metrics[mode]["reward"].append(rewards.mean().item()) + self._metrics[mode]["reward_std"].append(rewards.std().item()) + self._metrics[mode]["frac_reward_zero_std"].append(is_std_zero.float().mean().item()) + + # Log prompt and completion texts + self._logs["prompt"].extend(gather_object(prompts_text)) + self._logs["completion"].extend(gather_object(completions_text)) + for i, name in enumerate(self.reward_func_names): + self._logs["rewards"][name].extend(rewards_per_func[:, i].tolist()) + self._logs["advantages"].extend(all_process_advantages.tolist()) + + # Flush user-logged extra columns (from log_extra), gathering across processes. + # Keys must be sorted so that all ranks call gather_object in the same order, otherwise values + # get mis-attributed across columns (dict insertion order may differ between processes). + for column in sorted(self._pending_extra_logs): + self._logs["extra"][column].extend(gather_object(self._pending_extra_logs[column])) + self._pending_extra_logs.clear() + + # Flush user-logged metrics (from log_metric), averaging across processes. + # Keys must be sorted so that all ranks call accelerator.gather in the same order, otherwise values + # get mis-attributed across metrics (dict insertion order may differ between processes). + for name in sorted(self._pending_metrics): + values = self._pending_metrics[name] + local_mean = sum(values) / len(values) + global_mean = self.accelerator.gather(torch.tensor(local_mean, device=device)).mean().item() + self._metrics[mode][name].append(global_mean) + self._pending_metrics.clear() + + if images is not None: + self._logs["images"].extend(gather_object(images)) + + output = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "advantages": advantages, + "num_items_in_batch": num_items_in_batch, + "sampling_per_token_logps": sampling_per_token_logps, + } + if ref_per_token_logps is not None: + output["ref_per_token_logps"] = ref_per_token_logps + if "pixel_values" in forward_kwargs: + output["pixel_values"] = forward_kwargs["pixel_values"] + if "image_grid_thw" in forward_kwargs: + output["image_grid_thw"] = forward_kwargs["image_grid_thw"] + if "pixel_attention_mask" in forward_kwargs: + output["pixel_attention_mask"] = forward_kwargs["pixel_attention_mask"] + if "image_sizes" in forward_kwargs: + output["image_sizes"] = forward_kwargs["image_sizes"] + if "token_type_ids" in forward_kwargs: + output["token_type_ids"] = forward_kwargs["token_type_ids"] + if "mm_token_type_ids" in forward_kwargs: + output["mm_token_type_ids"] = forward_kwargs["mm_token_type_ids"] + if images is not None: + output["num_images"] = num_images + if tool_mask is not None: + output["tool_mask"] = tool_mask + if sampling_topk_logps is not None: + output["sampling_topk_logps"] = sampling_topk_logps + if sampling_topk_token_ids is not None: + output["sampling_topk_token_ids"] = sampling_topk_token_ids + return output + + @torch.no_grad() + def _compute_divergence_mask( + self, + per_token_logps, + sampling_per_token_logps, + advantages, + completion_mask, + current_topk_logps=None, + sampling_topk_logps=None, + ): + """ + Compute a per-token trust-region mask based on the configured divergence type. Tokens where the policy has + diverged too far from the sampling distribution (in a direction that would increase the loss) are masked out. + + Args: + per_token_logps (`torch.Tensor`): + Log-probabilities of the current policy at the sampled tokens, shape `(B, T)`. + sampling_per_token_logps (`torch.Tensor`): + Log-probabilities of the sampling (rollout) policy at the sampled tokens, shape `(B, T)`. + advantages (`torch.Tensor`): + Per-token or per-sequence advantage estimates, broadcastable to `(B, T)`. + completion_mask (`torch.Tensor`): + Binary mask of shape `(B, T)` where `1` indicates valid completion tokens and `0` padding. + current_topk_logps (`torch.Tensor` or `None`): + Log-probabilities of the current policy at the rollout's top-K token IDs, shape `(B, T, K)`. Required + when `divergence_type` is `"topk_tv"` or `"topk_kl"`. + sampling_topk_logps (`torch.Tensor` or `None`): + Log-probabilities of the sampling policy at the rollout's top-K token IDs, shape `(B, T, K)`. Required + when `divergence_type` is `"topk_tv"` or `"topk_kl"`. + + Returns: + `torch.Tensor`: + Float mask of shape `(B, T)` where `1.0` indicates tokens to keep and `0.0` tokens to mask out. + """ + prob = torch.exp(per_token_logps) + sampling_prob = torch.exp(sampling_per_token_logps) + + delta_low = self.epsilon_low + delta_high = self.epsilon_high + + if self.divergence_type == "binary_tv": + # TV = |π - μ| + divergence = (prob - sampling_prob).abs() + # Mask tokens where divergence > threshold AND policy moves away from trust region + invalid_pos = (divergence > delta_high) & (prob > sampling_prob) + invalid_neg = (divergence > delta_low) & (prob < sampling_prob) + mask = torch.where(advantages > 0, ~invalid_pos, ~invalid_neg) + + elif self.divergence_type == "binary_kl": + # Bernoulli KL: D = μ log(μ/π) + (1-μ) log((1-μ)/(1-π)) + kl = sampling_prob * (sampling_per_token_logps - per_token_logps) + (1 - sampling_prob) * ( + torch.log1p(-sampling_prob.clamp(max=1 - 1e-7)) - torch.log1p(-prob.clamp(max=1 - 1e-7)) + ) + + invalid_pos = (kl > delta_high) & (prob > sampling_prob) + invalid_neg = (kl > delta_low) & (prob < sampling_prob) + mask = torch.where(advantages > 0, ~invalid_pos, ~invalid_neg) + + elif self.divergence_type in ("topk_tv", "topk_kl"): + current_topk_probs = torch.exp(current_topk_logps.float()) + rollout_topk_probs = torch.exp(sampling_topk_logps.float()) + + # Aggregate remaining probability mass outside top-K into a single rest bucket. + rollout_rest = (1.0 - rollout_topk_probs.sum(dim=-1)).clamp(min=1e-12) + current_rest = (1.0 - current_topk_probs.sum(dim=-1)).clamp(min=1e-12) + + if self.divergence_type == "topk_tv": + topk_tv = (current_topk_probs - rollout_topk_probs).abs().sum(dim=-1) + rest_tv = (current_rest - rollout_rest).abs() + divergence = (topk_tv + rest_tv) / 2.0 + else: + topk_kl = (rollout_topk_probs * (sampling_topk_logps - current_topk_logps)).sum(dim=-1) + rest_kl = rollout_rest * (rollout_rest.log() - current_rest.log()) + divergence = topk_kl + rest_kl + + invalid_pos = (divergence > delta_high) & (prob > sampling_prob) + invalid_neg = (divergence > delta_low) & (prob < sampling_prob) + mask = torch.where(advantages > 0, ~invalid_pos, ~invalid_neg) + + else: + raise ValueError(f"Unknown divergence_type: {self.divergence_type}") + + return mask.float() * completion_mask + + def _compute_loss(self, model, inputs): + # Compute per-token log probabilities for the model + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) + mask = completion_mask if "tool_mask" not in inputs else completion_mask * inputs["tool_mask"] + + forward_kwargs = { + "pixel_values": inputs.get("pixel_values"), + "image_grid_thw": inputs.get("image_grid_thw"), + "num_images": inputs.get("num_images"), + "pixel_attention_mask": inputs.get("pixel_attention_mask"), + "image_sizes": inputs.get("image_sizes"), + "token_type_ids": inputs.get("token_type_ids"), + "mm_token_type_ids": inputs.get("mm_token_type_ids"), + } + + sampling_topk_token_ids = inputs.get("sampling_topk_token_ids") + if self.divergence_type.startswith("topk_") and sampling_topk_token_ids is not None: + per_token_logps, entropies, current_topk_logps = self._get_per_token_logps_with_topk( + model, + input_ids, + attention_mask, + logits_to_keep, + topk_token_ids=sampling_topk_token_ids, + compute_entropy=True, + **forward_kwargs, + ) + else: + per_token_logps, entropies = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=True, + **forward_kwargs, + ) + current_topk_logps = None + + sampling_per_token_logps = inputs["sampling_per_token_logps"] + sampling_topk_logps = inputs.get("sampling_topk_logps") + + advantages = inputs["advantages"] + if advantages.dim() == 1: + advantages = advantages.unsqueeze(1) + + # DPPO: compute IS ratio (clamped, detached) and divergence mask + log_ratio = per_token_logps - sampling_per_token_logps + ratio = torch.exp(log_ratio.clamp(max=math.log(self.clip_ratio_c))).detach() + divergence_mask = self._compute_divergence_mask( + per_token_logps, + sampling_per_token_logps, + advantages, + mask, + current_topk_logps=current_topk_logps, + sampling_topk_logps=sampling_topk_logps, + ) + + # DPPO loss: -advantages * ratio * mask * log_prob + per_token_loss = -advantages * ratio * divergence_mask * per_token_logps + + # KL divergence with reference model + if self.beta != 0.0: + ref_per_token_logps = inputs["ref_per_token_logps"] + per_token_kl = ( + torch.exp(ref_per_token_logps - per_token_logps) - (ref_per_token_logps - per_token_logps) - 1 + ) + per_token_loss = per_token_loss + self.beta * per_token_kl + + mode = "train" if self.model.training else "eval" + normalizer = inputs["num_items_in_batch"] / self.accelerator.num_processes + loss = (per_token_loss * mask).sum() / normalizer + + # Log metrics + completion_token_count = mask.sum().clamp(min=1.0) + + def masked_batch_mean(x): + if x.shape[1] == 1: + return x.mean() + return (x * mask).sum() / completion_token_count + + if self.beta != 0.0: + mean_kl = masked_batch_mean(per_token_kl) + self._metrics[mode]["kl"].append(self.accelerator.gather(mean_kl).nanmean().item()) + + mean_entropy = masked_batch_mean(entropies) + self._metrics[mode]["entropy"].append(self.accelerator.gather(mean_entropy).nanmean().item()) + + prob_diff = (torch.exp(per_token_logps) - torch.exp(sampling_per_token_logps)).abs() + self._metrics[mode]["prob_diff/mean"].append( + self.accelerator.gather(masked_batch_mean(prob_diff)).nanmean().item() + ) + per_seq_max = prob_diff.masked_fill(mask == 0, float("-inf")).max(dim=1).values + per_seq_min = prob_diff.masked_fill(mask == 0, float("inf")).min(dim=1).values + self._metrics[mode]["prob_diff/max"].append(self.accelerator.gather(per_seq_max).max().item()) + self._metrics[mode]["prob_diff/min"].append(self.accelerator.gather(per_seq_min).min().item()) + + self._metrics[mode]["advantages/mean"].append(advantages.mean().item()) + self._metrics[mode]["advantages/std"].append(advantages.std().item()) + + # Log divergence mask statistics (analogous to clip_ratio in GRPO) + is_masked = (divergence_mask == 0) & (mask > 0) + is_masked_pos = is_masked & (advantages > 0) + is_masked_neg = is_masked & (advantages < 0) + + mask_ratio_pos = masked_batch_mean(is_masked_pos.float()) + mask_ratio_neg = masked_batch_mean(is_masked_neg.float()) + mask_ratio = masked_batch_mean(is_masked.float()) + + gathered_mask_ratio_neg = self.accelerator.gather(mask_ratio_neg) + self._metrics[mode]["mask_ratio/negative_adv_mean"].append(gathered_mask_ratio_neg.nanmean().item()) + gathered_mask_ratio_pos = self.accelerator.gather(mask_ratio_pos) + self._metrics[mode]["mask_ratio/positive_adv_mean"].append(gathered_mask_ratio_pos.nanmean().item()) + gathered_mask_ratio = self.accelerator.gather(mask_ratio) + self._metrics[mode]["mask_ratio/overall_mean"].append(gathered_mask_ratio.nanmean().item()) + + return loss diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f91462a911daaff39038ef4cb53f18ffc845bea8 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .gfpo_config import GFPOConfig +from .gfpo_trainer import GFPOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/gfpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/gfpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..ae529987306eadc276115e425f4509e6dd7f1e1c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/gfpo_config.py @@ -0,0 +1,35 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ...trainer.grpo_config import GRPOConfig as _GRPOConfig + + +@dataclass +class GFPOConfig(_GRPOConfig): + num_remains_in_group: int | None = field( + default=None, + metadata={ + "help": "number inputs remains after group filter function, `'num_remains_in_group'` must be >=2 if given." + }, + ) + + def __post_init__(self): + super().__post_init__() + + if self.num_remains_in_group is not None and self.num_remains_in_group >= self.num_generations: + raise ValueError( + f"Number remains in Group {self.num_remains_in_group} must be less than num_generations : {self.num_generations}." + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/gfpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/gfpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..c5695be3cf05fa0034622d47daec56796fed4e7f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gfpo/gfpo_trainer.py @@ -0,0 +1,462 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +from collections.abc import Callable +from typing import Any + +import torch +from accelerate.utils import gather_object + +from ...data_utils import apply_chat_template, is_conversational, prepare_multimodal_messages +from ...models.utils import disable_gradient_checkpointing +from ...trainer.grpo_trainer import GRPOTrainer as _GRPOTrainer +from ...trainer.utils import nanmax, nanmin, nanstd, pad + + +logger = logging.getLogger(__name__) + +GroupFilterFunc = Callable[[list[list[Any]], list[list[Any]]], list[list[float]]] + + +class GFPOTrainer(_GRPOTrainer): + def __init__( + self, + model, + reward_funcs, + args=None, + train_dataset=None, + eval_dataset=None, + processing_class=None, + reward_processing_classes=None, + group_filter_func=None, + callbacks=None, + optimizers=(None, None), + peft_config=None, + ): + super().__init__( + model=model, + reward_funcs=reward_funcs, + args=args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=reward_processing_classes, + callbacks=callbacks, + optimizers=optimizers, + peft_config=peft_config, + ) + self.group_filter_func = group_filter_func + self.num_remains_in_group = args.num_remains_in_group + if self.group_filter_func is None and self.num_remains_in_group is not None: + raise ValueError( + f"Group filter function must not be None when num_remains_in_group ({self.num_remains_in_group}) is given." + ) + if self.group_filter_func is not None and self.num_remains_in_group is None: + logger.warning("Group filter function is not activated since num_remains_in_group is not set") + + def _generate_and_score_completions(self, inputs): + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + prompts = [x["prompt"] for x in inputs] + + if "images" in inputs[0]: + images = [example.get("images") for example in inputs] + elif "image" in inputs[0]: + images = [[example.get("image")] if example.get("image") is not None else None for example in inputs] + else: + images = None + # Transformers requires at least one image in the batch, otherwise it throws an error + if images is not None and all(img_list == [] for img_list in images): + images = None + + # If the prompts are conversational and the inputs contain images, we need to convert the prompts from + # [{"role": "user", "content": "What color is the sky?"}] to + # [{"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What color is the sky?"}]}] + if images is not None: + if not is_conversational(inputs[0]): + raise ValueError( + "Multimodal training requires conversational prompts. It looks like the dataset contains " + "non-conversational inputs, likely because a chat template was applied before passing the dataset " + "to the trainer. Please provide the raw conversational prompts and let the trainer apply the chat " + "template internally." + ) + prompts = [ + prepare_multimodal_messages(prompt, images=image_list) + for prompt, image_list in zip(prompts, images, strict=True) + ] + + dataset_images = images # preserve dataset images before _generate may overwrite + ( + prompt_ids_list, + completion_ids_list, + tool_mask_list, + completions, + num_items_in_batch, + sampling_per_token_logps_list, + extra_fields, + images, + tool_images, + ) = self._generate(prompts) + if images is None: + images = dataset_images # restore dataset images (rollout_func path returns None) + + # Convert lists of token IDs to padded tensors + prompt_ids = [torch.tensor(ids) for ids in prompt_ids_list] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + prompt_ids = pad( + prompt_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + prompt_mask = pad( + prompt_mask, + padding_value=0, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_ids = [torch.tensor(ids) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + completion_ids = pad( + completion_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_mask = pad( + completion_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + if sampling_per_token_logps_list is not None: + sampling_per_token_logps = [torch.tensor(logps) for logps in sampling_per_token_logps_list] + sampling_per_token_logps = pad( + sampling_per_token_logps, + padding_value=0.0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + else: + sampling_per_token_logps = None + + # If mask_truncated_completions is enabled, zero out truncated completions in completion_mask + if self.mask_truncated_completions: + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + completion_mask = completion_mask * (~is_truncated).unsqueeze(1).int() + + # Concatenate prompt_mask with completion_mask for logit computation + prompt_completion_ids = torch.cat([prompt_ids, completion_ids], dim=1) # (B, P+C) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) # (B, P+C) + + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_size + + num_images = [len(img_list) if img_list else 0 for img_list in images] if images is not None else None + + # Get forward_kwargs for models with multimodal inputs + if images is not None: + prompts_text = [ + apply_chat_template({"prompt": prompt}, self.processing_class)["prompt"] for prompt in prompts + ] + prompt_inputs = self.processing_class(images=images, text=prompts_text, padding=True, return_tensors="pt") + prompt_inputs = super()._prepare_inputs(prompt_inputs) + forward_kwargs = {k: v for k, v in prompt_inputs.items() if k not in ["input_ids", "attention_mask"]} + else: + forward_kwargs = {} + + # If token_type_ids are used, extend them with zeros for the completion part + if "token_type_ids" in forward_kwargs: + token_type_ids = forward_kwargs["token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and token_type_ids must have equal len + padding_size = prompt_ids.size(1) - token_type_ids.size(1) + if padding_size > 0: + token_type_ids = torch.cat( + [token_type_ids.new_zeros((token_type_ids.size(0), padding_size)), token_type_ids], dim=1 + ) + forward_kwargs["token_type_ids"] = torch.cat( + [token_type_ids, token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + # If mm_token_type_ids are used, extend them with zeros for the completion part + if "mm_token_type_ids" in forward_kwargs: + mm_token_type_ids = forward_kwargs["mm_token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and mm_token_type_ids must have equal len + padding_size = prompt_ids.size(1) - mm_token_type_ids.size(1) + if padding_size > 0: + mm_token_type_ids = torch.cat( + [mm_token_type_ids.new_zeros((mm_token_type_ids.size(0), padding_size)), mm_token_type_ids], + dim=1, + ) + forward_kwargs["mm_token_type_ids"] = torch.cat( + [mm_token_type_ids, mm_token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + + # When gradient checkpointing is enabled with use_reentrant=True (non default), calling the model inside a + # torch.no_grad() block triggers a harmless PyTorch warning ("None of the inputs have requires_grad=True"). + # Temporarily disable checkpointing to avoid this warning during inference. + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + # If the generation and optimization steps are misaligned—i.e., if generation does not occur at the end of + # a full optimizer step (when gradient_accumulation_steps is not a multiple of generate_every)—then the + # samples may come from an earlier version of the model. In that case, we need to track old_per_token_logps + # for importance sampling. If the steps are aligned, importance sampling isn't necessary and we set + # old_per_token_logps to None. + # When using vLLM, we always compute old_per_token_logps for importance sampling, it was shown that the + # distribution mismatch between vLLM and the training model can be large and harm the training. + generate_every = self.args.steps_per_generation * self.num_iterations # generation frequency + if self.args.gradient_accumulation_steps % generate_every != 0 or ( + self.use_vllm and self.vllm_importance_sampling_correction + ): + old_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + old_per_token_logps = None + + # Compute the importance sampling ratio when using vLLM, to correct for potential distribution mismatch + if self.use_vllm and self.vllm_importance_sampling_correction: + importance_sampling_ratio = torch.exp(old_per_token_logps - sampling_per_token_logps) + importance_sampling_ratio = torch.clamp( + importance_sampling_ratio, max=self.vllm_importance_sampling_cap + ) + + # Compute the per-token log probabilities for the reference model + if self.beta != 0.0: + if self.ref_model is not None: + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.ref_model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + with self.accelerator.unwrap_model(self.model).disable_adapter(): + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + ref_per_token_logps = None + + # Decode + prompts_text = self.processing_class.batch_decode(prompt_ids, skip_special_tokens=True) + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + if is_conversational(inputs[0]): + completions = [] + for prompt, completion in zip(prompts, completions_text, strict=True): + bootstrap = prompt.pop()["content"] if prompt[-1]["role"] == "assistant" else "" + if isinstance(bootstrap, list): # for VLM, the format might be [{"type": "text", "text": "..."}] + assert len(bootstrap) == 1 and bootstrap[0]["type"] == "text" + bootstrap = bootstrap[0]["text"] + completions.append([{"role": "assistant", "content": bootstrap + completion}]) + else: + completions = completions_text + + # Calculate rewards for each reward function. rewards_per_func aggregates rewards across all processes. This is + # important because rewards will be normalized per group, and completions are distributed. We will later slice + # rewards_per_func to extract each process's subset. + rewards_per_func = self._calculate_rewards(inputs, prompts, completions, completion_ids_list) + + # Apply weights to each reward function's output and sum + rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + + num_in_group = self.num_generations + num_inputs_in_device = len(prompts) + + if self.num_remains_in_group is not None and mode == "train": + num_in_group = self.num_remains_in_group + + all_completions = gather_object(completions) + + group_filter_scores = self.group_filter_func( + group_completions=[ + all_completions[i : i + 1 * self.num_generations] + for i in range(len(all_completions) // self.num_generations) + ], + group_rewards=rewards.view(-1, self.num_generations).tolist(), + ) + group_filter_scores = torch.tensor(group_filter_scores, device=device) + + _, group_local_indices = torch.topk(group_filter_scores, self.num_remains_in_group, dim=-1) + group_row_offsets = torch.arange(0, len(all_completions), self.num_generations, device=device).unsqueeze(1) + group_global_indices = group_row_offsets + group_local_indices + group_global_indices = group_global_indices.flatten() + + rewards = rewards[group_global_indices].contiguous() + rewards_per_func = rewards_per_func[group_global_indices, :].contiguous() + + num_inputs_in_device = int(len(prompts) / self.num_generations * self.num_remains_in_group) + + # Compute grouped-wise rewards + mean_grouped_rewards = rewards.view(-1, num_in_group).mean(dim=1) + + # Normalize the rewards to compute the advantages + mean_grouped_rewards = mean_grouped_rewards.repeat_interleave(num_in_group, dim=0) + advantages = rewards - mean_grouped_rewards + + if self.scale_rewards in ["group", "none"]: + # If self.scale_rewards = "none", we'll still log group level std + std_rewards = rewards.view(-1, num_in_group).std(dim=1) + std_rewards = std_rewards.repeat_interleave(num_in_group, dim=0) + elif self.scale_rewards == "batch": + # Compute global std + std_rewards = rewards.std().expand_as(rewards) + else: + raise ValueError( + f"Invalid value for scale_rewards: {self.scale_rewards}. Must be one of 'batch', 'group', or 'none'." + ) + + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) + if self.scale_rewards != "none": + advantages = advantages / (std_rewards + 1e-4) + + # Slice to keep only the local part of the data + process_slice = slice( + self.accelerator.process_index * num_inputs_in_device, + (self.accelerator.process_index + 1) * num_inputs_in_device, + ) + all_process_advantages = advantages.clone() # keep the aggregated advantages for logging + advantages = advantages[process_slice] + + if self.num_remains_in_group is not None and mode == "train": + local_input_indices_to_keep = group_global_indices[process_slice] - self.accelerator.process_index * len( + prompts + ) # step is length of prompts + + prompt_ids = prompt_ids[local_input_indices_to_keep].contiguous() + prompt_mask = prompt_mask[local_input_indices_to_keep].contiguous() + completion_ids = completion_ids[local_input_indices_to_keep].contiguous() + completion_mask = completion_mask[local_input_indices_to_keep].contiguous() + attention_mask = attention_mask[local_input_indices_to_keep].contiguous() + completion_lengths = completion_mask.sum(1) + agg_completion_lengths = self.accelerator.gather(completion_lengths) + num_items_in_batch = agg_completion_lengths.sum() + + if sampling_per_token_logps is not None: + sampling_per_token_logps = sampling_per_token_logps[local_input_indices_to_keep].contiguous() + if old_per_token_logps is not None: + old_per_token_logps = old_per_token_logps[local_input_indices_to_keep].contiguous() + if ref_per_token_logps is not None: + ref_per_token_logps = ref_per_token_logps[local_input_indices_to_keep].contiguous() + if self.use_vllm and self.vllm_importance_sampling_correction: + importance_sampling_ratio = importance_sampling_ratio[local_input_indices_to_keep].contiguous() + + # Calculate mean reward per function, but only for samples where the function was applied (non-NaN values) + for i, reward_func_name in enumerate(self.reward_func_names): + mean_rewards = torch.nanmean(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/mean"].append(mean_rewards) + std_func_rewards = nanstd(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/std"].append(std_func_rewards) + rewards = (rewards_per_func * self.reward_weights.to(rewards_per_func.device).unsqueeze(0)).nansum(dim=1) + self._metrics[mode]["reward"].append(rewards.mean().item()) + self._metrics[mode]["reward_std"].append(rewards.std().item()) + self._metrics[mode]["frac_reward_zero_std"].append(is_std_zero.float().mean().item()) + + # Log prompt and completion texts + all_prompts_text = gather_object(prompts_text) + all_completions_text = gather_object(completions_text) + all_images = gather_object(images) if images is not None else None + if self.num_remains_in_group is not None and mode == "train": + group_global_indices_list = group_global_indices.tolist() + all_prompts_text = [all_prompts_text[i] for i in group_global_indices_list] + all_completions_text = [all_completions_text[i] for i in group_global_indices_list] + if images is not None: + all_images = [all_images[i] for i in group_global_indices_list] + + self._logs["prompt"].extend(all_prompts_text) + self._logs["completion"].extend(all_completions_text) + for i, name in enumerate(self.reward_func_names): + self._logs["rewards"][name].extend(rewards_per_func[:, i].tolist()) + self._logs["advantages"].extend(all_process_advantages.tolist()) + + if images is not None: + self._logs["images"].extend(all_images) + + if self.use_vllm and self.vllm_importance_sampling_correction: + delta = torch.abs(old_per_token_logps - sampling_per_token_logps) + delta = delta[completion_mask.bool()] + mean_delta = torch.mean(delta) if delta.numel() > 0 else torch.tensor(0.0, device=device) + max_delta = torch.max(delta) if delta.numel() > 0 else torch.tensor(0.0, device=device) + self._metrics[mode]["sampling/sampling_logp_difference/mean"].append( + self.accelerator.gather(mean_delta).mean().item() + ) + self._metrics[mode]["sampling/sampling_logp_difference/max"].append( + self.accelerator.gather(max_delta).max().item() + ) + + flat_is_ratio = importance_sampling_ratio[completion_mask.bool()] + min_importance_sampling_ratio = ( + torch.min(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + mean_importance_sampling_ratio = ( + torch.mean(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + max_importance_sampling_ratio = ( + torch.max(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + self._metrics[mode]["sampling/importance_sampling_ratio/min"].append( + nanmin(self.accelerator.gather(min_importance_sampling_ratio)).item() + ) + self._metrics[mode]["sampling/importance_sampling_ratio/mean"].append( + self.accelerator.gather(mean_importance_sampling_ratio).nanmean().item() + ) + self._metrics[mode]["sampling/importance_sampling_ratio/max"].append( + nanmax(self.accelerator.gather(max_importance_sampling_ratio)).item() + ) + + output = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "advantages": advantages, + "num_items_in_batch": num_items_in_batch, + } + if old_per_token_logps is not None: + output["old_per_token_logps"] = old_per_token_logps + if self.use_vllm and self.vllm_importance_sampling_correction: + output["importance_sampling_ratio"] = importance_sampling_ratio + if ref_per_token_logps is not None: + output["ref_per_token_logps"] = ref_per_token_logps + if "pixel_values" in forward_kwargs: + output["pixel_values"] = forward_kwargs["pixel_values"] + if "image_grid_thw" in forward_kwargs: + output["image_grid_thw"] = forward_kwargs["image_grid_thw"] + if "pixel_attention_mask" in forward_kwargs: + output["pixel_attention_mask"] = forward_kwargs["pixel_attention_mask"] + if "image_sizes" in forward_kwargs: + output["image_sizes"] = forward_kwargs["image_sizes"] + if "token_type_ids" in forward_kwargs: + output["token_type_ids"] = forward_kwargs["token_type_ids"] + if images is not None: + output["num_images"] = num_images + return output diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d49fe68a623fbca5fdc6cd4581464ac65d892fa9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .gkd_config import GKDConfig +from .gkd_trainer import GKDTrainer + + +__all__ = ["GKDConfig", "GKDTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/gkd_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/gkd_config.py new file mode 100644 index 0000000000000000000000000000000000000000..4ea10761c45228f10c8acb42ce7cb48eba5eede8 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/gkd_config.py @@ -0,0 +1,110 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.sft_config import SFTConfig + + +@dataclass +class GKDConfig(SFTConfig): + """ + Configuration class for [`experimental.gkd.GKDTrainer`]. + + This class includes only the parameters that are specific to GKD training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] and [`SFTConfig`] documentation. + + Args: + temperature (`float`, *optional*, defaults to `0.9`): + Temperature for sampling. The higher the temperature, the more random the completions. + lmbda (`float`, *optional*, defaults to `0.5`): + Lambda parameter that controls the student data fraction (i.e., the proportion of on-policy + student-generated outputs). + beta (`float`, *optional*, defaults to `0.5`): + Interpolation coefficient between `0.0` and `1.0` of the Generalized Jensen-Shannon Divergence loss. When + beta is `0.0`, the loss is the KL divergence. When beta is `1.0`, the loss is the Inverse KL Divergence. + max_new_tokens (`int`, *optional*, defaults to `128`): + Maximum number of tokens to generate per completion. + teacher_model_name_or_path (`str`, *optional*): + Model name or path of the teacher model. If `None`, the teacher model will be the same as the model being + trained. + teacher_model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the teacher model + from a string. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + seq_kd (`bool`, *optional*, defaults to `False`): + Seq_kd parameter that controls whether to perform Sequence-Level KD (can be viewed as supervised FT on + teacher-generated output). + """ + + _VALID_DICT_FIELDS = SFTConfig._VALID_DICT_FIELDS + ["teacher_model_init_kwargs"] + + temperature: float = field( + default=0.9, + metadata={"help": "Temperature for sampling. The higher the temperature, the more random the completions."}, + ) + lmbda: float = field( + default=0.5, + metadata={ + "help": "Lambda parameter that controls the student data fraction (i.e., the proportion of on-policy " + "student-generated outputs)." + }, + ) + beta: float = field( + default=0.5, + metadata={ + "help": "Interpolation coefficient between `0.0` and `1.0` of the Generalized Jensen-Shannon Divergence " + "loss. When beta is `0.0`, the loss is the KL divergence. When beta is `1.0`, the loss is the Inverse KL " + "Divergence." + }, + ) + max_new_tokens: int = field( + default=128, + metadata={"help": "Maximum number of tokens to generate per completion."}, + ) + teacher_model_name_or_path: str | None = field( + default=None, + metadata={ + "help": "Model name or path of the teacher model. If `None`, the teacher model will be the same as the " + "model being trained." + }, + ) + teacher_model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the " + "teacher model from a string." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropouts in `model`."}, + ) + seq_kd: bool = field( + default=False, + metadata={ + "help": "Seq_kd parameter that controls whether to perform Sequence-Level KD (can be viewed as supervised " + "FT on teacher-generated output)." + }, + ) + + def __post_init__(self): + super().__post_init__() + # check lmbda and beta are in the range [0, 1] + if self.lmbda < 0.0 or self.lmbda > 1.0: + raise ValueError("lmbda must be in the range [0.0, 1.0].") + if self.beta < 0.0 or self.beta > 1.0: + raise ValueError("beta must be in the range [0.0, 1.0].") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/gkd_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/gkd_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..815fb7581396284204c470a1dc1ca8adecc381c7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gkd/gkd_trainer.py @@ -0,0 +1,456 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import random +import textwrap +from collections.abc import Callable +from typing import Any + +import torch +import torch.nn as nn +import torch.nn.functional as F +from datasets import Dataset +from transformers import ( + AutoModelForCausalLM, + BaseImageProcessor, + DataCollator, + FeatureExtractionMixin, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import EvalPrediction +from transformers.utils import is_liger_kernel_available, is_peft_available + +from ...models import prepare_deepspeed +from ...models.utils import unwrap_model_for_generation +from ...trainer.sft_trainer import SFTTrainer +from ...trainer.utils import disable_dropout_in_model +from ..utils import DataCollatorForChatML, empty_cache +from .gkd_config import GKDConfig + + +if is_peft_available(): + from peft import PeftConfig + +if is_liger_kernel_available(): + from liger_kernel.chunked_loss import LigerFusedLinearJSDLoss + + +class GKDTrainer(SFTTrainer): + """Trainer for Generalized Knowledge Distillation (GKD) of language models. + + For details on GKD, see the paper: [On-Policy Distillation of Language Models: Learning from Self-Generated + Mistakes](https://huggingface.co/papers/2306.13649). + + Args: + model ([`~transformers.PreTrainedModel`] or `torch.nn.Module` or `str`, *optional*): + Model to be trained, or the string identifier of the model to be instantiated from a pretrained model. + teacher_model ([`~transformers.PreTrainedModel`] or `torch.nn.Module` or `str`, *optional*): + Teacher model for knowledge distillation, or the string identifier of the model to be instantiated from a + pretrained model. + args ([`experimental.gkd.GKDConfig`], *optional*): + Training arguments. + data_collator ([`~transformers.DataCollator`], *optional*): + Data collator to batch samples from the dataset. It defaults to a + [`experimental.utils.DataCollatorForChatML`] using the `processing_class`. + train_dataset ([`~datasets.Dataset`], *optional*): + Dataset for training. + eval_dataset ([`~datasets.Dataset`] or `dict` of [`~datasets.Dataset`], *optional*): + Dataset for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Class to process the data. + compute_metrics (`Callable`, *optional*): + Function to compute metrics at evaluation. Must take in an [`~transformers.EvalPrediction`] and return a + dictionary string to float. + callbacks (`list` of [`~transformers.TrainerCallback`], *optional*): + Callbacks to use during training. + optimizers (`tuple` of `torch.optim.Optimizer` and `torch.optim.lr_scheduler.LambdaLR`, *optional*, defaults to `(None, None)`): + Tuple containing the optimizer and the learning rate scheduler to use for training. + preprocess_logits_for_metrics (`Callable`, *optional*): + Function to preprocess the logits before computing the metrics. Must take in the `logits` and `labels` and + return the logits to be used for metrics computation. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration to use PEFT for training. If `None`, PEFT is not used. If provided, the `model` will be + wrapped with the specified PEFT adapter. + formatting_func (`Callable`, *optional*): + Function to format the dataset. Must take in an example and return an example. + """ + + _tag_names = ["trl", "gkd"] + _name = "GKD" + _paper = { + "title": "On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes", + "id": "2306.13649", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{agarwal2024on-policy, + title = {{On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes}}, + author = {Rishabh Agarwal and Nino Vieillard and Yongchao Zhou and Piotr Stanczyk and Sabela Ramos Garea and Matthieu Geist and Olivier Bachem}, + year = 2024, + booktitle = {The Twelfth International Conference on Learning Representations, {ICLR} 2024, Vienna, Austria, May 7-11, 2024}, + publisher = {OpenReview.net}, + url = {https://openreview.net/forum?id=3zKtaqxLhW}, + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str | None = None, + teacher_model: PreTrainedModel | nn.Module | str = None, + args: GKDConfig | None = None, + data_collator: DataCollator | None = None, # type: ignore + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: "PeftConfig | None" = None, + formatting_func: Callable | None = None, + ): + # Ensure Trainer does not drop non-signature columns used by the collator (e.g., "prompts") + args.remove_unused_columns = False + # Respect a user-provided data_collator; otherwise, provide a ChatML collator that + if data_collator is None: + data_collator = DataCollatorForChatML(tokenizer=processing_class, max_length=args.max_length) + + # Ensure SFTTrainer does not pre-process the dataset when using a ChatML collator, + # so that raw conversational fields (e.g., "messages") remain available to the collator. + if args.dataset_kwargs is None: + args.dataset_kwargs = {"skip_prepare_dataset": True} + else: + args.dataset_kwargs["skip_prepare_dataset"] = True + + # Liger fused GKD loss (JSD) + self.use_liger_gkd_loss = False + if args.use_liger_kernel: + self.liger_jsd_loss = LigerFusedLinearJSDLoss( + beta=args.beta, + ignore_index=-100, + temperature=args.temperature, + compiled=False, + ) + self.use_liger_gkd_loss = True + + super().__init__( + model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + peft_config=peft_config, + formatting_func=formatting_func, + ) + + if args.teacher_model_init_kwargs is None: + teacher_model_init_kwargs = {} + elif not isinstance(teacher_model, str): + raise ValueError( + "You passed teacher_model_init_kwargs to the GKDConfig, but your teacher_model is already instantiated." + ) + else: + teacher_model_init_kwargs = args.teacher_model_init_kwargs + teacher_model_init_kwargs["dtype"] = ( + teacher_model_init_kwargs["dtype"] + if teacher_model_init_kwargs["dtype"] in ["auto", None] + else getattr(torch, teacher_model_init_kwargs["dtype"]) + ) + + if isinstance(teacher_model, str): + teacher_model = AutoModelForCausalLM.from_pretrained(teacher_model, **teacher_model_init_kwargs) + + # Disable dropout in the model + if args.disable_dropout: + disable_dropout_in_model(self.model) + + if self.is_deepspeed_enabled: + self.teacher_model = prepare_deepspeed(teacher_model, self.accelerator) + else: + self.teacher_model = self.accelerator.prepare_model(teacher_model, evaluation_mode=True) + + self.lmbda = args.lmbda + self.beta = args.beta + self.temperature = args.temperature + self.seq_kd = args.seq_kd + + generation_kwargs = { + "max_new_tokens": args.max_new_tokens, + "temperature": args.temperature, + "do_sample": True, + "top_k": 0, + "use_cache": False if args.gradient_checkpointing else True, + "pad_token_id": self.processing_class.pad_token_id, + } + self.generation_config = GenerationConfig(**generation_kwargs) + # Keep training-specific generation kwargs to overwrite model's original generation config + self.generation_kwargs = generation_kwargs + # Set custom EOS tokens if they are specified by the model's generation + # config. This is important for models with the Llama 3 chat template, + # which use special tokens <|eot_id|> and <|eom_id|> to mark the end of + # turns or messages. + if ( + hasattr(self.model.generation_config, "eos_token_id") + and self.model.generation_config.eos_token_id is not None + ): + self.generation_config.eos_token_id = self.model.generation_config.eos_token_id + + @staticmethod + def generalized_jsd_loss( + student_logits, teacher_logits, labels=None, beta=0.5, temperature=1.0, reduction="batchmean" + ): + """ + Compute the generalized Jensen-Shannon Divergence loss for knowledge distillation using F.kl_div. See Eq. (1) + of https://huggingface.co/papers/2306.13649 for the definition. + + Args: + student_logits: + Tensor of shape (batch_size, sequence_length, vocab_size) + teacher_logits: + Tensor of shape (batch_size, sequence_length, vocab_size) + labels: + Tensor of shape (batch_size, sequence_length) with -100 for padding tokens to ignore when computing + loss + beta: + Interpolation coefficient between 0 and 1 (default: 0.5) + temperature: + Softmax temperature (default: 1.0) + reduction: + Specifies the reduction to apply to the output (default: 'batchmean') + + Returns: + loss: Scalar tensor with the generalized JSD loss + """ + + # Apply temperature scaling + student_logits = student_logits / temperature + teacher_logits = teacher_logits / temperature + + # Compute log probabilities for student and probabilities for teacher + student_log_probs = F.log_softmax(student_logits, dim=-1) + teacher_log_probs = F.log_softmax(teacher_logits, dim=-1) + + if beta == 0: + jsd = F.kl_div(student_log_probs, teacher_log_probs, reduction="none", log_target=True) + elif beta == 1: + jsd = F.kl_div(teacher_log_probs, student_log_probs, reduction="none", log_target=True) + else: + # Compute the log of the mixture distribution + # log(a + b) = log(exp(log(a)) + exp(log(b))) -> for mixture + beta = torch.tensor(beta, dtype=student_log_probs.dtype, device=student_log_probs.device) + mixture_log_probs = torch.logsumexp( + torch.stack([student_log_probs + torch.log1p(-beta), teacher_log_probs + torch.log(beta)]), + dim=0, + ) + + # Compute KL divergences using F.kl_div + # PyTorch differs from the standard mathematical definition, so the order of the probability distributions is swapped compared to that defined in the paper. + kl_teacher = F.kl_div(mixture_log_probs, teacher_log_probs, reduction="none", log_target=True) + kl_student = F.kl_div(mixture_log_probs, student_log_probs, reduction="none", log_target=True) + + # Compute the Generalized Jensen-Shannon Divergence + jsd = beta * kl_teacher + (1 - beta) * kl_student + + # Masking + if labels is not None: + mask = labels != -100 + jsd = jsd[mask] + + # Apply reduction + if reduction == "batchmean": + return jsd.sum() / mask.sum() if labels is not None else jsd.sum() / jsd.size(0) + elif reduction == "sum": + return jsd.sum() + elif reduction == "mean": + return jsd.mean() + else: + return jsd + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if self.use_liger_gkd_loss: + # Forward only through the base models (avoid lm_head to save memory) + unwrapped_student = self.accelerator.unwrap_model(model) + if hasattr(unwrapped_student, "get_decoder") and unwrapped_student.get_decoder() is not None: + base_student = unwrapped_student.get_decoder() + else: + base_student = getattr( + unwrapped_student, getattr(unwrapped_student, "base_model_prefix", "model"), unwrapped_student + ) + + student_outputs = base_student( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + self.teacher_model.eval() + unwrapped_teacher = self.accelerator.unwrap_model(self.teacher_model) + if hasattr(unwrapped_teacher, "get_decoder") and unwrapped_teacher.get_decoder() is not None: + base_teacher = unwrapped_teacher.get_decoder() + else: + base_teacher = getattr( + unwrapped_teacher, getattr(unwrapped_teacher, "base_model_prefix", "model"), unwrapped_teacher + ) + with torch.no_grad(): + teacher_outputs = base_teacher( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + # hidden states (shifted) + student_hidden = student_outputs.last_hidden_state[:, :-1] + teacher_hidden = teacher_outputs.last_hidden_state[:, :-1] + + # Release full outputs to free memory + del student_outputs, teacher_outputs + + # labels mask and labels (shifted) + labels_mask = inputs["labels"] != -100 + masked_input_ids = torch.where( + labels_mask, inputs["input_ids"], torch.full_like(inputs["input_ids"], -100) + ) + true_labels = masked_input_ids[:, 1:].contiguous() + + # Release intermediate tensors + del labels_mask, masked_input_ids + + # heads + student_head = unwrapped_student.get_output_embeddings() + teacher_head = unwrapped_teacher.get_output_embeddings() + + # liger fused jsd loss + loss = self.liger_jsd_loss( + student_input=student_hidden, + student_weight=student_head.weight, + teacher_input=teacher_hidden, + teacher_weight=teacher_head.weight, + true_labels=true_labels, + student_bias=getattr(student_head, "bias", None), + teacher_bias=getattr(teacher_head, "bias", None), + ) + + # Release hidden states after loss computation + del student_hidden, teacher_hidden, true_labels + else: + # compute student output + student_outputs = model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + ) + + # compute teacher output in eval mode + self.teacher_model.eval() + with torch.no_grad(): + teacher_outputs = self.teacher_model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + ) + + # slice the logits for the generated tokens using the inputs["prompts"] lengths + prompt_lengths = inputs["prompts"].shape[1] + shifted_student_logits = student_outputs.logits[:, prompt_lengths - 1 : -1, :] + shifted_teacher_logits = teacher_outputs.logits[:, prompt_lengths - 1 : -1, :] + shifted_labels = inputs["labels"][:, prompt_lengths:] + + # compute loss + loss = self.generalized_jsd_loss( + student_logits=shifted_student_logits, + teacher_logits=shifted_teacher_logits, + labels=shifted_labels, + beta=self.beta, + ) + + # empty cache + empty_cache() + + # Return loss + return (loss, student_outputs) if return_outputs else loss + + @staticmethod + def generate_on_policy_outputs(model, inputs, generation_config, pad_token_id=None): + # Generate output with respect to the prompt-only + generated_outputs = model.generate( + input_ids=inputs["prompts"], + attention_mask=inputs.get("prompt_attention_mask", None), + generation_config=generation_config, + return_dict_in_generate=True, + ) + + # Get the generated token IDs + generated_tokens = generated_outputs.sequences + # Calculate new attention mask + new_attention_mask = torch.ones_like(generated_tokens) + new_labels = generated_tokens.clone() + + # If there's pad_token_id, set attention mask to 0 for padding tokens + if pad_token_id is not None: + new_labels[new_labels == pad_token_id] = -100 + new_attention_mask[generated_tokens == pad_token_id] = 0 + + return generated_tokens, new_attention_mask, new_labels + + def training_step( + self, model: nn.Module, inputs: dict[str, torch.Tensor | Any], num_items_in_batch: int | None = None + ) -> torch.Tensor: + """ + Perform a training step for the Generalized Knowledge Distillation (GKD) model. + + This method implements the on-policy learning approach described in the GKD paper. With probability + `self.lmbda`, it generates new responses using the student model, which are then used for training instead of + the original inputs. + """ + if self.seq_kd: + with ( + unwrap_model_for_generation( + self.teacher_model, + self.accelerator, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model + ): + new_input_ids, new_attention_mask, new_labels = self.generate_on_policy_outputs( + unwrapped_model, inputs, self.generation_config, self.processing_class.pad_token_id + ) + inputs["input_ids"] = new_input_ids + inputs["attention_mask"] = new_attention_mask + inputs["labels"] = new_labels + if random.random() <= self.lmbda: + with ( + unwrap_model_for_generation( + model, + self.accelerator, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model + ): + new_input_ids, new_attention_mask, new_labels = self.generate_on_policy_outputs( + unwrapped_model, inputs, self.generation_config, self.processing_class.pad_token_id + ) + inputs["input_ids"] = new_input_ids + inputs["attention_mask"] = new_attention_mask + inputs["labels"] = new_labels + + loss = super().training_step(model, inputs, num_items_in_batch) + return loss diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9c2a8c1149130a77081ed794d02c7d7629d265bb --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .gold_config import GOLDConfig +from .gold_trainer import GOLDTrainer + + +__all__ = ["GOLDConfig", "GOLDTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold.py new file mode 100644 index 0000000000000000000000000000000000000000..399344eab20a8b1f3a02b106bc3a526c181340b0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold.py @@ -0,0 +1,155 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl @ git+https://github.com/huggingface/trl.git", +# "peft", +# "trackio", +# ] +# /// + +# docstyle-ignore +""" +# Full training: +python trl/experimental/gold/gold.py \ + --model_name_or_path meta-llama/Llama-3.2-1B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-5 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --output_dir gold-model \ + --num_train_epochs 1 \ + --push_to_hub + +# LoRA: +python trl/experimental/gold/gold.py \ + --model_name_or_path meta-llama/Llama-3.2-1B-Instruct \ + --teacher_model_name_or_path Qwen/Qwen2-1.5B-Instruct \ + --dataset_name trl-lib/chatbot_arena_completions \ + --learning_rate 2e-4 \ + --per_device_train_batch_size 4 \ + --gradient_accumulation_steps 8 \ + --output_dir gold-model \ + --num_train_epochs 1 \ + --push_to_hub \ + --use_peft \ + --lora_r 64 \ + --lora_alpha 16 +""" + +import logging + +from datasets import load_dataset +from transformers import AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.experimental.gold.gold_config import GOLDConfig +from trl.experimental.gold.gold_trainer import GOLDTrainer + + +logger = logging.getLogger(__name__) + + +if __name__ == "__main__": + parser = TrlParser((ScriptArguments, GOLDConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + ################ + # Model & Tokenizer + ################ + quantization_config = get_quantization_config(model_args) + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + torch_dtype=model_args.dtype, + use_cache=False if training_args.gradient_checkpointing else True, + device_map=get_kbit_device_map() if quantization_config is not None else None, + quantization_config=quantization_config, + ) + training_args.model_init_kwargs = model_kwargs + + if training_args.teacher_tokenizer_name_or_path is None and training_args.use_uld_loss: + training_args.teacher_tokenizer_name_or_path = training_args.teacher_model_name_or_path + teacher_model_kwargs = dict( + revision=training_args.teacher_model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + torch_dtype=model_args.dtype, + use_cache=True, + device_map=get_kbit_device_map() if quantization_config is not None else None, + quantization_config=quantization_config, + ) + if training_args.teacher_model_init_kwargs is not None: + teacher_model_kwargs.update(training_args.teacher_model_init_kwargs) + training_args.teacher_model_init_kwargs = teacher_model_kwargs + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + ################ + # Training + ################ + eval_dataset = None + if training_args.eval_strategy != "no": + if script_args.dataset_test_split in dataset: + eval_dataset = dataset[script_args.dataset_test_split] + elif "validation" in dataset: + eval_dataset = dataset["validation"] + elif "dev" in dataset: + eval_dataset = dataset["dev"] + + trainer = GOLDTrainer( + model=model_args.model_name_or_path, + teacher_model=training_args.teacher_model_name_or_path, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=eval_dataset, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + if training_args.eval_strategy != "no": + generation_config = GenerationConfig( + max_new_tokens=training_args.max_completion_length, do_sample=True, temperature=training_args.temperature + ) + completions_callback = LogCompletionsCallback(trainer, generation_config, num_prompts=8) + trainer.add_callback(completions_callback) + + trainer.train() + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold_config.py new file mode 100644 index 0000000000000000000000000000000000000000..93e495e8c1f11422e9f8c29d2f58feacf51f07af --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold_config.py @@ -0,0 +1,470 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.sft_config import SFTConfig + + +@dataclass +class GOLDConfig(SFTConfig): + r""" + Configuration class for [`GOLDTrainer`]. + + This class includes only the parameters that are specific to GOLD training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] and [`SFTConfig`] documentation. + + Args: + temperature (`float`, *optional*, defaults to `0.9`): + Temperature for sampling. The higher the temperature, the more random the completions. + lmbda (`float`, *optional*, defaults to `0.5`): + Lambda parameter that controls the student data fraction (i.e., the proportion of on-policy + student-generated outputs). + beta (`float`, *optional*, defaults to `0.5`): + Interpolation coefficient between `0.0` and `1.0` of the Generalized Jensen-Shannon Divergence loss. When + beta is `0.0`, the loss is the KL divergence. When beta is `1.0`, the loss is the Inverse KL Divergence. + max_completion_length (`int`, *optional*, defaults to `128`): + Maximum number of tokens to generate per completion. + teacher_model_name_or_path (`str`, *optional*): + Model name or path of the teacher model. If `None`, the teacher model will be the same as the model being + trained. + teacher_model_revision (`str` or `None`, *optional*, defaults to `None`): + Model revision of the teacher model (e.g., branch name, tag, or commit hash). If `None`, the default + revision is used. + teacher_model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the teacher model + from a string. + teacher_tokenizer_name_or_path (`str`, *optional*): + Tokenizer name or path for the teacher model. If None when using ULD loss, will use the same tokenizer as + the student model (not recommended for cross-tokenizer distillation). + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + seq_kd (`bool`, *optional*, defaults to `False`): + Seq_kd parameter that controls whether to perform Sequence-Level KD (can be viewed as supervised FT on + teacher-generated output). + num_generations (`int`, *optional*, defaults to `1`): + Number of generations per prompt. Each prompt is repeated this many times in the generation batch. + generation_batch_size (`int` or `None`, *optional*, defaults to `None`): + Number of unique prompts per worker per optimizer step. If `None`, it is computed from + `(per_device_train_batch_size * gradient_accumulation_steps) // num_generations`. + use_uld_loss (`bool`, *optional*, defaults to `False`): + Whether to use Universal Logit Distillation (ULD) loss instead of Generalized Jensen-Shannon Divergence + loss. + uld_crossentropy_weight (`float`, *optional*, defaults to `0.0`): + Weight for the cross-entropy loss component in ULD loss. If 0, only ULD distillation loss is used. + uld_distillation_weight (`float`, *optional*, defaults to `1.0`): + Weight for the distillation loss component in ULD loss. + uld_student_temperature (`float`, *optional*, defaults to `1.0`): + Temperature for student logits in ULD loss computation. + uld_teacher_temperature (`float`, *optional*, defaults to `1.0`): + Temperature for teacher logits in ULD loss computation. + uld_skip_student_eos (`bool`, *optional*, defaults to `True`): + Whether to skip EOS token for student in ULD loss computation. + uld_skip_teacher_eos (`bool`, *optional*, defaults to `True`): + Whether to skip EOS token for teacher in ULD loss computation. + use_vllm (`bool`, *optional*, defaults to `False`): + Whether to use vLLM for generating completions from the student model. Requires `vllm` to be installed. + vllm_mode (`str`, *optional*, defaults to `"colocate"`): + Mode for student vLLM integration. Either `"server"` (connect to a running TRL vLLM server) or `"colocate"` + (run vLLM in the same process). + vllm_server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the vLLM server for the student model (if `vllm_mode="server"`). + vllm_server_port (`int`, *optional*, defaults to `8001`): + Port of the vLLM server for the student model (if `vllm_mode="server"`). + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Timeout for connecting to the student vLLM server (if `vllm_mode="server"`). + vllm_gpu_memory_utilization (`float`, *optional*, defaults to `0.9`): + GPU memory utilization for the colocated student vLLM engine (if `vllm_mode="colocate"`). It is recommended + to set this to a low value if the student and teacher models share the same GPU. + vllm_tensor_parallel_size (`int`, *optional*, defaults to `1`): + Tensor parallel size for the colocated student vLLM engine (if `vllm_mode="colocate"`). + vllm_structured_outputs_regex (`str`, *optional*): + Regex for vLLM structured outputs for the student model. + vllm_server_base_url (`str`, *optional*): + Base URL for the vLLM server (e.g., `"http://localhost:8001"`). If provided, `vllm_server_host` and + `vllm_server_port` are ignored. + vllm_group_port (`int`, *optional*, defaults to `51216`): + Port for the vLLM weight-update group (NCCL communicator). Unless the port is occupied, there is no need to + change it. + vllm_max_model_length (`int`, *optional*): + Maximum model sequence length for the colocated vLLM engine when `vllm_mode="colocate"`. Defaults to the + model's maximum context length. + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation backend to use in vLLM. Use `"vllm"` (default) or `"transformers"`. + vllm_sync_frequency (`int`, *optional*, defaults to `1`): + Frequency (in training steps) to synchronize student model weights to vLLM engine. Set to 1 to sync after + every step. + vllm_enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Enable vLLM sleep mode to offload student weights/cache during the optimizer step. Keeps GPU memory usage + low, but waking the engine adds host–device transfer latency. + """ + + _VALID_DICT_FIELDS = SFTConfig._VALID_DICT_FIELDS + ["teacher_model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-7, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # GOLD-specific parameters + temperature: float = field( + default=0.9, + metadata={"help": "Temperature for sampling. The higher the temperature, the more random the completions."}, + ) + top_p: float = field( + default=0.95, + metadata={ + "help": "If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to " + "`top_p` or higher are kept for generation." + }, + ) + top_k: int = field( + default=0, + metadata={ + "help": "Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, " + "top-k-filtering is disabled and all tokens are considered." + }, + ) + lmbda: float = field( + default=0.5, + metadata={ + "help": "Lambda parameter that controls the student data fraction (i.e., the proportion of on-policy " + "student-generated outputs)." + }, + ) + beta: float = field( + default=0.5, + metadata={ + "help": "Interpolation coefficient between `0.0` and `1.0` of the Generalized Jensen-Shannon Divergence " + "loss. When beta is `0.0`, the loss is the KL divergence. When beta is `1.0`, the loss is the Inverse KL " + "Divergence." + }, + ) + max_completion_length: int = field( + default=128, + metadata={"help": "Maximum number of tokens to generate per completion."}, + ) + teacher_model_name_or_path: str | None = field( + default=None, + metadata={ + "help": "Model name or path of the teacher model. If `None`, the teacher model will be the same as the " + "model being trained." + }, + ) + teacher_model_revision: str | None = field( + default=None, + metadata={ + "help": "Model revision of the teacher model (e.g., branch name, tag, or commit hash). If `None`, the " + "default revision is used." + }, + ) + teacher_model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the " + "teacher model from a string." + }, + ) + teacher_tokenizer_name_or_path: str | None = field( + default=None, + metadata={ + "help": "Tokenizer name or path for the teacher model. If None when using ULD loss, will use the same " + "tokenizer as the student model (not recommended for cross-tokenizer distillation)." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropouts in `model`."}, + ) + seq_kd: bool = field( + default=False, + metadata={ + "help": "Seq_kd parameter that controls whether to perform Sequence-Level KD (can be viewed as supervised " + "FT on teacher-generated output)." + }, + ) + num_generations: int = field( + default=1, + metadata={ + "help": "Number of generations per prompt. Increasing this will decrease the number of unique prompts per optimization step." + }, + ) + generation_batch_size: int | None = field( + default=None, + metadata={ + "help": "Number of unique prompts per worker per optimizer step. " + "If None, computed from (per_device_train_batch_size * gradient_accumulation_steps) // num_generations." + }, + ) + + # ULD Loss parameters + use_uld_loss: bool = field( + default=False, + metadata={ + "help": "Whether to use Universal Logit Distillation (ULD) loss instead of Generalized Jensen-Shannon Divergence loss." + }, + ) + use_extended_uld: bool = field( + default=True, + metadata={ + "help": ( + "Whether to enable extended ULD alignment that uses tokenizers to align and merge token " + "probabilities across student and teacher tokenizations. When True, the trainer will compute " + "token mappings and merge probabilities for split tokens; when False, ULD will use simple " + "positional truncation like in the original ULD paper." + ) + }, + ) + uld_use_hybrid_loss: bool = field( + default=False, + metadata={ + "help": ( + "Whether to use a hybrid loss that combines ULD loss and JSD loss. When True, the final loss is a " + "a combination of JSD for known token mappings and ULD for unknown token mappings." + ) + }, + ) + uld_hybrid_matched_weight: float | None = field( + default=None, + metadata={ + "help": ( + "Weight for the matched token loss component when using hybrid ULD + JSD loss. This weight scales " + "the JSD loss computed over tokens that have a direct mapping between student and teacher " + "tokenizations. If None, uses adaptive weighting based on vocabulary overlap. Must be set together " + "with uld_hybrid_unmatched_weight (both None or both float)." + ) + }, + ) + uld_hybrid_unmatched_weight: float | None = field( + default=None, + metadata={ + "help": ( + "Weight for the unmatched token loss component when using hybrid ULD + JSD loss. This weight scales " + "the ULD loss computed over tokens that do not have a direct mapping between student and teacher " + "tokenizations. If None, uses adaptive weighting based on vocabulary overlap. Must be set together " + "with uld_hybrid_matched_weight (both None or both float)." + ) + }, + ) + uld_crossentropy_weight: float = field( + default=0.0, + metadata={"help": "Weight for the cross-entropy loss component in ULD loss."}, + ) + uld_distillation_weight: float = field( + default=1.0, + metadata={"help": "Weight for the distillation loss component in ULD loss."}, + ) + uld_student_temperature: float = field( + default=1.0, + metadata={"help": "Temperature for student logits in ULD loss computation."}, + ) + uld_teacher_temperature: float = field( + default=1.0, + metadata={"help": "Temperature for teacher logits in ULD loss computation."}, + ) + + uld_skip_student_eos: bool = field( + default=True, + metadata={"help": "Whether to skip EOS token for student in ULD loss computation."}, + ) + uld_skip_teacher_eos: bool = field( + default=True, + metadata={"help": "Whether to skip EOS token for teacher in ULD loss computation."}, + ) + + # vLLM parameters + use_vllm: bool = field( + default=False, + metadata={"help": "Whether to use vLLM for generating completions. Requires `vllm` to be installed."}, + ) + vllm_mode: str = field( + default="colocate", + metadata={ + "help": 'Mode for vLLM integration. Either "server" (connect to a running TRL vLLM server) or "colocate" (run vLLM in the same process).' + }, + ) + vllm_server_base_url: str | None = field( + default=None, + metadata={ + "help": 'Base URL for the vLLM server (e.g., "http://localhost:8001"). If provided, vllm_server_host and vllm_server_port are ignored.' + }, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": 'Host of the vLLM server when `vllm_mode="server"`.'}, + ) + vllm_server_port: int = field( + default=8001, + metadata={"help": 'Port of the vLLM server when `vllm_mode="server"`.'}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={"help": 'Timeout (in seconds) for connecting to the vLLM server when `vllm_mode="server"`.'}, + ) + vllm_group_port: int = field( + default=51216, + metadata={"help": "Port for the vLLM weight-update group (NCCL communicator)."}, + ) + vllm_gpu_memory_utilization: float = field( + default=0.9, + metadata={ + "help": 'GPU memory utilization for the colocated vLLM engine when `vllm_mode="colocate"`. Lower values reduce contention when sharing a device with the student/teacher models.' + }, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={"help": 'Tensor parallel size for the colocated vLLM engine when `vllm_mode="colocate"`.'}, + ) + vllm_max_model_length: int | None = field( + default=None, + metadata={ + "help": 'Maximum model sequence length for the colocated vLLM engine when `vllm_mode="colocate"`. Defaults to the model\'s maximum context length.' + }, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={"help": 'Model implementation backend to use in vLLM. Use "vllm" (default) or "transformers".'}, + ) + vllm_structured_outputs_regex: str | None = field( + default=None, + metadata={"help": "Regex pattern used for vLLM structured outputs (optional)."}, + ) + vllm_sync_frequency: int = field( + default=1, + metadata={ + "help": "Frequency (in training steps) to synchronize model weights to the vLLM engine. Set to 1 to sync after every step." + }, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={ + "help": "Enable vLLM sleep mode to offload student weights/cache during the optimizer step. Keeps GPU " + "memory usage low, but waking the engine adds host–device transfer latency." + }, + ) + # Parameters that control the logging + log_completions: bool = field( + default=False, + metadata={ + "help": "Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. If `rich` is " + "installed, it prints the sample. If `wandb` logging is enabled, it logs it to `wandb`." + }, + ) + log_completions_steps: int = field( + default=100, + metadata={ + "help": "Number of steps between logging (prompt, completion) pairs. Only used if `log_completions` is " + "set to `True`." + }, + ) + num_completions_to_print: int | None = field( + default=None, + metadata={"help": "Number of completions to print with `rich`. If `None`, all completions are logged."}, + ) + wandb_entity: str | None = field( + default=None, + metadata={"help": ("The entity to store runs under.")}, + ) + wandb_project: str | None = field( + default=None, + metadata={"help": ("The project to store runs under.")}, + ) + wandb_run_group: str | None = field( + default=None, + metadata={"help": ("The group to store runs under.")}, + ) + wandb_log_unique_prompts: bool = field( + default=True, + metadata={ + "help": ("Whether to log the unique prompts to wandb. This will create a new run for each unique prompt.") + }, + ) + callbacks: list[str] = field( + default_factory=lambda: [], + metadata={"help": "The callbacks to run during training."}, + ) + hub_model_revision: str | None = field( + default="main", metadata={"help": "The Hub model branch to push the model to."} + ) + overwrite_hub_revision: bool = field(default=False, metadata={"help": "Whether to overwrite the Hub revision."}) + push_to_hub_revision: bool = field(default=False, metadata={"help": "Whether to push to a Hub revision/branch."}) + + def __post_init__(self): + super().__post_init__() + + # check lmbda and beta are in the range [0, 1] + if self.lmbda < 0.0 or self.lmbda > 1.0: + raise ValueError("lmbda must be in the range [0.0, 1.0].") + if self.beta < 0.0 or self.beta > 1.0: + raise ValueError("beta must be in the range [0.0, 1.0].") + + # Validate that max_length is sufficient for max_completion_length + if self.max_length is not None and self.max_completion_length >= self.max_length: + raise ValueError( + f"max_completion_length ({self.max_completion_length}) must be smaller than max_length ({self.max_length}) " + f"to leave room for the prompt. Consider increasing max_length or reducing max_completion_length." + ) + + if self.num_generations < 1: + raise ValueError(f"num_generations must be at least 1, got {self.num_generations}.") + local_sequence_batch_size = self.per_device_train_batch_size * self.gradient_accumulation_steps + if self.generation_batch_size is None: + self.generation_batch_size = local_sequence_batch_size // self.num_generations + if self.generation_batch_size < 1: + raise ValueError( + f"generation_batch_size must be at least 1. Got generation_batch_size={self.generation_batch_size}." + ) + if self.generation_batch_size * self.num_generations != local_sequence_batch_size: + raise ValueError( + "generation_batch_size and num_generations must exactly partition the local optimizer-step batch. " + "Expected generation_batch_size * num_generations == per_device_train_batch_size * " + f"gradient_accumulation_steps, got {self.generation_batch_size} * {self.num_generations} != " + f"{self.per_device_train_batch_size} * {self.gradient_accumulation_steps}." + ) + if self.num_generations > 1 and self.lmbda < 1.0: + warnings.warn( + f"num_generations={self.num_generations} with lmbda={self.lmbda} means off-policy batches include " + f"{self.num_generations} copies of each sample; consider lmbda=1.0 when num_generations > 1.", + UserWarning, + stacklevel=2, + ) + + # Validate ULD parameters + if self.use_uld_loss: + if self.uld_crossentropy_weight < 0.0: + raise ValueError("uld_crossentropy_weight must be non-negative.") + if self.uld_distillation_weight < 0.0: + raise ValueError("uld_distillation_weight must be non-negative.") + if self.uld_student_temperature <= 0.0: + raise ValueError("uld_student_temperature must be positive.") + if self.uld_teacher_temperature <= 0.0: + raise ValueError("uld_teacher_temperature must be positive.") + + # Validate hybrid loss weights - both must be None or both must be set + if self.uld_use_hybrid_loss: + if (self.uld_hybrid_matched_weight is None) != (self.uld_hybrid_unmatched_weight is None): + raise ValueError( + "uld_hybrid_matched_weight and uld_hybrid_unmatched_weight must both be None (for adaptive " + "weighting) or both be set to numeric values. Got uld_hybrid_matched_weight=" + f"{self.uld_hybrid_matched_weight} and uld_hybrid_unmatched_weight=" + f"{self.uld_hybrid_unmatched_weight}." + ) + if self.uld_hybrid_matched_weight is not None: + if self.uld_hybrid_matched_weight < 0.0: + raise ValueError("uld_hybrid_matched_weight must be non-negative.") + if self.uld_hybrid_unmatched_weight < 0.0: + raise ValueError("uld_hybrid_unmatched_weight must be non-negative.") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..9f36d610612fee1e84b68686ab1a36823457331b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gold/gold_trainer.py @@ -0,0 +1,2070 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import random +import textwrap +import warnings +from collections import defaultdict, deque +from collections.abc import Callable +from contextlib import nullcontext +from functools import partial +from typing import Any, Optional + +import torch +import torch.distributed as dist +import torch.nn as nn +import torch.nn.functional as F +from accelerate import PartialState +from accelerate.utils import DistributedType, broadcast_object_list, gather_object +from datasets import Dataset, IterableDataset +from torch.utils.data import DataLoader +from transformers import AutoTokenizer, TrainerCallback +from transformers.data.data_collator import DataCollator +from transformers.feature_extraction_utils import FeatureExtractionMixin +from transformers.generation.configuration_utils import GenerationConfig +from transformers.image_processing_utils import BaseImageProcessor +from transformers.integrations.integration_utils import is_wandb_available +from transformers.modeling_utils import PreTrainedModel +from transformers.processing_utils import ProcessorMixin +from transformers.tokenization_utils_base import PreTrainedTokenizerBase +from transformers.trainer_utils import EvalPrediction, seed_worker +from transformers.utils import is_datasets_available, is_liger_kernel_available, is_peft_available, is_rich_available + +from ...data_utils import is_conversational, maybe_convert_to_chatml, pack_dataset +from ...extras.profiling import profiling_decorator +from ...generation.vllm_generation import VLLMGeneration +from ...import_utils import is_vllm_available +from ...models import prepare_deepspeed +from ...models.utils import unwrap_model_for_generation +from ...trainer.sft_trainer import SFTTrainer +from ...trainer.utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + pad, + split_tensor_dict, +) +from ..utils import DataCollatorForChatML, empty_cache, truncate_dataset +from .gold_config import GOLDConfig + + +if is_peft_available(): + from peft import PeftConfig + +if is_wandb_available(): + import wandb + + +if is_liger_kernel_available(): + from liger_kernel.chunked_loss import LigerFusedLinearJSDLoss + +if is_rich_available(): + from rich.console import Console + from rich.panel import Panel + from rich.table import Table + from rich.text import Text + + +def print_prompt_completions_sample_uld( + prompts: list[str], + completions: list[str], + step: int, + num_samples: int = None, +) -> None: + """ + Print out a sample of model completions to the console with multiple reward metrics. + + This function creates a nicely formatted table showing prompt-completion pairs, useful for monitoring model outputs + during training. It requires the `rich` library to be installed. + + Args: + prompts (`list[str]`): + List of prompts. + completions (`list[str]`): + List of completions corresponding to the prompts. + rewards (`dict[str, list[float]]`): + Dictionary where keys are reward names and values are lists of rewards. + advantages (`list[float]`): + List of advantages corresponding to the prompts and completions. + step (`int`): + Current training step number, used in the output title. + num_samples (`int` or `None`, *optional*, defaults to `None`): + Number of random samples to display. If `None` (default), all items will be displayed. + + Example: + ```python + >>> from trl.trainer.utils import print_prompt_completions_sample + + >>> prompts = ["The sky is", "The sun is"] + >>> completions = [" blue.", " in the sky."] + >>> rewards = {"Correctness": [0.123, 0.456], "Format": [0.789, 0.101]} + >>> advantages = [0.987, 0.654] + >>> print_prompt_completions_sample(prompts, completions, rewards, advantages, 42) + ╭──────────────────────────── Step 42 ─────────────────────────────╮ + │ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Correctness ┃ Format ┃ Advantage ┃ │ + │ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ The sky is │ blue. │ 0.12 │ 0.79 │ 0.99 │ │ + │ ├────────────┼──────────────┼─────────────┼────────┼───────────┤ │ + │ │ The sun is │ in the sky. │ 0.46 │ 0.10 │ 0.65 │ │ + │ └────────────┴──────────────┴─────────────┴────────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────╯ + ``` + """ + if not is_rich_available(): + raise ImportError( + "The function `print_prompt_completions_sample` requires the `rich` library. Please install it with " + "`pip install rich`." + ) + console = Console() + table = Table(show_header=True, header_style="bold white", expand=True) + + # Add columns + table.add_column("Prompt", style="bright_yellow") + table.add_column("Completion", style="bright_green") + + # Some basic input validation + if num_samples is not None: + if num_samples >= len(prompts): + num_samples = None + elif num_samples <= 0: + return + + # Subsample data if num_samples is specified + if num_samples is not None: + indices = random.sample(range(len(prompts)), num_samples) + prompts = [prompts[i] for i in indices] + completions = [completions[i] for i in indices] + + for i in range(len(prompts)): + table.add_row(Text(prompts[i]), Text(completions[i])) + table.add_section() # Adds a separator between rows + + panel = Panel(table, expand=False, title=f"Step {step}", border_style="bold white") + console.print(panel) + + +def build_teacher_inputs_from_texts( + tokenizer: PreTrainedTokenizerBase, + prompt_texts: list[str], + completion_texts: list[str], +) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, int]: + """Tokenize teacher prompts/completions and produce tensors ready for GOLD loss.""" + + pad_token_id = tokenizer.pad_token_id + eos_token_id = tokenizer.eos_token_id + + prompt_token_ids = tokenizer(prompt_texts, add_special_tokens=True)["input_ids"] + completion_token_ids = tokenizer(completion_texts, add_special_tokens=False)["input_ids"] + + sequences: list[torch.Tensor] = [] + attention_masks: list[torch.Tensor] = [] + labels_list: list[torch.Tensor] = [] + prompt_lengths: list[int] = [] + + for prompt_ids, completion_ids in zip(prompt_token_ids, completion_token_ids, strict=True): + # Remove trailing EOS from prompt so completions can extend cleanly + if eos_token_id is not None and prompt_ids and prompt_ids[-1] == eos_token_id: + prompt_ids = prompt_ids[:-1] + + prompt_lengths.append(len(prompt_ids)) + sequence = list(prompt_ids) + sequence.extend(completion_ids) + if eos_token_id is not None: + sequence.append(eos_token_id) + + seq_tensor = torch.tensor(sequence, dtype=torch.long) + sequences.append(seq_tensor) + attention_masks.append(torch.ones_like(seq_tensor)) + + labels = seq_tensor.clone() + labels[: len(prompt_ids)] = -100 + if pad_token_id is not None: + labels[labels == pad_token_id] = -100 + labels_list.append(labels) + + teacher_input_ids = pad( + sequences, + padding_side="right", + padding_value=pad_token_id if pad_token_id is not None else 0, + ) + teacher_attention_mask = pad(attention_masks, padding_side="right", padding_value=0).bool() + teacher_labels = pad(labels_list, padding_side="right", padding_value=-100) + + if eos_token_id is not None: + for row in range(teacher_attention_mask.size(0)): + valid = ( + teacher_input_ids[row] != pad_token_id + if pad_token_id is not None + else teacher_attention_mask[row].bool() + ) + if valid.any(): + last_idx = valid.nonzero(as_tuple=True)[0][-1] + teacher_attention_mask[row, last_idx + 1 :] = False + + teacher_prompt_length = max(prompt_lengths) if prompt_lengths else 0 + + return teacher_input_ids, teacher_labels, teacher_attention_mask, teacher_prompt_length + + +class ULDLoss(nn.Module): + """ + Universal Logit Distillation Loss. + """ + + def __init__(self, config: GOLDConfig, student_tokenizer=None, teacher_tokenizer=None, device=None): + super().__init__() + self.device = device + self.crossentropy_weight = config.uld_crossentropy_weight + self.distillation_weight = config.uld_distillation_weight + self.student_temperature = config.uld_student_temperature + self.teacher_temperature = config.uld_teacher_temperature + self.skip_student_eos = config.uld_skip_student_eos + self.skip_teacher_eos = config.uld_skip_teacher_eos + self.use_extended_uld = config.use_extended_uld + self.ignore_index = -100 + + # Add tokenizers for enhanced alignment + self.student_tokenizer = student_tokenizer + self.teacher_tokenizer = teacher_tokenizer + + # Hybrid ULD configuration + self.use_hybrid_loss = getattr(config, "uld_use_hybrid_loss", False) + self.hybrid_matched_weight = getattr(config, "uld_hybrid_matched_weight", None) + self.hybrid_unmatched_weight = getattr(config, "uld_hybrid_unmatched_weight", None) + self.beta = getattr(config, "beta", 1.0) # For JSD loss in hybrid matched tokens + + # Initialize vocabulary mapping for hybrid loss + self._vocab_mapping = None + self._teacher_matched_ids = None + self._student_matched_ids = None + if self.use_hybrid_loss and student_tokenizer is not None and teacher_tokenizer is not None: + self._initialize_vocabulary_mapping() + + def __call__( + self, student_logits, teacher_logits, student_labels, teacher_labels, student_input_ids, teacher_input_ids + ): + """ + Compute ULD loss with GKD trainer interface. + + Args: + student_logits: Student model logits [batch_size, seq_len, vocab_size] + teacher_logits: Teacher model logits [batch_size, seq_len, vocab_size] + student_labels: Student target labels [batch_size, seq_len] + teacher_labels: Teacher target labels [batch_size, seq_len] + student_input_ids: Student input token IDs [batch_size, seq_len] + teacher_input_ids: Teacher input token IDs [batch_size, seq_len] + + Returns: + Total loss (cross-entropy + distillation) + """ + # Compute cross-entropy loss for student + if self.crossentropy_weight > 0: + shift_logits = student_logits[..., :-1, :].contiguous() + shift_labels = student_labels[..., 1:].contiguous() + loss_fct = nn.CrossEntropyLoss(ignore_index=self.ignore_index) + crossentropy_loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1)) + crossentropy_loss = self.crossentropy_weight * crossentropy_loss + else: + crossentropy_loss = 0.0 + + # Compute distillation loss using ULD approximation + distillation_loss = self._compute_distillation_loss( + student_logits, teacher_logits, student_labels, teacher_labels, student_input_ids, teacher_input_ids + ) + + return crossentropy_loss + distillation_loss + + def _initialize_vocabulary_mapping(self): + """Initialize vocabulary mapping for hybrid ULD loss.""" + # Computing vocabulary mapping for hybrid ULD + + student_vocab = self.student_tokenizer.get_vocab() + teacher_vocab = self.teacher_tokenizer.get_vocab() + + # Create reverse mapping for student + student_token_to_id = dict(student_vocab.items()) + + vocab_mapping = {} + teacher_matched_ids = set() + student_matched_ids = set() + + for token_str, teacher_id in teacher_vocab.items(): + if token_str in student_token_to_id: + student_id = student_token_to_id[token_str] + vocab_mapping[teacher_id] = student_id + teacher_matched_ids.add(teacher_id) + student_matched_ids.add(student_id) + + self._vocab_mapping = vocab_mapping + self._teacher_matched_ids = teacher_matched_ids + self._student_matched_ids = student_matched_ids + + max_matched_teacher_id = max(self._vocab_mapping.keys()) + self.mapping_tensor = torch.full((max_matched_teacher_id + 1,), -1, dtype=torch.long) # -1 for unmapped ids + for k, v in self._vocab_mapping.items(): + self.mapping_tensor[k] = v + if self.device is not None: + self.mapping_tensor = self.mapping_tensor.to(self.device) + + def _compute_distillation_loss( + self, student_logits, teacher_logits, student_labels, teacher_labels, student_input_ids, teacher_input_ids + ): + """ + Compute the Universal Logit Distillation loss with token mapping. + + This version uses actual input_ids for accurate token mapping and multiplies probabilities for split tokens. + Both student_input_ids and teacher_input_ids are required for optimal alignment. + """ + # Get answer regions (same as original) + student_answer_index, student_answer_size = self._get_start_and_size_answers(student_labels) + teacher_answer_index, teacher_answer_size = self._get_start_and_size_answers(teacher_labels) + + if self.skip_student_eos: + student_answer_size = [size - 1 for size in student_answer_size] + if self.skip_teacher_eos: + teacher_answer_size = [size - 1 for size in teacher_answer_size] + + # Handle edge case where all answer sizes are 0 + if ( + not student_answer_size + or not teacher_answer_size + or max(max(student_answer_size), max(teacher_answer_size)) <= 0 + ): + return torch.zeros(1, device=student_logits.device, requires_grad=True) * student_logits.sum() * 1e-8 + + batch_size = student_logits.size(0) + distillation_losses = [] + + for i in range(batch_size): + # Get answer regions for this batch item + student_start = student_answer_index[i] + student_size = student_answer_size[i] + teacher_start = teacher_answer_index[i] + teacher_size = teacher_answer_size[i] + + if student_size <= 0 or teacher_size <= 0: + loss_i = student_logits[i].sum() * 0.0 + distillation_losses.append(loss_i) + continue + + # Extract answer logits + student_answer_logits = student_logits[i, student_start : student_start + student_size] + teacher_answer_logits = teacher_logits[i, teacher_start : teacher_start + teacher_size] + + # Convert to probabilities + student_probs = F.softmax(student_answer_logits / self.student_temperature, dim=-1) + teacher_probs = F.softmax(teacher_answer_logits / self.teacher_temperature, dim=-1) + + # Get token IDs for mapping (always use actual input_ids) + student_token_ids = student_input_ids[i, student_start : student_start + student_size].tolist() + teacher_token_ids = teacher_input_ids[i, teacher_start : teacher_start + teacher_size].tolist() + + if self.use_extended_uld: + # Build alignment groups directly from token ids using greedy text matching + student_alignment_groups, teacher_alignment_groups = self._build_alignment_groups_from_ids( + student_token_ids, teacher_token_ids + ) + + # Merge student probabilities using student alignment groups + # Pass student_token_ids to enable corrected conditional probability merging + student_aligned = self._merge_probabilities_with_alignment_groups( + student_probs, student_alignment_groups, student_token_ids + ) + + # Merge teacher probabilities using teacher alignment groups + # Pass teacher_token_ids to enable corrected conditional probability merging + teacher_aligned = self._merge_probabilities_with_alignment_groups( + teacher_probs, teacher_alignment_groups, teacher_token_ids + ) + else: + min_length = min(len(student_token_ids), len(teacher_token_ids)) + student_aligned = student_probs[:min_length, :] + teacher_aligned = teacher_probs[:min_length, :] + + # Apply ULD loss computation + if self.use_hybrid_loss and self._vocab_mapping is not None: + # Use hybrid approach: direct comparison for matched tokens, sorting for unmatched + aligned_loss = self._compute_hybrid_uld_loss(student_aligned, teacher_aligned) + else: + # Original approach: sort all probabilities + student_sorted = student_aligned.sort(dim=-1, descending=True).values + teacher_sorted = teacher_aligned.sort(dim=-1, descending=True).values + + # Pad vocabularies to same size + student_vocab_size = student_sorted.size(-1) + teacher_vocab_size = teacher_sorted.size(-1) + max_vocab_size = max(student_vocab_size, teacher_vocab_size) + + if student_vocab_size < max_vocab_size: + student_sorted = F.pad(student_sorted, (0, max_vocab_size - student_vocab_size)) + if teacher_vocab_size < max_vocab_size: + teacher_sorted = F.pad(teacher_sorted, (0, max_vocab_size - teacher_vocab_size)) + + # Compute L1 distance (ULD approach) + aligned_loss = F.l1_loss(student_sorted, teacher_sorted, reduction="sum") + aligned_loss /= student_aligned.size(0) # Normalize by sequence length + distillation_losses.append(aligned_loss) + + distillation_loss = torch.stack(distillation_losses).mean() + return self.distillation_weight * distillation_loss + + def _build_alignment_groups_from_ids(self, student_token_ids, teacher_token_ids): + """ + Build alignment groups using a greedy substring-equality algorithm on decoded token pieces. + + Args: + student_token_ids: List[int] + teacher_token_ids: List[int] + + Returns: + Tuple[List[List[int]], List[List[int]]]: student and teacher alignment groups + """ + + def to_canonical_pieces(tok, ids): + pieces = [] + prev = "" + for k in range(len(ids)): + # IMPORTANT: Do NOT skip special tokens - we need to align them too + cur = tok.decode(ids[: k + 1], skip_special_tokens=False, clean_up_tokenization_spaces=False) + # Extract the incremental addition (may include spaces/ZWJ/etc.) + pieces.append(cur[len(prev) :]) + prev = cur + return pieces + + s_pieces = to_canonical_pieces(self.student_tokenizer, student_token_ids) + t_pieces = to_canonical_pieces(self.teacher_tokenizer, teacher_token_ids) + + i = j = 0 + s_buf = t_buf = "" + s_group = [] + t_group = [] + s_groups = [] + t_groups = [] + + def flush(): + if s_group and t_group: + s_groups.append(s_group.copy()) + t_groups.append(t_group.copy()) + + # Greedily accumulate pieces until substrings match, then flush + while i < len(s_pieces) or j < len(t_pieces): + if s_buf == t_buf and s_buf != "": + flush() + s_buf = t_buf = "" + s_group = [] + t_group = [] + continue + + if s_buf == "" and i < len(s_pieces): + s_buf += s_pieces[i] + s_group.append(i) + i += 1 + continue + if t_buf == "" and j < len(t_pieces): + t_buf += t_pieces[j] + t_group.append(j) + j += 1 + continue + + if len(s_buf) <= len(t_buf): + if i < len(s_pieces): + s_buf += s_pieces[i] + s_group.append(i) + i += 1 + elif j < len(t_pieces): + t_buf += t_pieces[j] + t_group.append(j) + j += 1 + else: + if j < len(t_pieces): + t_buf += t_pieces[j] + t_group.append(j) + j += 1 + elif i < len(s_pieces): + s_buf += s_pieces[i] + s_group.append(i) + i += 1 + + # Flush any remainder if both sides accumulated something + if s_buf == t_buf and s_group and t_group: + flush() + elif s_group or t_group: + # Handle remaining unmatched tokens by forcing a flush + # This ensures both sides have the same number of alignment groups + if s_group or t_group: + # Ensure both groups have content (even if empty list) + if not s_group: + s_group = [] + if not t_group: + t_group = [] + # Force flush even if buffers don't match + if s_group or t_group: + s_groups.append(s_group.copy() if s_group else []) + t_groups.append(t_group.copy() if t_group else []) + + return s_groups, t_groups + + def _merge_probabilities_with_alignment_groups(self, probs, alignment_groups, token_ids=None): + """ + Merge probabilities based on alignment groups with corrected conditional probability handling. + + For a group merging tokens at positions [i, i+1, ..., i+k], we compute: + P_merged(y | x) = P(y | x) × P(token_{i+1} | token_i, x) × ... × P(token_{i+k} | ..., x) + + Where: + - P(y | x) is the marginal probability distribution over all vocabulary tokens at position i + - token_{i+1}, ..., token_{i+k} are the ACTUAL tokens that were generated + - The conditional probabilities P(token_j | ..., x) are extracted as SCALARS + - y ranges over all vocabulary tokens at position i + + This ensures the probability of the actual generated sequence is correct (by the chain rule), while introducing + a known bias for counterfactual tokens (since we don't have P(token_{i+k} | y, x) for y != token_i). The merged + distribution is unnormalized but preserves correct relative probabilities. + + Args: + probs: Probability tensor [seq_len, vocab_size] + alignment_groups: List of alignment groups (each group is a list of positions to merge) + token_ids: Actual token IDs that were generated [seq_len]. REQUIRED when any group has + len(group) > 1. If None when multi-token groups exist, raises ValueError. + + Returns: + Merged probability tensor [num_groups, vocab_size] + + Raises: + ValueError: If token_ids is None when merging multi-token groups + """ + if not alignment_groups: + return probs + + # Create aligned tensor + vocab_size = probs.size(-1) + target_len = len(alignment_groups) + aligned_probs = torch.zeros(target_len, vocab_size, device=probs.device, dtype=probs.dtype) + eps = 1e-8 + + # Process each alignment group + for group_idx, group in enumerate(alignment_groups): + # Handle probability merging + if len(group) > 1: + # Multiple tokens map to this group - merge using corrected conditional probability approach + if token_ids is None: + raise ValueError( + "token_ids must be provided when merging multi-token groups. " + "This is required for mathematically correct probability merging." + ) + + # Start with the marginal distribution at the first position + first_pos = group[0] + marginal_probs = probs[first_pos] # P(y | x₀) for all y + + # For each subsequent token in the group, extract the SCALAR conditional probability + # of the actual token that was generated, and multiply + conditional_prob_product = 1.0 + for idx in group[1:]: + # Get the actual token ID that was generated at this position + actual_token_id = token_ids[idx] + # Extract its probability (scalar) + token_prob = probs[idx, actual_token_id].clamp_min(eps) + conditional_prob_product *= token_prob + + # Merge: multiply the scalar conditional prob product with the entire marginal distribution + # This gives: P(y | x_0) × P(token_1 | token_0, x) × ... × P(token_k | ..., x) + # Note: This is unnormalized, but preserves the correct joint probability for the actual sequence + merged_probs = marginal_probs * conditional_prob_product + aligned_probs[group_idx] = merged_probs + + elif len(group) == 1: + aligned_probs[group_idx] = probs[group[0]] + else: + # No tokens map to this group + aligned_probs[group_idx] = torch.zeros_like(probs[0]) + + return aligned_probs + + def _compute_hybrid_uld_loss(self, student_aligned, teacher_aligned): + """ + Compute hybrid ULD loss on aligned probability distributions. This method: + 1. Directly compares probabilities for tokens with matching vocabulary entries + 2. Uses sorting approach only for tokens with different vocabulary entries + + Args: + student_aligned: Aligned student probabilities [seq_len, student_vocab_size] + teacher_aligned: Aligned teacher probabilities [seq_len, teacher_vocab_size] + Returns: + Combined hybrid loss + """ + device = student_aligned.device + # seq_len = student_aligned.size(0) # Unused variable + student_vocab_size = student_aligned.size(-1) + teacher_vocab_size = teacher_aligned.size(-1) + + # Convert sets to sorted tensors for indexing + if self._teacher_matched_ids: + teacher_matched_indices = torch.tensor(sorted(self._teacher_matched_ids), dtype=torch.long, device=device) + student_matched_indices = self.mapping_tensor[teacher_matched_indices] + else: + teacher_matched_indices = torch.tensor([], dtype=torch.long, device=device) + student_matched_indices = torch.tensor([], dtype=torch.long, device=device) + + # Create masks for unmatched tokens + teacher_matched_mask = torch.zeros(teacher_vocab_size, dtype=torch.bool, device=device) + student_matched_mask = torch.zeros(student_vocab_size, dtype=torch.bool, device=device) + + if len(teacher_matched_indices) > 0: + teacher_matched_mask[teacher_matched_indices] = True + student_matched_mask[student_matched_indices] = True + + # 1. JSD loss for matched vocabulary tokens (direct semantic correspondence) + matched_loss = torch.tensor(0.0, device=device) + matched_token_count = 0 + if len(teacher_matched_indices) > 0: + # Extract probabilities for matched tokens + teacher_matched_probs = teacher_aligned[:, teacher_matched_indices] # [seq_len, num_matched] + student_matched_probs = student_aligned[:, student_matched_indices] # [seq_len, num_matched] + matched_token_count = teacher_matched_probs.size(-1) + + # Use JSD loss for semantically aligned tokens + # Convert probabilities back to logits for JSD computation + + # Apply generalized JSD loss to matched tokens + matched_loss = self._compute_jsd_loss_for_matched_tokens(student_matched_probs, teacher_matched_probs) + + # 2. Sorted comparison loss for unmatched vocabulary tokens + teacher_unmatched_mask = ~teacher_matched_mask + student_unmatched_mask = ~student_matched_mask + + teacher_unmatched_probs = teacher_aligned[:, teacher_unmatched_mask] # [seq_len, num_teacher_unmatched] + student_unmatched_probs = student_aligned[:, student_unmatched_mask] # [seq_len, num_student_unmatched] + + unmatched_loss = torch.tensor(0.0, device=device) + if teacher_unmatched_probs.size(-1) > 0 and student_unmatched_probs.size(-1) > 0: + # Sort unmatched probabilities + teacher_unmatched_sorted = teacher_unmatched_probs.sort(dim=-1, descending=True).values + student_unmatched_sorted = student_unmatched_probs.sort(dim=-1, descending=True).values + + # Pad to same size if needed + teacher_unmatched_size = teacher_unmatched_sorted.size(-1) + student_unmatched_size = student_unmatched_sorted.size(-1) + max_unmatched_size = max(teacher_unmatched_size, student_unmatched_size) + + if teacher_unmatched_size < max_unmatched_size: + teacher_unmatched_sorted = F.pad( + teacher_unmatched_sorted, (0, max_unmatched_size - teacher_unmatched_size) + ) + if student_unmatched_size < max_unmatched_size: + student_unmatched_sorted = F.pad( + student_unmatched_sorted, (0, max_unmatched_size - student_unmatched_size) + ) + + # L1 loss on sorted unmatched tokens + unmatched_loss = F.l1_loss(student_unmatched_sorted, teacher_unmatched_sorted, reduction="sum") + unmatched_loss /= student_aligned.size(0) # Normalize by sequence length + + # 3. Combine losses with weights + if self.hybrid_matched_weight is None: + # Use adaptive weighting based on vocabulary overlap + hybrid_matched_weight = matched_token_count / max(1, teacher_vocab_size) + hybrid_unmatched_weight = 1.0 - hybrid_matched_weight + else: + # Use fixed weights provided in config + hybrid_matched_weight = self.hybrid_matched_weight + hybrid_unmatched_weight = self.hybrid_unmatched_weight + + total_loss = hybrid_matched_weight * matched_loss + hybrid_unmatched_weight * unmatched_loss + + # Store matched/unmatched components for logging + self.last_matched_loss = matched_loss + self.last_unmatched_loss = unmatched_loss + + return total_loss + + def _compute_jsd_loss_for_matched_tokens(self, student_logits, teacher_logits): + """ + Compute JSD loss for matched vocabulary tokens. + + Args: + student_logits: Student logits for matched tokens [seq_len, num_matched] + teacher_logits: Teacher logits for matched tokens [seq_len, num_matched] + Returns: + JSD loss for matched tokens + """ + # Reshape to [batch_size * seq_len, vocab_size] format expected by generalized_jsd_loss + batch_seq_len, num_matched = student_logits.shape + + student_logits_reshaped = student_logits.view(-1, num_matched) + teacher_logits_reshaped = teacher_logits.view(-1, num_matched) + + # Use the GOLD generalized JSD loss implementation that accepts probability inputs + jsd_loss = GOLDTrainer.generalized_jsd_loss( + student_logits_reshaped, + teacher_logits_reshaped, + labels=None, # No masking needed for matched tokens + beta=self.beta, # Standard JSD beta + temperature=1.0, # Already applied in main computation + reduction="batchmean", + logits_are_probs=True, + ) + + return jsd_loss + + def _get_start_and_size_answers(self, answer_tensors): + answers_index = [] + answers_size = [] + + for answer in answer_tensors: + answer_mask = answer.ne(self.ignore_index) + if not answer_mask.any(): + answers_index.append(0) + answers_size.append(0) + continue + + valid_indices = answer_mask.nonzero(as_tuple=True)[0] + answers_index.append(int(valid_indices[0].item())) + answers_size.append(int(answer_mask.sum().item())) + return answers_index, answers_size + + +class GOLDTrainer(SFTTrainer): + _tag_names = ["trl", "gold"] + _name = "GOLD" + _paper = { + "title": "Unlocking On-Policy Distillation for Any Model Family", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @misc{patino2025unlocking, + title = {{Unlocking On-Policy Distillation for Any Model Family}}, + author = {Carlos Miguel Patiño and Kashif Rasul and Quentin Gallouédec and Ben Burtenshaw and Sergio Paniego and Vaibhav Srivastav and Thibaud Frere and Ed Beeching and Lewis Tunstall and Leandro von Werra and Thomas Wolf}, + year = 2025, + url = {https://huggingface.co/spaces/HuggingFaceH4/general-on-policy-logit-distillation}, + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str | None = None, + teacher_model: PreTrainedModel | nn.Module | str = None, + args: GOLDConfig | None = None, + data_collator: DataCollator | None = None, # type: ignore + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: Optional["PeftConfig"] = None, + ): + self.model_name_or_path = model if isinstance(model, str) else model.config._name_or_path + self.model_revision = (args.model_init_kwargs or {}).get("revision") + + # Respect a user-provided data_collator; otherwise, provide a ChatML collator that + if data_collator is None: + data_collator = DataCollatorForChatML(tokenizer=processing_class, max_length=args.max_length) + + # Liger fused GKD loss (JSD) + self.use_liger_gkd_loss = False + if args.use_liger_kernel: + self.liger_jsd_loss = LigerFusedLinearJSDLoss( + beta=args.beta, + ignore_index=-100, + temperature=args.temperature, + compiled=False, + weight_hard_loss=0.0, + weight_soft_loss=1.0, + ) + self.use_liger_gkd_loss = True + + if args.teacher_model_init_kwargs is None: + teacher_model_init_kwargs = {} + elif not isinstance(teacher_model, str): + raise ValueError( + "You passed teacher_model_init_kwargs to the GOLDConfig, but your teacher_model is already instantiated." + ) + else: + teacher_model_init_kwargs = args.teacher_model_init_kwargs + teacher_model_init_kwargs["torch_dtype"] = ( + teacher_model_init_kwargs["torch_dtype"] + if teacher_model_init_kwargs["torch_dtype"] in ["auto", None] + else getattr(torch, teacher_model_init_kwargs["torch_dtype"]) + ) + + if args.use_uld_loss and args.teacher_tokenizer_name_or_path is None: + if isinstance(teacher_model, str): + args.teacher_tokenizer_name_or_path = teacher_model + else: + raise ValueError( + "`teacher_tokenizer_name_or_path` must be set when using ULD loss with a pre-instantiated teacher model." + ) + + if isinstance(teacher_model, str): + init_kwargs = dict(teacher_model_init_kwargs) + if args.teacher_model_revision is not None: + init_kwargs.setdefault("revision", args.teacher_model_revision) + if "torch_dtype" in init_kwargs and "dtype" not in init_kwargs: + init_kwargs["dtype"] = init_kwargs.pop("torch_dtype") + teacher_model = create_model_from_path(teacher_model, **init_kwargs) + self.use_uld_loss = args.use_uld_loss + self.teacher_tokenizer = None + if args.use_uld_loss and args.teacher_tokenizer_name_or_path is not None: + self.teacher_tokenizer = AutoTokenizer.from_pretrained(args.teacher_tokenizer_name_or_path) + if not hasattr(self.teacher_tokenizer, "pad_token") or self.teacher_tokenizer.pad_token is None: + self.teacher_tokenizer.pad_token = self.teacher_tokenizer.eos_token + + # Hybrid ULD loss configuration is handled in ULDLoss class + + super().__init__( + model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + peft_config=peft_config, + ) + + if args.disable_dropout: + disable_dropout_in_model(self.model) + if not args.use_uld_loss: + teacher_model.resize_token_embeddings(self.model.config.vocab_size) + + if self.is_deepspeed_enabled: + self.teacher_model = prepare_deepspeed(teacher_model, self.accelerator) + else: + self.teacher_model = self.accelerator.prepare_model(teacher_model, evaluation_mode=True) + + self.lmbda = args.lmbda + self.beta = args.beta + self.temperature = args.temperature + self.top_p = args.top_p + self.seq_kd = args.seq_kd + self.num_generations = args.num_generations + + # Track per-step loss statistics for on/off-policy batches (used in logging) + self._on_policy_loss_total = 0.0 + self._off_policy_loss_total = 0.0 + self._on_policy_step_equiv = 0.0 + self._off_policy_step_equiv = 0.0 + + # Buffering for rollouts across gradient accumulation steps + self._buffered_inputs = None + self._buffered_on_policy = None + self._buffered_text_logs = None + self._step = 0 + + # Hybrid ULD matched/unmatched accumulators (logged every step when ULD hybrid is used) + self._matched_sum = 0.0 + self._unmatched_sum = 0.0 + self._matched_step_eq = 0.0 + self._unmatched_step_eq = 0.0 + + self.uld_loss_fn = None + if self.use_uld_loss: + self.uld_loss_fn = ULDLoss( + config=args, + student_tokenizer=processing_class, + teacher_tokenizer=self.teacher_tokenizer, + device=self.accelerator.device, + ) + + generation_kwargs = { + "max_new_tokens": args.max_completion_length, + "temperature": args.temperature, + "top_p": args.top_p, + "do_sample": True, + "top_k": args.top_k, + "pad_token_id": self.processing_class.pad_token_id, + } + self.generation_config = GenerationConfig(**generation_kwargs) + # Keep training-specific generation kwargs to overwrite model's original generation config + self.generation_kwargs = generation_kwargs + if ( + hasattr(self.model.generation_config, "eos_token_id") + and self.model.generation_config.eos_token_id is not None + ): + self.generation_config.eos_token_id = self.model.generation_config.eos_token_id + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + self.log_completions = args.log_completions + self.log_completion_steps = args.log_completions_steps + self.wandb_log_unique_prompts = args.wandb_log_unique_prompts + self.num_completions_to_print = args.num_completions_to_print + # maxlen is set to the total number of forward passes per step. This value of `maxlen` ensures we log only the + # final optimization step. + maxlen = self.accelerator.num_processes * args.per_device_train_batch_size * args.gradient_accumulation_steps + self._textual_logs = { + "prompt": deque(maxlen=maxlen), + "completion": deque(maxlen=maxlen), + "rewards": defaultdict(lambda: deque(maxlen=maxlen)), + "advantages": deque(maxlen=maxlen), + } + + self.use_vllm = args.use_vllm + if self.use_vllm: + if not is_vllm_available(): + raise ImportError( + "vLLM is not available and use_vllm is set to True. Please install vLLM with " + "`pip install vllm` to use it." + ) + self.vllm_generation = VLLMGeneration( + model=self.model, + accelerator=self.accelerator, + is_fsdp_enabled=self.is_fsdp_enabled, + processing_class=self.processing_class, + mode=args.vllm_mode, + structured_outputs_regex=args.vllm_structured_outputs_regex, + server_base_url=args.vllm_server_base_url, + server_host=args.vllm_server_host, + server_port=args.vllm_server_port, + group_port=args.vllm_group_port, + server_timeout=args.vllm_server_timeout, + tensor_parallel_size=args.vllm_tensor_parallel_size, + gpu_memory_utilization=args.vllm_gpu_memory_utilization, + max_model_length=args.vllm_max_model_length or args.max_length, + max_num_seqs=args.per_device_train_batch_size * args.gradient_accumulation_steps, + enable_sleep_mode=args.vllm_enable_sleep_mode, + model_impl=args.vllm_model_impl, + repetition_penalty=getattr(args, "repetition_penalty", 1.0), + temperature=args.temperature, + top_p=args.top_p, + top_k=args.top_k, + min_p=getattr(args, "min_p", 0.0), + max_completion_length=args.max_completion_length, + logprobs=None, + ) + self.vllm_sync_frequency = args.vllm_sync_frequency + self._last_vllm_sync_step = -self.vllm_sync_frequency + + def _set_signature_columns_if_needed(self): + super()._set_signature_columns_if_needed() + required_columns = [ + "prompts", + "prompt_attention_mask", + "messages", + "chat_template_kwargs", + "tools", + "original_prompt_text", + "original_completion_text", + ] + if self._signature_columns is None: + self._signature_columns = required_columns + else: + for column in required_columns: + if column not in self._signature_columns: + self._signature_columns.append(column) + + def _get_train_sampler(self, dataset=None): + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size * self.accelerator.num_processes, + repeat_count=self.args.gradient_accumulation_steps, + shuffle=True, + seed=self.args.seed, + ) + + def get_train_dataloader(self): + """ + Override Trainer.get_train_dataloader to load one generation batch per optimizer window. + + The dataloader yields local batches of size `per_device_train_batch_size * gradient_accumulation_steps`. The + `RepeatSampler` (with `repeat_count=gradient_accumulation_steps`) ensures each generation batch is sampled + `gradient_accumulation_steps` times so Trainer's loop iterates the correct number of times. Only the first + batch in each window triggers `_fill_buffer`; the rest are ignored by `_prepare_inputs`. + """ + if self.train_dataset is None: + raise ValueError("Trainer: training requires a train_dataset.") + + train_dataset = self.train_dataset + data_collator = self.data_collator + if is_datasets_available() and isinstance(train_dataset, Dataset): + train_dataset = self._remove_unused_columns(train_dataset, description="training") + else: + data_collator = self._get_collator_with_removed_columns(data_collator, description="training") + + dataloader_params = { + "batch_size": self._train_batch_size * self.args.gradient_accumulation_steps, + "collate_fn": data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "persistent_workers": self.args.dataloader_persistent_workers, + } + + if not isinstance(train_dataset, torch.utils.data.IterableDataset): + dataloader_params["sampler"] = self._get_train_sampler() + dataloader_params["drop_last"] = self.args.dataloader_drop_last + dataloader_params["worker_init_fn"] = partial( + seed_worker, + num_workers=self.args.dataloader_num_workers, + rank=self.args.process_index, + ) + if self.args.dataloader_num_workers > 0: + dataloader_params["prefetch_factor"] = self.args.dataloader_prefetch_factor + + return self.accelerator.prepare(DataLoader(train_dataset, **dataloader_params)) + + @profiling_decorator + def _prepare_inputs(self, generation_batch: dict[str, torch.Tensor | Any]) -> dict[str, torch.Tensor | Any]: + if not self.model.training: + return generation_batch + + buffer_steps = self.args.gradient_accumulation_steps + if self._step % buffer_steps == 0 or self._buffered_inputs is None: + self._fill_buffer(generation_batch, buffer_steps) + + slice_idx = self._step % buffer_steps + inputs = self._buffered_inputs[slice_idx] + self._step += 1 + return inputs + + def _decode_completion_texts_from_labels(self, slice_inputs: dict[str, torch.Tensor | Any]) -> list[str] | None: + """Decode completion text from labels when raw text is absent.""" + labels = slice_inputs.get("labels") + if labels is None or not isinstance(labels, torch.Tensor): + return None + + labels_cpu = labels.detach().cpu() + decoded_completion_tokens: list[list[int]] = [] + for row in labels_cpu: + token_ids = row[row != -100].tolist() + if self.processing_class.pad_token_id is not None: + token_ids = [tok for tok in token_ids if tok != self.processing_class.pad_token_id] + decoded_completion_tokens.append(token_ids) + + return self.processing_class.batch_decode( + decoded_completion_tokens, + skip_special_tokens=False, + clean_up_tokenization_spaces=False, + ) + + def _ensure_original_text_fields( + self, slice_inputs: dict[str, torch.Tensor | Any] + ) -> dict[str, torch.Tensor | Any]: + """Populate original prompt/completion text fields when missing.""" + if "original_prompt_text" in slice_inputs and "original_completion_text" in slice_inputs: + return slice_inputs + + prompts = slice_inputs.get("prompts") + if prompts is None or not isinstance(prompts, torch.Tensor): + return slice_inputs + + prompt_texts = self.processing_class.batch_decode( + prompts, + skip_special_tokens=False, + clean_up_tokenization_spaces=False, + ) + completion_texts = self._decode_completion_texts_from_labels(slice_inputs) + if completion_texts is None: + return slice_inputs + + updated_slice = dict(slice_inputs) + updated_slice["original_prompt_text"] = prompt_texts + updated_slice["original_completion_text"] = completion_texts + return updated_slice + + @staticmethod + def _build_sequence_batch( + new_input_ids: torch.Tensor, + prompt_lengths: torch.Tensor, + pad_token_id: int | None, + attention_mask: torch.Tensor | None = None, + ) -> tuple[torch.Tensor, torch.Tensor]: + """Build attention mask and labels from full sequences and prompt lengths.""" + prompt_lengths = prompt_lengths.to(device=new_input_ids.device, dtype=torch.long) + positions = torch.arange(new_input_ids.shape[1], device=new_input_ids.device).unsqueeze(0) + completion_mask = positions >= prompt_lengths.unsqueeze(1) + + if attention_mask is not None: + new_attention_mask = attention_mask.to(device=new_input_ids.device, dtype=new_input_ids.dtype) + else: + new_attention_mask = torch.ones_like(new_input_ids) + if pad_token_id is not None: + new_attention_mask[new_input_ids == pad_token_id] = 0 + + new_labels = torch.full_like(new_input_ids, -100) + new_labels[completion_mask & new_attention_mask.bool()] = new_input_ids[ + completion_mask & new_attention_mask.bool() + ] + if attention_mask is None and pad_token_id is not None: + new_labels[new_input_ids == pad_token_id] = -100 + + return new_attention_mask, new_labels + + @profiling_decorator + def _fill_buffer(self, generation_batch: dict[str, torch.Tensor | Any], buffer_steps: int): + slices = split_tensor_dict(generation_batch, buffer_steps) + + if self.accelerator.is_main_process: + on_policy_flags = [random.random() <= self.lmbda for _ in range(buffer_steps)] + else: + on_policy_flags = [False] * buffer_steps + + on_policy_flags = broadcast_object_list(on_policy_flags, from_process=0) + on_policy_indices = [i for i, flag in enumerate(on_policy_flags) if flag] + + self._buffered_inputs = [None] * buffer_steps + self._buffered_on_policy = on_policy_flags + self._buffered_text_logs = [None] * buffer_steps + + for i, flag in enumerate(on_policy_flags): + if not flag: + slice_inputs = slices[i] + + if self.use_uld_loss and self.teacher_tokenizer is not None: + slice_inputs = self._ensure_original_text_fields(slice_inputs) + if "original_prompt_text" not in slice_inputs or "original_completion_text" not in slice_inputs: + raise ValueError( + "Off-policy batch missing 'original_prompt_text' or 'original_completion_text' fields. " + "When using ULD loss with cross-tokenizer alignment, datasets must be prepared with " + "_prepare_dataset_with_original_text(). Ensure your dataset includes these fields." + ) + + self._buffered_inputs[i] = slice_inputs + + if on_policy_indices: + self._generate_on_policy_for_slices(slices, on_policy_indices) + + @profiling_decorator + def _generate_on_policy_for_slices( + self, slices: list[dict[str, torch.Tensor | Any]], on_policy_indices: list[int] + ): + prompt_ids_list = [] + local_slice_indices = [] + for slice_idx in on_policy_indices: + slice_inputs = slices[slice_idx] + prompt_attention_mask = slice_inputs.get("prompt_attention_mask") + for prompt_idx, prompt in enumerate(slice_inputs["prompts"]): + if prompt_attention_mask is not None: + prompt = prompt[prompt_attention_mask[prompt_idx].bool()] + prompt_ids_list.append(prompt.tolist()) + local_slice_indices.append(slice_idx) + + prompts_text = self.processing_class.batch_decode( + prompt_ids_list, + skip_special_tokens=True, + ) + prompts_text_with_special = self.processing_class.batch_decode( + prompt_ids_list, + skip_special_tokens=False, + ) + + if not self.use_vllm: + self._generate_non_vllm_for_slices(slices, on_policy_indices) + return + + if ( + self.state.global_step != self._last_vllm_sync_step + and self.state.global_step >= self._last_vllm_sync_step + self.vllm_sync_frequency + ): + self.vllm_generation.sync_weights() + self._last_vllm_sync_step = self.state.global_step + + _, completion_ids, _, _ = self.vllm_generation.generate( + prompts=prompt_ids_list, + images=None, + num_generations=self.num_generations, + ) + + self._process_completions_to_buffer( + slices, + on_policy_indices, + local_slice_indices, + completion_ids, + prompt_ids_list, + prompts_text_with_special, + prompts_text, + self.generation_config.max_new_tokens, + ) + + def _generate_non_vllm_for_slices(self, slices: list[dict[str, torch.Tensor | Any]], on_policy_indices: list[int]): + """Fallback generation without vLLM (uses model.generate per slice).""" + with unwrap_model_for_generation( + self.model, + self.accelerator, + generation_kwargs=self.generation_kwargs, + ) as unwrapped_model: + for slice_idx in on_policy_indices: + slice_inputs = slices[slice_idx] + result = self.generate_on_policy_outputs( + unwrapped_model, + slice_inputs, + self.generation_config, + self.processing_class.pad_token_id, + ) + new_input_ids, new_attention_mask, new_labels, prompt_texts, completion_texts = result + + updated_slice = dict(slice_inputs) + updated_slice["input_ids"] = new_input_ids + updated_slice["attention_mask"] = new_attention_mask + updated_slice["labels"] = new_labels + updated_slice["original_prompt_text"] = prompt_texts + updated_slice["original_completion_text"] = completion_texts + + self._buffered_inputs[slice_idx] = updated_slice + self._buffered_text_logs[slice_idx] = (prompt_texts, completion_texts) + + def _process_completions_to_buffer( + self, + slices: list[dict[str, torch.Tensor | Any]], + on_policy_indices: list[int], + local_slice_indices: list[int], + completion_ids: list, + prompt_ids_list: list[list[int]], + prompts_text_with_special: list[str], + prompts_text: list[str], + max_completion_length: int, + ): + """ + Process vLLM completions and update buffered inputs for on-policy slices. + """ + device = self.accelerator.device + pad_token_id = self.processing_class.pad_token_id if self.processing_class.pad_token_id is not None else 0 + + slice_completions = {idx: [] for idx in on_policy_indices} + slice_prompt_ids = {idx: [] for idx in on_policy_indices} + slice_prompts = {idx: [] for idx in on_policy_indices} + slice_prompts_special = {idx: [] for idx in on_policy_indices} + + for i, slice_idx in enumerate(local_slice_indices): + slice_completions[slice_idx].append(completion_ids[i]) + slice_prompt_ids[slice_idx].append(prompt_ids_list[i]) + slice_prompts_special[slice_idx].append(prompts_text_with_special[i]) + slice_prompts[slice_idx].append(prompts_text[i]) + + for slice_idx in on_policy_indices: + slice_inputs = slices[slice_idx] + completion_ids_for_slice = slice_completions[slice_idx] + prompt_ids_for_slice = slice_prompt_ids[slice_idx] + prompt_txts = slice_prompts[slice_idx] + prompt_txts_with_special = slice_prompts_special[slice_idx] + + prompt_max_length = max(1, self.args.max_length - max_completion_length) if self.args.max_length else None + truncated_prompt_ids = [] + prompt_attention_masks = [] + truncation_side = getattr(self.processing_class, "truncation_side", "right") + for prompt_ids in prompt_ids_for_slice: + if prompt_max_length and len(prompt_ids) > prompt_max_length: + if truncation_side == "left": + prompt_ids = prompt_ids[-prompt_max_length:] + else: + prompt_ids = prompt_ids[:prompt_max_length] + prompt_tensor = torch.tensor(prompt_ids, device=device, dtype=torch.long) + truncated_prompt_ids.append(prompt_tensor) + prompt_attention_masks.append(torch.ones(len(prompt_ids), device=device, dtype=torch.long)) + + prompt_ids = pad(truncated_prompt_ids, padding_side="left", padding_value=pad_token_id) + prompt_attention_mask = pad(prompt_attention_masks, padding_side="left", padding_value=0) + + completion_ids_tensors = [torch.tensor(ids, device=device) for ids in completion_ids_for_slice] + completion_ids_for_text: list[list[int]] = [] + padded_completion_ids_list = [] + completion_attention_masks = [] + for completion_tensor in completion_ids_tensors: + if len(completion_tensor) > max_completion_length: + truncated_completion_tensor = completion_tensor[:max_completion_length] + padded_completion_ids_list.append(truncated_completion_tensor) + completion_ids_for_text.append(truncated_completion_tensor.tolist()) + completion_attention_masks.append( + torch.ones(len(truncated_completion_tensor), device=device, dtype=torch.long) + ) + elif len(completion_tensor) < max_completion_length: + padding_needed = max_completion_length - len(completion_tensor) + padded_tensor = torch.cat( + [ + completion_tensor, + torch.full( + (padding_needed,), + pad_token_id, + device=device, + dtype=completion_tensor.dtype, + ), + ] + ) + padded_completion_ids_list.append(padded_tensor) + completion_ids_for_text.append(completion_tensor.tolist()) + completion_attention_masks.append( + torch.cat( + [ + torch.ones(len(completion_tensor), device=device, dtype=torch.long), + torch.zeros(padding_needed, device=device, dtype=torch.long), + ] + ) + ) + else: + padded_completion_ids_list.append(completion_tensor) + completion_ids_for_text.append(completion_tensor.tolist()) + completion_attention_masks.append( + torch.ones(len(completion_tensor), device=device, dtype=torch.long) + ) + + completion_ids_padded = torch.stack(padded_completion_ids_list) + completion_attention_mask = torch.stack(completion_attention_masks) + + new_input_ids = torch.cat([prompt_ids, completion_ids_padded], dim=1) + new_attention_mask = torch.cat([prompt_attention_mask, completion_attention_mask], dim=1) + prompt_lengths = torch.full((prompt_ids.shape[0],), prompt_ids.shape[1], device=device) + new_attention_mask, new_labels = self._build_sequence_batch( + new_input_ids, + prompt_lengths, + pad_token_id, + attention_mask=new_attention_mask, + ) + + completion_texts = self.processing_class.batch_decode( + completion_ids_for_text, + skip_special_tokens=False, + clean_up_tokenization_spaces=False, + ) + + updated_slice = dict(slice_inputs) + updated_slice["input_ids"] = new_input_ids + updated_slice["attention_mask"] = new_attention_mask + updated_slice["labels"] = new_labels + updated_slice["original_prompt_text"] = prompt_txts_with_special + updated_slice["original_completion_text"] = completion_texts + + self._buffered_inputs[slice_idx] = updated_slice + self._buffered_text_logs[slice_idx] = (prompt_txts, completion_texts) + + def _prepare_dataset( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase | BaseImageProcessor | FeatureExtractionMixin | ProcessorMixin, + args, + packing: bool, + formatting_func: Callable[[dict], str] | None, + dataset_name: str, + ) -> Dataset | IterableDataset: + """Preserve original text fields for ULD when needed.""" + column_names = list(next(iter(dataset)).keys()) + is_processed = "input_ids" in column_names + + if not is_processed or (self.use_uld_loss and self.teacher_tokenizer is not None): + return self._prepare_dataset_with_original_text( + dataset, processing_class, args, packing, formatting_func, dataset_name + ) + + return super()._prepare_dataset(dataset, processing_class, args, packing, formatting_func, dataset_name) + + def _prepare_dataset_with_original_text( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase | BaseImageProcessor | FeatureExtractionMixin | ProcessorMixin, + args, + packing: bool, + formatting_func: Callable[[dict], str] | None, + dataset_name: str, + ) -> Dataset | IterableDataset: + """ + Prepare dataset while preserving original text for cross-tokenizer distillation. + """ + # Build the kwargs for the `map` function + map_kwargs = {} + if isinstance(dataset, Dataset): # IterableDataset does not support num_proc + map_kwargs["num_proc"] = args.dataset_num_proc + + with PartialState().main_process_first(): + # Apply the formatting function if any + if formatting_func is not None: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Applying formatting function to {dataset_name} dataset" + + def _func(example): + return {"text": formatting_func(example)} + + dataset = dataset.map(_func, batched=False, **map_kwargs) + + # Convert the dataset to ChatML if needed + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Converting {dataset_name} dataset to ChatML" + column_names = next(iter(dataset)).keys() + dataset = dataset.map( + maybe_convert_to_chatml, + remove_columns="conversations" if "conversations" in column_names else None, + **map_kwargs, + ) + + # Add EOS token if needed: non-conversational only + first_example = next(iter(dataset)) + if not is_conversational(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Adding EOS to {dataset_name} dataset" + + def add_eos(example, eos_token): + if "text" in example and not example["text"].endswith(eos_token): # language modeling case + example["text"] = example["text"] + eos_token + elif "completion" in example and not example["completion"].endswith(eos_token): + example["completion"] = example["completion"] + eos_token + return example + + dataset = dataset.map( + add_eos, + fn_kwargs={"eos_token": processing_class.eos_token}, + remove_columns="messages" if "messages" in column_names else None, # renamed to "text" + **map_kwargs, + ) + + # Tokenize the dataset while preserving original text + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Tokenizing {dataset_name} dataset (preserving original text)" + + def tokenize_with_original_text(example, processing_class, dataset_text_field, assistant_only_loss): + """Modified tokenization function that preserves original text.""" + result = {} + + if "prompt" in example: # prompt-completion case + # Store original text + result["original_prompt_text"] = example["prompt"] + result["original_completion_text"] = example["completion"] + + if is_conversational(example): + prompt_ids = processing_class.apply_chat_template( + example["prompt"], return_dict=False, **example.get("chat_template_kwargs", {}) + ) + prompt_completion_ids = processing_class.apply_chat_template( + example["prompt"] + example["completion"], + return_dict=False, + **example.get("chat_template_kwargs", {}), + ) + else: + prompt_ids = processing_class(text=example["prompt"]).input_ids + prompt_completion_ids = processing_class( + text=example["prompt"] + example["completion"] + ).input_ids + + # Check if the tokenized prompt starts with the tokenized prompt+completion + if not prompt_completion_ids[: len(prompt_ids)] == prompt_ids: + warnings.warn( + "Mismatch between tokenized prompt and the start of tokenized prompt+completion. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently.", + stacklevel=2, + ) + + # Create a completion mask + completion_mask = [0] * len(prompt_ids) + [1] * (len(prompt_completion_ids) - len(prompt_ids)) + result.update( + { + "input_ids": prompt_completion_ids, + "completion_mask": completion_mask, + "attention_mask": [1] * len(prompt_completion_ids), # Add attention mask + } + ) + + else: # language modeling or conversational case + if is_conversational(example): + # For conversational data (ChatML), extract prompt and completion properly + messages = example["messages"] + + # Extract user and assistant messages separately + user_messages = [msg for msg in messages if msg["role"] != "assistant"] + assistant_messages = [msg for msg in messages if msg["role"] == "assistant"] + + if user_messages and assistant_messages: + # Apply chat template to get the prompt (everything up to assistant) + prompt_text = processing_class.apply_chat_template( + user_messages, + add_generation_prompt=True, # add assistant prompt + tokenize=False, + **example.get("chat_template_kwargs", {}), + ) + + # Get the full conversation with assistant response + full_text = processing_class.apply_chat_template( + messages, + add_generation_prompt=False, + tokenize=False, + **example.get("chat_template_kwargs", {}), + ) + + # Extract completion as everything after the prompt + # This ensures we capture any extra tokens (like tags) that the template adds + if full_text.startswith(prompt_text): + completion_text = full_text[len(prompt_text) :] + else: + # Fallback: use assistant content + EOS + assistant_content = assistant_messages[0]["content"] + completion_text = ( + assistant_content + processing_class.eos_token + if hasattr(processing_class, "eos_token") + else assistant_content + ) + + # Store original text for cross-tokenizer distillation + result["original_prompt_text"] = prompt_text + result["original_completion_text"] = completion_text + else: + # Fallback: use empty prompt and full text as completion + full_text = processing_class.apply_chat_template( + messages, tokenize=False, **example.get("chat_template_kwargs", {}) + ) + result["original_prompt_text"] = "" + result["original_completion_text"] = full_text + + # Process the conversation normally + processed = processing_class.apply_chat_template( + example["messages"], + return_dict=True, + return_assistant_tokens_mask=assistant_only_loss, + **example.get("chat_template_kwargs", {}), + ) + if "assistant_masks" in processed and 1 not in processed["assistant_masks"]: + raise RuntimeError( + "You're using `assistant_only_loss=True`, but at least one example has no " + "assistant tokens. This usually means the tokenizer's chat template doesn't " + "generate assistant masks — it may be missing the `{% generation %}` tag. Please " + "check the template and ensure it's correctly configured to support assistant " + "masking." + ) + result.update({k: processed[k] for k in ("input_ids", "assistant_masks") if k in processed}) + # Add attention_mask if not already present + if "attention_mask" not in result: + result["attention_mask"] = [1] * len(result["input_ids"]) + else: + # For regular language modeling, store the full text as completion and empty prompt + result["original_prompt_text"] = "" + result["original_completion_text"] = example.get(dataset_text_field, example.get("text", "")) + + tokenized = processing_class(text=example[dataset_text_field]) + result.update( + { + "input_ids": tokenized.input_ids, + "attention_mask": getattr(tokenized, "attention_mask", [1] * len(tokenized.input_ids)), + } + ) + + return result + + dataset = dataset.map( + tokenize_with_original_text, + fn_kwargs={ + "processing_class": processing_class, + "dataset_text_field": args.dataset_text_field, + "assistant_only_loss": args.assistant_only_loss, + }, + **map_kwargs, + ) + + # Pack or truncate + if packing: + if args.max_length is None: + raise ValueError("When packing is enabled, `max_length` can't be `None`.") + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Packing {dataset_name} dataset" + + columns_to_keep = ["input_ids", "original_prompt_text", "original_completion_text"] + existing_columns = set(dataset.column_names) + columns_to_select = [col for col in columns_to_keep if col in existing_columns] + + dataset = dataset.select_columns(columns_to_select) + dataset = pack_dataset(dataset, args.max_length, args.packing_strategy, map_kwargs) + elif args.max_length is not None: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Truncating {dataset_name} dataset" + dataset = truncate_dataset(dataset, args.max_length, map_kwargs=map_kwargs) + + if args.use_liger_kernel: + required_columns = { + "input_ids", + "attention_mask", + "position_ids", + "completion_mask", + "messages", + "assistant_masks", + "original_prompt_text", + "original_completion_text", + } + dataset = dataset.select_columns(required_columns.intersection(dataset.column_names)) + + return dataset + + @staticmethod + def generalized_jsd_loss( + student_logits, + teacher_logits, + labels=None, + beta=0.5, + temperature=1.0, + reduction="batchmean", + logits_are_probs=False, + ): + """ + Compute the generalized Jensen-Shannon Divergence loss for knowledge distillation using F.kl_div. See Eq. (1) + of https://huggingface.co/papers/2306.13649 for the definition. + + Args: + student_logits: + Tensor of shape (batch_size, sequence_length, vocab_size) + teacher_logits: + Tensor of shape (batch_size, sequence_length, vocab_size) + labels: + Tensor of shape (batch_size, sequence_length) with -100 for padding tokens to ignore when computing + loss + beta: + Interpolation coefficient between 0 and 1 (default: 0.5) + temperature: + Softmax temperature (default: 1.0) + reduction: + Specifies the reduction to apply to the output (default: 'batchmean') + + Returns: + loss: Scalar tensor with the generalized JSD loss + """ + + if logits_are_probs: + student_log_probs = torch.log(student_logits.clamp_min(1e-8)) + teacher_log_probs = torch.log(teacher_logits.clamp_min(1e-8)) + else: + # Apply temperature scaling to logits before computing probabilities + student_logits = student_logits / temperature + teacher_logits = teacher_logits / temperature + # Compute log probabilities for student and probabilities for teacher + student_log_probs = F.log_softmax(student_logits, dim=-1) + teacher_log_probs = F.log_softmax(teacher_logits, dim=-1) + + if beta == 0: + jsd = F.kl_div(student_log_probs, teacher_log_probs, reduction="none", log_target=True) + elif beta == 1: + jsd = F.kl_div(teacher_log_probs, student_log_probs, reduction="none", log_target=True) + else: + # Compute the log of the mixture distribution + # log(a + b) = log(exp(log(a)) + exp(log(b))) -> for mixture + beta = torch.tensor(beta, dtype=student_log_probs.dtype, device=student_log_probs.device) + mixture_log_probs = torch.logsumexp( + torch.stack([student_log_probs + torch.log1p(-beta), teacher_log_probs + torch.log(beta)]), + dim=0, + ) + + # Compute KL divergences using F.kl_div + # PyTorch differs from the standard mathematical definition, so the order of the probability distributions is swapped compared to that defined in the paper. + kl_teacher = F.kl_div(mixture_log_probs, teacher_log_probs, reduction="none", log_target=True) + kl_student = F.kl_div(mixture_log_probs, student_log_probs, reduction="none", log_target=True) + + # Compute the Generalized Jensen-Shannon Divergence + jsd = beta * kl_teacher + (1 - beta) * kl_student + + # Masking + if labels is not None: + mask = labels != -100 + jsd = jsd[mask] + + # Apply reduction + if reduction == "batchmean": + return jsd.sum() / mask.sum() if labels is not None else jsd.sum() / jsd.size(0) + elif reduction == "sum": + return jsd.sum() + elif reduction == "mean": + return jsd.mean() + else: + return jsd + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if self.use_uld_loss and self.teacher_tokenizer is not None: + if "original_prompt_text" in inputs and "original_completion_text" in inputs: + prompt_texts = inputs["original_prompt_text"] + completion_texts = inputs["original_completion_text"] + full_texts = [p + c for p, c in zip(prompt_texts, completion_texts, strict=True)] + else: + # Fallback: decode student input_ids (current approach) + # WARNING: This may not work perfectly for cross-tokenizer distillation + full_sequences = inputs["input_ids"] + full_texts = self.processing_class.batch_decode(full_sequences, skip_special_tokens=False) + + # Try to split prompt/completion using original prompt length + prompt_lengths = inputs["prompts"].shape[1] + prompt_texts = self.processing_class.batch_decode(inputs["prompts"], skip_special_tokens=False) + completion_texts = [ + full.replace(prompt, "", 1) for full, prompt in zip(full_texts, prompt_texts, strict=True) + ] + + ( + teacher_input_ids, + teacher_labels, + teacher_attention_mask, + teacher_prompt_length, + ) = build_teacher_inputs_from_texts( + self.teacher_tokenizer, + prompt_texts, + completion_texts, + ) + + teacher_input_ids = teacher_input_ids.to(self.accelerator.device) + teacher_labels = teacher_labels.to(self.accelerator.device) + teacher_attention_mask = teacher_attention_mask.to(self.accelerator.device) + + outputs_student = model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + self.teacher_model.eval() + with torch.no_grad(): + outputs_teacher = self.teacher_model( + input_ids=teacher_input_ids, + attention_mask=teacher_attention_mask, + ) + + # These are not used for ULD loss but are needed if JSD loss were to be used in this branch + student_prompt_length = inputs["prompts"].shape[1] + shifted_student_logits = outputs_student.logits[:, student_prompt_length - 1 : -1, :] + shifted_teacher_logits = outputs_teacher.logits[:, teacher_prompt_length - 1 : -1, :] + shifted_labels = inputs["labels"][:, student_prompt_length:] + else: + if self.use_liger_gkd_loss: + # Forward only through the base models (avoid lm_head to save memory) + unwrapped_student = self.accelerator.unwrap_model(model) + if hasattr(unwrapped_student, "get_decoder") and unwrapped_student.get_decoder() is not None: + base_student = unwrapped_student.get_decoder() + else: + base_student = getattr( + unwrapped_student, getattr(unwrapped_student, "base_model_prefix", "model"), unwrapped_student + ) + + student_outputs = base_student( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + self.teacher_model.eval() + unwrapped_teacher = self.accelerator.unwrap_model(self.teacher_model) + if hasattr(unwrapped_teacher, "get_decoder") and unwrapped_teacher.get_decoder() is not None: + base_teacher = unwrapped_teacher.get_decoder() + else: + base_teacher = getattr( + unwrapped_teacher, getattr(unwrapped_teacher, "base_model_prefix", "model"), unwrapped_teacher + ) + with torch.no_grad(): + teacher_outputs = base_teacher( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + use_cache=False, + ) + + student_hidden = student_outputs.last_hidden_state[:, :-1] + teacher_hidden = teacher_outputs.last_hidden_state[:, :-1] + + del student_outputs, teacher_outputs + + student_hidden = student_hidden.reshape(-1, student_hidden.shape[-1]) + teacher_hidden = teacher_hidden.reshape(-1, teacher_hidden.shape[-1]) + + labels_mask = inputs["labels"] != -100 + masked_input_ids = torch.where( + labels_mask, inputs["input_ids"], torch.full_like(inputs["input_ids"], -100) + ) + true_labels = masked_input_ids[:, 1:].contiguous().reshape(-1) + + student_head = unwrapped_student.get_output_embeddings() + teacher_head = unwrapped_teacher.get_output_embeddings() + + loss = self.liger_jsd_loss( + student_input=student_hidden, + student_weight=student_head.weight, + teacher_input=teacher_hidden, + teacher_weight=teacher_head.weight, + true_labels=true_labels, + student_bias=getattr(student_head, "bias", None), + teacher_bias=getattr(teacher_head, "bias", None), + ) + + del student_hidden, teacher_hidden, true_labels + else: + outputs_student = model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + ) + + self.teacher_model.eval() + with torch.no_grad(): + outputs_teacher = self.teacher_model( + input_ids=inputs["input_ids"], + attention_mask=inputs["attention_mask"], + ) + + prompt_lengths = inputs["prompts"].shape[1] + shifted_student_logits = outputs_student.logits[:, prompt_lengths - 1 : -1, :] + shifted_teacher_logits = outputs_teacher.logits[:, prompt_lengths - 1 : -1, :] + shifted_labels = inputs["labels"][:, prompt_lengths:] + loss = self.generalized_jsd_loss( + student_logits=shifted_student_logits, + teacher_logits=shifted_teacher_logits, + labels=shifted_labels, + beta=self.beta, + temperature=self.temperature, + ) + + if self.use_uld_loss: + student_input_ids = inputs["input_ids"] + + teacher_labels_for_loss = teacher_labels if "teacher_labels" in locals() else inputs["labels"] + teacher_input_ids_for_loss = teacher_input_ids if "teacher_input_ids" in locals() else inputs["input_ids"] + + student_labels = inputs["labels"].clone() + if hasattr(self.processing_class, "pad_token_id") and self.processing_class.pad_token_id is not None: + student_labels[student_labels == self.processing_class.pad_token_id] = -100 + + if ( + hasattr(self, "teacher_tokenizer") + and hasattr(self.teacher_tokenizer, "pad_token_id") + and self.teacher_tokenizer.pad_token_id is not None + ): + teacher_labels[teacher_labels == self.teacher_tokenizer.pad_token_id] = -100 + + loss = self.uld_loss_fn( + student_logits=outputs_student.logits, + teacher_logits=outputs_teacher.logits, + student_labels=student_labels, + teacher_labels=teacher_labels_for_loss, + student_input_ids=student_input_ids, + teacher_input_ids=teacher_input_ids_for_loss, + ) + + if hasattr(self.uld_loss_fn, "last_matched_loss") and hasattr(self.uld_loss_fn, "last_unmatched_loss"): + ga = max(1, int(self.args.gradient_accumulation_steps)) + step_eq = 1.0 / ga + matched_val = ( + self.uld_loss_fn.last_matched_loss.item() + if self.uld_loss_fn.last_matched_loss is not None + else 0.0 + ) + unmatched_val = ( + self.uld_loss_fn.last_unmatched_loss.item() + if self.uld_loss_fn.last_unmatched_loss is not None + else 0.0 + ) + + self._matched_sum += matched_val + self._unmatched_sum += unmatched_val + self._matched_step_eq += step_eq + self._unmatched_step_eq += step_eq + + empty_cache() + + return (loss, outputs_student) if return_outputs else loss + + def generate_on_policy_outputs(self, model, inputs, generation_config, pad_token_id=None): + # Generate output with respect to the prompt only + generated_outputs = model.generate( + input_ids=inputs["prompts"], + attention_mask=inputs.get("prompt_attention_mask", None), + generation_config=generation_config, + return_dict_in_generate=True, + ) + # Get the generated token IDs + generated_tokens = generated_outputs.sequences + + batch_size = generated_tokens.size(0) + device = generated_tokens.device + + prompt_mask = inputs.get("prompt_attention_mask") + pad_token_id = pad_token_id if pad_token_id is not None else self.processing_class.pad_token_id + + # model.generate() returns full sequences (prompt + completion), so completions start + # after the full padded prompt width. + prompt_lengths = torch.full((batch_size,), inputs["prompts"].shape[1], dtype=torch.long, device=device) + + new_input_ids = generated_tokens + new_attention_mask, new_labels = self._build_sequence_batch(new_input_ids, prompt_lengths, pad_token_id) + + prompt_texts = [] + completion_texts = [] + for idx in range(batch_size): + length = int(prompt_lengths[idx].item()) + prompt_tokens = inputs["prompts"][idx] + if prompt_mask is not None: + prompt_tokens = prompt_tokens[prompt_mask[idx].bool()] + elif pad_token_id is not None: + prompt_tokens = prompt_tokens[prompt_tokens != pad_token_id] + prompt_texts.append( + self.processing_class.decode( + prompt_tokens.tolist(), + skip_special_tokens=False, + clean_up_tokenization_spaces=False, + ) + ) + completion_tokens = new_input_ids[idx, length:] + completion_texts.append( + self.processing_class.decode( + completion_tokens.tolist(), + skip_special_tokens=False, + clean_up_tokenization_spaces=False, + ) + ) + + return new_input_ids, new_attention_mask, new_labels, prompt_texts, completion_texts + + def _get_liger_zero3_lm_head_gather_ctx(self, model: nn.Module): + if not self.use_liger_gkd_loss: + return nullcontext() + + deepspeed_plugin = self.accelerator.state.deepspeed_plugin + if deepspeed_plugin is None or deepspeed_plugin.zero_stage != 3: + return nullcontext() + + import deepspeed + + unwrapped_student = self.accelerator.unwrap_model(model) + unwrapped_teacher = self.accelerator.unwrap_model(self.teacher_model) + student_head = unwrapped_student.get_output_embeddings() + teacher_head = unwrapped_teacher.get_output_embeddings() + params = [student_head.weight, teacher_head.weight] + if student_head.bias is not None: + params.append(student_head.bias) + if teacher_head.bias is not None: + params.append(teacher_head.bias) + return deepspeed.zero.GatheredParameters(params, modifier_rank=None) + + @profiling_decorator + def training_step( + self, model: nn.Module, inputs: dict[str, torch.Tensor | Any], num_items_in_batch: int | None = None + ) -> torch.Tensor: + """ + Perform a training step for the General Online Logit Distillation (GOLD) model. + + This method implements the on-policy learning approach described in the GOLD blog post. With probability + `self.lmbda`, it generates new responses using the student model, which are then used for training instead of + the offline original inputs. + """ + buffer_steps = self.args.gradient_accumulation_steps + + # Keep lm_head gathered across forward+backward for Liger + ZeRO-3. + with self._get_liger_zero3_lm_head_gather_ctx(model): + loss = super().training_step(model, inputs, num_items_in_batch) + + slice_idx = (self._step - 1) % buffer_steps + + on_policy = False + if self._buffered_on_policy is not None and slice_idx < len(self._buffered_on_policy): + on_policy = self._buffered_on_policy[slice_idx] + + if on_policy and self._buffered_text_logs is not None and self._buffered_text_logs[slice_idx] is not None: + prompt_texts, completion_texts = self._buffered_text_logs[slice_idx] + self._textual_logs["prompt"].extend(gather_object(prompt_texts)) + self._textual_logs["completion"].extend(gather_object(completion_texts)) + + loss_scalar = float(loss.detach()) + step_equiv = 1.0 / self.args.gradient_accumulation_steps + + if on_policy: + self._on_policy_loss_total += loss_scalar + self._on_policy_step_equiv += step_equiv + else: + self._off_policy_loss_total += loss_scalar + self._off_policy_step_equiv += step_equiv + return loss + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + metrics = {key: sum(val) / len(val) for key, val in self._metrics[mode].items()} # average the metrics + + if mode == "train": + device = self.accelerator.device if hasattr(self.accelerator, "device") else torch.device("cpu") + vec = torch.tensor( + [ + self._on_policy_loss_total, + self._off_policy_loss_total, + self._on_policy_step_equiv, + self._off_policy_step_equiv, + self._matched_sum, + self._unmatched_sum, + self._matched_step_eq, + self._unmatched_step_eq, + ], + dtype=torch.float64, + device=device, + ) + + if ( + getattr(self.accelerator, "distributed_type", DistributedType.NO) != DistributedType.NO + and dist.is_available() + and dist.is_initialized() + ): + dist.all_reduce(vec, op=dist.ReduceOp.SUM) + + ( + on_sum, + off_sum, + on_eq, + off_eq, + matched_sum, + unmatched_sum, + matched_eq, + unmatched_eq, + ) = vec.tolist() + + if on_eq > 0: + logs["on_policy_loss"] = round(on_sum / on_eq, 4) + if off_eq > 0: + logs["off_policy_loss"] = round(off_sum / off_eq, 4) + + if matched_eq > 0: + logs["matched_loss"] = round(matched_sum / matched_eq, 4) + if unmatched_eq > 0: + logs["unmatched_loss"] = round(unmatched_sum / unmatched_eq, 4) + + self._on_policy_loss_total = self._off_policy_loss_total = 0.0 + self._on_policy_step_equiv = self._off_policy_step_equiv = 0.0 + self._matched_sum = self._unmatched_sum = 0.0 + self._matched_step_eq = self._unmatched_step_eq = 0.0 + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + if ( + self.accelerator.is_main_process + and self.log_completions + and ((self.state.global_step % self.log_completion_steps) == 0) + ): + if is_rich_available(): + print_prompt_completions_sample_uld( + self._textual_logs["prompt"], + self._textual_logs["completion"], + self.state.global_step, + self.num_completions_to_print, + ) + + if self.args.report_to and "wandb" in self.args.report_to and wandb.run is not None: + import pandas as pd + + table = { + "step": [self.state.global_step] * len(self._textual_logs["prompt"]), + "prompt": self._textual_logs["prompt"], + "completion": self._textual_logs["completion"], + } + df = pd.DataFrame(table) + if self.wandb_log_unique_prompts: + df = df.drop_duplicates(subset=["prompt"]) + if self.num_completions_to_print and len(df) > 0: + df = df.sample(n=self.num_completions_to_print, random_state=42) + wandb.log({"completions": wandb.Table(dataframe=df)}) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..708ea62d6740e6ca43c7de21bb716abce1e7c284 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .grpo_with_replay_buffer_config import GRPOWithReplayBufferConfig +from .grpo_with_replay_buffer_trainer import GRPOWithReplayBufferTrainer, ReplayBuffer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/grpo_with_replay_buffer_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/grpo_with_replay_buffer_config.py new file mode 100644 index 0000000000000000000000000000000000000000..f271a40d5acae80f0cb00ba10501bfa6865b2653 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/grpo_with_replay_buffer_config.py @@ -0,0 +1,34 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ...trainer.grpo_config import GRPOConfig + + +@dataclass +class GRPOWithReplayBufferConfig(GRPOConfig): + """ + New Parameters: + replay_buffer_size (`int`, *optional*, defaults to `0`): + A cache that stores the rollouts with the highest advantage scores and variance per group. If a new + group has 0 variance, it is replaced with a group sampled from the replay buffer. + """ + + replay_buffer_size: int = field( + default=64, + metadata={ + "help": "A cache that stores the rollouts with the highest advantage scores and variance per group. If a new group has 0 variance, it is replaced with a group sampled from the replay buffer." + }, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/grpo_with_replay_buffer_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/grpo_with_replay_buffer_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..523363d689a200ed69103abb00e2f9822987069b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/grpo_with_replay_buffer/grpo_with_replay_buffer_trainer.py @@ -0,0 +1,795 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import heapq +from typing import Any + +import torch +from accelerate.utils import gather_object + +from ...data_utils import apply_chat_template, is_conversational, prepare_multimodal_messages +from ...models.utils import disable_gradient_checkpointing +from ...trainer.grpo_trainer import GRPOTrainer +from ...trainer.utils import nanmax, nanmin, nanstd, pad +from .grpo_with_replay_buffer_config import GRPOWithReplayBufferConfig + + +class ReplayBuffer: + """ + A simple replay buffer to store and sample previously seen rollouts. + """ + + def __init__(self, max_size: int): + self.max_size = max_size + self.heap = [] # Min-heap of (score, data) tuples + + def add(self, scores: list[float], data: list[dict]): + for score, datum in zip(scores, data, strict=True): + if len(self.heap) < self.max_size: + heapq.heappush(self.heap, (score, datum)) + else: + # Only add if score is better than worst (minimum) item + if score > self.heap[0][0]: + heapq.heapreplace(self.heap, (score, datum)) + + def sample(self, num_samples: int) -> list[dict[str, torch.Tensor]]: + if not self.heap: + return None + + # Sample by normalized scores + scores = torch.tensor([item[0] for item in self.heap], dtype=torch.float32) + probabilities = scores / scores.sum() + replacement = False + if num_samples > len(self.heap): + replacement = True + chosen_indices = torch.multinomial(probabilities, num_samples, replacement=replacement).tolist() + return [self.heap[i][1] for i in chosen_indices] + + +class GRPOWithReplayBufferTrainer(GRPOTrainer): + def __init__(self, args: GRPOWithReplayBufferConfig | None = None, **kwargs): + super().__init__(args=args, **kwargs) + self.replay_buffer = ReplayBuffer(args.replay_buffer_size) if args.replay_buffer_size > 0 else None + + def _generate_and_score_completions( + self, inputs: list[dict[str, torch.Tensor | Any]] + ) -> dict[str, torch.Tensor | Any]: + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + prompts = [x["prompt"] for x in inputs] + + if "images" in inputs[0]: + images = [example.get("images") for example in inputs] + elif "image" in inputs[0]: + images = [[example.get("image")] if example.get("image") is not None else None for example in inputs] + else: + images = None + # Transformers requires at least one image in the batch, otherwise it throws an error + if images is not None and all(img_list == [] for img_list in images): + images = None + + # If the prompts are conversational and the inputs contain images, we need to convert the prompts from + # [{"role": "user", "content": "What color is the sky?"}] to + # [{"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What color is the sky?"}]}] + if images is not None: + if not is_conversational(inputs[0]): + raise ValueError( + "Multimodal training requires conversational prompts. It looks like the dataset contains " + "non-conversational inputs, likely because a chat template was applied before passing the dataset " + "to the trainer. Please provide the raw conversational prompts and let the trainer apply the chat " + "template internally." + ) + prompts = [ + prepare_multimodal_messages(prompt, images=image_list) + for prompt, image_list in zip(prompts, images, strict=True) + ] + + dataset_images = images # preserve dataset images before _generate may overwrite + ( + prompt_ids_list, + completion_ids_list, + tool_mask_list, + completions, + num_items_in_batch, + sampling_per_token_logps_list, + extra_fields, + images, + tool_images, + ) = self._generate(prompts) + if images is None: + images = dataset_images # restore dataset images (rollout_func path returns None) + + # Convert lists of token IDs to padded tensors + prompt_ids = [torch.tensor(ids) for ids in prompt_ids_list] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + prompt_ids = pad( + prompt_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + prompt_mask = pad( + prompt_mask, + padding_value=0, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_ids = [torch.tensor(ids) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + completion_ids = pad( + completion_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_mask = pad( + completion_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + if sampling_per_token_logps_list is not None: + sampling_per_token_logps = [torch.tensor(logps) for logps in sampling_per_token_logps_list] + sampling_per_token_logps = pad( + sampling_per_token_logps, + padding_value=0.0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + else: + sampling_per_token_logps = None + if self.tools: + tool_mask = [torch.tensor(mask) for mask in tool_mask_list] + tool_mask = pad( + tool_mask, + padding_value=1, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) # 0 for tool result tokens, 1 elsewhere + + # If mask_truncated_completions is enabled, zero out truncated completions in completion_mask + if self.mask_truncated_completions: + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + completion_mask = completion_mask * (~is_truncated).unsqueeze(1).int() + + # Concatenate prompt_mask with completion_mask for logit computation + prompt_completion_ids = torch.cat([prompt_ids, completion_ids], dim=1) # (B, P+C) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) # (B, P+C) + + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_size + + num_images = [len(img_list) if img_list else 0 for img_list in images] if images is not None else None + + # Get forward_kwargs for models with multimodal inputs + if images is not None: + prompts_text = [ + apply_chat_template( + {"prompt": prompt}, self.processing_class, tools=self.tools, **self.chat_template_kwargs + )["prompt"] + for prompt in prompts + ] + prompt_inputs = self.processing_class(images=images, text=prompts_text, padding=True, return_tensors="pt") + prompt_inputs = super()._prepare_inputs(prompt_inputs) + forward_kwargs = {k: v for k, v in prompt_inputs.items() if k not in ["input_ids", "attention_mask"]} + else: + forward_kwargs = {} + + # If token_type_ids are used, extend them with zeros for the completion part + if "token_type_ids" in forward_kwargs: + token_type_ids = forward_kwargs["token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and token_type_ids must have equal len + padding_size = prompt_ids.size(1) - token_type_ids.size(1) + if padding_size > 0: + token_type_ids = torch.cat( + [token_type_ids.new_zeros((token_type_ids.size(0), padding_size)), token_type_ids], dim=1 + ) + forward_kwargs["token_type_ids"] = torch.cat( + [token_type_ids, token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + # If mm_token_type_ids are used, extend them with zeros for the completion part + if "mm_token_type_ids" in forward_kwargs: + mm_token_type_ids = forward_kwargs["mm_token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and mm_token_type_ids must have equal len + padding_size = prompt_ids.size(1) - mm_token_type_ids.size(1) + if padding_size > 0: + mm_token_type_ids = torch.cat( + [mm_token_type_ids.new_zeros((mm_token_type_ids.size(0), padding_size)), mm_token_type_ids], + dim=1, + ) + forward_kwargs["mm_token_type_ids"] = torch.cat( + [mm_token_type_ids, mm_token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + + # When gradient checkpointing is enabled with use_reentrant=True (non default), calling the model inside a + # torch.no_grad() block triggers a harmless PyTorch warning ("None of the inputs have requires_grad=True"). + # Temporarily disable checkpointing to avoid this warning during inference. + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + # If the generation and optimization steps are misaligned—i.e., if generation does not occur at the end of + # a full optimizer step (when gradient_accumulation_steps is not a multiple of generate_every)—then the + # samples may come from an earlier version of the model. In that case, we need to track old_per_token_logps + # for importance sampling. If the steps are aligned, importance sampling isn't necessary and we set + # old_per_token_logps to None. + # When using vLLM, we always compute old_per_token_logps for importance sampling, it was shown that the + # distribution mismatch between vLLM and the training model can be large and harm the training. + generate_every = self.args.steps_per_generation * self.num_iterations # generation frequency + if self.args.gradient_accumulation_steps % generate_every != 0 or ( + self.use_vllm and self.vllm_importance_sampling_correction + ): + old_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + old_per_token_logps = None + + # Compute the importance sampling ratio when using vLLM, to correct for potential distribution mismatch + if self.use_vllm and self.vllm_importance_sampling_correction: + importance_sampling_ratio = torch.exp(old_per_token_logps - sampling_per_token_logps) + importance_sampling_ratio = torch.clamp( + importance_sampling_ratio, max=self.vllm_importance_sampling_cap + ) + + # Compute the per-token log probabilities for the reference model + if self.beta != 0.0: + if self.ref_model is not None: + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.ref_model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + with self.accelerator.unwrap_model(self.model).disable_adapter(): + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask and image_sizes + ) + else: + ref_per_token_logps = None + + # Decode + prompts_text = self.processing_class.batch_decode(prompt_ids, skip_special_tokens=True) + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Merge extra_fields from rollout_func into inputs for reward functions + if extra_fields: + for i, inp in enumerate(inputs): + for key, values in extra_fields.items(): + if isinstance(values, list) and i < len(values): + inp[key] = values[i] + elif not isinstance(values, list): + inp[key] = values + + # Calculate rewards for each reward function. rewards_per_func aggregates rewards across all processes. This is + # important because rewards will be normalized per group, and completions are distributed. We will later slice + # rewards_per_func to extract each process's subset. + rewards_per_func = self._calculate_rewards(inputs, prompts, completions, completion_ids_list) + + # Apply weights to each reward function's output and sum + rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + + # Compute grouped-wise rewards + mean_grouped_rewards = rewards.view(-1, self.num_generations).mean(dim=1) + + # Normalize the rewards to compute the advantages + mean_grouped_rewards = mean_grouped_rewards.repeat_interleave(self.num_generations, dim=0) + advantages = rewards - mean_grouped_rewards + + grouped_std_rewards = rewards.view(-1, self.num_generations).std(dim=1) + grouped_std_rewards = grouped_std_rewards.repeat_interleave(self.num_generations, dim=0) + + if self.scale_rewards in ["group", "none"]: + # If self.scale_rewards = "none", we'll still log group level std + std_rewards = grouped_std_rewards.clone() + elif self.scale_rewards == "batch": + # Compute global std + std_rewards = rewards.std().expand_as(rewards) + else: + raise ValueError( + f"Invalid value for scale_rewards: {self.scale_rewards}. Must be one of 'batch', 'group', or 'none'." + ) + + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) + if self.scale_rewards != "none": + advantages = advantages / (std_rewards + 1e-4) + + # Slice to keep only the local part of the data + process_slice = slice( + self.accelerator.process_index * len(prompts), + (self.accelerator.process_index + 1) * len(prompts), + ) + all_process_advantages = advantages.clone() # keep the aggregated advantages for logging + advantages = advantages[process_slice] + grouped_std_rewards = grouped_std_rewards[process_slice] + + # Calculate mean reward per function, but only for samples where the function was applied (non-NaN values) + for i, reward_func_name in enumerate(self.reward_func_names): + mean_rewards = torch.nanmean(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/mean"].append(mean_rewards) + std_func_rewards = nanstd(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/std"].append(std_func_rewards) + rewards = (rewards_per_func * self.reward_weights.to(rewards_per_func.device).unsqueeze(0)).nansum(dim=1) + self._metrics[mode]["reward"].append(rewards.mean().item()) + self._metrics[mode]["reward_std"].append(rewards.std().item()) + self._metrics[mode]["frac_reward_zero_std"].append(is_std_zero.float().mean().item()) + + # Log prompt and completion texts + self._logs["prompt"].extend(gather_object(prompts_text)) + self._logs["completion"].extend(gather_object(completions_text)) + for i, name in enumerate(self.reward_func_names): + self._logs["rewards"][name].extend(rewards_per_func[:, i].tolist()) + self._logs["advantages"].extend(all_process_advantages.tolist()) + + if images is not None: + self._logs["images"].extend(gather_object(images)) + + if self.use_vllm and self.vllm_importance_sampling_correction: + delta = torch.abs(old_per_token_logps - sampling_per_token_logps) + mask = completion_mask.bool() if not self.tools else (completion_mask * tool_mask).bool() + delta = delta[mask] + mean_delta = torch.mean(delta) if delta.numel() > 0 else torch.tensor(0.0, device=device) + max_delta = torch.max(delta) if delta.numel() > 0 else torch.tensor(0.0, device=device) + self._metrics[mode]["sampling/sampling_logp_difference/mean"].append( + self.accelerator.gather(mean_delta).mean().item() + ) + self._metrics[mode]["sampling/sampling_logp_difference/max"].append( + self.accelerator.gather(max_delta).max().item() + ) + + flat_is_ratio = importance_sampling_ratio[mask] + min_importance_sampling_ratio = ( + torch.min(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + mean_importance_sampling_ratio = ( + torch.mean(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + max_importance_sampling_ratio = ( + torch.max(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + self._metrics[mode]["sampling/importance_sampling_ratio/min"].append( + nanmin(self.accelerator.gather(min_importance_sampling_ratio)).item() + ) + self._metrics[mode]["sampling/importance_sampling_ratio/mean"].append( + self.accelerator.gather(mean_importance_sampling_ratio).nanmean().item() + ) + self._metrics[mode]["sampling/importance_sampling_ratio/max"].append( + nanmax(self.accelerator.gather(max_importance_sampling_ratio)).item() + ) + outputs_after_sampling_buffer = self.update_with_replay_buffer( + advantages, + grouped_std_rewards, + prompt_ids, + prompt_mask, + completion_ids, + completion_mask, + forward_kwargs, + num_items_in_batch, + old_per_token_logps, + ref_per_token_logps, + importance_sampling_ratio if self.use_vllm and self.vllm_importance_sampling_correction else None, + ) + if outputs_after_sampling_buffer is not None: + return outputs_after_sampling_buffer + else: + output = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "advantages": advantages, + "num_items_in_batch": num_items_in_batch, + } + if old_per_token_logps is not None: + output["old_per_token_logps"] = old_per_token_logps + if self.use_vllm and self.vllm_importance_sampling_correction: + output["importance_sampling_ratio"] = importance_sampling_ratio + if ref_per_token_logps is not None: + output["ref_per_token_logps"] = ref_per_token_logps + if "pixel_values" in forward_kwargs: + output["pixel_values"] = forward_kwargs["pixel_values"] + if "image_grid_thw" in forward_kwargs: + output["image_grid_thw"] = forward_kwargs["image_grid_thw"] + if "pixel_attention_mask" in forward_kwargs: + output["pixel_attention_mask"] = forward_kwargs["pixel_attention_mask"] + if "image_sizes" in forward_kwargs: + output["image_sizes"] = forward_kwargs["image_sizes"] + if "token_type_ids" in forward_kwargs: + output["token_type_ids"] = forward_kwargs["token_type_ids"] + if images is not None: + output["num_images"] = num_images + if self.tools: + output["tool_mask"] = tool_mask + return output + + def slice_group_data( + self, data: torch.Tensor, mask: torch.Tensor, group_idx: int + ) -> tuple[torch.Tensor, torch.Tensor]: + """ + Slices the input data and mask tensors for a specific group index. Also trims the sequence length to the + maximum length in the group based on the mask. + + Args: + data: Tensor of shape (num_groups * num_generations, seq_length) + mask: Tensor of shape (num_groups * num_generations, seq_length) + group_idx: Index of the group to slice + Returns: + Tuple of (sliced_data, sliced_mask) for the specified group, with sequence length trimmed to the maximum + length in the group. + """ + start_idx = group_idx * self.num_generations + end_idx = (group_idx + 1) * self.num_generations + group_data = data[start_idx:end_idx] + group_mask = mask[start_idx:end_idx] + group_max_len = group_mask.sum(dim=1).max().item() + return group_data[:, :group_max_len], group_mask[:, :group_max_len] + + def update_replay_buffer( + self, + groups_with_variance: torch.Tensor, + group_advantages: torch.Tensor, + group_std_rewards: torch.Tensor, + prompt_ids: torch.Tensor, + prompt_mask: torch.Tensor, + completion_ids: torch.Tensor, + completion_mask: torch.Tensor, + forward_kwargs: dict, + optional_vision_fields: list[str] = None, + old_per_token_logps: torch.Tensor | None = None, + ref_per_token_logps: torch.Tensor | None = None, + importance_sampling_ratio: float | None = None, + ) -> None: + """ + Update the replay buffer with groups that have reward variance (std > 0). + + Args: + groups_with_variance: Boolean tensor indicating which groups have reward variance + group_advantages: Tensor of shape (num_groups, num_generations) containing advantage values + std_rewards: Tensor of shape (num_groups, num_generations) containing std of rewards per group + prompt_ids: Tensor containing prompt token IDs + prompt_mask: Tensor containing prompt attention masks + completion_ids: Tensor containing completion token IDs + completion_mask: Tensor containing completion attention masks + forward_kwargs: Dictionary containing additional prompt inputs (vision data, etc.) + optional_vision_fields: List of optional vision-related fields to include if present in forward_kwargs + old_per_token_logps: Optional tensor of old per-token log probabilities + ref_per_token_logps: Optional tensor of reference per-token log probabilities + importance_sampling_ratio: Optional importance sampling correction ratio + """ + # Prepare buffered outputs for groups with variance + buffered_outputs = [] + for _, group_idx in enumerate(groups_with_variance.nonzero(as_tuple=True)[0].unique().tolist()): + group_prompt_ids, group_prompt_mask = self.slice_group_data(prompt_ids, prompt_mask, group_idx) + group_completion_ids, group_completion_mask = self.slice_group_data( + completion_ids, completion_mask, group_idx + ) + + # Store unpadded data in the buffer + buffered_output = { + "prompt_ids": group_prompt_ids, + "completion_ids": group_completion_ids, + "advantages": group_advantages[group_idx].tolist(), + "prompt_mask": group_prompt_mask, + "completion_mask": group_completion_mask, + } + + # Add optional fields if they exist + optional_fields = { + "old_per_token_logps": old_per_token_logps if old_per_token_logps is not None else None, + "ref_per_token_logps": ref_per_token_logps if ref_per_token_logps is not None else None, + } + + for field_name, field_data in optional_fields.items(): + if field_data is not None: + buffered_output[field_name] = self.slice_group_data(field_data, completion_mask, group_idx)[0] + + # Add importance sampling if needed + if self.use_vllm and self.vllm_importance_sampling_correction: + buffered_output["importance_sampling_ratio"] = importance_sampling_ratio + + if optional_vision_fields: + # Add vision-related fields if they exist + for field_name in optional_vision_fields: + if field_name in forward_kwargs: + buffered_output[field_name] = self.slice_group_data( + forward_kwargs[field_name], prompt_mask, group_idx + )[0] + + buffered_outputs.append(buffered_output) + + if groups_with_variance.any(): + # Calculate replay buffer scores for groups with variance + replay_buffer_scores = (group_advantages.abs() * group_std_rewards).sum(dim=-1)[groups_with_variance] + # Add all groups to replay buffer at once (batch operation) + self.replay_buffer.add(replay_buffer_scores.tolist(), buffered_outputs) + + def sample_from_replay_buffer( + self, num_samples: int, optional_vision_fields: list[str] = None, optional_tensor_fields: list[str] = None + ) -> list[dict]: + """ + Sample groups from the replay buffer. + + Args: + num_samples: Number of samples to draw from the replay buffer + optional_vision_fields: List of optional vision-related fields to include if present in sampled data + optional_tensor_fields: List of optional tensor fields to include if present in sampled data + Returns: + List of sampled data dictionaries from the replay buffer + """ + sampled = self.replay_buffer.sample(num_samples=num_samples) + + # Extract and concatenate sampled data + sampled_data = { + "prompt_ids": [], + "prompt_mask": [], + "completion_ids": [], + "completion_mask": [], + "advantages": [], + } + + all_optional_fields = (optional_tensor_fields or []) + (optional_vision_fields or []) + # Initialize containers for optional fields if they exist in sampled data + for field in all_optional_fields: + if sampled and field in sampled[0]: + sampled_data[field] = [] + + # Extract data from each sampled item + for item in sampled: + # Handle core fields + for key in ["prompt_ids", "prompt_mask", "completion_ids", "completion_mask"]: + sampled_data[key].append(item[key]) + + # Handle advantages (list, not tensor) + sampled_data["advantages"].append(item["advantages"]) + + # Handle optional fields + for field in all_optional_fields: + if field in item: + sampled_data[field].append(item[field]) + + return sampled_data + + def update_with_replay_buffer( + self, + group_advantages: torch.Tensor, + group_std_rewards: torch.Tensor, + prompt_ids: torch.Tensor, + prompt_mask: torch.Tensor, + completion_ids: torch.Tensor, + completion_mask: torch.Tensor, + forward_kwargs: dict, + num_items_in_batch: int, + old_per_token_logps: torch.Tensor | None = None, + ref_per_token_logps: torch.Tensor | None = None, + importance_sampling_ratio: float | None = None, + ) -> None: + """ + Update current batch data with samples from replay buffer. + + Groups with reward variance (std > 0) are added to the replay buffer and then replaced with samples from the + buffer to improve training stability. + + Args: + group_advantages: Tensor of shape (num_groups, num_generations) containing advantage values + std_rewards: Tensor of shape (num_groups, num_generations) containing std of rewards per group + prompt_ids: Tensor containing prompt token IDs + prompt_mask: Tensor containing prompt attention masks + completion_ids: Tensor containing completion token IDs + completion_mask: Tensor containing completion attention masks + forward_kwargs: Dictionary containing additional prompt inputs (vision data, etc.) + num_items_in_batch: Number of items in the current batch + old_per_token_logps: Optional tensor of old per-token log probabilities + ref_per_token_logps: Optional tensor of reference per-token log probabilities + importance_sampling_ratio: Optional importance sampling correction ratio + """ + if self.replay_buffer.max_size <= 0: + return + + # Groups to consider for adding to the replay buffer + groups_with_variance = group_std_rewards.max(dim=0).values > 0 + # Groups to replace from the replay buffer + groups_without_variance = ~groups_with_variance + + # Track which optional fields are present in sampled data + optional_tensor_fields = ["old_per_token_logps", "ref_per_token_logps"] + vision_fields = ["pixel_values", "image_grid_thw", "pixel_attention_mask", "image_sizes"] + + self.update_replay_buffer( + groups_with_variance, + group_advantages, + group_std_rewards, + prompt_ids, + prompt_mask, + completion_ids, + completion_mask, + forward_kwargs, + vision_fields, + old_per_token_logps, + ref_per_token_logps, + importance_sampling_ratio, + ) + + # Sample from replay buffer to replace groups with variance + num_groups_to_replace = groups_without_variance.sum().item() + if not num_groups_to_replace: + return + + sampled_data = self.sample_from_replay_buffer( + num_samples=num_groups_to_replace, + optional_vision_fields=vision_fields, + optional_tensor_fields=optional_tensor_fields, + ) + + # Pad sampled data if they are shorter than the current batch sequences + # Or pad the current batch if sampled are longer + current_batch_prompt_seq_len = prompt_ids.size(1) + current_batch_completion_seq_len = completion_ids.size(1) + + groups_to_replace_idxs = groups_with_variance.logical_not().nonzero(as_tuple=True)[0].unique().tolist() + + # Determine target (max) sequence lengths once + sampled_prompt_lengths = [t.size(1) for t in sampled_data["prompt_ids"]] + sampled_completion_lengths = [t.size(1) for t in sampled_data["completion_ids"]] + target_prompt_len = max([current_batch_prompt_seq_len] + sampled_prompt_lengths) + target_completion_len = max([current_batch_completion_seq_len] + sampled_completion_lengths) + + # If any sampled prompt is longer, pad the whole batch prompt tensors once (left padding) + if target_prompt_len > current_batch_prompt_seq_len: + prompt_ids = pad( + list(prompt_ids.unbind(0)), + padding_value=self._tokenizer.pad_token_id, + pad_to_multiple_of=target_prompt_len, + padding_side="left", + ) + prompt_mask = pad( + list(prompt_mask.unbind(0)), padding_value=0, pad_to_multiple_of=target_prompt_len, padding_side="left" + ) + # If any sampled completion is longer, pad the whole batch completion tensors once (right padding) + if target_completion_len > current_batch_completion_seq_len: + completion_ids = pad( + list(completion_ids.unbind(0)), + padding_value=self._tokenizer.pad_token_id, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + completion_mask = pad( + list(completion_mask.unbind(0)), + padding_value=0, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + if old_per_token_logps is not None: + old_per_token_logps = pad( + list(old_per_token_logps.unbind(0)), + padding_value=0.0, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + if ref_per_token_logps is not None: + ref_per_token_logps = pad( + list(ref_per_token_logps.unbind(0)), + padding_value=0.0, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + + # Replace per-group data, padding only sampled groups that are shorter than the target + for i, group_idx in enumerate(groups_to_replace_idxs): + start_idx = group_idx * self.num_generations + end_idx = (group_idx + 1) * self.num_generations + idx_range = slice(start_idx, end_idx) + + # Pad sampled prompt to target length if needed + if sampled_data["prompt_ids"][i].size(1) < target_prompt_len: + sampled_data["prompt_ids"][i] = pad( + sampled_data["prompt_ids"][i], + padding_value=self._tokenizer.pad_token_id, + pad_to_multiple_of=target_prompt_len, + padding_side="left", + ) + sampled_data["prompt_mask"][i] = pad( + sampled_data["prompt_mask"][i], + padding_value=0, + pad_to_multiple_of=target_prompt_len, + padding_side="left", + ) + + # Pad sampled completion to target length if needed + if sampled_data["completion_ids"][i].size(1) < target_completion_len: + sampled_data["completion_ids"][i] = pad( + sampled_data["completion_ids"][i], + padding_value=self._tokenizer.pad_token_id, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + sampled_data["completion_mask"][i] = pad( + sampled_data["completion_mask"][i], + padding_value=0, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + if "old_per_token_logps" in sampled_data: + sampled_data["old_per_token_logps"][i] = pad( + sampled_data["old_per_token_logps"][i], + padding_value=0.0, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + if "ref_per_token_logps" in sampled_data: + sampled_data["ref_per_token_logps"][i] = pad( + sampled_data["ref_per_token_logps"][i], + padding_value=0.0, + pad_to_multiple_of=target_completion_len, + padding_side="right", + ) + + # Assign (replace) group slice + prompt_ids[idx_range] = sampled_data["prompt_ids"][i] + prompt_mask[idx_range] = sampled_data["prompt_mask"][i] + completion_ids[idx_range] = sampled_data["completion_ids"][i] + completion_mask[idx_range] = sampled_data["completion_mask"][i] + group_advantages[group_idx] = sampled_data["advantages"][i] + + if "old_per_token_logps" in sampled_data: + old_per_token_logps[idx_range] = sampled_data["old_per_token_logps"][i] + if "ref_per_token_logps" in sampled_data: + ref_per_token_logps[idx_range] = sampled_data["ref_per_token_logps"][i] + + for field in vision_fields: + if field in sampled_data and field in forward_kwargs: + forward_kwargs[field][idx_range] = sampled_data[field][i] + + # Prepare final outputs after sampling and replacement + outputs_after_sampling_buffer = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "advantages": group_advantages, + } + + # Replace optional tensor fields if they exist + for field in optional_tensor_fields: + if field in sampled_data: + outputs_after_sampling_buffer[field] = ( + old_per_token_logps if field == "old_per_token_logps" else ref_per_token_logps + ) + + # Replace vision fields if they exist + for field in vision_fields: + if field in sampled_data and field in forward_kwargs: + outputs_after_sampling_buffer[field] = forward_kwargs[field] + + outputs_after_sampling_buffer["num_items_in_batch"] = num_items_in_batch + if self.use_vllm and self.vllm_importance_sampling_correction: + outputs_after_sampling_buffer["importance_sampling_ratio"] = importance_sampling_ratio + + return outputs_after_sampling_buffer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gspo_token/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gspo_token/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4c9814fddca65cfe8d5ccabccc9d646141e19364 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gspo_token/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .grpo_trainer import GRPOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gspo_token/grpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gspo_token/grpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..0522058bc6eeda33779b6182130478545d1ff9b6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/gspo_token/grpo_trainer.py @@ -0,0 +1,157 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import torch + +from ...trainer.grpo_trainer import GRPOTrainer as _GRPOTrainer +from ...trainer.utils import nanmax, nanmin + + +class GRPOTrainer(_GRPOTrainer): + def _compute_loss(self, model, inputs): + # Compute the per-token log probabilities for the model + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + + # Compute the per_token_logps and the entropy at each position in the completion + per_token_logps, entropies = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=True, + pixel_values=inputs.get("pixel_values"), + image_grid_thw=inputs.get("image_grid_thw"), + num_images=inputs.get("num_images"), + pixel_attention_mask=inputs.get("pixel_attention_mask"), + image_sizes=inputs.get("image_sizes"), + token_type_ids=inputs.get("token_type_ids"), + ) + + if self.top_entropy_quantile < 1.0: + entropy_mask = self.get_high_entropy_mask(entropies, completion_mask, 1 - self.top_entropy_quantile) + else: + entropy_mask = None + + # Compute the KL divergence between the model and the reference model + if self.beta != 0.0: + ref_per_token_logps = inputs["ref_per_token_logps"] + per_token_kl = ( + torch.exp(ref_per_token_logps - per_token_logps) - (ref_per_token_logps - per_token_logps) - 1 + ) + + # Compute the loss + advantages = inputs["advantages"] + # When num_iterations == 1 and steps_per_generation <= gradient_accumulation_steps, + # old_per_token_logps == per_token_logps. In this case we can skip its computation + # (see _generate_and_score_completions) and instead use per_token_logps.detach(). + # The exception is when using vLLM, where we always compute old_per_token_logps + # for importance sampling + old_per_token_logps = inputs.get("old_per_token_logps") + old_per_token_logps = per_token_logps.detach() if old_per_token_logps is None else old_per_token_logps + + log_ratio = per_token_logps - old_per_token_logps + if self.importance_sampling_level == "token": + log_importance_weights = log_ratio + elif self.importance_sampling_level == "sequence": + log_importance_weights = (log_ratio * completion_mask).sum(-1) / completion_mask.sum(-1).clamp(min=1.0) + log_importance_weights = log_importance_weights.unsqueeze(-1) + elif self.importance_sampling_level == "sequence_token": + # GSPO-token: sg[si(θ)] * πθ(yi,t)/sg[πθ(yi,t)] + seq_level_log_weight = (log_ratio * completion_mask).sum(-1) / completion_mask.sum(-1).clamp(min=1.0) + seq_level_log_weight = seq_level_log_weight.detach().unsqueeze(-1) # Stop gradient + log_importance_weights = per_token_logps - per_token_logps.detach() + seq_level_log_weight + else: + raise ValueError( + f"Unknown importance sampling level: {self.importance_sampling_level}. Possible values are 'token' " + "and 'sequence'." + ) + # From here, log_importance_weights (and all subsequent tensors, coef_1, coef_2, etc.) shape depends on + # importance_sampling_level: "token" level: (B, T); "sequence" level: (B, 1) + + coef_1 = torch.exp(log_importance_weights) + coef_2 = torch.clamp(coef_1, 1 - self.epsilon_low, 1 + self.epsilon_high) + + # Two-sided clipping + if self.args.delta is not None: + coef_1 = torch.clamp(coef_1, max=self.args.delta) + + per_token_loss1 = coef_1 * advantages.unsqueeze(1) + per_token_loss2 = coef_2 * advantages.unsqueeze(1) + per_token_loss = -torch.min(per_token_loss1, per_token_loss2) + if entropy_mask is not None: + per_token_loss = per_token_loss * entropy_mask + + if self.use_vllm and self.vllm_importance_sampling_correction: + per_token_loss = per_token_loss * inputs["importance_sampling_ratio"] + + if self.beta != 0.0: + per_token_loss = per_token_loss + self.beta * per_token_kl + + mode = "train" if self.model.training else "eval" + if self.loss_type == "grpo": + loss = ((per_token_loss * completion_mask).sum(-1) / completion_mask.sum(-1).clamp(min=1.0)).mean() + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + loss = loss / normalizer + elif self.loss_type == "bnpo": + loss = (per_token_loss * completion_mask).sum() / completion_mask.sum().clamp(min=1.0) + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + loss = loss / normalizer + elif self.loss_type == "dr_grpo": + loss = (per_token_loss * completion_mask).sum() / (per_token_loss.size(0) * self.max_completion_length) + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + loss = loss / normalizer + elif self.loss_type == "dapo": + normalizer = inputs["num_items_in_batch"] / self.accelerator.num_processes + loss = (per_token_loss * completion_mask).sum() / normalizer + else: + raise ValueError(f"Unknown loss type: {self.loss_type}") + + # Log the metrics + completion_token_count = completion_mask.sum().clamp(min=1.0) + + def masked_batch_mean(x): + if x.shape[1] == 1: # when importance_sampling_level == "sequence" + return x.mean() + else: + return (x * completion_mask).sum() / completion_token_count + + if self.beta != 0.0: + mean_kl = masked_batch_mean(per_token_kl) + self._metrics[mode]["kl"].append(self.accelerator.gather(mean_kl).nanmean().item()) + + mean_entropy = masked_batch_mean(entropies) + self._metrics[mode]["entropy"].append(self.accelerator.gather(mean_entropy).nanmean().item()) + + # Compute the clipped probability ratios + is_low_clipped = (coef_1 < 1 - self.epsilon_low) & (advantages.unsqueeze(1) < 0) + is_high_clipped = (coef_1 > 1 + self.epsilon_high) & (advantages.unsqueeze(1) > 0) + is_region_clipped = is_low_clipped | is_high_clipped + + low_clip = masked_batch_mean(is_low_clipped.float()) + high_clip = masked_batch_mean(is_high_clipped.float()) + clip_ratio = masked_batch_mean(is_region_clipped.float()) + + gathered_low_clip = self.accelerator.gather(low_clip) + self._metrics[mode]["clip_ratio/low_mean"].append(gathered_low_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/low_min"].append(nanmin(gathered_low_clip).item()) + gathered_high_clip = self.accelerator.gather(high_clip) + self._metrics[mode]["clip_ratio/high_mean"].append(gathered_high_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/high_max"].append(nanmax(gathered_high_clip).item()) + gathered_clip_ratio = self.accelerator.gather(clip_ratio) + self._metrics[mode]["clip_ratio/region_mean"].append(gathered_clip_ratio.nanmean().item()) + return loss diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d7c21e2316bff7d621faa06622584271ee176d0e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .kto_config import KTOConfig +from .kto_trainer import KTOTrainer + + +__all__ = ["KTOConfig", "KTOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/kto_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/kto_config.py new file mode 100644 index 0000000000000000000000000000000000000000..b840b71217f789d7f5b8d8b54546ea6d89dd9664 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/kto_config.py @@ -0,0 +1,162 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class KTOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.kto.KTOTrainer`]. + + This class includes only the parameters that are specific to KTO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`KTOTrainer`] is provided as a string. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model and reference model. + + > Parameters that control the data preprocessing + + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from the left. + If `None`, no truncation is applied. + precompute_ref_log_probs (`bool`, *optional*, defaults to `False`): + Whether to precompute the reference model log probabilities for the entire training dataset before + training. This allows to save memory during training, as the reference model does not need to be kept in + memory. + precompute_ref_batch_size (`int`, *optional*): + Batch size to use when precomputing reference model log probabilities. This can be set higher than the + training batch size to speed up preprocessing. If `None`, defaults to `per_device_train_batch_size` for + training and `per_device_eval_batch_size` for evaluation. + + > Parameters that control the training + + loss_type (`str`, *optional*, defaults to `"kto"`): + Type of loss to use. Possible values are: + + - `"kto"`: KTO loss from the [KTO](https://huggingface.co/papers/2402.01306) paper. + - `"apo_zero_unpaired"`: Unpaired variant of APO-zero loss from the + [APO](https://huggingface.co/papers/2408.06266) paper. + + beta (`float`, *optional*, defaults to `0.1`): + Parameter controlling the deviation from the reference model. Higher β means less deviation from the + reference model. + desirable_weight (`float`, *optional*, defaults to `1.0`): + Desirable losses are weighed by this factor to counter unequal number of desirable and undesirable pairs. + undesirable_weight (`float`, *optional*, defaults to `1.0`): + Undesirable losses are weighed by this factor to counter unequal number of desirable and undesirable pairs. + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument of " + "the `KTOTrainer` is provided as a string." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model and reference model."}, + ) + + # Parameters that control the data preprocessing + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + max_length: int | None = field( + default=1024, + metadata={ + "help": "Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from " + "the left. If `None`, no truncation is applied." + }, + ) + precompute_ref_log_probs: bool = field( + default=False, + metadata={ + "help": "Whether to precompute the reference model log probabilities for the entire training dataset " + "before training. This allows to save memory during training, as the reference model does not need to be " + "kept in memory." + }, + ) + precompute_ref_batch_size: int | None = field( + default=None, + metadata={ + "help": "Batch size to use when precomputing reference model log probabilities. This can be set higher " + "than the training batch size to speed up preprocessing. If `None`, defaults to " + "`per_device_train_batch_size` for training and `per_device_eval_batch_size` for evaluation." + }, + ) + + # Parameters that control the training + loss_type: str = field( + default="kto", + metadata={ + "help": "Type of loss to use.", + "choices": ["kto", "apo_zero_unpaired"], + }, + ) + beta: float = field( + default=0.1, + metadata={ + "help": "Parameter controlling the deviation from the reference model. Higher β means less deviation from " + "the reference model." + }, + ) + desirable_weight: float = field( + default=1.0, + metadata={ + "help": "Desirable losses are weighed by this factor to counter unequal number of desirable and " + "undesirable pairs.", + }, + ) + undesirable_weight: float = field( + default=1.0, + metadata={ + "help": "Undesirable losses are weighed by this factor to counter unequal number of desirable and " + "undesirable pairs.", + }, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/kto_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/kto_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..d47fa02637b21d3be20b1097e81e2dc54986e06d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/kto/kto_trainer.py @@ -0,0 +1,1292 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import inspect +import textwrap +from collections import defaultdict +from collections.abc import Callable +from contextlib import contextmanager, nullcontext +from dataclasses import dataclass +from pathlib import Path +from typing import TYPE_CHECKING, Any, Literal + +import torch +import torch.nn as nn +import torch.nn.functional as F +import transformers +from accelerate import PartialState, logging +from accelerate.utils import is_peft_model, tqdm +from datasets import Dataset, IterableDataset, IterableDatasetDict, concatenate_datasets +from packaging.version import Version +from torch import autocast +from torch.utils.data import DataLoader, SequentialSampler +from transformers import ( + AutoProcessor, + DataCollator, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.data.data_collator import DataCollatorMixin +from transformers.trainer_utils import EvalLoopOutput, has_length +from transformers.utils import is_peft_available + +from ...data_utils import ( + extract_prompt, + is_conversational, + unpair_preference_dataset, +) +from ...import_utils import is_liger_kernel_available +from ...models.utils import prepare_deepspeed, prepare_fsdp +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import ( + create_model_from_path, + disable_dropout_in_model, + get_config_model_id, + pad, + selective_log_softmax, + use_adapter, +) +from ..utils import peft_module_casting_to_bf16 +from .kto_config import KTOConfig + + +if is_liger_kernel_available(): + from liger_kernel.chunked_loss import LigerFusedLinearKTOLoss + +if is_peft_available(): + from peft import PeftModel, get_peft_model, prepare_model_for_kbit_training + + +if TYPE_CHECKING: + from transformers import PreTrainedModel + + +logger = logging.get_logger(__name__) + +RUNNING_NAME = "running.pt" + + +def get_dataset_column_names(dataset: Dataset | IterableDataset) -> list[str]: + return list(next(iter(dataset)).keys()) if dataset.column_names is None else dataset.column_names + + +def _get_kl_dataset(batch: dict[str, list[Any]]) -> dict[str, list[Any]]: + """ + Creates mismatched pairs of prompts and completions for the KL dataset by adding a +1 offset to the order of + completions. For best results, the mismatched outputs y' used to estimate the KL term for a batch should be the + same set as the matched outputs y used to estimate the rewards in that batch, just paired with different x. + """ + batch["completion_ids"] = [batch["completion_ids"][-1]] + batch["completion_ids"][:-1] + return batch + + +@dataclass +class DataCollatorForUnpairedPreference(DataCollatorMixin): + """ + Data collator for unpaired preference data. Assembles completions from raw token IDs and pads sequences to the + maximum length of the batch. + + Args: + pad_token_id (`int`): + Token ID to use for padding `input_ids` sequences. + max_length (`int`, *optional*): + Maximum sequence length after assembly. Sequences longer than `max_length` are truncated from the end. + return_tensors (`str`, *optional*, defaults to `"pt"`): + The tensor type to return. Currently, only `"pt"` (PyTorch tensors) is supported. + """ + + pad_token_id: int + max_length: int | None = None + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + batch = {} + for prefix, ids_key in [("completion", "completion_ids"), ("KL_completion", "KL_completion_ids")]: + if ids_key not in examples[0]: + continue + + full_ids_list = [] + labels_list = [] + for ex in examples: + prompt_ids = ex["prompt_ids"] + answer_ids = ex[ids_key] + full_ids = prompt_ids + answer_ids + labels = [-100] * len(prompt_ids) + answer_ids + if self.max_length is not None: + full_ids = full_ids[: self.max_length] + labels = labels[: self.max_length] + full_ids_list.append(full_ids) + labels_list.append(labels) + + batch[f"{prefix}_input_ids"] = pad( + [torch.tensor(ids, dtype=torch.int64) for ids in full_ids_list], + padding_value=self.pad_token_id, + padding_side="right", + ) + batch[f"{prefix}_attention_mask"] = pad( + [torch.ones(len(ids), dtype=torch.int64) for ids in full_ids_list], + padding_value=0, + padding_side="right", + ) + batch[f"{prefix}_labels"] = pad( + [torch.tensor(lbl, dtype=torch.int64) for lbl in labels_list], + padding_value=-100, + padding_side="right", + ) + + if "reference_logps" in examples[0]: + batch["reference_logps"] = torch.tensor([ex["reference_logps"] for ex in examples]) + if "reference_KL_logps" in examples[0]: + batch["reference_KL_logps"] = torch.tensor([ex["reference_KL_logps"] for ex in examples]) + batch["label"] = [ex["label"] for ex in examples] + return batch + + +class KTOTrainer(_BaseTrainer): + """ + Initialize KTOTrainer. + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + ref_model ([`~transformers.PreTrainedModel`], *optional*): + Reference model used to compute the reference log probabilities. + + - If provided, this model is used directly as the reference policy. + - If `None`, the trainer will automatically use the initial policy corresponding to `model`, i.e. the model + state before KTO training starts. + args ([`experimental.kto.KTOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. The padding side must be set to "left". If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoProcessor.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + data_collator ([`~transformers.DataCollator`], *optional*): + The data collator to use for training. If None is specified, the default data collator + ([`~experimental.kto.kto_trainer.DataCollatorForUnpairedPreference`]) will be used which will pad the + sequences to the maximum length of the sequences in the batch. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + peft_config (`dict`, defaults to `None`): + The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in + a PEFT model. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + """ + + _tag_names = ["trl", "kto"] + _name = "KTO" + _paper = { + "title": "KTO: Model Alignment as Prospect Theoretic Optimization", + "id": "2402.01306", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{ethayarajh2024kto, + title = {{KTO: Model Alignment as Prospect Theoretic Optimization}}, + author = {Kawin Ethayarajh and Winnie Xu and Niklas Muennighoff and Dan Jurafsky and Douwe Kiela}, + year = 2024, + eprint = {arXiv:2402.01306}, + }"""), + } + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + ref_model: PreTrainedModel | None = None, + args: KTOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + data_collator: DataCollator | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + peft_config: dict | None = None, + compute_metrics: Callable[[EvalLoopOutput], dict] | None = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = KTOConfig(f"{model_name}-KTO") + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif isinstance(train_dataset, IterableDataset): + # IterableDataset requires dispatch_batches=False because Accelerate's dispatch mode may try to concatenate + # batches from multiple processes, leading to mismatch errors. + if args.accelerator_config.dispatch_batches is True: + logger.warning( + "You are using an `IterableDataset` for training with `dispatch_batches=True`. `dispatch_batches` " + "is forced to `False` when using an `IterableDataset`. To remove this warning, unset " + "`dispatch_batches` in `KTOConfig` or set it to `False`." + ) + args.accelerator_config.dispatch_batches = False + + # Model + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the KTOConfig, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + if ref_model is model: + raise ValueError( + "`model` and `ref_model` cannot be the same object. In most cases you should omit `ref_model` and " + "we'll initialize it to a copy of `model` for you." + ) + + # Processing class + if processing_class is None: + processing_class = AutoProcessor.from_pretrained(get_config_model_id(model.config)) + if isinstance(processing_class, ProcessorMixin): + tokenizer = processing_class.tokenizer + elif isinstance(processing_class, PreTrainedTokenizerBase): + tokenizer = processing_class + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + # Initialize this variable to False. This helps tracking the case when `peft_module_casting_to_bf16` + # has been called in order to properly call autocast if needed. + self._peft_has_been_casted_to_bf16 = False + + if not is_peft_available() and peft_config is not None: + raise ValueError( + "PEFT is not installed and you passed a `peft_config` in the trainer's kwargs, please install it with `pip install peft` to use the PEFT models" + ) + if is_peft_available() and isinstance(model, PeftModel) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + if is_peft_available() and isinstance(model, PeftModel) and ref_model is None: + # If the model is a PEFT model with a pretrained adapter, we need to create a "ref" adapter that is a copy + # of the "default" adapter, so that we can use it as the reference model during KTO training. + model.add_adapter("ref", model.peft_config["default"]) + for name, param in model.named_parameters(): + if ".default." in name: + ref_name = name.replace(".default.", ".ref.") + ref_param = model.get_parameter(ref_name) + ref_param.data.copy_(param.data) + if is_peft_available() and peft_config is not None: + if getattr(model, "is_loaded_in_8bit", False) or getattr(model, "is_loaded_in_4bit", False): + _support_gc_kwargs = hasattr( + args, "gradient_checkpointing_kwargs" + ) and "gradient_checkpointing_kwargs" in list( + inspect.signature(prepare_model_for_kbit_training).parameters + ) + + prepare_model_kwargs = {"use_gradient_checkpointing": args.gradient_checkpointing} + + if _support_gc_kwargs: + prepare_model_kwargs["gradient_checkpointing_kwargs"] = args.gradient_checkpointing_kwargs + + model = prepare_model_for_kbit_training(model, **prepare_model_kwargs) + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + # get peft model with the given config + model = get_peft_model(model, peft_config) + if args.bf16 and getattr(model, "is_loaded_in_4bit", False): + peft_module_casting_to_bf16(model) + # If args.bf16 we need to explicitly call `generate` with torch amp autocast context manager + self._peft_has_been_casted_to_bf16 = True + + # For models that use gradient_checkpointing, we need to attach a hook that enables input + # to explicitly have `requires_grad=True`, otherwise training will either silently + # fail or completely fail. + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + # KTO only supports causal language models, not encoder-decoder models + if model is not None and hasattr(model.config, "is_encoder_decoder") and model.config.is_encoder_decoder: + raise ValueError( + "KTO only supports causal language models. Encoder-decoder models are not supported. " + "Please use a causal LM (e.g., GPT, Llama, Mistral) instead of an encoder-decoder model (e.g., T5, BART)." + ) + + self.is_peft_model = is_peft_available() and isinstance(model, PeftModel) + + if args.max_length is None: + logger.warning( + "When using DataCollatorForUnpairedPreference, you should set `max_length` in the KTOTrainer's init" + " it will be set to `512` by default, but you should do it yourself in the future.", + ) + max_length = 512 + if args.max_length is not None: + max_length = args.max_length + + if data_collator is None: + data_collator = DataCollatorForUnpairedPreference( + pad_token_id=tokenizer.pad_token_id, + max_length=max_length, + ) + + if args.remove_unused_columns: + args.remove_unused_columns = False + # warn users + logger.warning( + "When using DataCollatorForUnpairedPreference, you should set `remove_unused_columns=False` in your KTOConfig" + " we have set it for you, but you should do it yourself in the future.", + ) + + self.use_dpo_data_collator = True + else: + self.use_dpo_data_collator = False + + self.loss_type = args.loss_type + self.max_length = max_length + self.precompute_ref_log_probs = args.precompute_ref_log_probs + + # Not all losses require a KL calculation + self.calculate_KL = True + if self.loss_type in ["apo_zero_unpaired"]: + self.calculate_KL = False + if self.calculate_KL and args.per_device_train_batch_size <= 1: + raise ValueError( + "Actual (not effective) batch size must be > 1. KTO will not work properly because the KL term will be equivalent to the implied reward." + ) + + # metric + self._stored_metrics = defaultdict(lambda: defaultdict(list)) + + # KTO parameter + self.beta = args.beta + self.desirable_weight = args.desirable_weight + self.undesirable_weight = args.undesirable_weight + self.aux_loss_enabled = getattr(model.config, "output_router_logits", False) + self.aux_loss_coef = getattr(model.config, "router_aux_loss_coef", 0.0) + if self.aux_loss_enabled and self.aux_loss_coef == 0.0: + logger.warning( + "You set `output_router_logits` to `True` in the model config, but `router_aux_loss_coef` is set to " + "`0.0`, meaning the auxiliary loss will not be used. Either set `router_aux_loss_coef` to a value " + "greater than `0.0`, or set `output_router_logits` to `False` if you don't want to use the auxiliary " + "loss.", + ) + + # Dataset + train_dataset = self._prepare_dataset(train_dataset, processing_class, args, "train") + if eval_dataset is not None: + if isinstance(eval_dataset, dict): + eval_dataset = { + key: self._prepare_dataset(dataset, processing_class, args, key) + for key, dataset in eval_dataset.items() + } + else: + eval_dataset = self._prepare_dataset(eval_dataset, processing_class, args, "eval") + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + ) + + # Reference model + if ref_model is None: + if is_peft_model(self.model) or args.precompute_ref_log_probs: + # If PEFT is used, the reference model is not needed since the adapter can be disabled to revert to the + # initial model. If precompute_ref_log_probs is True, the reference model does not need to be kept in + # memory during training. + self.ref_model = None + else: + ref_model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if self.args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + ref_model_init_kwargs["device_map"] = None + ref_model_path = get_config_model_id(self.model.config) + self.ref_model = create_model_from_path(ref_model_path, **ref_model_init_kwargs) + else: + self.ref_model = ref_model + + # Disable dropout in the model and reference model + if args.disable_dropout: + disable_dropout_in_model(model) + if self.ref_model is not None: + disable_dropout_in_model(self.ref_model) + + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + if self.ref_model is not None: + if self.is_deepspeed_enabled: + self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) + elif self.is_fsdp_enabled: + self.ref_model = prepare_fsdp(self.ref_model, self.accelerator) + else: + self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) + + # Import Liger kernel if enabled + if self.args.use_liger_kernel: + if not is_liger_kernel_available(): + raise ImportError( + "You set `use_liger_kernel=True` but the liger kernel is not available. " + "Please install liger-kernel first: `pip install liger-kernel`" + ) + if self.loss_type in ["apo_zero_unpaired"]: + raise ValueError( + "You cannot set `loss_type='apo_zero_unpaired'` with liger-kernel." + "Only KTO loss is supported with liger-kernel." + ) + if self.precompute_ref_log_probs: + raise ValueError( + "You cannot use `precompute_ref_log_probs=True` with liger kernel. Please set " + "`precompute_ref_log_probs=False`." + ) + if self.is_peft_model: + raise ValueError( + "You cannot use `use_liger_kernel=True` with Peft models. Please set `use_liger_kernel=False`." + ) + self.kto_loss_fn = LigerFusedLinearKTOLoss(beta=self.beta, use_ref_model=(self.ref_model is not None)) + + if self.precompute_ref_log_probs: + if isinstance(self.train_dataset, IterableDataset) or isinstance( + self.eval_dataset, (IterableDataset, IterableDatasetDict) + ): + raise ValueError( + "`precompute_ref_log_probs=True` is not supported with IterableDataset. Please use a map-style " + "Dataset or set `precompute_ref_log_probs=False`." + ) + self.train_dataset = self._precompute_ref_logps( + self.train_dataset, + "train", + self.args.precompute_ref_batch_size or self.args.per_device_train_batch_size, + ) + if self.eval_dataset is not None: + if isinstance(self.eval_dataset, dict): + self.eval_dataset = { + name: self._precompute_ref_logps( + dataset, name, self.args.precompute_ref_batch_size or self.args.per_device_eval_batch_size + ) + for name, dataset in self.eval_dataset.items() + } + else: + self.eval_dataset = self._precompute_ref_logps( + self.eval_dataset, + "eval", + self.args.precompute_ref_batch_size or self.args.per_device_eval_batch_size, + ) + + def _tokenize( + self, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + input: str | list, + **kwargs, + ) -> dict[str, list]: + """Tokenize a single example for dataset preprocessing. + + Dispatches to `apply_chat_template` for conversational input (list of message dicts) and to `__call__` for + non-conversational input (str). + + Args: + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`]): + The tokenizer or processor to use. + input (`str` or `list`): + A string for non-conversational input, or a list of message dicts for conversational input. + **kwargs: + Forwarded to `apply_chat_template` (e.g. `add_generation_prompt`, `return_assistant_tokens_mask`). + + Returns: + `dict` with at least an `"input_ids"` key mapping to a flat `list[int]`. + """ + if isinstance(input, list): # conversational: list of message dicts + result = processing_class.apply_chat_template(input, tokenize=True, return_dict=True, **kwargs) + else: # non-conversational: plain text string + result = processing_class(text=input) + return result + + def _prepare_dataset( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + args: KTOConfig | None, + dataset_name: str, + ) -> Dataset | IterableDataset: + # Build the kwargs for the `map` function + map_kwargs = {} + if isinstance(dataset, Dataset): # IterableDataset does not support num_proc + map_kwargs["num_proc"] = args.dataset_num_proc + + # Compute that only on the main process for faster data processing. + # see: https://github.com/huggingface/trl/pull/1255 + with PartialState().main_process_first(): + # Extract the prompt if needed + first_example = next(iter(dataset)) + if "prompt" not in first_example: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Extracting prompt from {dataset_name} dataset" + dataset = dataset.map(extract_prompt, **map_kwargs) + + # Unpair the dataset if needed + first_example = next(iter(dataset)) + if "chosen" in first_example and "rejected" in first_example: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Unpairing {dataset_name} dataset" + dataset = unpair_preference_dataset(dataset, **map_kwargs) + + tokenizer = getattr(processing_class, "tokenizer", processing_class) + + # Add EOS token if needed: non-conversational only + first_example = next(iter(dataset)) + if not is_conversational(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Adding EOS to {dataset_name} dataset" + + def add_eos(example, eos_token): + if not example["completion"].endswith(eos_token): + example["completion"] = example["completion"] + eos_token + return example + + dataset = dataset.map(add_eos, fn_kwargs={"eos_token": tokenizer.eos_token}, **map_kwargs) + + # Tokenize dataset + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Tokenizing {dataset_name} dataset" + + def tokenize_fn(example, processing_class): + if is_conversational(example): + chat_template_kwargs = example.get("chat_template_kwargs", {}) + prompt_ids = self._tokenize( + processing_class, + example["prompt"], + add_generation_prompt=True, + **chat_template_kwargs, + )["input_ids"] + prompt_completion_ids = self._tokenize( + processing_class, + example["prompt"] + example["completion"], + **chat_template_kwargs, + )["input_ids"] + else: + prompt_ids = self._tokenize(processing_class, example["prompt"])["input_ids"] + prompt_completion_ids = self._tokenize( + processing_class, example["prompt"] + example["completion"] + )["input_ids"] + + if not prompt_completion_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+completion. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + + return { + "prompt_ids": prompt_ids, + "completion_ids": prompt_completion_ids[len(prompt_ids) :], + } + + dataset = dataset.map(tokenize_fn, fn_kwargs={"processing_class": processing_class}, **map_kwargs) + + # Get KL datasets if needed + if self.calculate_KL: + + def rename_kl_fn(example): + return {"KL_completion_ids": example["completion_ids"]} + + # create pairs for estimating the KL term by flipping the matched pairs in each batch of size total_batch_size + # i.e., (x_1, y_1), ..., (x_n, y_n) --> (x_1, y_n), ..., (x_n, y_1) = (x'_1, y'_1), ..., (x'_n, y'_n) + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Extracting KL {dataset_name} dataset" + kl_dataset = dataset.map( + _get_kl_dataset, batched=True, batch_size=args.per_device_train_batch_size, **map_kwargs + ) + + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Assembling KL {dataset_name} dataset" + column_names = get_dataset_column_names(dataset) + kl_dataset = kl_dataset.map( + rename_kl_fn, + remove_columns=[c for c in get_dataset_column_names(kl_dataset) if c in column_names], + **map_kwargs, + ) + + # merge the datasets + dataset = concatenate_datasets([dataset, kl_dataset], axis=1) + + # Calculate dataset desirability balance + if dataset_name == "train" and isinstance(dataset, Dataset): # IterableDataset does not support len + num_desirable = max(sum(dataset["label"]), 1) + num_undesirable = max(len(dataset["label"]) - num_desirable, 1) # "label" is binary + + if num_desirable != num_undesirable: + # The lower and upper bounds come from Eq. (8) of https://huggingface.co/papers/2402.01306 + des_weight_lower_bound = round((num_undesirable * self.undesirable_weight / num_desirable) * 1, 2) + des_weight_upper_bound = round( + (num_undesirable * self.undesirable_weight / num_desirable) * 1.33, 2 + ) + und_weight_lower_bound = round((num_desirable * self.desirable_weight / num_undesirable) / 1.33, 2) + und_weight_upper_bound = round((num_desirable * self.desirable_weight / num_undesirable) / 1, 2) + + des_weight_in_range = des_weight_lower_bound <= self.desirable_weight <= des_weight_upper_bound + und_weight_in_range = und_weight_lower_bound <= self.undesirable_weight <= und_weight_upper_bound + + if not (des_weight_in_range or und_weight_in_range): + logger.warning( + "You have different amounts of desirable/positive and undesirable/negative examples but the " + "weights on the desirable and undesirable losses don't seem to be in an ideal range. Based " + f"on your data, we recommend EITHER " + f"desirable_weight in [{des_weight_lower_bound}, {des_weight_upper_bound}] or " + f"undesirable_weight in [{und_weight_lower_bound}, {und_weight_upper_bound}] (but NOT BOTH). " + "See the documentation on how to optimally set these weights.", + ) + return dataset + + @contextmanager + def null_ref_context(self): + """Context manager for handling null reference model (that is, peft adapter manipulation).""" + if self.is_peft_model: + model = self.accelerator.unwrap_model(self.model) + with use_adapter(model, adapter_name="ref" if "ref" in model.peft_config else None): + yield + else: + yield + + def _precompute_ref_logps(self, dataset: Dataset, name: str, batch_size: int) -> Dataset: + dataloader_params = { + "batch_size": batch_size, + "collate_fn": self.data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "shuffle": False, + } + data_loader = self.accelerator.prepare(DataLoader(dataset, **dataloader_params)) + reference_completion_logps = [] + reference_KL_logps = [] + for padded_batch in tqdm(iterable=data_loader, desc=f"Computing reference log probs for {name} dataset"): + reference_completion_logp, reference_KL_logp = self.compute_reference_log_probs(padded_batch) + reference_completion_logp = self.accelerator.gather_for_metrics(reference_completion_logp) + reference_completion_logps.append(reference_completion_logp.cpu()) + if self.calculate_KL: + reference_KL_logp = self.accelerator.gather_for_metrics(reference_KL_logp) + reference_KL_logps.append(reference_KL_logp.cpu()) + dataset = dataset.add_column( + name="reference_logps", column=torch.cat(reference_completion_logps).float().numpy() + ) + if self.calculate_KL: + dataset = dataset.add_column( + name="reference_KL_logps", column=torch.cat(reference_KL_logps).float().numpy() + ) + return dataset + + def compute_reference_log_probs(self, padded_batch: dict) -> dict: + """Computes log probabilities of the reference model for a single padded batch of a KTO specific dataset.""" + with torch.no_grad(): + if self.ref_model is None: + with self.null_ref_context(): + completion_logits = self.model( + padded_batch["completion_input_ids"], + attention_mask=padded_batch["completion_attention_mask"], + ).logits + + if self.calculate_KL: + KL_logits = self.model( + padded_batch["KL_completion_input_ids"], + attention_mask=padded_batch["KL_completion_attention_mask"], + ).logits + else: + completion_logits = self.ref_model( + padded_batch["completion_input_ids"], attention_mask=padded_batch["completion_attention_mask"] + ).logits + + if self.calculate_KL: + KL_logits = self.ref_model( + padded_batch["KL_completion_input_ids"], + attention_mask=padded_batch["KL_completion_attention_mask"], + ).logits + + completion_logps = self.get_batch_logps( + completion_logits, + padded_batch["completion_labels"], + average_log_prob=False, + ) + + if self.calculate_KL: + KL_logps = self.get_batch_logps( + KL_logits, + padded_batch["KL_completion_labels"], + average_log_prob=False, + ) + else: + KL_logps = None + + return completion_logps, KL_logps + + @staticmethod + def get_batch_logps( + logits: torch.FloatTensor, + labels: torch.LongTensor, + average_log_prob: bool = False, + ) -> torch.FloatTensor: + """Compute the log probabilities of the given labels under the given logits. + + Args: + logits: + Logits of the model (unnormalized). Shape: (batch_size, sequence_length, vocab_size) + labels: + Labels for which to compute the log probabilities. Label tokens with a value of `-100` are ignored. + Shape: (batch_size, sequence_length) + average_log_prob: + If True, return the average log probability per (non-masked) token. Otherwise, return the sum of the + log probabilities of the (non-masked) tokens. + + Returns: + A tensor of shape (batch_size,) containing the average/sum log probabilities of the given labels under the + given logits. + """ + if logits.shape[:-1] != labels.shape: + raise ValueError("Logits (batch and sequence length dim) and labels must have the same shape.") + + # For causal LM, shift labels and logits by one position + labels = labels[:, 1:].clone() + logits = logits[:, :-1, :] + + loss_mask = labels != -100 + + # dummy token; we'll ignore the losses on these tokens later + labels[labels == -100] = 0 + + per_token_logps = selective_log_softmax(logits, labels) + + if average_log_prob: + return (per_token_logps * loss_mask).sum(-1) / loss_mask.sum(-1) + else: + return (per_token_logps * loss_mask).sum(-1) + + def forward( + self, model: nn.Module, batch: dict[str, list | torch.LongTensor] + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + KL_logps = self._compute_kl_logps(model, batch) + + model_kwargs = {} + if self.aux_loss_enabled: + model_kwargs["output_router_logits"] = True + + outputs = model( + batch["completion_input_ids"], + attention_mask=batch["completion_attention_mask"], + **model_kwargs, + ) + completion_logits = outputs.logits + + completion_logps = self.get_batch_logps( + completion_logits, + batch["completion_labels"], + average_log_prob=False, + ) + + if completion_logps.shape[0] != len(batch["label"]): + raise ValueError( + "There is a mismatch between the number of examples in this batch and the number of " + "examples for which an output sequence was predicted." + ) + + # Use torch.nonzero for efficient tensor index selection + device = completion_logits.device + labels = torch.as_tensor(batch["label"], dtype=torch.bool, device=device) + chosen_idx = torch.nonzero(labels, as_tuple=False).view(-1) + rejected_idx = torch.nonzero(~labels, as_tuple=False).view(-1) + + # Use index_select for efficient CUDA operations + chosen_logps = completion_logps.index_select(0, chosen_idx) + rejected_logps = completion_logps.index_select(0, rejected_idx) + + chosen_logits = completion_logits.index_select(0, chosen_idx) + rejected_logits = completion_logits.index_select(0, rejected_idx) + + if self.aux_loss_enabled: + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, KL_logps, outputs.aux_loss) + else: + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, KL_logps) + + def kto_loss( + self, + policy_chosen_logps: torch.FloatTensor, + policy_rejected_logps: torch.FloatTensor, + policy_KL_logps: torch.FloatTensor, + reference_chosen_logps: torch.FloatTensor, + reference_rejected_logps: torch.FloatTensor, + reference_KL_logps: torch.FloatTensor, + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + """Compute the KTO loss for a batch of policy and reference model log probabilities. + + Args: + policy_chosen_logps: + Log probabilities of the policy model for the chosen responses. Shape: (num(chosen) in batch_size,) + policy_rejected_logps: + Log probabilities of the policy model for the rejected responses. Shape: (num(rejected) in batch_size,) + policy_KL_logps: Log probabilities of the policy model for the KL responses. Shape: (batch_size,) + reference_chosen_logps: + Log probabilities of the reference model for the chosen responses. Shape: (num(chosen) in batch_size,) + reference_rejected_logps: + Log probabilities of the reference model for the rejected responses. Shape: (num(rejected) in + batch_size,) + reference_KL_logps: Log probabilities of the reference model for the KL responses. Shape: (batch_size,) + + Returns: + A tuple of four tensors: (losses, chosen_rewards, rejected_rewards, KL). The losses tensor contains the KTO + loss for each example in the batch. The chosen_rewards and rejected_rewards tensors contain the rewards for + the chosen and rejected responses, respectively. The KL tensor contains the detached KL divergence estimate + between the policy and reference models. + """ + if self.calculate_KL: + kl = (policy_KL_logps - reference_KL_logps).mean().detach() + kl = self.accelerator.gather_for_metrics(kl).mean().clamp(min=0) + else: + kl = torch.zeros(1).to(policy_chosen_logps.device) + + # Chosen losses + if policy_chosen_logps.shape[0] != 0 or reference_chosen_logps.shape[0] != 0: + chosen_logratios = policy_chosen_logps - reference_chosen_logps + + if self.loss_type == "kto": + # Eqn (7) of the KTO paper (https://huggingface.co/papers/2402.01306) + chosen_losses = 1 - F.sigmoid(self.beta * (chosen_logratios - kl)) + elif self.loss_type == "apo_zero_unpaired": + # Unpaired variant of Eqn (7) of the APO paper (https://huggingface.co/papers/2408.06266) + # Use this loss when you believe the chosen outputs are better than your model's default output + chosen_losses = 1 - F.sigmoid(self.beta * chosen_logratios) + + chosen_rewards = self.beta * chosen_logratios.detach() + + else: + # lists can't be empty -- if they are, then accelerate.gather will hang + chosen_losses = torch.Tensor([]).to(self.accelerator.device) + chosen_rewards = torch.Tensor([]).to(self.accelerator.device) + + # Rejected losses + if policy_rejected_logps.shape[0] != 0 or reference_rejected_logps.shape[0] != 0: + rejected_logratios = policy_rejected_logps - reference_rejected_logps + + if self.loss_type == "kto": + rejected_losses = 1 - F.sigmoid(self.beta * (kl - rejected_logratios)) + elif self.loss_type == "apo_zero_unpaired": + rejected_losses = F.sigmoid(self.beta * rejected_logratios) + + rejected_rewards = self.beta * rejected_logratios.detach() + else: + # lists can't be empty -- if they are, then accelerate.gather will hang + rejected_losses = torch.Tensor([]).to(self.accelerator.device) + rejected_rewards = torch.Tensor([]).to(self.accelerator.device) + + losses = torch.cat( + (self.desirable_weight * chosen_losses, self.undesirable_weight * rejected_losses), + 0, + ) + + return losses, chosen_rewards, rejected_rewards, kl + + def _compute_kl_logps(self, model, batch): + """Compute KL log probabilities for a given batch.""" + KL_logps = None + if self.calculate_KL: + KL_model_kwargs = { + "input_ids": batch["KL_completion_input_ids"], + "attention_mask": batch["KL_completion_attention_mask"], + } + + with torch.no_grad(): + KL_logits = model(**KL_model_kwargs).logits + + KL_logps = self.get_batch_logps( + KL_logits, + batch["KL_completion_labels"], + average_log_prob=False, + ) + return KL_logps + + def _compute_loss_liger(self, model, batch): + """ + Compute the KTO loss using the Liger-Kernel's LigerFusedLinearKTOLoss. + + Args: + model: + The policy model used for generating log probabilities and outputs. It could be an encoder-decoder + model or a regular language model. + batch: A dictionary containing the input data and labels for the batch. + + Returns: + A dictionary containing the following keys: + - "loss": The computed KTO loss for the batch. + - "chosen_logits_sum": Sum of the logits for the chosen responses from the policy model. + - "rejected_logits_sum": Sum of the logits for the rejected responses from the policy model. + - "chosen_logps": Log probabilities of the chosen responses from the policy model. + - "rejected_logps": Log probabilities of the rejected responses from the policy model. + - "chosen_rewards": Rewards for the chosen responses. + - "rejected_rewards": Rewards for the rejected responses. + - "kl": The KL divergence between the policy and reference models (detached). + + If auxiliary loss is enabled, the dictionary will also include: + - "aux_loss": The auxiliary loss from the model outputs. + """ + policy_KL_logps = self._compute_kl_logps(model, batch) + reference_KL_logps = self._compute_kl_logps(self.ref_model, batch) + if self.calculate_KL: + kl = (policy_KL_logps - reference_KL_logps).mean().detach() + kl = self.accelerator.gather_for_metrics(kl).mean().clamp(min=0) + else: + kl = torch.zeros(1).to(self.accelerator.device) + + model_kwargs = {} + if self.aux_loss_enabled: + model_kwargs["output_router_logits"] = True + + # skip the lm head and get the last hidden state + base_model = model.get_decoder() + outputs = base_model( + batch["completion_input_ids"], + attention_mask=batch["completion_attention_mask"], + use_cache=False, + **model_kwargs, + ) + + # reference model + ref_base_model = self.ref_model.get_decoder() + ref_outputs = ref_base_model( + batch["completion_input_ids"], + attention_mask=batch["completion_attention_mask"], + use_cache=False, + **model_kwargs, + ) + lm_head = model.get_output_embeddings() + ref_lm_head = self.ref_model.get_output_embeddings() + + ( + loss, + ( + chosen_logps_sum, + rejected_logps_sum, + chosen_logits_sum, + rejected_logits_sum, + chosen_rewards_sum, + rejected_rewards_sum, + ), + ) = self.kto_loss_fn( + _input=outputs.last_hidden_state[:, :-1], + lin_weight=lm_head.weight, + target=batch["completion_labels"][:, 1:], + bias=lm_head.bias if hasattr(lm_head, "bias") else None, + preference_labels=torch.tensor(batch["label"], dtype=torch.bool).to(self.accelerator.device), + ref_input=ref_outputs.last_hidden_state[:, :-1], + ref_weight=ref_lm_head.weight, + ref_bias=ref_lm_head.bias if hasattr(lm_head, "bias") else None, + kl=kl, + ) + + output = { + "loss": loss, + "chosen_logits_sum": chosen_logits_sum, + "rejected_logits_sum": rejected_logits_sum, + "chosen_logps_sum": chosen_logps_sum, + "rejected_logps_sum": rejected_logps_sum, + "chosen_rewards_sum": chosen_rewards_sum, + "rejected_rewards_sum": rejected_rewards_sum, + "kl": kl, + } + if self.aux_loss_enabled: + output["aux_loss"] = outputs.aux_loss + + return output + + def get_batch_loss_metrics( + self, + model, + batch: dict[str, list | torch.LongTensor], + ): + """Compute the KTO loss and other metrics for the given batch of inputs for train or test.""" + metrics = {} + batch = {k: (v.to(self.accelerator.device) if isinstance(v, torch.Tensor) else v) for k, v in batch.items()} + + labels = torch.tensor(batch["label"]) + num_chosen = labels.sum().to(self.accelerator.device) + num_rejected = (len(labels) - num_chosen).to(self.accelerator.device) + + if self.args.use_liger_kernel: + model_output = self._compute_loss_liger(model, batch) + losses = model_output["loss"] + policy_chosen_logits = model_output["chosen_logits_sum"] + policy_rejected_logits = model_output["rejected_logits_sum"] + policy_chosen_logps = model_output["chosen_logps_sum"] + policy_rejected_logps = model_output["rejected_logps_sum"] + chosen_rewards = model_output["chosen_rewards_sum"] + rejected_rewards = model_output["rejected_rewards_sum"] + kl = model_output["kl"] + if self.aux_loss_enabled: + aux_loss = model_output["aux_loss"] + else: + forward_output = self.forward(model, batch) + ( + policy_chosen_logps, + policy_rejected_logps, + policy_chosen_logits, + policy_rejected_logits, + policy_KL_logps, + ) = forward_output[:5] + if self.aux_loss_enabled: + aux_loss = forward_output[5] + + # if reference_logps in batch use them, otherwise use the reference model + if "reference_logps" in batch: + # Convert Python lists to tensor indices for efficient CUDA operations + device = batch["reference_logps"].device + labels = torch.as_tensor(batch["label"], dtype=torch.bool, device=device) + chosen_idx = torch.nonzero(labels, as_tuple=False).view(-1) + rejected_idx = torch.nonzero(~labels, as_tuple=False).view(-1) + + # Use index_select for efficient CUDA operations + reference_chosen_logps = batch["reference_logps"].index_select(0, chosen_idx) + reference_rejected_logps = batch["reference_logps"].index_select(0, rejected_idx) + if self.calculate_KL: + reference_KL_logps = batch["reference_KL_logps"] + else: + reference_KL_logps = None + else: + with torch.no_grad(): + if self.ref_model is None: + with self.null_ref_context(): + ( + reference_chosen_logps, + reference_rejected_logps, + _, + _, + reference_KL_logps, + ) = self.forward(self.model, batch)[:5] + else: + ( + reference_chosen_logps, + reference_rejected_logps, + _, + _, + reference_KL_logps, + ) = self.forward(self.ref_model, batch)[:5] + + losses, chosen_rewards, rejected_rewards, kl = self.kto_loss( + policy_chosen_logps, + policy_rejected_logps, + policy_KL_logps, + reference_chosen_logps, + reference_rejected_logps, + reference_KL_logps, + ) + + metrics["kl"] = kl.item() + + all_num_chosen = self.accelerator.gather_for_metrics(num_chosen).sum().item() + all_num_rejected = self.accelerator.gather_for_metrics(num_rejected).sum().item() + + if all_num_chosen > 0: + metrics["rewards/chosen_sum"] = ( + self.accelerator.gather_for_metrics(chosen_rewards.nansum()).nansum().item() + ) + metrics["logps/chosen_sum"] = ( + self.accelerator.gather_for_metrics(policy_chosen_logps.nansum()).nansum().item() + ) + metrics["logits/chosen_sum"] = ( + self.accelerator.gather_for_metrics(policy_chosen_logits.nansum()).nansum().item() + ) + metrics["count/chosen"] = all_num_chosen + + if all_num_rejected > 0: + metrics["rewards/rejected_sum"] = ( + self.accelerator.gather_for_metrics(rejected_rewards.nansum()).nansum().item() + ) + metrics["logps/rejected_sum"] = ( + self.accelerator.gather_for_metrics(policy_rejected_logps.nansum()).nansum().item() + ) + metrics["logits/rejected_sum"] = ( + self.accelerator.gather_for_metrics(policy_rejected_logits.nansum()).nansum().item() + ) + metrics["count/rejected"] = all_num_rejected + + loss = losses.nanmean() + if self.aux_loss_enabled: + loss += self.aux_loss_coef * aux_loss + + return loss, metrics + + def compute_loss( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + return_outputs=False, + num_items_in_batch=None, + ) -> torch.Tensor | tuple[torch.Tensor, dict[str, torch.Tensor]]: + compute_loss_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with compute_loss_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs) + + # Make sure to move the loss to the device the original accumulating loss is at back in the `Trainer` class: + loss = loss.to(self.args.device) + # force log the metrics + if self.accelerator.is_main_process: + self.store_metrics(metrics, train_eval="train") + + if return_outputs: + return (loss, metrics) + return loss + + def store_metrics(self, metrics: dict[str, float], train_eval: Literal["train", "eval"] = "train") -> None: + for key, value in metrics.items(): + self._stored_metrics[train_eval][key].append(value) + + def _get_train_sampler(self, dataset: Dataset | None = None) -> torch.utils.data.Sampler | None: + if dataset is None: + dataset = self.train_dataset + if dataset is None or not has_length(dataset): + return None + return SequentialSampler(dataset) + + def prediction_step( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + prediction_loss_only: bool, + ignore_keys: list[str] | None = None, + ): + if ignore_keys is None: + if hasattr(model, "config"): + ignore_keys = getattr(model.config, "keys_to_ignore_at_inference", []) + else: + ignore_keys = [] + + prediction_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + with torch.no_grad(), prediction_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs) + + # force log the metrics + if self.accelerator.is_main_process: + self.store_metrics(metrics, train_eval="eval") + + if prediction_loss_only: + return (loss.detach(), None, None) + + # logits for the chosen and rejected samples from model + logits_dict = {} + if "logits/chosen_sum" in metrics: + logits_dict["eval_logits/chosen"] = metrics["logits/chosen_sum"] + if "logits/rejected_sum" in metrics: + logits_dict["eval_logits/rejected"] = metrics["logits/rejected_sum"] + logits = [v for k, v in logits_dict.items() if k not in ignore_keys] + logits = torch.tensor(logits, device=self.accelerator.device) + labels = torch.zeros(logits.shape[0], device=self.accelerator.device) + + return (loss.detach(), logits, labels) + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + """ + Log `logs` on the various objects watching training, including stored metrics. + + Args: + logs (`dict[str, float]`): + The values to log. + start_time (`float`, *optional*): + Start time of the training. + """ + # logs either has 'loss' or 'eval_loss' + train_eval = "train" if "loss" in logs else "eval" + # train metrics should have no prefix, eval should have 'eval_' + prefix = "eval_" if train_eval == "eval" else "" + # accumulate average metrics from sums and lengths + for split in ["chosen", "rejected"]: + if f"count/{split}" in self._stored_metrics[train_eval]: + count_sum = torch.Tensor(self._stored_metrics[train_eval][f"count/{split}"]).sum().item() + for metric in ["rewards", "logps", "logits"]: + logs[f"{prefix}{metric}/{split}"] = ( + torch.Tensor(self._stored_metrics[train_eval][f"{metric}/{split}_sum"]).sum().item() + / count_sum + ) + # delete obsolete metric + del self._stored_metrics[train_eval][f"{metric}/{split}_sum"] + del self._stored_metrics[train_eval][f"count/{split}"] + # calculate reward margin + if f"{prefix}rewards/chosen" in logs and f"{prefix}rewards/rejected" in logs: + logs[f"{prefix}rewards/margins"] = logs[f"{prefix}rewards/chosen"] - logs[f"{prefix}rewards/rejected"] + # Add averaged stored metrics to logs + for key, metrics in self._stored_metrics[train_eval].items(): + logs[f"{prefix}{key}"] = torch.Tensor(metrics).mean().item() + del self._stored_metrics[train_eval] + return super().log(logs, start_time) + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/merge_model_callback.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/merge_model_callback.py new file mode 100644 index 0000000000000000000000000000000000000000..2f8478759204105aa02eea715b884c755bfc9757 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/merge_model_callback.py @@ -0,0 +1,352 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import os + +import torch +from huggingface_hub import HfApi +from transformers import TrainerCallback + +from ..import_utils import is_mergekit_available +from ..trainer.utils import get_config_model_id + + +if is_mergekit_available(): + from mergekit.config import MergeConfiguration + from mergekit.merge import MergeOptions, run_merge + + +# Logger for module-level logging +logger = logging.getLogger(__name__) + + +def upload_model_to_hf(folder_path: str, repo_id: str): + api = HfApi() + # Create the repository if it doesn't exist + repo = api.create_repo(repo_id, repo_type="model") + + # Upload the folder to the specified repository + api.upload_folder( + folder_path=folder_path, + repo_id=repo.repo_id, + repo_type=repo.repo_type, + ) + + +class MergeConfig: + r""" + Configuration class for merging two models using `mergekit`. + + This class provides a structured way to configure and generate merge configurations for various merge methods, such + as `linear`, `ties`, `dare_ties`, and `slerp`. + + Args: + method (`str`, *optional*, defaults to `"linear"`): + Merge method to use. Supported methods include: + + - `"linear"`: Linearly combines two models with specified weights. + - `"ties"`: Combines two models using the TIES method with density parameters. + - `"dare_ties"`: A variant of TIES for domain adaptation. + - `"slerp"`: Combines models using spherical linear interpolation. + + Note: + + For more details about the merge methods and how they are implemented, see the [MergeKit GitHub + repository](https://github.com/arcee-ai/mergekit?tab=readme-ov-file#merge-methods). + + Attributes: + method (`str`): The merge method to use. + policy_model_path (`str` or `None`): Path to the policy model. + target_model_path (`str` or `None`): Path to the target model. + policy_model_weight (`float`): Weight for the policy model (for `linear` and `ties` methods). + target_model_weight (`float`): Weight for the target model (for `linear` and `ties` methods). + policy_model_density (`list[float]`): Density parameters for the policy model (for `ties` and `dare_ties`). + target_model_density (`list[float]`): Density parameters for the target model (for `ties` and `dare_ties`). + normalize (`float` or `None`): Normalization factor for the TIES method. + t_values (`float` or `None`): Interpolation factor for the SLERP method. + dtype (`str`): Data type to use for merging, e.g., `"float16"`. + """ + + def __init__(self, method: str = "linear"): + if not is_mergekit_available(): + raise ImportError("MergeConfig requires the `mergekit` extra. To install, run `pip install mergekit`.") + self.method = method + self.policy_model_path = None + self.target_model_path = None + + # Initialize relevant parameters based on the method + if method == "linear": + self.policy_model_weight = 0.5 + self.target_model_weight = 0.5 + self.dtype = "float16" + elif method == "ties": + self.policy_model_weight = 1.0 + self.policy_model_density = [1.0, 0.7, 0.1] + self.target_model_weight = 1.0 + self.target_model_density = [1.0] + self.normalize = 1.0 + self.dtype = "float16" + elif method == "dare_ties": + self.policy_model_weight = 1.0 + self.policy_model_density = [1.0, 0.7, 0.1] + self.target_model_weight = 1.0 + self.target_model_density = [1.0] + self.normalize = 1.0 + self.dtype = "float16" + elif method == "slerp": + self.t_values = 0.5 + self.dtype = "float16" + else: + raise ValueError(f"Unsupported merge method: {method}") + + def create_merge_config_linear(self) -> "MergeConfiguration": + """ + Creates a merge configuration for a linear merge of two models with specified weights. + """ + # Create the merge configuration dictionary + merge_config_dict = { + "dtype": self.dtype, + "merge_method": "linear", + "models": [ + {"model": self.policy_model_path, "parameters": {"weight": self.policy_model_weight}}, + {"model": self.target_model_path, "parameters": {"weight": self.target_model_weight}}, + ], + } + + # Create the MergeConfiguration from the dictionary + merge_config = MergeConfiguration.model_validate(merge_config_dict) + + return merge_config + + def create_merge_config_ties(self) -> "MergeConfiguration": + """ + Creates a merge configuration for a TIES merge of two models, with specified weights and densities. + """ + # Create the TIES merge configuration dictionary + merge_config_dict = { + "merge_method": "ties", + "slices": None, # Optional slices if needed + "models": [ + { + "model": { + "model": {"path": self.target_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "parameters": {"density": self.target_model_density, "weight": self.target_model_weight}, + }, + { + "model": { + "model": {"path": self.policy_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "parameters": {"density": self.policy_model_density, "weight": self.policy_model_weight}, + }, + ], + "parameters": {"normalize": self.normalize}, + "base_model": { + "model": {"path": self.policy_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "dtype": self.dtype, + "tokenizer_source": None, + "tokenizer": None, + "chat_template": None, + "out_dtype": None, + } + + # Create the MergeConfiguration from the dictionary + merge_config = MergeConfiguration.model_validate(merge_config_dict) + + return merge_config + + def create_merge_config_dare_ties(self) -> "MergeConfiguration": + """ + Creates a merge configuration for a DARE TIES merge of two models, with specified weights and densities. + """ + # Create the DARE TIES merge configuration dictionary + merge_config_dict = { + "merge_method": "dare_ties", + "slices": None, # Optional slices if needed + "models": [ + { + "model": { + "model": {"path": self.target_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "parameters": {"density": self.target_model_density, "weight": self.target_model_weight}, + }, + { + "model": { + "model": {"path": self.policy_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "parameters": {"density": self.policy_model_density, "weight": self.policy_model_weight}, + }, + ], + "parameters": {"normalize": self.normalize}, + "base_model": { + "model": {"path": self.policy_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "dtype": self.dtype, + "tokenizer_source": None, + "tokenizer": None, + "chat_template": None, + "out_dtype": None, + } + + # Create the MergeConfiguration from the dictionary + merge_config = MergeConfiguration.model_validate(merge_config_dict) + + return merge_config + + def create_merge_config_slerp(self) -> "MergeConfiguration": + """ + Creates a merge configuration for a SLERP merge of a model with a base model. + """ + + # Create the SLERP merge configuration dictionary + merge_config_dict = { + "merge_method": "slerp", + "slices": None, # Optional slices if needed + "models": [ + { + "model": { + "model": {"path": self.target_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "parameters": None, # No specific parameters for SLERP model + } + ], + "parameters": { + "t": self.t_values # Set the t values for SLERP + }, + "base_model": { + "model": {"path": self.policy_model_path, "revision": None}, + "lora": None, + "override_architecture": None, + }, + "dtype": self.dtype, + "tokenizer_source": None, + "tokenizer": None, + "chat_template": None, + "out_dtype": None, + } + + # Create the MergeConfiguration from the dictionary + merge_config = MergeConfiguration.model_validate(merge_config_dict) + + return merge_config + + def create(self) -> "MergeConfiguration": + if self.method == "linear": + return self.create_merge_config_linear() + elif self.method == "ties": + return self.create_merge_config_ties() + elif self.method == "dare_ties": + return self.create_merge_config_dare_ties() + elif self.method == "slerp": + return self.create_merge_config_slerp() + + +def merge_models(config: "MergeConfiguration", out_path: str): + """ + Merge two models using mergekit + + Args: + config (`MergeConfiguration`): The merge configuration. + out_path (`str`): The output path for the merged model. + """ + if not is_mergekit_available(): + raise ImportError("merge_models requires the `mergekit` extra. To install, run `pip install mergekit`.") + run_merge( + config, + out_path=out_path, + options=MergeOptions( + device="auto", + cuda=torch.cuda.is_available(), + copy_tokenizer=True, + lazy_unpickle=False, + low_cpu_memory=False, + ), + ) + + +class MergeModelCallback(TrainerCallback): + r""" + A [`~transformers.TrainerCallback`] that merges the policy model (the model being trained) with another model based + on a merge configuration. + + Args: + merge_config ([`experimental.merge_model_callback.MergeConfig`], *optional*): + Configuration used for the merging process. If not provided, the default + [`~experimental.merge_model_callback.MergeConfig`] is used. + merge_at_every_checkpoint (`bool`, *optional*, defaults to `False`): + Whether to merge the model at every checkpoint. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the merged model to the Hub after merging. + + Example: + + ```python + from trl.experimental.merge_model_callback import MergeConfig, MergeModelCallback + + config = MergeConfig() + merge_callback = MergeModelCallback(config) + trainer = DPOTrainer(..., callbacks=[merge_callback]) + ``` + """ + + def __init__( + self, + merge_config: "MergeConfig | None" = None, + merge_at_every_checkpoint: bool = False, + push_to_hub: bool = False, + ): + if not is_mergekit_available(): + raise ImportError( + "MergeModelCallback requires the `mergekit` extra. To install, run `pip install mergekit`." + ) + self.merge_config = merge_config or MergeConfig() + self.merge_at_every_checkpoint = merge_at_every_checkpoint + self.push_to_hub = push_to_hub + + def _merge_and_maybe_push(self, output_dir, global_step, model): + checkpoint_path = os.path.join(output_dir, f"checkpoint-{global_step}") + self.merge_config.policy_model_path = checkpoint_path + if self.merge_config.target_model_path is None: + self.merge_config.target_model_path = get_config_model_id(model.config) + merge_path = os.path.join(checkpoint_path, "merged") + + merge_models(self.merge_config.create(), merge_path) + + if self.push_to_hub: + repo_name = f"{output_dir}_checkpoint-{global_step}_merged" + upload_model_to_hf(merge_path, repo_name) + + def on_save(self, args, state, control, model=None, **kwargs): + if self.merge_at_every_checkpoint: + self._merge_and_maybe_push(args.output_dir, state.global_step, model) + + def on_train_end(self, args, state, control, model=None, **kwargs): + if not self.merge_at_every_checkpoint: + self._merge_and_maybe_push(args.output_dir, state.global_step, model) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..07bc38f0ef9973010a3eed3c9adf4ef5137ec6b1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .minillm_config import MiniLLMConfig +from .minillm_trainer import MiniLLMTrainer + + +__all__ = ["MiniLLMConfig", "MiniLLMTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/minillm_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/minillm_config.py new file mode 100644 index 0000000000000000000000000000000000000000..678868aabb8aa78a50eb53282ca390364674b82d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/minillm_config.py @@ -0,0 +1,137 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig +from ...trainer.grpo_config import GRPOConfig + + +@dataclass +class MiniLLMConfig(GRPOConfig): + """ + Configuration class for [`MiniLLMTrainer`]. + + This class includes only the parameters that are specific to MiniLLM training. For a full list of training + arguments, please refer to the [`~transformers.TrainingArguments`] and [`GRPOConfig`] documentation. + + Args: + teacher_model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the teacher model + from a string. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + rkl_advantage (`bool`, *optional*, defaults to `True`): + Whether to add the reverse KL advantage to the reward advantage. + single_step_decomposition (`bool`, *optional*, defaults to `True`): + Whether to use single-step decomposition for the KL divergence computation. + kd_temperature (`float`, *optional*, defaults to `1.0`): + Temperature for knowledge distillation. Higher temperatures produce softer probability distributions over + classes. + gamma (`float`, *optional*, defaults to `0.0`): + Discount factor for future rewards in reinforcement learning. + length_normalization (`bool`, *optional*, defaults to `True`): + Whether to apply length normalization to the rewards. + """ + + _VALID_DICT_FIELDS = GRPOConfig._VALID_DICT_FIELDS + ["teacher_model_init_kwargs"] + + teacher_model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the " + "teacher model from a string." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropouts in `model`."}, + ) + rkl_advantage: bool = field( + default=True, + metadata={"help": "Whether to add the reverse KL advantage to the reward advantage."}, + ) + single_step_decomposition: bool = field( + default=True, + metadata={"help": "Whether to use single-step decomposition for the KL divergence computation."}, + ) + kd_temperature: float = field( + default=1.0, + metadata={ + "help": "Temperature for knowledge distillation. Higher temperatures produce softer probability " + "distributions over classes." + }, + ) + gamma: float = field( + default=0.0, + metadata={"help": "Discount factor for future rewards in reinforcement learning."}, + ) + length_normalization: bool = field( + default=True, + metadata={"help": "Whether to apply length normalization to the rewards."}, + ) + + def __post_init__(self): + # We do not use the post_init of GRPOConfig because: + # 1. num_generations can be < 2 in MiniLLMConfig. Scale_rewards must be set to "none" to avoid nan. + _BaseConfig.__post_init__(self) + + self.scale_rewards = {True: "group", False: "none"}.get(self.scale_rewards, self.scale_rewards) + if self.num_generations == 1: + self.scale_rewards = "none" + + num_processes = self.world_size + # The current default effective batch size + if self.generation_batch_size is None and self.steps_per_generation is None: + self.steps_per_generation = self.gradient_accumulation_steps + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + elif self.generation_batch_size is not None and self.steps_per_generation is None: + # Just ensure the value is divisible by the global batch size + if self.generation_batch_size % (self.per_device_train_batch_size * num_processes) != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by the global batch size " + f"({self.per_device_train_batch_size * num_processes})." + ) + self.steps_per_generation = self.generation_batch_size // ( + self.per_device_train_batch_size * num_processes + ) + elif self.generation_batch_size is None and self.steps_per_generation is not None: + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + else: + raise ValueError( + "'generation_batch_size' and 'steps_per_generation' can not be both configured at the same time" + ) + + if self.do_eval and self.eval_strategy != "no": + # Determine the number of generations to use for evaluation + num_generations = self.num_generations_eval or self.num_generations + + # Just ensure the value is divisible by the global batch size + if (self.per_device_eval_batch_size * num_processes) % num_generations != 0: + raise ValueError( + f"The global eval batch size ({self.per_device_eval_batch_size} * {num_processes}) must be " + f"divisible by the number of generations used for evaluation ({num_generations})." + ) + + # The generation batch must contain full prompt groups (no partials), so it must be divisible by + # num_generations. + if self.generation_batch_size % self.num_generations != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by num_generations " + f"({self.num_generations})." + ) + + if self.delta is not None and self.use_liger_kernel: + raise ValueError("Liger kernel does not support two-sided GRPO loss yet.") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/minillm_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/minillm_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..ab787611a16d3b195a434f76f9431224f18eaa65 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/minillm/minillm_trainer.py @@ -0,0 +1,412 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import textwrap + +import torch +import torch.nn as nn +import torch.nn.functional as F +import transformers +from datasets import Dataset, IterableDataset +from packaging.version import Version +from transformers import ( + AutoModelForCausalLM, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.utils import is_peft_available + +from ...models import prepare_deepspeed +from ...trainer.grpo_trainer import GRPOTrainer, RewardFunc, RolloutFunc +from ...trainer.utils import disable_dropout_in_model, get_config_model_id +from ..utils import empty_cache +from .minillm_config import MiniLLMConfig + + +if is_peft_available(): + from peft import PeftConfig + + +def dummy_reward_func(completions: list, **kwargs): + # placeholder reward function when no reward function is provided + return [1.0 for _ in completions] + + +class MiniLLMTrainer(GRPOTrainer): + """ + Trainer for the Knowledge Distillation of Language Models (MiniLLM) method. This algorithm was initially proposed + in the paper [Knowledge Distillation of Large Language Models](https://huggingface.co/papers/2306.08543). + + Example: + + ```python + from datasets import load_dataset + from trl.experimental.minillm import MiniLLMTrainer + + dataset = load_dataset("trl-lib/tldr", split="train") + + trainer = MiniLLMTrainer( + model="Qwen/Qwen3-0.6B", + teacher_model="Qwen/Qwen3-1.7B", + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str | PreTrainedModel`): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForCausalLM.from_pretrained`] with the keyword arguments in + `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + teacher_model (`PreTrainedModel | nn.Module | str`): + Teacher model used for knowledge distillation. Instantiated similarly to `model`. + reward_funcs (`RewardFunc | list[RewardFunc]`, *optional*): + Reward functions to be used for computing the rewards. To compute the rewards, we call all the reward + functions with the prompts and completions and sum the rewards. Can be either: + + - A single reward function, such as: + - A string: The *model ID* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForSequenceClassification.from_pretrained`] with `num_labels=1` and the + keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object: Only sequence classification models are supported. + - A custom reward function: The function is provided with the prompts and the generated completions, + plus any additional columns in the dataset. It should return a list of rewards. Custom reward + functions can also return `None` when the reward is not applicable to those samples. This is useful + for multi-task training where different reward functions apply to different types of samples. When a + reward function returns `None` for a sample, that reward function is excluded from the reward + calculation for that sample. For more details, see [Using a custom reward + function](#using-a-custom-reward-function). + + The trainer's state is also passed to the reward function. The trainer's state is an instance of + [`~transformers.TrainerState`] and can be accessed by accessing the `trainer_state` argument to the + reward function's signature. + - A list of reward functions, where each item can independently be any of the above types. Mixing different + types within the list (e.g., a string model ID and a custom reward function) is allowed. + args ([`experimental.minillm.MiniLLMConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. It must include a column `"prompt"`. Any additional columns in the dataset is + ignored. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. The padding side must be set to "left". If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoProcessor.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + reward_processing_classes ([`~transformers.PreTrainedTokenizerBase`] or `list[PreTrainedTokenizerBase]`, *optional*): + Processing classes corresponding to the reward functions specified in `reward_funcs`. Can be either: + + - A single processing class: Used when `reward_funcs` contains only one reward function. + - A list of processing classes: Must match the order and length of the reward functions in `reward_funcs`. + If set to `None`, or if an element of the list corresponding to a [`~transformers.PreTrainedModel`] is + `None`, the tokenizer for the model is automatically loaded using + [`~transformers.AutoTokenizer.from_pretrained`]. For elements in `reward_funcs` that are custom reward + functions (not [`~transformers.PreTrainedModel`]), the corresponding entries in `reward_processing_classes` + are ignored. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of [`AdamW`] on your + model and a scheduler given by [`get_linear_schedule_with_warmup`] controlled by `args`. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + rollout_func (`RolloutFunc`, *optional*): + Function to use for generating completions. It must take prompts, args, and processing_class as parameters + and return a dict with `"prompt_ids"`, `"completion_ids"`, and `"logprobs"` fields. Any other fields that + are forwarded to the reward functions. This feature is experimental and may change or be removed at any + time without prior notice. + """ + + _tag_names = ["trl", "minillm"] + _name = "MiniLLM" + _paper = { + "title": "MiniLLM: Knowledge Distillation of Large Language Models", + "id": "2306.08543", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{ + gu2024minillm, + title={{MiniLLM: Knowledge Distillation of Large Language Models}}, + author={Yuxian Gu and Li Dong and Furu Wei and Minlie Huang}, + booktitle={The Twelfth International Conference on Learning Representations}, + year={2024}, + url={https://openreview.net/forum?id=5h0qf7IBZZ} + }"""), + } + + def __init__( + self, + model: str | PreTrainedModel, + teacher_model: PreTrainedModel | nn.Module | str, + reward_funcs: RewardFunc | list[RewardFunc] | None = None, + args: MiniLLMConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: "PeftConfig | None" = None, + rollout_func: RolloutFunc | None = None, + ): + if reward_funcs is None: + reward_funcs = [dummy_reward_func] + + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = MiniLLMConfig(f"{model_name}-MiniLLM") + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model, + reward_funcs, + args=args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=reward_processing_classes, + callbacks=callbacks, + optimizers=optimizers, + peft_config=peft_config, + rollout_func=rollout_func, + ) + + if args.teacher_model_init_kwargs is None: + teacher_model_init_kwargs = {} + elif not isinstance(teacher_model, str): + raise ValueError( + "You passed teacher_model_init_kwargs to the MiniLLMConfig, but your teacher_model is already instantiated." + ) + else: + teacher_model_init_kwargs = args.teacher_model_init_kwargs + teacher_model_init_kwargs["dtype"] = ( + teacher_model_init_kwargs["dtype"] + if teacher_model_init_kwargs["dtype"] in ["auto", None] + else getattr(torch, teacher_model_init_kwargs["dtype"]) + ) + + if isinstance(teacher_model, str): + teacher_model = AutoModelForCausalLM.from_pretrained(teacher_model, **teacher_model_init_kwargs) + + # Disable dropout in the model + if args.disable_dropout: + disable_dropout_in_model(self.model) + + if self.is_deepspeed_enabled: + self.teacher_model = prepare_deepspeed(teacher_model, self.accelerator) + else: + self.teacher_model = self.accelerator.prepare_model(teacher_model, evaluation_mode=True) + + self.temperature = args.temperature + self.kd_temperature = args.kd_temperature + self.single_step_decomposition = args.single_step_decomposition + self.rkl_advantage = args.rkl_advantage + self.gamma = args.gamma + self.length_normalization = args.length_normalization + + def _single_step_decomposition_loss( + self, + student_log_probs: torch.Tensor, + teacher_log_probs: torch.Tensor, + mask: torch.Tensor | None = None, + reduction: str = "batchmean", + ): + """ + Compute the MiniLLM loss for knowledge distillation using F.kl_div. See Eq. (1) of + https://huggingface.co/papers/2306.08543 for the definition. + + Args: + student_logits: + Tensor of shape (batch_size, sequence_length, vocab_size) + teacher_logits: + Tensor of shape (batch_size, sequence_length, vocab_size) + labels: + Tensor of shape (batch_size, sequence_length) with -100 for padding tokens to ignore when computing + loss + beta: + Interpolation coefficient between 0 and 1 (default: 0.5) + temperature: + Softmax temperature (default: 1.0) + reduction: + Specifies the reduction to apply to the output (default: 'batchmean') + + Returns: + loss: Scalar tensor with the generalized JSD loss + """ + reg_loss = F.kl_div( + teacher_log_probs, student_log_probs, reduction="none", log_target=True + ) # (batch_size, sequence_length) + + # Masking + if mask is not None: + reg_loss = reg_loss[mask] + + # Apply reduction + if reduction == "batchmean": + return reg_loss.sum() / mask.sum() if mask is not None else reg_loss.sum() / reg_loss.size(0) + elif reduction == "sum": + return reg_loss.sum() + elif reduction == "mean": + return reg_loss.mean() + else: + return reg_loss + + def _compute_advantage( + self, + student_log_probs_on_labels: torch.Tensor, + teacher_log_probs_on_labels: torch.Tensor, + mask: torch.Tensor | None = None, + ) -> torch.Tensor: + r"""Compute the advantage for Reverse KL Divergence. + + Mostly following [this + implementation](https://github.com/microsoft/LMOps/blob/e210d2c026b9958617887762400778ace81172e6/minillm/minillm/losses.py#L37-L49). + + $$ \text{rewards}_t = \text{teacher\_log\_probs\_on\_labels}_t - \text{student\_log\_probs\_on\_labels}_t $$ + + If length normalization is enabled: + + $$ \text{lengths}_t = \sum_{i=t}^{T} \gamma^{i-t} $$ + + $$ \text{advantages}_t = \frac{\sum_{i=t}^{T} \gamma^{i-t} R_i}{\text{lengths}_t} $$ + + Otherwise: + + $$ \text{advantages}_t = \sum_{i=t}^{T} \gamma^{i-t} R_i $$ + + Args: + student_log_probs_on_labels: Log probabilities of the student model on the labels. + Shape: (batch_size, sequence_length) + teacher_log_probs_on_labels: Log probabilities of the teacher model on the labels. + Shape: (batch_size, sequence_length) + mask: Optional mask to apply to the log probabilities. Shape: (batch_size, sequence_length) + Returns: + advantage: Computed advantage. Shape: (batch_size, sequence_length) + """ + response_length = student_log_probs_on_labels.size(1) + if mask is None: + mask = torch.ones_like(student_log_probs_on_labels) + mask = mask.float() + student_log_probs_on_labels = student_log_probs_on_labels * mask + teacher_log_probs_on_labels = teacher_log_probs_on_labels * mask + + rewards = teacher_log_probs_on_labels - student_log_probs_on_labels # (batch_size, sequence_length) + + if self.gamma > 0.0: + gamma_pow = torch.pow(self.gamma, torch.arange(response_length, device=rewards.device)) + + advantages = rewards * gamma_pow + advantages = advantages.flip(1).cumsum(dim=1).flip(1) + + if self.length_normalization: + mask = torch.where(mask < 0.5, 1e-4, mask) + lengths = mask * gamma_pow + lengths = lengths.flip(1).cumsum(dim=1).flip(1) + advantages = advantages / lengths + else: + advantages = rewards + + return advantages + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + input_ids = torch.cat([inputs["prompt_ids"], inputs["completion_ids"]], dim=1) + attention_mask = torch.cat([inputs["prompt_mask"], inputs["completion_mask"]], dim=1) + labels = input_ids.clone() + labels[attention_mask == 0] = -100 + + # Compute student output + student_outputs = model(input_ids=input_ids, attention_mask=attention_mask, use_cache=False) + + # Compute teacher output in eval mode + self.teacher_model.eval() + with torch.no_grad(): + teacher_outputs = self.teacher_model(input_ids=input_ids, attention_mask=attention_mask, use_cache=False) + + # Slice the logits for the generated tokens using the inputs["prompts"] lengths + prompt_lengths = inputs["prompt_ids"].shape[1] + student_logits = student_outputs.logits[:, prompt_lengths - 1 : -1, :] + teacher_logits = teacher_outputs.logits[:, prompt_lengths - 1 : -1, :] + shifted_labels = input_ids[:, prompt_lengths:] + + # Apply temperature scaling + student_logits = student_logits / self.kd_temperature + teacher_logits = teacher_logits / self.kd_temperature + + # Compute log probabilities for student and probabilities for teacher + student_log_probs = F.log_softmax(student_logits, dim=-1) + teacher_log_probs = F.log_softmax(teacher_logits, dim=-1) + + student_log_probs_on_labels = torch.gather( + student_log_probs, dim=-1, index=shifted_labels.unsqueeze(-1) + ).squeeze(-1) + teacher_log_probs_on_labels = torch.gather( + teacher_log_probs, dim=-1, index=shifted_labels.unsqueeze(-1) + ).squeeze(-1) + + mask = shifted_labels != -100 + + if self.rkl_advantage: + reverse_kl_advantage = self._compute_advantage( + student_log_probs_on_labels=student_log_probs_on_labels, + teacher_log_probs_on_labels=teacher_log_probs_on_labels, + mask=mask, + ) + + inputs["advantages"] = inputs["advantages"].unsqueeze(1) + reverse_kl_advantage + + # Compute GRPO loss on verifiable reward + loss = self._compute_loss(model, inputs) + + # Compute loss + if self.single_step_decomposition: + single_step_decomposition_loss = self._single_step_decomposition_loss( + student_log_probs=student_log_probs, + teacher_log_probs=teacher_log_probs, + mask=mask, + ) + + loss += single_step_decomposition_loss + + # Empty cache + empty_cache() + + # Return loss + return (loss, student_outputs) if return_outputs else loss diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..5b80c1515bed13913e9497e35e6f79552deb40dc --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .nash_md_config import NashMDConfig +from .nash_md_trainer import NashMDTrainer + + +__all__ = ["NashMDConfig", "NashMDTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/nash_md_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/nash_md_config.py new file mode 100644 index 0000000000000000000000000000000000000000..2d52d08ecbe7bde752f9b1ae3455c56bf31e445d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/nash_md_config.py @@ -0,0 +1,46 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ..online_dpo import OnlineDPOConfig + + +@dataclass +class NashMDConfig(OnlineDPOConfig): + r""" + Configuration class for the [`experimental.nash_md.NashMDTrainer`]. + + Subclass of [`experimental.online_dpo.OnlineDPOConfig`] we can use all its arguments and add the following: + + Parameters: + mixture_coef (`float` or `list[float]`, *optional*, defaults to `0.5`): + Logit mixture coefficient for the model and reference model. If a list of floats is provided then the + mixture coefficient is selected for each new epoch and the last coefficient is used for the rest of the + epochs. + """ + + mixture_coef: list[float] = field( + default_factory=lambda: [0.5], + metadata={ + "help": "Logit mixture coefficient for the model and reference model. If a list of floats is provided " + "then the mixture coefficient is selected for each new epoch and the last coefficient is used for the " + "rest of the epochs." + }, + ) + + def __post_init__(self): + super().__post_init__() + if hasattr(self.mixture_coef, "__len__") and len(self.mixture_coef) == 1: + self.mixture_coef = self.mixture_coef[0] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/nash_md_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/nash_md_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..f8b10b3392d259349ed2b6eb97a4a5eb3091e2da --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/nash_md/nash_md_trainer.py @@ -0,0 +1,509 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import textwrap +from collections.abc import Callable +from typing import Any + +import torch +import torch.nn as nn +import torch.nn.functional as F +from datasets import Dataset, IterableDataset +from transformers import ( + BaseImageProcessor, + FeatureExtractionMixin, + GenerationMixin, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import EvalPrediction +from transformers.training_args import OptimizerNames +from transformers.utils import is_peft_available + +from ...data_utils import maybe_apply_chat_template +from ...models.utils import unwrap_model_for_generation +from ...trainer.utils import selective_log_softmax +from ..online_dpo import OnlineDPOTrainer +from ..utils import empty_cache, get_reward, truncate_right +from .nash_md_config import NashMDConfig + + +if is_peft_available(): + from peft import PeftModel + + +class GeometricMixtureWrapper(GenerationMixin): + """ + Geometric Mixture generation wrapper that samples from the logits of two model's geometric mixture. + + Args: + model ([`~transformers.PreTrainedModel`]): The model to be wrapped. + ref_model ([`~transformers.PreTrainedModel`]): The reference model. + generation_config ([`~transformers.GenerationConfig`]): The generation config. + mixture_coef (`float`, *optional* - default: 0.5): The mixture coefficient. + """ + + main_input_name = "input_ids" + _supports_cache_class = False + _supports_static_cache = False + _is_stateful = False + + def __init__(self, model, ref_model, generation_config, mixture_coef=0.5, device=None): + super().__init__() + + self.model = model + self.config = model.config + self.ref_model = ref_model + self.generation_config = generation_config + self.mixture_coef = mixture_coef + self.device = device + if hasattr(self.model, "_is_stateful"): + self._is_stateful = self.model._is_stateful + + def __call__(self, *args, **kwargs): + return self.forward(*args, **kwargs) + + @torch.inference_mode() + def forward(self, *args, **kwargs): + model_outputs = self.model(*args, **kwargs) + model_logits = model_outputs.logits + ref_model_logits = self.ref_model(*args, **kwargs).logits + + model_outputs.logits = torch.nn.functional.log_softmax( + self.mixture_coef * ref_model_logits + (1 - self.mixture_coef) * model_logits, dim=-1 + ) + + return model_outputs + + def prepare_inputs_for_generation(self, *args, **kwargs): + # turn off cache in the generation config + kwargs["use_cache"] = False + model_inputs = self.model.prepare_inputs_for_generation(*args, **kwargs) + _ = self.ref_model.prepare_inputs_for_generation(*args, **kwargs) + + return model_inputs + + def _validate_model_class(self): + self.model._validate_model_class() + + def _validate_model_kwargs(self, model_kwargs): + return self.model._validate_model_kwargs(model_kwargs) + + +class NashMDTrainer(OnlineDPOTrainer): + """ + Trainer for the Nash-MD method. + + It is implemented as a subclass of [`experimental.online_dpo.OnlineDPOTrainer`]. + + Args: + model ([`~transformers.PreTrainedModel`]): + The model to train, preferably an `AutoModelForCausalLM`. + ref_model ([`~transformers.PreTrainedModel`]): + Hugging Face transformer model with a casual language modelling head. Used for implicit reward computation + and loss. If no reference model is provided, the trainer will create a reference model with the same + architecture as the model to be optimized. + reward_funcs ([`~transformers.PreTrainedModel`]): + The reward model to score completions with, preferably an + [`~transformers.AutoModelForSequenceClassification`]. + args ([`experimental.nash_md.NashMDConfig`]): + The NashMD config arguments to use for training. + data_collator ([`~transformers.DataCollator`]): + The data collator to use for training. If None is specified, the default data collator + ([`experimental.utils.DPODataCollatorWithPadding`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + train_dataset ([`~datasets.Dataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`]): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + peft_config (`dict`): + The peft config to use for training. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + """ + + _tag_names = ["trl", "nash-md"] + _name = "Nash-MD" + _paper = { + "title": "Nash Learning from Human Feedback", + "id": "2312.00886", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{munos2024nash, + title = {{Nash Learning from Human Feedback}}, + author = {R{\'{e}}mi Munos and Michal Valko and Daniele Calandriello and Mohammad Gheshlaghi Azar and Mark Rowland and Zhaohan Daniel Guo and Yunhao Tang and Matthieu Geist and Thomas Mesnard and C{\\^{o}}me Fiegel and Andrea Michi and Marco Selvi and Sertan Girgin and Nikola Momchev and Olivier Bachem and Daniel J. Mankowitz and Doina Precup and Bilal Piot}, + year = 2024, + booktitle = {Forty-first International Conference on Machine Learning, {ICML} 2024, Vienna, Austria, July 21-27, 2024}, + publisher = {OpenReview.net}, + url = {https://openreview.net/forum?id=Y5AmNYiyCQ} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module = None, + ref_model: PreTrainedModel | nn.Module = None, + reward_funcs: PreTrainedModel | nn.Module | None = None, + args: NashMDConfig | None = None, + data_collator: Callable | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + peft_config: dict | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + ) -> None: + super().__init__( + model=model, + ref_model=ref_model, + reward_funcs=reward_funcs, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=processing_class, + peft_config=peft_config, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + self._mixture_coef = self.args.mixture_coef + + # Overwrite the stats dictionary to include NashMD specific statistics + self.stats = { + # Remove "non_score_reward", "rlhf_reward", "scores_margin" + # Add "mixture_coef" + "loss/kl": [], + "objective/entropy": [], + "loss/score": [], + "rewards/probabilities": [], + "rewards/accuracies": [], + "rewards/margins": [], + "logps/chosen": [], + "logps/rejected": [], + "val/model_contain_eos_token": [], + "val/ref_contain_eos_token": [], + "rewards/chosen": [], + "rewards/rejected": [], + "beta": [], + "mixture_coef": [], + } + if len(self.reward_funcs) != 1: + raise ValueError("NashMDTrainer only supports one reward function/model.") + self.reward_funcs = self.reward_funcs[0] + + @property + def mixture_coef(self): + if isinstance(self._mixture_coef, list): + epoch = self.state.epoch + return self._mixture_coef[epoch] if epoch < len(self._mixture_coef) else self._mixture_coef[-1] + else: + return self._mixture_coef + + def _generate_completions(self, model, prompts): + # Generate completions from the policy model. + with ( + unwrap_model_for_generation( + model, + self.accelerator, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_policy_for_gen_ctx + ): + model_output = unwrapped_policy_for_gen_ctx.generate( + input_ids=prompts["input_ids"], + attention_mask=prompts["attention_mask"], + generation_config=self.generation_config, + ) + + # Get the DDP/FSDP unwrapped version of the main model. + # This will be the policy model for GeometricMixtureWrapper (PEFT adapters active if PEFT is used). + policy_model_for_gmw = self.accelerator.unwrap_model(model) + + # Determine the correct reference model for GeometricMixtureWrapper. + # This also needs to be DDP/FSDP unwrapped. + ref_model_for_gmw: torch.nn.Module + if self.ref_model is None: + # No explicit ref_model is provided. + # Use the base of the main `model` if it's a PEFT model. + # policy_model_for_gmw is already DDP-unwrapped. + if is_peft_available() and isinstance(policy_model_for_gmw, PeftModel): + ref_model_for_gmw = policy_model_for_gmw.get_base_model() + else: + # Not a PEFT model (or PEFT not available), or already a base model. + # Use the DDP-unwrapped policy model itself as the reference. + ref_model_for_gmw = policy_model_for_gmw + else: + # An explicit ref_model is provided. Unwrap it for DDP/FSDP. + ref_model_for_gmw = self.accelerator.unwrap_model(self.ref_model) + + # Both models given to GeometricMixtureWrapper (policy_model_for_gmw and ref_model_for_gmw) are DDP-unwrapped. + with torch.no_grad(): # Ensure no_grad context for mixture model generation + mixture_model = GeometricMixtureWrapper( + model=policy_model_for_gmw, + ref_model=ref_model_for_gmw, + generation_config=self.generation_config, + mixture_coef=self.mixture_coef, + device=self.accelerator.device, + ) + + # TODO: use self._override_model_generation_config for both models? + mixture_output = mixture_model.generate( + input_ids=prompts["input_ids"], + attention_mask=prompts["attention_mask"], + generation_config=self.generation_config, + ) + + return model_output, mixture_output + + def _process_completions(self, model_output, mixture_output, prompts): + context_length = prompts["input_ids"].shape[1] + + # Process model completions + model_completion_ids = model_output[:, context_length:] + model_completion_ids, model_completion_mask = truncate_right( + model_completion_ids, self.processing_class.eos_token_id, self.processing_class.pad_token_id + ) + model_data = { + "input_ids": torch.cat((prompts["input_ids"], model_completion_ids), dim=1), + "attention_mask": torch.cat((prompts["attention_mask"], model_completion_mask), dim=1), + "raw": prompts["raw"], + } + + # Process reference model completions + mixture_completion_ids = mixture_output[:, context_length:] + mixture_completion_ids, mixture_completion_mask = truncate_right( + mixture_completion_ids, self.processing_class.eos_token_id, self.processing_class.pad_token_id + ) + mixture_data = { + "input_ids": torch.cat((prompts["input_ids"], mixture_completion_ids), dim=1), + "attention_mask": torch.cat((prompts["attention_mask"], mixture_completion_mask), dim=1), + "raw": prompts["raw"], + } + + return model_data, mixture_data + + def _compute_rewards(self, model_data, mixture_data, context_length): + with torch.no_grad(): + _, model_scores, _ = get_reward( + self.reward_funcs, model_data["input_ids"], self.processing_class.pad_token_id, context_length + ) + _, mixture_scores, _ = get_reward( + self.reward_funcs, mixture_data["input_ids"], self.processing_class.pad_token_id, context_length + ) + + # Apply EOS penalty if needed + if self.args.missing_eos_penalty is not None: + model_contain_eos = torch.any(model_data["input_ids"] == self.processing_class.eos_token_id, dim=-1) + mixture_contain_eos = torch.any(mixture_data["input_ids"] == self.processing_class.eos_token_id, dim=-1) + model_scores[~model_contain_eos] -= self.args.missing_eos_penalty + mixture_scores[~mixture_contain_eos] -= self.args.missing_eos_penalty + + return model_scores, mixture_scores + + def _compute_logprobs(self, model, model_data, context_length): + def compute_logprobs_for_data(m, data): + output = m(data["input_ids"], attention_mask=data["attention_mask"]) + logits = output.logits[:, context_length - 1 : -1] + token_logprobs = selective_log_softmax(logits, data["input_ids"][:, context_length:]) + return token_logprobs + + # Compute logprobs for model completions under the model + model_logprobs_model_data = compute_logprobs_for_data(model, model_data) + + # Compute logprobs of model completions under the reference model + with torch.no_grad(): + if self.ref_model is None: + with model.disable_adapter(): + ref_logprobs_model_data = compute_logprobs_for_data(model, model_data) + else: + ref_logprobs_model_data = compute_logprobs_for_data(self.ref_model, model_data) + + # Mask padding tokens + model_padding_mask = model_data["attention_mask"][:, context_length:] == 0 + model_logprobs_model_data = model_logprobs_model_data.masked_fill(model_padding_mask, 0.0) + ref_logprobs_model_data = ref_logprobs_model_data.masked_fill(model_padding_mask, 0.0) + + return (model_logprobs_model_data, ref_logprobs_model_data) + + def _compute_losses( + self, + model_logprobs_model_data, + ref_logprobs_model_data, + probability, + ): + # reinforce score where 0.5 is a control variate + score = (probability - 0.5) * model_logprobs_model_data.sum(1) + + # kl divergence via reinforce + with torch.no_grad(): + log_ratio = model_logprobs_model_data - ref_logprobs_model_data + kl_div_log = log_ratio.sum(1) + kl_div_loss = (log_ratio * model_logprobs_model_data).sum(1) + + # final loss + loss = self.beta * kl_div_loss - score + + return loss.mean(), score, kl_div_log + + def _log_statistics( + self, + model_data, + mixture_data, + model_logprobs_model_data, + ref_logprobs_model_data, + probability, + score, + kl_div, + context_length, + model_scores, + mixture_scores, + ): + # Helper function to gather and compute mean + def gather_mean(tensor): + return self.accelerator.gather_for_metrics(tensor).mean().item() + + # Log score + self.stats["loss/score"].append(gather_mean(score)) + # Log KL divergence + self.stats["loss/kl"].append(gather_mean(kl_div)) + + # Log logprobs + model_logprobs_model_data_sum = model_logprobs_model_data.sum(1) + ref_logprobs_model_data_sum = ref_logprobs_model_data.sum(1) + + self.stats["logps/chosen"].append(gather_mean(model_logprobs_model_data_sum)) + self.stats["logps/rejected"].append(gather_mean(ref_logprobs_model_data_sum)) + + # Log rewards + self.stats["rewards/chosen"].append(gather_mean(model_scores)) + self.stats["rewards/rejected"].append(gather_mean(mixture_scores)) + + # Log probabilities + self.stats["rewards/probabilities"].append(gather_mean(probability)) + + # Calculate entropy for model data + entropy_model_data = -model_logprobs_model_data.sum(1) + self.stats["objective/entropy"].append(gather_mean(entropy_model_data)) + + # Calculate margins + margin = model_logprobs_model_data_sum - ref_logprobs_model_data_sum + self.stats["rewards/margins"].append(gather_mean(margin)) + + # Calculate accuracy + accuracy = (margin > 0).float() + self.stats["rewards/accuracies"].append(gather_mean(accuracy)) + + # Log EOS token statistics + model_eos = (model_data["input_ids"][:, context_length:] == self.processing_class.eos_token_id).any(dim=1) + mixture_eos = (mixture_data["input_ids"][:, context_length:] == self.processing_class.eos_token_id).any(dim=1) + self.stats["val/model_contain_eos_token"].append(gather_mean(model_eos.float())) + self.stats["val/ref_contain_eos_token"].append(gather_mean(mixture_eos.float())) + + # Log beta and mixture coef + self.stats["beta"].append(self.beta) + self.stats["mixture_coef"].append(self.mixture_coef) + + def training_step( + self, model: nn.Module, inputs: dict[str, torch.Tensor | Any], num_items_in_batch: int | None = None + ) -> torch.Tensor: + model.train() + + # Apply chat template and tokenize the input + batch_size = len(next(iter(inputs.values()))) + prompts = inputs["prompt"] + inputs = [{k: v[i] for k, v in inputs.items()} for i in range(batch_size)] + inputs = [maybe_apply_chat_template(x, self.processing_class) for x in inputs] + inputs = [self.tokenize_row(x, self.model.config.is_encoder_decoder, self.processing_class) for x in inputs] + inputs = self.data_collator(inputs) + + # need the prompt_ only + inputs = self._prepare_inputs(inputs) + context_length = inputs["prompt_input_ids"].shape[1] + prompts = { + "input_ids": inputs["prompt_input_ids"], + "attention_mask": inputs["prompt_attention_mask"], + "raw": prompts, + } + del inputs + + # Sample completions from both the model and the reference model + model_output, mixture_output = self._generate_completions(model, prompts) + + # Process model completions + model_data, mixture_data = self._process_completions(model_output, mixture_output, prompts) + + # Compute rewards + model_scores, mixture_scores = self._compute_rewards(model_data, mixture_data, context_length) + # probability of the model data vs the mixture data + probability = F.sigmoid(model_scores - mixture_scores) + + # Compute logprobs + model_logprobs_model_data, ref_logprobs_model_data = self._compute_logprobs(model, model_data, context_length) + + # Compute loss + loss, score, kl_div = self._compute_losses(model_logprobs_model_data, ref_logprobs_model_data, probability) + + # Log everything + self._log_statistics( + model_data, + mixture_data, + model_logprobs_model_data.detach(), + ref_logprobs_model_data, + probability, + score.detach(), + kl_div.detach(), + context_length, + model_scores, + mixture_scores, + ) + + if ( + self.args.torch_empty_cache_steps is not None + and self.state.global_step % self.args.torch_empty_cache_steps == 0 + ): + empty_cache() + + kwargs = {} + # For LOMO optimizers you need to explicitly use the learning rate + if self.args.optim in [OptimizerNames.LOMO, OptimizerNames.ADALOMO]: + kwargs["learning_rate"] = self._get_learning_rate() + + if self.args.n_gpu > 1: + loss = loss.mean() # mean() to average on multi-gpu parallel training + + self.accelerator.backward(loss, **kwargs) + + return loss.detach() / self.args.gradient_accumulation_steps diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..2a109cabc240f871544e5ccc56ee5616794c0ba9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .online_dpo_config import OnlineDPOConfig +from .online_dpo_trainer import OnlineDPOTrainer + + +__all__ = ["OnlineDPOConfig", "OnlineDPOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/online_dpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/online_dpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..9ff4b4e657f10a22ecd5056884669da3e513be06 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/online_dpo_config.py @@ -0,0 +1,376 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class OnlineDPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.online_dpo.OnlineDPOTrainer`]. + + This class includes only the parameters that are specific to Online DPO training. For a full list of training + arguments, please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this + class may differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + reward_model_path (`str`, *optional*): + Path to the reward model. + max_new_tokens (`int`, *optional*, defaults to `64`): + Maximum number of tokens to generate per completion. + max_length (`int`, *optional*, defaults to `256`): + Maximum total length of the sequence (prompt + completion) used to compute log probabilities. If the + sequence exceeds this limit, the leftmost tokens will be truncated to preserve as much of the completion as + possible. + temperature (`float`, *optional*, defaults to `0.9`): + Temperature for sampling. The higher the temperature, the more random the completions. + missing_eos_penalty (`float`, *optional*): + Penalty applied to the score when the model fails to generate an EOS token. This is useful to encourage to + generate completions shorter than the maximum length (`max_new_tokens`). The penalty must be a positive + value. + beta (`float` or `list[float]`, *optional*, defaults to `0.1`): + Parameter controlling the deviation from the reference model. Higher β means less deviation from the + reference model. For the IPO loss (`loss_type="ipo"`), β is the regularization parameter denoted by τ in + the [paper](https://huggingface.co/papers/2310.12036). If a list of floats is provided then the β is + selected for each new epoch and the last β is used for the rest of the epochs. + loss_type (`str`, *optional*, defaults to `"sigmoid"`): + Type of loss to use. Possible values are: + + - `"sigmoid"`: sigmoid loss from the original [DPO](https://huggingface.co/papers/2305.18290) paper. + - `"ipo"`: IPO loss from the [IPO](https://huggingface.co/papers/2310.12036) paper. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model and reference model. + + > Parameters that control generation + + top_p (`float`, *optional*, defaults to `1.0`): + Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. Set to + `1.0` to consider all tokens. + top_k (`int`, *optional*, defaults to `0`): + Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, top-k-filtering is + disabled and all tokens are considered. + min_p (`float`, *optional*): + Minimum token probability, which will be scaled by the probability of the most likely token. It must be a + value between `0.0` and `1.0`. Typical values are in the `0.01-0.2` range. + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. + Values > `1.0` encourage the model to use new tokens, while values < `1.0` encourage the model to repeat + tokens. + cache_implementation (`str`, *optional*): + Implementation of the cache method for faster generation when `use_vllm` is set to `False`. + generation_kwargs (`dict[str, Any]`, *optional*): + Additional keyword arguments to pass to [`~transformers.GenerationConfig`] (if using transformers) or + `SamplingParams` (if using vLLM) when sampling completions. This can be used to further customize the + generation behavior, such as setting `suppress_tokens`, `num_beams`, etc. If it contains keys that conflict + with the other generation parameters (like `min_p`, `top_p`, etc.), they will override them. + + > Parameters that control generation acceleration powered by vLLM + + use_vllm (`bool`, *optional*, defaults to `False`): + Whether to use vLLM for generating completions. If set to `True`, the trainer will use vLLM for generation + instead of the default model.generate(). Requires `vllm` to be installed. + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation to use for vLLM. Must be one of `"transformers"` or `"vllm"`. `"transformers"`: Use + the `transformers` backend for model implementation. `"vllm"`: Use the `vllm` library for model + implementation. + vllm_mode (`str`, *optional*, defaults to `"colocate"`): + Mode to use for vLLM integration when `use_vllm` is set to `True`. Must be one of `"server"` or + `"colocate"`. + + - `"server"`: The trainer will send generation requests to a separate vLLM server. Make sure a TRL vLLM + server is running (start with `trl vllm-serve`). + - `"colocate"`: vLLM will run in the same process and share the training GPUs. This avoids the need for a + separate server but may cause resource contention with training. + vllm_structured_outputs_regex (`str`, *optional*): + Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled. + + > Parameters that control the vLLM server (only used when `vllm_mode` is `"server"`) + + vllm_server_base_url (`str`, *optional*): + Base URL for the vLLM server (e.g., `"http://localhost:8000"`). If provided, `vllm_server_host` and + `vllm_server_port` are ignored. + vllm_server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the vLLM server to connect to. Ignored if `vllm_server_base_url` is provided. + vllm_server_port (`int`, *optional*, defaults to `8000`): + Port of the vLLM server to connect to. Ignored if `vllm_server_base_url` is provided. + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up after the + timeout, a `ConnectionError` is raised. + vllm_group_port (`int`, *optional*, defaults to `51216`): + Port number for the weight update group. This is used to communicate with the vLLM server. Unless the port + is occupied, there is no need to change it. + + > Parameters that control colocated vLLM execution (only used when `vllm_mode` is `"colocate"`) + + vllm_gpu_memory_utilization (`float`, *optional*, defaults to `0.55`): + Control the GPU memory utilization for vLLM. This setting only applies when `vllm_mode` is set to + `"colocate"`. If you are using `vllm_mode="server"`, this parameter must be passed separately when + launching the vLLM server via the `--vllm_gpu_memory_utilization` flag. + vllm_tensor_parallel_size (`int`, *optional*, defaults to `1`): + Control the tensor parallel size for vLLM. This setting only applies when `vllm_mode` is set to + `"colocate"`. If you are using `vllm_mode="server"`, this parameter must be passed separately when + launching the vLLM server via the `--vllm_tensor_parallel_size` flag. + vllm_enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Enable vLLM sleep mode to offload weights/cache during the optimizer step. Keeps GPU memory usage low, but + waking the engine adds host–device transfer latency. + + > Other parameters + + ds3_gather_for_generation (`bool`, *optional*, defaults to `True`): + This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for generation, + improving generation speed. However, disabling this option allows training models that exceed the VRAM + capacity of a single GPU, albeit at the cost of slower generation. Disabling this option is not compatible + with vLLM generation. + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model from a + string. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `5e-7` instead of `5e-5`. + > - `remove_unused_columns`: Defaults to `False` instead of `True`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=5e-7, + metadata={"help": "The initial learning rate for AdamW."}, + ) + remove_unused_columns: bool = field( + default=False, + metadata={"help": "Whether or not to automatically remove the columns unused by the model forward method."}, + ) + + reward_model_path: str | None = field( + default=None, + metadata={"help": "Path to the reward model."}, + ) + max_new_tokens: int = field( + default=64, + metadata={"help": "Maximum number of tokens to generate per completion."}, + ) + max_length: int = field( + default=512, + metadata={ + "help": "Maximum total length of the sequence (prompt + completion) used to compute log probabilities. If " + "the sequence exceeds this limit, the leftmost tokens will be truncated to preserve as much of the " + "completion as possible." + }, + ) + temperature: float = field( + default=0.9, + metadata={"help": "Temperature for sampling. The higher the temperature, the more random the completions."}, + ) + top_p: float = field( + default=1.0, + metadata={ + "help": "Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. " + "Set to 1.0 to consider all tokens." + }, + ) + top_k: int = field( + default=0, + metadata={ + "help": "Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, " + "top-k-filtering is disabled and all tokens are considered." + }, + ) + min_p: float | None = field( + default=None, + metadata={ + "help": "Minimum token probability, which will be scaled by the probability of the most likely token. It " + "must be a value between 0.0 and 1.0. Typical values are in the 0.01-0.2 range." + }, + ) + repetition_penalty: float = field( + default=1.0, + metadata={ + "help": "Float that penalizes new tokens based on whether they appear in the prompt and the generated " + "text so far. Values > 1.0 encourage the model to use new tokens, while values < 1.0 encourage the model " + "to repeat tokens." + }, + ) + generation_kwargs: dict | None = field( + default=None, + metadata={ + "help": "Additional keyword arguments to pass to `GenerationConfig` (if using transformers) or " + "`SamplingParams` (if using vLLM) when sampling completions. This can be used to further customize the " + "generation behavior, such as setting `suppress_tokens`, `num_beams`, etc. If it contains keys that " + "conflict with the other generation parameters (like `min_p`, `top_p`, etc.), they will override them." + }, + ) + cache_implementation: str | None = field( + default=None, + metadata={"help": "Implementation of the cache method for faster generation when use_vllm is set to False."}, + ) + missing_eos_penalty: float | None = field( + default=None, + metadata={ + "help": "Penalty applied to the score when the model fails to generate an EOS token. This is useful to " + "encourage to generate completions shorter than the maximum length (`max_new_tokens`). The penalty must be " + "a positive value." + }, + ) + beta: list[float] = field( + default_factory=lambda: [0.1], + metadata={ + "help": "Parameter controlling the deviation from the reference model. Higher β means less deviation from " + "the reference model. For the IPO loss (`loss_type='ipo'`), β is the regularization parameter denoted by " + "τ in the [paper](https://huggingface.co/papers/2310.12036). If a list of floats is provided then the β " + "is selected for each new epoch and the last β is used for the rest of the epochs." + }, + ) + loss_type: str = field( + default="sigmoid", + metadata={ + "help": "Type of loss to use.", + "choices": ["sigmoid", "ipo"], + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model."}, + ) + use_vllm: bool = field( + default=False, + metadata={ + "help": "Whether to use vLLM for generating completions. Requires vLLM to be installed " + "(`pip install trl[vllm]`)." + }, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={ + "help": "Model implementation to use for vLLM. Must be one of `transformers` or `vllm`. `transformers`: " + "Use the `transformers` backend for model implementation. `vllm`: Use the `vllm` library for " + "model implementation." + }, + ) + vllm_structured_outputs_regex: str | None = field( + default=None, + metadata={"help": "Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled."}, + ) + vllm_gpu_memory_utilization: float | None = field( + default=0.55, + metadata={ + "help": "Control the GPU memory utilization for vLLM. This setting only applies when `vllm_mode` is set " + "to `'colocate'`. If you are using `vllm_mode='server'`, this parameter must be passed separately when " + "launching the vLLM server via the `--vllm_gpu_memory_utilization` flag.", + }, + ) + vllm_mode: str = field( + default="colocate", + metadata={ + "help": "Mode to use for vLLM integration when `use_vllm` is set to `True`. Must be one of `'server'` or " + "`'colocate'`. `'server'`: The trainer will send generation requests to a separate vLLM server. Make sure " + "a TRL vLLM server is running (start with `trl vllm-serve`). `'colocate'`: vLLM will run in the same " + "process and share the training GPUs. This avoids the need for a separate server but may cause resource " + "contention with training.", + }, + ) + vllm_server_base_url: str | None = field( + default=None, + metadata={ + "help": "Base URL for the vLLM server (e.g., 'http://localhost:8000'). If provided, `vllm_server_host` " + "and `vllm_server_port` are ignored.", + }, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": "Host of the vLLM server to connect to. Ignored if vllm_server_base_url is provided."}, + ) + vllm_server_port: int = field( + default=8000, + metadata={"help": "Port of the vLLM server to connect to. Ignored if vllm_server_base_url is provided."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={ + "help": "Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up " + "after the timeout, a `ConnectionError` is raised.", + }, + ) + vllm_group_port: int = field( + default=51216, + metadata={ + "help": "Port number for the weight update group. This is used to communicate with the vLLM server. " + "Unless the port is occupied, there is no need to change it.", + }, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={ + "help": "Control the tensor parallel size for vLLM. This setting only applies when `vllm_mode` is set " + "to `'colocate'`. If you are using `vllm_mode='server'`, this parameter must be passed separately when " + "launching the vLLM server via the `--vllm_tensor_parallel_size` flag.", + }, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={ + "help": "Enable vLLM sleep mode to offload weights/cache during the optimizer step. Keeps GPU memory " + "usage low, but waking the engine adds host–device transfer latency." + }, + ) + ds3_gather_for_generation: bool = field( + default=True, + metadata={ + "help": "This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for " + "generation, improving generation speed. However, disabling this option allows training models that " + "exceed the VRAM capacity of a single GPU, albeit at the cost of slower generation. Disabling this option " + "is not compatible with vLLM generation." + }, + ) + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model " + "from a string." + }, + ) + reward_weights: list[float] | None = field( + default=None, + metadata={ + "help": "Weights for combining multiple reward functions. Must match the number of reward functions. " + "If None, all reward functions are equally weighted." + }, + ) + + def __post_init__(self): + super().__post_init__() + + if hasattr(self.beta, "__len__") and len(self.beta) == 1: + self.beta = self.beta[0] + + if self.max_new_tokens >= self.max_length: + warnings.warn( + f"The configuration has `max_new_tokens` ({self.max_new_tokens}) >= `max_length` ({self.max_length}). " + "This will cause prompts to be truncated or completely removed in the forward pass. " + "To preserve prompts, ensure e.g. `max_length > max_new_tokens + 512`. ", + stacklevel=3, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/online_dpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/online_dpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7adef3b6dfdb82ccd89967e3094b1021425e5a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/online_dpo/online_dpo_trainer.py @@ -0,0 +1,1343 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re +import textwrap +from collections.abc import Callable +from contextlib import nullcontext +from pathlib import Path +from typing import Any + +import torch +import torch.nn as nn +import torch.nn.functional as F +import torch.utils.data +import transformers +from accelerate import logging +from accelerate.utils import broadcast_object_list, gather_object, is_peft_model +from datasets import Dataset +from packaging.version import Version +from torch.distributed.fsdp import FullyShardedDataParallel as FSDP +from torch.utils.data import IterableDataset +from transformers import ( + AutoModelForCausalLM, + AutoModelForSequenceClassification, + AutoTokenizer, + DataCollator, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + is_bitsandbytes_available, +) +from transformers.models.auto.modeling_auto import MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES +from transformers.trainer_utils import EvalPrediction +from transformers.training_args import OptimizerNames +from transformers.utils import is_peft_available, is_sagemaker_mp_enabled + +from ...data_utils import apply_chat_template, is_conversational, maybe_apply_chat_template +from ...extras.profiling import profiling_context +from ...generation.vllm_client import VLLMClient +from ...import_utils import is_vllm_available +from ...models.utils import prepare_deepspeed, prepare_fsdp, unwrap_model_for_generation +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import disable_dropout_in_model, ensure_master_addr_port, get_config_model_id +from ..utils import DPODataCollatorWithPadding, create_reference_model, empty_cache, prepare_peft_model, truncate_right +from .online_dpo_config import OnlineDPOConfig + + +if is_peft_available(): + from peft import PeftConfig, PeftModel + + +if is_sagemaker_mp_enabled(): + from smdistributed.modelparallel import __version__ as SMP_VERSION + + IS_SAGEMAKER_MP_POST_1_10 = Version(SMP_VERSION) >= Version("1.10") + +else: + IS_SAGEMAKER_MP_POST_1_10 = False + + +if Version(transformers.__version__) >= Version("5.2.0"): + from transformers.trainer_pt_utils import nested_gather + + +if is_vllm_available(): + from vllm import LLM, SamplingParams + from vllm.sampling_params import StructuredOutputsParams + +if is_bitsandbytes_available(): + import bitsandbytes as bnb + +logger = logging.get_logger(__name__) + +# A reward function can be a string, interpreted as a model ID and loaded as a pretrained model, a pretrained model, or +# a callable that returns a list of floats (the rewards). The callable receives prompts, completions, and additional +# arguments from the trainer (refer to the trainer's source for details). To ensure forward compatibility, it should +# accept **kwargs. +RewardFunc = str | PreTrainedModel | Callable[..., list[float | None]] + + +class OnlineDPOTrainer(_BaseTrainer): + r""" + Initialize OnlineDPOTrainer. + + Args: + model (`str | nn.Module | PreTrainedModel`): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForCausalLM.from_pretrained`] with the keyword arguments in + `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + ref_model ([`~transformers.PreTrainedModel`] or `torch.nn.Module` or `None`): + The reference model to use for training. If None is specified, the reference model will be created from the + model. + reward_funcs (`RewardFunc | list[RewardFunc]`): + Reward functions to be used for computing the rewards. To compute the rewards, we call all the reward + functions with the prompts and completions and sum the rewards. Can be either: + + - A single reward function: Can be a string (path to model), a [`~transformers.PreTrainedModel`], or a + custom callable function. + - A list of reward functions: Must all be of compatible types. + args ([`experimental.online_dpo.OnlineDPOConfig`]): + The online DPO config arguments to use for training. + data_collator ([`~transformers.DataCollator`]): + The data collator to use for training. If None is specified, the default data collator + ([`experimental.utils.DPODataCollatorWithPadding`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + reward_processing_classes ([`~transformers.PreTrainedTokenizerBase`] or `list[PreTrainedTokenizerBase]`, *optional*): + Processing classes corresponding to the reward functions specified in `reward_funcs`. Can be either: + + - A single processing class: Used when `reward_funcs` contains only one reward function. + - A list of processing classes: Must match the order and length of the reward functions in `reward_funcs`. + + If set to `None`, the tokenizer for each model-based reward function is automatically loaded using + [`~transformers.AutoTokenizer.from_pretrained`]. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + """ + + _tag_names = ["trl", "online-dpo"] + _name = "Online DPO" + _paper = { + "title": "Direct Language Model Alignment from Online AI Feedback", + "id": "2402.04792", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{guo2024direct, + title = {{Direct Language Model Alignment from Online AI Feedback}}, + author = {Shangmin Guo and Biao Zhang and Tianlin Liu and Tianqi Liu and Misha Khalman and Felipe Llinares and Alexandre Ram{\'{e}} and Thomas Mesnard and Yao Zhao and Bilal Piot and Johan Ferret and Mathieu Blondel}, + year = 2024, + eprint = {arXiv:2402.04792} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str, + ref_model: PreTrainedModel | nn.Module | None = None, + reward_funcs: RewardFunc | list[RewardFunc] | None = None, + args: OnlineDPOConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + peft_config: "PeftConfig | None" = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + ) -> None: + if train_dataset is None: + raise ValueError("`train_dataset` is required") + + if ref_model is model: + raise ValueError( + "`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the " + "same as `model`, either omit the `ref_model` argument or pass `None`." + ) + + self.ref_model = ref_model + + if reward_funcs is None: + raise ValueError("`reward_funcs` must be provided.") + + # Handle reward_funcs + if not isinstance(reward_funcs, list): + reward_funcs = [reward_funcs] + self.reward_func_names = [] + + # Process reward functions (convert strings to models, collect names) + model_init_kwargs = args.model_init_kwargs or {} + for i, reward_func in enumerate(reward_funcs): + if isinstance(reward_func, str): + # Load model from string path + reward_funcs[i] = AutoModelForSequenceClassification.from_pretrained( + reward_func, num_labels=1, **model_init_kwargs + ) + if isinstance(reward_funcs[i], nn.Module): + self.reward_func_names.append(get_config_model_id(reward_funcs[i].config).split("/")[-1]) + else: + self.reward_func_names.append(reward_funcs[i].__name__) + self.reward_funcs = reward_funcs + + # Handle reward processing classes for reward_funcs + if reward_processing_classes is None: + reward_processing_classes = [None] * len(reward_funcs) + elif not isinstance(reward_processing_classes, list): + reward_processing_classes = [reward_processing_classes] + else: + if len(reward_processing_classes) != len(reward_funcs): + raise ValueError("The number of reward processing classes must match the number of reward functions.") + + self.reward_processing_classes = [] + for reward_processing_class_i, reward_func in zip(reward_processing_classes, reward_funcs, strict=True): + if isinstance(reward_func, PreTrainedModel): + if reward_processing_class_i is None: + reward_processing_class_i = AutoTokenizer.from_pretrained(reward_func.config._name_or_path) + if reward_processing_class_i.pad_token_id is None: + reward_processing_class_i.pad_token = reward_processing_class_i.eos_token + # Set pad token ID on reward model config + reward_func.config.pad_token_id = reward_processing_class_i.pad_token_id + self.reward_processing_classes.append(reward_processing_class_i) + + # Handle reward_weights + if args.reward_weights is not None: + if len(args.reward_weights) != len(self.reward_funcs): + raise ValueError( + f"Number of reward weights ({len(args.reward_weights)}) must match number of reward " + f"functions ({len(self.reward_funcs)})" + ) + self.reward_weights = torch.tensor(args.reward_weights, dtype=torch.float32) + else: + self.reward_weights = torch.ones(len(self.reward_funcs), dtype=torch.float32) + + if args is None: + raise ValueError("`args` must be provided.") + + # Check that the processing_class is provided + if processing_class is None: + raise ValueError("`processing_class` must be provided.") + + model_init_kwargs = args.model_init_kwargs or {} + if isinstance(model, str): + model_id = model + + # Handle dtype in model_init_kwargs + dtype = model_init_kwargs.get("dtype", "auto") + if isinstance(dtype, torch.dtype) or dtype == "auto" or dtype is None: + pass + elif isinstance(dtype, str): + dtype = getattr(torch, dtype) + model_init_kwargs["dtype"] = dtype + else: + raise ValueError( + "Invalid `dtype` passed to `OnlineDPOConfig`. Expected either 'auto' or a string " + f"representing a `torch.dtype` (e.g., 'float32'), but got {dtype}." + ) + model_init_kwargs["device_map"] = model_init_kwargs.get("device_map", "auto") + + model = AutoModelForCausalLM.from_pretrained(model_id, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + raise ValueError( + "You passed `model_init_kwargs` to the `OnlineDPOConfig`, but your model is already instantiated. " + "This argument can only be used when the `model` argument is a string." + ) + self.is_encoder_decoder = model.config.is_encoder_decoder + self.is_vision_model = model.config.model_type in MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES.keys() + + if peft_config is not None or (is_peft_available() and isinstance(model, PeftModel)): + model = prepare_peft_model(model, peft_config, args) + + # Enable gradient checkpointing if requested + if args.gradient_checkpointing: + model = self._enable_gradient_checkpointing(model, args) + + # Disable dropout in the model and reference model + if args.disable_dropout: + disable_dropout_in_model(model) + if self.ref_model is not None: + disable_dropout_in_model(self.ref_model) + + # Handle the ref_model + # Usually, the user wants the ref model to be the initial version of the model. When using PEFT, it's easy to + # get the ref model, as it's just the model with a disabled adapter. When not using PEFT, we need to create + # the ref model from the model by copying it and disable the gradients and set it in evaluation mode. + if ref_model is None: # No ref model provided, the most common case + if peft_config is None: + self.ref_model = create_reference_model(model) # copy, disable gradients, set eval mode + else: + self.ref_model = None # we don't need a ref model here, we can just disable the adapter. + else: # rare case, the user provided a ref model + self.ref_model = ref_model + self.ref_model.eval() + + # Disable the gradient and set the reward model in eval mode + if reward_funcs is not None: + for reward_func in reward_funcs: + if isinstance(reward_func, PreTrainedModel): + reward_func.eval() + + self.max_length = args.max_length + + self.stats = { + "objective/kl": [], + "objective/entropy": [], + "objective/non_score_reward": [], + "rewards/chosen": [], + "rewards/rejected": [], + "rewards/accuracies": [], + "rewards/margins": [], + "logps/chosen": [], + "logps/rejected": [], + "val/contain_eos_token": [], + "beta": [], + } + if self.reward_funcs is not None: + self.stats["objective/rlhf_reward"] = [] + self.stats["objective/scores_margin"] = [] + self.stats["objective/scores"] = [] + + # Store generation parameters for later use + self.use_vllm = args.use_vllm + self.num_generations = 2 # Generate 2 completions per prompt for Online DPO + self.temperature = args.temperature + self.top_p = args.top_p + self.top_k = args.top_k + self.min_p = args.min_p + self.repetition_penalty = args.repetition_penalty + self.vllm_mode = args.vllm_mode if args.use_vllm else None + self.vllm_gpu_memory_utilization = args.vllm_gpu_memory_utilization + self.vllm_tensor_parallel_size = args.vllm_tensor_parallel_size + self.vllm_model_impl = args.vllm_model_impl + + # Handle pad token for processors or tokenizers + if isinstance(processing_class, ProcessorMixin): + tokenizer = processing_class.tokenizer + elif isinstance(processing_class, PreTrainedTokenizerBase): + tokenizer = processing_class + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + self.pad_token_id = tokenizer.pad_token_id + self.eos_token_id = tokenizer.eos_token_id + + # Vision tokens for VLM support + self.image_token_id = getattr(processing_class, "image_token_id", None) + self.vision_start_token_id = getattr(processing_class, "vision_start_token_id", None) + self.vision_end_token_id = getattr(processing_class, "vision_end_token_id", None) + # Get the image token string for token collapsing + self.image_token = None + if self.image_token_id is not None: + self.image_token = tokenizer.decode([self.image_token_id]) + + # Define the collator if not provided + if data_collator is None: + data_collator = DPODataCollatorWithPadding(pad_token_id=self.pad_token_id) + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # Add tags for models that have been loaded with the correct transformers version + if hasattr(self.model, "add_model_tags"): + self.model.add_model_tags(self._tag_names) + + self._beta = args.beta + + # Set up generation configuration and vLLM after super().__init__ + if self.use_vllm: + if not is_vllm_available(): + raise ImportError( + "vLLM is not available and `use_vllm` is set to True. Please install vLLM with " + "`pip install trl[vllm]` to use it." + ) + + if self.vllm_mode == "server": + if self.accelerator.is_main_process: + if args.vllm_server_base_url is not None: + base_url = args.vllm_server_base_url + else: + base_url = f"http://{args.vllm_server_host}:{args.vllm_server_port}" + self.vllm_client = VLLMClient( + base_url=base_url, group_port=args.vllm_group_port, connection_timeout=args.vllm_server_timeout + ) + + # Determine device type (supports cuda, xpu, etc.) + accelerator_type = torch.accelerator.current_accelerator().type + current_device = getattr(torch, accelerator_type).current_device() + self.vllm_client.init_communicator(device=current_device) + else: + self.vllm_client = None + elif self.vllm_mode == "colocate": + # vLLM dynamically adjusts the size of the key-value cache based on available GPU memory at instantiation. + # A larger cache size improves speed, so we would expect gpu_memory_utilization=1. + # However, at this stage, the optimizer's weights are not yet loaded onto the GPU; they will be loaded + # after the first optimizer step and remain in GPU memory throughout training. So we must reserve enough + # space for them. + # Configure vLLM parameters + vllm_quantization = None + if is_bitsandbytes_available(): + for _, module in model.named_modules(): + if isinstance(module, bnb.nn.Linear4bit): + vllm_quantization = "bitsandbytes" + break + elif isinstance(module, bnb.nn.Linear8bitLt): + raise ValueError("vLLM does not support in-flight 8-bit quantization.") + vllm_kwargs = { + "model": model.name_or_path, + "tensor_parallel_size": self.vllm_tensor_parallel_size, + "gpu_memory_utilization": self.vllm_gpu_memory_utilization, + "model_impl": self.vllm_model_impl, + "max_num_seqs": self.args.per_device_train_batch_size * self.vllm_tensor_parallel_size, + "max_model_len": args.max_length + args.max_new_tokens, # max_length includes prompt + completion + "distributed_executor_backend": "external_launcher", + # Feed identical seed for tp groups to ensure sampling results are the same across workers + "seed": self.accelerator.process_index // self.vllm_tensor_parallel_size, + # Latest vLLM v1 memory profiler is misled by the high default value (i.e., 32768) + "max_num_batched_tokens": 4096, + "enable_sleep_mode": self.args.vllm_enable_sleep_mode, + "quantization": vllm_quantization, + } + + # vLLM requires the environment variables to be set for distributed training. + os.environ["RANK"] = str(self.accelerator.process_index) + os.environ["LOCAL_RANK"] = str(self.accelerator.local_process_index) + os.environ["WORLD_SIZE"] = str(self.accelerator.num_processes) + # Ensure distributed rendezvous variables are set without colliding across concurrent runs + ensure_master_addr_port() + + self.llm = LLM(**vllm_kwargs) + if self.args.vllm_enable_sleep_mode: + self.llm.sleep(level=2) + else: + raise ValueError(f"vllm_mode must be either 'server' or 'colocate', got '{self.vllm_mode}'.") + # vLLM specific sampling arguments + self.structured_outputs_regex = args.vllm_structured_outputs_regex + self._last_loaded_step = -1 # tag to avoid useless loading during grad accumulation + + # Set up vLLM generation config + generation_kwargs = { + "n": 2, # 2 generations per prompt for Online DPO + "repetition_penalty": self.repetition_penalty, + "temperature": self.temperature, + "top_p": self.top_p, + "top_k": self.top_k, + "min_p": 0.0 if self.min_p is None else self.min_p, + "max_tokens": args.max_new_tokens, + "detokenize": False, # to avoid vllm to decode (we don't need it) + } + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + if self.structured_outputs_regex is not None: + if generation_kwargs.get("structured_outputs") is not None: + logger.warning( + "Both `vllm_structured_outputs_regex` and `generation_kwargs['structured_outputs']` are set; " + "`vllm_structured_outputs_regex` takes precedence." + ) + generation_kwargs["structured_outputs"] = StructuredOutputsParams(regex=self.structured_outputs_regex) + elif isinstance(structured_outputs_kwargs := generation_kwargs.get("structured_outputs"), dict): + generation_kwargs["structured_outputs"] = StructuredOutputsParams(**structured_outputs_kwargs) + self.generation_config = SamplingParams(**generation_kwargs) + + # When using vLLM, the main process is responsible for loading the model weights. This can cause process + # desynchronization and seems to lead to DeepSpeed hanging during initialization. To prevent this, we + # synchronize all processes after vLLM has been fully initialized. + self.accelerator.wait_for_everyone() + else: + # Set up transformers generation config + generation_kwargs = { + "max_new_tokens": args.max_new_tokens, + "do_sample": True, + "pad_token_id": self.pad_token_id, + "bos_token_id": tokenizer.bos_token_id, + "eos_token_id": self.eos_token_id, + "temperature": self.temperature, + "top_k": self.top_k, + "top_p": self.top_p, + "repetition_penalty": self.repetition_penalty, + "use_cache": True if not self.args.gradient_checkpointing else False, + } + # Add min_p if supported + if self.min_p is not None: + generation_kwargs["min_p"] = self.min_p + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + # Remove None values + generation_kwargs = {k: v for k, v in generation_kwargs.items() if v is not None} + self.generation_config = GenerationConfig(**generation_kwargs) + # Keep training-specific generation kwargs to overwrite model's original generation config + self.generation_kwargs = generation_kwargs + + if self.ref_model is not None: + if self.is_deepspeed_enabled: + self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) + elif self.is_fsdp_enabled: + self.ref_model = prepare_fsdp(self.ref_model, self.accelerator) + else: + self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) + if self.reward_funcs is not None: + for i, reward_func in enumerate(self.reward_funcs): + if isinstance(reward_func, PreTrainedModel): + if self.is_deepspeed_enabled: + self.reward_funcs[i] = prepare_deepspeed(reward_func, self.accelerator) + else: + # set device placement to True to make `prepare_model` move `reward_func` to device when using fsdp + self.reward_funcs[i] = self.accelerator.prepare_model( + reward_func, evaluation_mode=True, device_placement=True + ) + + @property + def beta(self): + if isinstance(self._beta, list): + epoch = self.state.epoch + return self._beta[epoch] if epoch < len(self._beta) else self._beta[-1] + else: + return self._beta + + @staticmethod + def tokenize_row(feature, is_encoder_decoder: bool, tokenizer: PreTrainedTokenizerBase) -> dict[str, Any]: + """Tokenize a single row from a DPO specific dataset.""" + if not is_encoder_decoder: + batch = tokenizer(feature["prompt"], add_special_tokens=False) + # Add BOS token to head of prompt. Avoid adding if it's already there + if tokenizer.bos_token_id is not None: + prompt_len_input_ids = len(batch["input_ids"]) + if prompt_len_input_ids == 0 or tokenizer.bos_token_id != batch["input_ids"][0]: + batch["input_ids"] = [tokenizer.bos_token_id] + batch["input_ids"] + batch["attention_mask"] = [1] + batch["attention_mask"] + else: + batch = tokenizer(feature["prompt"], add_special_tokens=True) + batch = {f"prompt_{key}": value for key, value in batch.items()} + return batch + + def _enable_gradient_checkpointing(self, model: PreTrainedModel, args: OnlineDPOConfig) -> PreTrainedModel: + """Enables gradient checkpointing for the model.""" + # Ensure use_cache is disabled + model.config.use_cache = False + + # Enable gradient checkpointing on the base model for PEFT + if is_peft_model(model): + model.base_model.gradient_checkpointing_enable() + # Enable gradient checkpointing for non-PEFT models + else: + model.gradient_checkpointing_enable() + + model.enable_input_require_grads() + return model + + def _generate_vllm(self, prompts, images=None): + eos_token_id = self.eos_token_id + pad_token_id = self.pad_token_id + + # Generate completion_ids and prompt_ids based on mode + if self.vllm_mode == "server": + completion_ids, prompt_ids = self._generate_vllm_server(prompts, images) + elif self.vllm_mode == "colocate": + completion_ids, prompt_ids = self._generate_vllm_colocate(prompts, images) + + # Shared padding, masking, and tensor conversion logic + max_prompt_length = max(len(ids) for ids in prompt_ids) + prompt_mask = [[0] * (max_prompt_length - len(ids)) + [1] * len(ids) for ids in prompt_ids] + prompt_ids = [[pad_token_id] * (max_prompt_length - len(ids)) + ids for ids in prompt_ids] + max_tokens = self.generation_config.max_tokens + completion_mask = [[1] * len(ids) + [0] * (max_tokens - len(ids)) for ids in completion_ids] + completion_ids = [ + ids + [eos_token_id] if ids[-1] != eos_token_id and len(ids) < max_tokens else ids + for ids in completion_ids + ] + completion_ids = [ids + [pad_token_id] * (max_tokens - len(ids)) for ids in completion_ids] + + # Convert to tensors + prompt_ids = torch.tensor(prompt_ids, device=self.accelerator.device) + prompt_mask = torch.tensor(prompt_mask, device=self.accelerator.device) + completion_ids = torch.tensor(completion_ids, device=self.accelerator.device) + completion_mask = torch.tensor(completion_mask, device=self.accelerator.device) + + return prompt_ids, prompt_mask, completion_ids, completion_mask + + def _generate_vllm_server(self, prompts, images=None): + """Generate completions using vLLM server mode""" + has_images = images is not None + + # Update vLLM server weights if needed + if hasattr(self, "_last_loaded_step") and self.state.global_step != self._last_loaded_step: + self._move_model_to_vllm() + self._last_loaded_step = self.state.global_step + elif not hasattr(self, "_last_loaded_step"): + self._move_model_to_vllm() + self._last_loaded_step = self.state.global_step + + # Apply chat template if conversational + if is_conversational({"prompt": prompts[0]}): + prompts_text = [apply_chat_template({"prompt": p}, self.processing_class)["prompt"] for p in prompts] + else: + prompts_text = prompts + # Gather all prompts to main process + all_prompts = gather_object(prompts_text) + if has_images: + all_images = gather_object(images) + + if self.accelerator.is_main_process: + # Since 'prompts' contains 'num_generations' duplicates, we first take unique prompts, and generate + # num_generations outputs for each one. This is faster than generating outputs for each duplicate + # prompt individually. + ordered_set_of_prompts = all_prompts[:: self.num_generations] + if has_images: + ordered_set_of_images = [ + [img] if img is not None else None for img in all_images[:: self.num_generations] + ] + else: + ordered_set_of_images = None + completion_ids = self.vllm_client.generate( + prompts=ordered_set_of_prompts, + images=ordered_set_of_images, + n=self.num_generations, + repetition_penalty=self.repetition_penalty, + temperature=self.temperature, + top_p=self.top_p, + top_k=-1 if self.top_k is None else self.top_k, + min_p=0.0 if self.min_p is None else self.min_p, + max_tokens=self.generation_config.max_tokens, + structured_outputs_regex=self.structured_outputs_regex + if hasattr(self, "structured_outputs_regex") + else None, + generation_kwargs=self.args.generation_kwargs, + )["completion_ids"] + # Flatten: each prompt generates 2 completions + completion_ids = [[comp_id] for prompt_completions in completion_ids for comp_id in prompt_completions] + else: + completion_ids = [None] * (len(all_prompts) * 2) + + # Broadcast completions to all processes + completion_ids = broadcast_object_list(completion_ids, from_process=0) + + # Each process takes its slice + process_slice = slice( + self.accelerator.process_index * len(prompts) * 2, + (self.accelerator.process_index + 1) * len(prompts) * 2, + ) + completion_ids = completion_ids[process_slice] + + # Create prompt_ids by tokenizing locally + prompt_inputs = self.processing_class( + text=prompts_text, + return_tensors="pt", + padding=True, + padding_side="left", + add_special_tokens=False, + ) + prompt_ids = [] + for prompt_tokens in prompt_inputs["input_ids"]: + prompt_ids.extend([prompt_tokens.tolist(), prompt_tokens.tolist()]) # 2 copies for 2 completions + return completion_ids, prompt_ids + + def _generate_vllm_colocate(self, prompts, images=None): + """Generate completions using vLLM colocate mode""" + if self.args.vllm_enable_sleep_mode: + # wake up colocated vLLM instances if needed + torch.cuda.empty_cache() # required to avoid OOM in some cases + self.llm.wake_up(tags=["weights"]) + + # Update model weights if needed - only after gradient accumulation completes + if self.state.global_step != self._last_loaded_step: + self._move_model_to_vllm() + self._last_loaded_step = self.state.global_step + + # Apply chat template if conversational + if is_conversational({"prompt": prompts[0]}): + prompts_text = [apply_chat_template({"prompt": p}, self.processing_class)["prompt"] for p in prompts] + else: + prompts_text = prompts + + # Prepare vLLM inputs with images if available + if images is not None: + vllm_inputs = [] + for prompt, image in zip(prompts_text, images, strict=True): + if image is not None: + vllm_inputs.append({"prompt": prompt, "multi_modal_data": {"image": image}}) + else: + vllm_inputs.append(prompt) + else: + vllm_inputs = prompts_text + + if self.args.vllm_enable_sleep_mode: + self.llm.wake_up(tags=["kv_cache"]) + + outputs = self.llm.generate(vllm_inputs, self.generation_config, use_tqdm=False) + + completion_ids = [list(output.outputs[i].token_ids) for i in range(2) for output in outputs] + prompt_ids = [list(output.prompt_token_ids) for _ in range(2) for output in outputs] + if self.args.vllm_enable_sleep_mode: + self.llm.sleep(level=2) + + return completion_ids, prompt_ids + + def _sync_fsdp2_params_to_vllm(self, module: nn.Module): + # For FSDP2, module.state_dict() already covers all parameters, so no need for recursion + for name, param in module.state_dict().items(): + # When using PEFT, we need to recover the original parameter name + name = name.removeprefix("base_model.model.").replace(".base_layer", "") + # Skip PEFT layers: they don’t exist in vLLM, and they are merged already. + if is_peft_model(module) and module.prefix in name: + continue + # When module to save, remove its prefix and discard the original module + if "original_module" in name: + continue + name = self._fix_param_name_to_vllm(name, extra_prefixes=["modules_to_save.default."]) + + if param.is_cpu: + param = param.to(torch.device("cuda")) + param = param.full_tensor() + + if self.vllm_mode == "server" and self.accelerator.is_main_process: + self.vllm_client.update_named_param(name, param) + elif self.vllm_mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(name, param)]) + + def _move_model_to_vllm(self): + # For DeepSpeed ZeRO-3 and FSDP, we need to gather all parameters before operations + deepspeed_plugin = self.accelerator.state.deepspeed_plugin + zero_stage_3 = deepspeed_plugin is not None and deepspeed_plugin.zero_stage == 3 + if zero_stage_3: + import deepspeed + + gather_if_zero3 = deepspeed.zero.GatheredParameters + else: + gather_if_zero3 = nullcontext + + if is_peft_model(self.model): + # With PEFT and FSDP/DeepSpeed ZeRO Stage 3, we must gather the full model at once before merging, as + # merging adapters in a sharded manner is not supported. + # TODO: does this work with FSDP? + with gather_if_zero3(list(self.model.parameters())): + self.model.merge_adapter() + + # Update vLLM weights while parameters are gathered + if self.is_fsdp_enabled: # note if using FSDP, gather_if_zero3 is nullcontext + # Update vLLM weights while parameters are gathered + # For PEFT with FSDP we need to use the memory efficient post-order traversal + fsdp_plugin = getattr(self.accelerator.state, "fsdp_plugin", None) + fsdp_version = getattr(fsdp_plugin, "fsdp_version", 1) if fsdp_plugin else 1 + if fsdp_version == 1: + self._sync_fsdp1_params_to_vllm( + self.model + ) # use memory-efficient post-order traversal for FSDP + elif fsdp_version == 2: + self._sync_fsdp2_params_to_vllm(self.model) + else: + # DeepSpeed ZeRO-3 with PEFT + for name, param in self.model.named_parameters(): + # When using PEFT, we need to recover the original parameter name + name = name.removeprefix("base_model.model.").replace(".base_layer", "") + # Skip PEFT layers: they don’t exist in vLLM, and they are merged already. + if self.model.prefix in name: + continue + # When module to save, remove its prefix and discard the original module + if "original_module" in name: + continue + name = self._fix_param_name_to_vllm(name, extra_prefixes=["modules_to_save.default."]) + + if self.vllm_mode == "server" and self.accelerator.is_main_process: + self.vllm_client.update_named_param(name, param.data) + elif self.vllm_mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(name, param.data)]) + # Unmerge adapters while parameters are still gathered + self.model.unmerge_adapter() + # Parameters will automatically be repartitioned when exiting the context + else: + # For non-PEFT models, simply gather (if needed) and update each parameter individually. + if self.is_fsdp_enabled: + fsdp_plugin = getattr(self.accelerator.state, "fsdp_plugin", None) + fsdp_version = getattr(fsdp_plugin, "fsdp_version", 1) if fsdp_plugin else 1 + if fsdp_version == 1: + self._sync_fsdp1_params_to_vllm(self.model) # use memory-efficient post-order traversal for FSDP + elif fsdp_version == 2: + self._sync_fsdp2_params_to_vllm(self.model) + else: + for name, param in self.model.named_parameters(): + name = self._fix_param_name_to_vllm(name) + with gather_if_zero3([param]): + if self.vllm_mode == "server" and self.accelerator.is_main_process: + self.vllm_client.update_named_param(name, param.data) + elif self.vllm_mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(name, param.data)]) + + # Reset cache on vLLM + if self.vllm_mode == "server" and self.accelerator.is_main_process: + self.vllm_client.reset_prefix_cache() + elif self.vllm_mode == "colocate": + self.llm.reset_prefix_cache() + + def _sync_fsdp1_params_to_vllm(self, module: nn.Module, prefix: str = "", visited=None): + """Memory-efficient post-order traversal of FSDP modules to extract full parameters and sync with vLLM.""" + # For FSDP1, we need to recurse into children and also use summon_full_params + if visited is None: + visited = set() + for child_name, child_module in module.named_children(): + child_prefix = f"{prefix}.{child_name}" if prefix else child_name + self._sync_fsdp1_params_to_vllm( + child_module, prefix=child_prefix, visited=visited + ) # recurse into the child + + if isinstance(module, FSDP): + with FSDP.summon_full_params(module, recurse=False, writeback=False): + for param_name, param in module.named_parameters(): + full_name = f"{prefix}.{param_name}" if prefix else param_name + full_name = self._fix_param_name_to_vllm(full_name, extra_prefixes=["_fsdp_wrapped_module."]) + + if full_name in visited: + continue # skip FSDP subtrees already traversed + visited.add(full_name) + + if self.vllm_mode == "server" and self.accelerator.is_main_process: + self.vllm_client.update_named_param(full_name, param.data) + elif self.vllm_mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(full_name, param.data)]) + + def _fix_param_name_to_vllm(self, name, extra_prefixes: list[str] | None = None): + """Clean parameter names for vLLM compatibility""" + extra_prefixes = extra_prefixes or [] + prefixes = ["_checkpoint_wrapped_module."] + extra_prefixes + for prefix in prefixes: + name = name.replace(prefix, "") + return name + + def process_vision_row( + self, features: dict[str, list | torch.Tensor], processing_class=None + ) -> dict[str, list[int]]: + """ + Process a vision row for VLM models (adapted from DPO trainer) + """ + processor = processing_class or self.processing_class + processed_features = processor(images=[features["image"]], text=features["prompt"], add_special_tokens=False) + + prompt_input_ids = processed_features["input_ids"][0] + + # Create the output dict with required fields + output = { + "prompt_input_ids": prompt_input_ids, + "prompt_attention_mask": processed_features["attention_mask"][0], + } + + # Add vision-specific fields + if "pixel_values" in processed_features: + output["pixel_values"] = processed_features["pixel_values"][0] + if "pixel_attention_mask" in processed_features: + output["pixel_attention_mask"] = processed_features["pixel_attention_mask"][0] + if "image_sizes" in processed_features: + output["image_sizes"] = processed_features["image_sizes"][0] + + return output + + def _generate(self, model, prompts, images=None): + """Generate completions using the model""" + device = next(model.parameters()).device + eos_token_id = self.eos_token_id + pad_token_id = self.pad_token_id + + # Apply chat template and tokenize the input + inputs = [{"prompt": prompt} for prompt in prompts] + + # Add images if provided (VLM support) + if images is not None: + for i, image in enumerate(images): + inputs[i]["image"] = image + + # Apply chat template to get text prompts + prompts_text = [maybe_apply_chat_template(x, self.processing_class)["prompt"] for x in inputs] + + # Handle image token collapsing/removal + # The chat template sometimes inserts a single image token into the prompt text. However, when this text is + # later tokenized, the single image token string is expanded into multiple image token IDs, depending on the + # image size. We need to handle this properly. + if self.image_token is not None and images is not None: + escaped_img_token = re.escape(self.image_token) + # Search for the image token in the chat template + if hasattr(self.processing_class, "chat_template") and self.processing_class.chat_template: + if re.search(escaped_img_token, self.processing_class.chat_template): + # Collapse repeated image tokens back into a single token + prompts_text = [ + re.sub(rf"({escaped_img_token})+", self.image_token, text) for text in prompts_text + ] + else: + # If the chat template doesn't use the image token, remove all instances + if self.vision_end_token_id is not None: + escaped_eoi_token = re.escape( + self.processing_class.tokenizer.decode([self.vision_end_token_id]) + ) + prompts_text = [ + re.sub(rf"({escaped_img_token})+{escaped_eoi_token}", "", text) for text in prompts_text + ] + else: + # If vision_end_token_id is None, just remove the image tokens + prompts_text = [re.sub(rf"({escaped_img_token})+", "", text) for text in prompts_text] + + # Prepare kwargs for processing class + kwargs = {} + if images is not None: + kwargs = {"images": [[img] for img in images]} + + # Process inputs using the processing class (handles both VLM and LLM) + prompt_inputs = self.processing_class( + text=prompts_text, + return_tensors="pt", + padding=True, + padding_side="left", + add_special_tokens=False, + **kwargs, + ) + + prompt_inputs = {k: v.to(device) for k, v in prompt_inputs.items()} + # Convert vision inputs to model's dtype for proper computation + if "pixel_values" in prompt_inputs: + # Handle DataParallel wrapped models + model_dtype = getattr(model, "dtype", None) + if model_dtype is None and hasattr(model, "module"): + model_dtype = model.module.dtype + if model_dtype is not None: + prompt_inputs["pixel_values"] = prompt_inputs["pixel_values"].to(model_dtype) + + # Sample 2 completions per prompt of size `max_new_tokens` from the model + prompt_ids = prompt_inputs["input_ids"].repeat(2, 1) + prompt_mask = prompt_inputs["attention_mask"].repeat(2, 1) + + # Prepare vision inputs if available + vision_generation_kwargs = {} + if self.is_vision_model and images is not None: + if "pixel_values" in prompt_inputs: + vision_generation_kwargs["pixel_values"] = prompt_inputs["pixel_values"].repeat(2, 1, 1, 1) + if "pixel_attention_mask" in prompt_inputs: + vision_generation_kwargs["pixel_attention_mask"] = prompt_inputs["pixel_attention_mask"].repeat(2, 1) + if "image_sizes" in prompt_inputs: + vision_generation_kwargs["image_sizes"] = prompt_inputs["image_sizes"].repeat(2, 1) + if "image_grid_thw" in prompt_inputs: + vision_generation_kwargs["image_grid_thw"] = prompt_inputs["image_grid_thw"].repeat(2, 1) + + with ( + profiling_context(self, "transformers.generate"), + unwrap_model_for_generation( + model, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model, + torch.no_grad(), + FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), + ): + # Setup cache implementation if specified + if self.args.cache_implementation is not None: + unwrapped_model.generation_config.cache_implementation = self.args.cache_implementation + + # Standard generation + output = unwrapped_model.generate( + input_ids=prompt_ids, + attention_mask=prompt_mask, + generation_config=self.generation_config, + **vision_generation_kwargs, + ) + + completion_ids = output[:, prompt_ids.size(1) :] + completion_ids, completion_mask = truncate_right(completion_ids, eos_token_id, pad_token_id) + + return prompt_ids, prompt_mask, completion_ids, completion_mask + + def _calculate_rewards_from_functions(self, prompts, completions, completion_ids_list, **reward_kwargs): + """ + Calculate rewards using reward functions + """ + device = self.accelerator.device + rewards_per_func = torch.zeros(len(prompts), len(self.reward_funcs), device=device) + + # Add trainer state to reward kwargs for dynamic reward shaping + reward_kwargs["trainer_state"] = self.state + + for i, (reward_func, reward_processing_class) in enumerate( + zip(self.reward_funcs, self.reward_processing_classes, strict=True) + ): + if isinstance(reward_func, nn.Module): # Model-based reward function + # Handle conversational vs text input + if is_conversational({"prompt": prompts[0]}): + messages = [{"messages": p + c} for p, c in zip(prompts, completions, strict=True)] + texts = [apply_chat_template(x, reward_processing_class)["text"] for x in messages] + else: + texts = [p + c for p, c in zip(prompts, completions, strict=True)] + + # Tokenize and get reward scores + reward_inputs = reward_processing_class( + text=texts, return_tensors="pt", padding=True, padding_side="right", add_special_tokens=False + ) + reward_inputs = {k: v.to(device) for k, v in reward_inputs.items()} + + with torch.inference_mode(): + rewards_per_func[:, i] = reward_func(**reward_inputs).logits[:, 0] # Shape (B*G,) + else: + # Custom reward function + output_reward_func = reward_func( + prompts=prompts, completions=completions, completion_ids=completion_ids_list, **reward_kwargs + ) + # Convert None values to NaN + output_reward_func = [reward if reward is not None else torch.nan for reward in output_reward_func] + rewards_per_func[:, i] = torch.tensor(output_reward_func, dtype=torch.float32, device=device) + + # Weight and sum across all reward functions + if self.reward_weights is not None: + total_rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + else: + total_rewards = rewards_per_func.nansum(dim=1) + + return total_rewards + + def _forward(self, model, prompt_ids, prompt_mask, completion_ids, completion_mask, vision_inputs=None): + # Get the number of tokens to truncate from prompt + num_tokens_to_truncate = max(prompt_ids.size(1) + completion_ids.size(1) - self.max_length, 0) + + # Truncate left to avoid oom + prompt_ids = prompt_ids[:, num_tokens_to_truncate:] + prompt_mask = prompt_mask[:, num_tokens_to_truncate:] + + # Concat the prompt and completion + prompt_completion_ids = torch.cat((prompt_ids, completion_ids), dim=1) + prompt_completion_mask = torch.cat((prompt_mask, completion_mask), dim=1) + + # Prepare model kwargs with vision inputs if available + model_kwargs = {"attention_mask": prompt_completion_mask} + if vision_inputs is not None: + if "pixel_values" in vision_inputs: + model_kwargs["pixel_values"] = vision_inputs["pixel_values"] + if "pixel_attention_mask" in vision_inputs: + model_kwargs["pixel_attention_mask"] = vision_inputs["pixel_attention_mask"] + if "image_sizes" in vision_inputs: + model_kwargs["image_sizes"] = vision_inputs["image_sizes"] + if "image_grid_thw" in vision_inputs: + model_kwargs["image_grid_thw"] = vision_inputs["image_grid_thw"] + + # Get the logprobs of the completions from the model + output = model(prompt_completion_ids, **model_kwargs) + + # There is 1 offset, because the model predicts the next token + prompt_len = prompt_ids.size(1) + start_idx = prompt_len - 1 if prompt_len > 0 else 0 + # Only slice off the last logit when we have a prompt, otherwise we need all logits + end_idx = -1 if prompt_len > 0 else None + logits = output.logits[:, start_idx:end_idx] + + # Take the completion tokens logprob + logprobs = torch.take_along_dim(logits.log_softmax(dim=-1), completion_ids.unsqueeze(-1), dim=2).squeeze(-1) + return logprobs + + def training_step( + self, model: nn.Module, inputs: dict[str, torch.Tensor | Any], num_items_in_batch: int | None = None + ) -> torch.Tensor: + model.train() + + prompts = inputs["prompt"] + batch_size = len(prompts) + + # Handle images for VLM support + has_images = "image" in inputs + images = None + if has_images: + images = inputs["image"] + # Convert conversational prompts to include image tokens + for prompt in prompts: + if isinstance(prompt, list): + for message in prompt: + if not isinstance(message, dict): + continue + content = message.get("content") + role = message.get("role") + if isinstance(content, str): + if role == "user": + message["content"] = [{"type": "image"}, {"type": "text", "text": content}] + elif role == "system": + message["content"] = [{"type": "text", "text": content}] + + if self.args.use_vllm: + prompt_ids, prompt_mask, completion_ids, completion_mask = self._generate_vllm(prompts, images) + else: + prompt_ids, prompt_mask, completion_ids, completion_mask = self._generate(model, prompts, images) + + contain_eos_token = torch.any(completion_ids == self.eos_token_id, dim=-1) + + # Extract vision inputs if available for VLM support + vision_inputs = None + if has_images and self.is_vision_model and not self.args.use_vllm: + # For vision models with transformers generation, we need to prepare vision inputs + # Process the images to get vision inputs that can be passed through the forward pass + vision_inputs = {} + kwargs = {"images": [[img] for img in images]} + processed = self.processing_class( + text=[""] * len(images), # Dummy text for vision processing + return_tensors="pt", + **kwargs, + ) + # Handle DataParallel wrapped models + model_device = getattr(model, "device", None) + model_dtype = getattr(model, "dtype", None) + if model_device is None and hasattr(model, "module"): + model_device = model.module.device + model_dtype = model.module.dtype + # Move vision tensors to device and convert to model dtype + # Need to duplicate for 2 completions per prompt + if "pixel_values" in processed: + vision_inputs["pixel_values"] = ( + processed["pixel_values"].to(model_device, dtype=model_dtype).repeat(2, 1, 1, 1) + ) + if "pixel_attention_mask" in processed: + vision_inputs["pixel_attention_mask"] = processed["pixel_attention_mask"].to(model_device).repeat(2, 1) + if "image_sizes" in processed: + vision_inputs["image_sizes"] = processed["image_sizes"].to(model_device).repeat(2, 1) + if "image_grid_thw" in processed: + vision_inputs["image_grid_thw"] = processed["image_grid_thw"].to(model_device).repeat(2, 1) + + logprobs = self._forward(model, prompt_ids, prompt_mask, completion_ids, completion_mask, vision_inputs) + with torch.no_grad(): + if self.ref_model is not None: + ref_logprobs = self._forward( + self.ref_model, prompt_ids, prompt_mask, completion_ids, completion_mask, vision_inputs + ) + else: # peft case: we just need to disable the adapter + with self.model.disable_adapter(): + ref_logprobs = self._forward( + self.model, prompt_ids, prompt_mask, completion_ids, completion_mask, vision_inputs + ) + + # Decode the completions, and format them if the input is conversational + device = logprobs.device + completions = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + if is_conversational({"prompt": prompts[0]}): + completions = [[{"role": "assistant", "content": completion}] for completion in completions] + + # Get the reward from reward functions + # First create completion_ids_list for custom reward functions + completion_ids_list = [completion_ids[i].tolist() for i in range(completion_ids.shape[0])] + + # Extract additional fields from inputs for reward functions + reward_kwargs = {} + keys = [key for key in inputs if key not in ["prompt"]] + for key in keys: + if isinstance(inputs[key], (list, tuple)): + # Repeat input fields to match number of completions (2 per prompt) + reward_kwargs[key] = inputs[key] * 2 + else: + reward_kwargs[key] = inputs[key] + + # Calculate rewards using reward functions + rewards = self._calculate_rewards_from_functions( + prompts=2 * prompts, completions=completions, completion_ids_list=completion_ids_list, **reward_kwargs + ) + + # Apply missing EOS penalty if configured + if self.args.missing_eos_penalty is not None: + rewards[~contain_eos_token] -= self.args.missing_eos_penalty + + # Split rewards into chosen/rejected pairs + first_half, second_half = rewards.split(batch_size) + mask = first_half >= second_half + + batch_range = torch.arange(batch_size, device=device) + chosen_indices = batch_range + (~mask * batch_size) + rejected_indices = batch_range + (mask * batch_size) + + # Build tensor so that the first half is the chosen examples and the second half the rejected examples + cr_indices = torch.cat((chosen_indices, rejected_indices), dim=0) # cr = chosen and rejected + cr_logprobs = logprobs[cr_indices] + cr_ref_logprobs = ref_logprobs[cr_indices] + + # mask out the padding tokens + padding_mask = ~completion_mask.bool() + cr_padding_mask = padding_mask[cr_indices] + + cr_logprobs_sum = (cr_logprobs * ~cr_padding_mask).sum(1) + cr_ref_logprobs_sum = (cr_ref_logprobs * ~cr_padding_mask).sum(1) + + # Split the chosen and rejected examples + chosen_logprobs_sum, rejected_logprobs_sum = torch.split(cr_logprobs_sum, batch_size) + chosen_ref_logprobs_sum, rejected_ref_logprobs_sum = torch.split(cr_ref_logprobs_sum, batch_size) + pi_logratios = chosen_logprobs_sum - rejected_logprobs_sum + ref_logratios = chosen_ref_logprobs_sum - rejected_ref_logprobs_sum + + logits = pi_logratios - ref_logratios + + if self.args.loss_type == "sigmoid": + losses = -F.logsigmoid(self.beta * logits) + elif self.args.loss_type == "ipo": + losses = (logits - 1 / (2 * self.beta)) ** 2 + else: + raise NotImplementedError(f"invalid loss type {self.args.loss_type}") + + loss = losses.mean() + + # Log everything + if self.reward_funcs is not None: + # When using reward_funcs, we have rewards instead of scores + scores_margin = rewards[chosen_indices] - rewards[rejected_indices] + self.stats["objective/scores_margin"].append( + self.accelerator.gather_for_metrics(scores_margin.mean()).mean().item() + ) + self.stats["objective/scores"].append(self.accelerator.gather_for_metrics(rewards.mean()).mean().item()) + self.stats["val/contain_eos_token"].append(contain_eos_token.float().mean().item()) + self.stats["logps/chosen"].append(self.accelerator.gather_for_metrics(chosen_logprobs_sum).mean().item()) + self.stats["logps/rejected"].append(self.accelerator.gather_for_metrics(rejected_logprobs_sum).mean().item()) + + kl = logprobs - ref_logprobs + mean_kl = kl.sum(1).mean() + self.stats["objective/kl"].append(self.accelerator.gather_for_metrics(mean_kl).mean().item()) + non_score_reward = (-self.beta * kl).sum(1) + mean_non_score_reward = non_score_reward.mean() + self.stats["objective/non_score_reward"].append( + self.accelerator.gather_for_metrics(mean_non_score_reward).mean().item() + ) + if self.reward_funcs is not None: + # Calculate RLHF reward by combining rewards with non_score_reward + rlhf_reward = rewards + non_score_reward + self.stats["objective/rlhf_reward"].append(self.accelerator.gather_for_metrics(rlhf_reward).mean().item()) + + mean_entropy = -logprobs.sum(1).mean() + self.stats["objective/entropy"].append(self.accelerator.gather_for_metrics(mean_entropy).mean().item()) + chosen_rewards = self.beta * (chosen_logprobs_sum - chosen_ref_logprobs_sum) + gathered_chosen_rewards = self.accelerator.gather_for_metrics(chosen_rewards) + self.stats["rewards/chosen"].append(gathered_chosen_rewards.mean().item()) + rejected_rewards = self.beta * (rejected_logprobs_sum - rejected_ref_logprobs_sum) + gathered_rejected_rewards = self.accelerator.gather_for_metrics(rejected_rewards) + self.stats["rewards/rejected"].append(gathered_rejected_rewards.mean().item()) + margin = gathered_chosen_rewards - gathered_rejected_rewards + self.stats["rewards/margins"].append(margin.mean().item()) + accuracy = margin > 0 + self.stats["rewards/accuracies"].append(accuracy.float().mean().item()) + self.stats["beta"].append(self.beta) + + if ( + self.args.torch_empty_cache_steps is not None + and self.state.global_step % self.args.torch_empty_cache_steps == 0 + ): + empty_cache() + + kwargs = {} + + # For LOMO optimizers you need to explicitly use the learning rate + if self.args.optim in [OptimizerNames.LOMO, OptimizerNames.ADALOMO]: + kwargs["learning_rate"] = self._get_learning_rate() + + if self.args.n_gpu > 1: + loss = loss.mean() # mean() to average on multi-gpu parallel training + + self.accelerator.backward(loss, **kwargs) + + return loss.detach() / self.args.gradient_accumulation_steps + + # Same as Trainer._maybe_log_save_evaluate but log our metrics + def _maybe_log_save_evaluate( + self, tr_loss, grad_norm, model, trial, epoch, ignore_keys_for_eval, start_time, learning_rate=None + ): + if self.control.should_log and self.state.global_step > self._globalstep_last_logged: + logs: dict[str, float] = {} + + # all_gather + mean() to get average loss over all processes + if Version(transformers.__version__) >= Version("5.2.0"): + tr_loss_scalar = nested_gather(tr_loss, self.args.parallel_mode).mean().item() + else: + tr_loss_scalar = self._nested_gather(tr_loss).mean().item() + + # reset tr_loss to zero + tr_loss -= tr_loss + + logs["loss"] = round(tr_loss_scalar / (self.state.global_step - self._globalstep_last_logged), 4) + if grad_norm is not None: + logs["grad_norm"] = grad_norm.detach().item() if isinstance(grad_norm, torch.Tensor) else grad_norm + if learning_rate is not None: + logs["learning_rate"] = learning_rate + else: + logs["learning_rate"] = self._get_learning_rate() + + # Add our metrics + for key, val in self.stats.items(): + logs[key] = sum(val) / len(val) + self.stats = {key: [] for key in self.stats} # reset stats + + self._total_loss_scalar += tr_loss_scalar + self._globalstep_last_logged = self.state.global_step + self.store_flos() + self.log(logs, start_time) + + metrics = None + if self.control.should_evaluate: + metrics = self._evaluate(trial, ignore_keys_for_eval) + is_new_best_metric = self._determine_best_metric(metrics=metrics, trial=trial) + + if self.args.save_strategy == "best": + self.control.should_save = is_new_best_metric + + if self.control.should_save: + self._save_checkpoint(model, trial) + self.control = self.callback_handler.on_save(self.args, self.state, self.control) + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/openenv/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/openenv/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4325e17f284102bd02848b432cd9d9ffedd32f58 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/openenv/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .utils import generate_rollout_completions + + +__all__ = ["generate_rollout_completions"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/openenv/utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/openenv/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..f8f4d573854a4fa9cf93fb8f7a354d54c7fad0c9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/openenv/utils.py @@ -0,0 +1,214 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Any + +import torch + +from ...data_utils import is_conversational +from ...extras.profiling import profiling_context +from ...import_utils import is_vllm_available + + +if is_vllm_available(): + from vllm import SamplingParams + from vllm.sampling_params import StructuredOutputsParams + + +def _build_base_generation_kwargs( + trainer, + overrides: dict[str, Any] | None = None, +) -> dict[str, Any]: + """Build base generation kwargs common to both colocate and server modes.""" + generation_kwargs: dict[str, Any] = { + "n": 1, + "temperature": trainer.temperature, + "top_k": trainer.top_k, + "min_p": 0.0 if trainer.min_p is None else trainer.min_p, + "max_tokens": trainer.max_completion_length, + } + if trainer.repetition_penalty is not None: + generation_kwargs["repetition_penalty"] = trainer.repetition_penalty + if trainer.top_p is not None: + generation_kwargs["top_p"] = trainer.top_p + + if trainer.args.generation_kwargs is not None: + generation_kwargs.update(trainer.args.generation_kwargs) + + if overrides is not None: + generation_kwargs.update(overrides) + + generation_kwargs = {key: value for key, value in generation_kwargs.items() if value is not None} + + if generation_kwargs.get("n", 1) != 1: + raise ValueError("generate_rollout_completions expects n=1.") + + return generation_kwargs + + +def _build_colocate_sampling_params( + trainer, + overrides: dict[str, Any] | None = None, + *, + logprobs: bool = True, +) -> "SamplingParams": + """Build SamplingParams for colocate mode.""" + generation_kwargs = _build_base_generation_kwargs(trainer, overrides) + + # Add colocate-specific parameters + if trainer.vllm_generation.structured_outputs_regex: + generation_kwargs["structured_outputs"] = StructuredOutputsParams( + regex=trainer.vllm_generation.structured_outputs_regex + ) + if logprobs: + generation_kwargs["logprobs"] = 0 + + return SamplingParams(**generation_kwargs) + + +def _build_server_generation_kwargs( + trainer, + overrides: dict[str, Any] | None = None, +) -> dict[str, Any]: + """Build generation kwargs for server mode.""" + return _build_base_generation_kwargs(trainer, overrides) + + +def generate_rollout_completions( + trainer, + prompts: list[str], + *, + generation_overrides: dict[str, Any] | None = None, + as_chat: bool | None = None, +) -> list[dict[str, Any]]: + """ + Generate completions for custom rollouts when vLLM is running in colocate or server mode. + + Returns one result per prompt, containing prompt and completion token ids along with per-token log probabilities + and the generated text. + """ + + if not prompts: + return [] + + if not trainer.use_vllm: + raise RuntimeError("Custom rollouts require vLLM to call generate_rollout_completions.") + + if trainer.vllm_mode == "server": + return _generate_rollout_completions_server(trainer, prompts, generation_overrides, as_chat) + elif trainer.vllm_mode == "colocate": + return _generate_rollout_completions_colocate(trainer, prompts, generation_overrides, as_chat) + else: + raise ValueError(f"vllm_mode must be 'server' or 'colocate', got '{trainer.vllm_mode}'") + + +def _generate_rollout_completions_server( + trainer, + prompts: list[str], + generation_overrides: dict[str, Any] | None = None, + as_chat: bool | None = None, +) -> list[dict[str, Any]]: + """Generate completions using vLLM server mode.""" + generation_kwargs = _build_server_generation_kwargs(trainer, generation_overrides) + + if as_chat is None: + as_chat = prompts and is_conversational({"prompt": prompts[0]}) + + with profiling_context(trainer, "vLLM.generate_rollout_server"): + if as_chat: + # Prompts are raw message dicts; use .chat() so the vLLM server applies the chat template + output = trainer.vllm_generation.vllm_client.chat( + messages=prompts, + **generation_kwargs, + chat_template_kwargs=trainer.chat_template_kwargs, + tools=trainer.tools or None, + chat_template=trainer.chat_template, + ) + else: + output = trainer.vllm_generation.vllm_client.generate(prompts=prompts, **generation_kwargs) + + # Format results to match colocate output format + results: list[dict[str, Any]] = [] + for i in range(len(prompts)): + results.append( + { + "prompt_ids": output["prompt_ids"][i], + "completion_ids": list(output["completion_ids"][i]), + "logprobs": list(output["logprobs"][i]), + "text": trainer.processing_class.decode(output["completion_ids"][i], skip_special_tokens=True), + } + ) + + return results + + +def _generate_rollout_completions_colocate( + trainer, + prompts: list[str], + generation_overrides: dict[str, Any] | None = None, + as_chat: bool | None = None, +) -> list[dict[str, Any]]: + """Generate completions using vLLM colocate mode.""" + sampling_params = _build_colocate_sampling_params(trainer, generation_overrides) + prompts_for_generation = prompts + original_size = len(prompts) + + if trainer.vllm_tensor_parallel_size > 1: + gathered_prompts = [None for _ in range(trainer.vllm_tensor_parallel_size)] + torch.distributed.all_gather_object(gathered_prompts, prompts, group=trainer.vllm_generation.tp_group) + prompts_for_generation = [prompt for group_prompts in gathered_prompts for prompt in group_prompts] + + if as_chat is None: + as_chat = prompts_for_generation and is_conversational({"prompt": prompts_for_generation[0]}) + + if trainer.args.vllm_enable_sleep_mode: + trainer.vllm_generation.llm.wake_up(tags=["kv_cache"]) + # Work around for https://github.com/vllm-project/vllm/issues/29341 + trainer.vllm_generation.llm.collective_rpc("reload_weights") + + with profiling_context(trainer, "vLLM.generate_rollout"): + if as_chat: + vllm_outputs = trainer.vllm_generation.llm.chat( + prompts_for_generation, sampling_params=sampling_params, use_tqdm=False + ) + else: + vllm_outputs = trainer.vllm_generation.llm.generate( + prompts_for_generation, sampling_params=sampling_params, use_tqdm=False + ) + + results: list[dict[str, Any]] = [] + for request in vllm_outputs: + if not request.outputs: + results.append({"prompt_ids": request.prompt_token_ids, "completion_ids": [], "logprobs": [], "text": ""}) + continue + sequence = request.outputs[0] + logprobs = [next(iter(token_logprob.values())).logprob for token_logprob in sequence.logprobs] + results.append( + { + "prompt_ids": request.prompt_token_ids, + "completion_ids": sequence.token_ids, + "logprobs": logprobs, + "text": sequence.text, + } + ) + + if trainer.vllm_tensor_parallel_size > 1: + local_rank_in_group = torch.distributed.get_rank(group=trainer.vllm_generation.tp_group) + tp_slice = slice(local_rank_in_group * original_size, (local_rank_in_group + 1) * original_size) + results = results[tp_slice] + + if trainer.args.vllm_enable_sleep_mode: + trainer.vllm_generation.llm.sleep(level=2) + + return results diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..88abd9e1826eae8a0d201b84a048614059b9e264 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .orpo_config import ORPOConfig +from .orpo_trainer import ORPOTrainer + + +__all__ = ["ORPOConfig", "ORPOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/orpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/orpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..ac2cf84d758d9b8c8e94d6518c934e62e77b9431 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/orpo_config.py @@ -0,0 +1,124 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class ORPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.orpo.ORPOTrainer`]. + + This class includes only the parameters that are specific to ORPO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the sequences (prompt + completion) in the batch. This argument is required if you want + to use the default data collator. + max_completion_length (`int`, *optional*): + Maximum length of the completion. This argument is required if you want to use the default data collator + and your model is an encoder-decoder. + beta (`float`, *optional*, defaults to `0.1`): + Parameter controlling the relative ratio loss weight in the ORPO loss. In the + [paper](https://huggingface.co/papers/2403.07691), it is denoted by λ. In the + [code](https://github.com/xfactlab/orpo), it is denoted by `alpha`. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + padding_value (`int`, *optional*): + Padding value to use. If `None`, the padding value of the tokenizer is used. + generate_during_eval (`bool`, *optional*, defaults to `False`): + If `True`, generates and logs completions from the model to W&B or Comet during evaluation. + is_encoder_decoder (`bool`, *optional*): + When using the `model_init` argument (callable) to instantiate the model instead of the `model` argument, + you need to specify if the model returned by the callable is an encoder-decoder model. + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model from a + string. + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + max_length: int | None = field( + default=1024, + metadata={"help": "Maximum length of the sequences (prompt + completion) in the batch."}, + ) + max_completion_length: int | None = field( + default=None, + metadata={ + "help": "Maximum length of the completion. This argument is required if you want to use the default data " + "collator and your model is an encoder-decoder." + }, + ) + beta: float = field( + default=0.1, + metadata={ + "help": "Parameter controlling the relative ratio loss weight in the ORPO loss. In the paper, it is " + "denoted by λ." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model."}, + ) + padding_value: int | None = field( + default=None, + metadata={"help": "Padding value to use. If `None`, the padding value of the tokenizer is used."}, + ) + generate_during_eval: bool = field( + default=False, + metadata={"help": "If `True`, generates and logs completions from the model to W&B during evaluation."}, + ) + is_encoder_decoder: bool | None = field( + default=None, + metadata={ + "help": "When using the `model_init` argument (callable) to instantiate the model instead of the `model` " + "argument, you need to specify if the model returned by the callable is an encoder-decoder model." + }, + ) + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments to pass to `AutoModelForCausalLM.from_pretrained` when instantiating the model " + "from a string." + }, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/orpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/orpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..59d7636efb73f58f808749b696a45c87b5382fd7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/orpo/orpo_trainer.py @@ -0,0 +1,1032 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import inspect +import random +import textwrap +from collections import defaultdict +from collections.abc import Callable +from contextlib import nullcontext +from pathlib import Path +from typing import Any, Literal + +import numpy as np +import pandas as pd +import torch +import torch.nn as nn +import torch.nn.functional as F +import transformers +from accelerate import PartialState, logging +from datasets import Dataset +from packaging.version import Version +from torch import autocast +from torch.utils.data import DataLoader +from transformers import ( + AutoModelForCausalLM, + BaseImageProcessor, + DataCollator, + FeatureExtractionMixin, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + is_comet_available, + is_torch_xla_available, + is_wandb_available, +) +from transformers.trainer_utils import EvalLoopOutput +from transformers.utils import is_peft_available, is_torch_fx_proxy + +from ...data_utils import maybe_apply_chat_template, maybe_extract_prompt +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import disable_dropout_in_model, log_table_to_comet_experiment, selective_log_softmax +from ..utils import ( + DPODataCollatorWithPadding, + add_bos_token_if_needed, + add_eos_token_if_needed, + pad_to_length, + peft_module_casting_to_bf16, +) +from .orpo_config import ORPOConfig + + +if is_peft_available(): + from peft import PeftModel, get_peft_model, prepare_model_for_kbit_training + + +if is_wandb_available(): + import wandb + +if is_torch_xla_available(): + import torch_xla.core.xla_model as xm + + +logger = logging.get_logger(__name__) + + +def log1mexp(x: torch.FloatTensor) -> torch.FloatTensor: + """Numerically stable computation of log(1-exp(x)).""" + # branch at -ln 2 ~ -0.693 to avoid cancellation + t = -0.6931471805599453 + return torch.where(x < t, torch.log1p(-torch.exp(x)), torch.log(-torch.expm1(x))) + + +class ORPOTrainer(_BaseTrainer): + r""" + Initialize ORPOTrainer. + + Args: + model ([`~transformers.PreTrainedModel`]): + The model to train, preferably an [`~transformers.AutoModelForSequenceClassification`]. + args ([`experimental.orpo.ORPOConfig`]): + The ORPO config arguments to use for training. + data_collator ([`~transformers.DataCollator`]): + The data collator to use for training. If None is specified, the default data collator + ([`experimental.utils.DPODataCollatorWithPadding`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + train_dataset ([`~datasets.Dataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`]): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + model_init (`Callable[[], transformers.PreTrainedModel]`): + The model initializer to use for training. If None is specified, the default model initializer will be + used. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + peft_config (`dict`, defaults to `None`): + The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in + a PEFT model. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + """ + + _tag_names = ["trl", "orpo"] + _name = "ORPO" + _paper = { + "title": "ORPO: Monolithic Preference Optimization without Reference Model", + "id": "2403.07691", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{hong2024orpo, + title = {{ORPO: Monolithic Preference Optimization without Reference Model}}, + author = {Jiwoo Hong and Noah Lee and James Thorne}, + year = 2024, + eprint = {arXiv:2403.07691} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | str | None = None, + args: ORPOConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + model_init: Callable[[], PreTrainedModel] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: dict | None = None, + compute_metrics: Callable[[EvalLoopOutput], dict] | None = None, + ): + if train_dataset is None: + raise ValueError("`train_dataset` is required") + + if args.model_init_kwargs is None: + model_init_kwargs = {} + elif not isinstance(model, str): + raise ValueError("You passed model_kwargs to the ORPOTrainer. But your model is already instantiated.") + else: + model_init_kwargs = args.model_init_kwargs + dtype = model_init_kwargs.get("dtype", "auto") + if dtype is not None: + # Convert to `torch.dtype` if an str is passed + if isinstance(dtype, str) and dtype != "auto": + dtype = getattr(torch, dtype) + if dtype != "auto" and not isinstance(dtype, torch.dtype): + raise ValueError( + f"Invalid `dtype` passed to the ORPOConfig. Expected a string with either `torch.dtype` or 'auto', but got {dtype}." + ) + model_init_kwargs["dtype"] = dtype + model_init_kwargs["device_map"] = model_init_kwargs.get("device_map", "auto") + + if isinstance(model, str): + model = AutoModelForCausalLM.from_pretrained(model, **model_init_kwargs) + + # Initialize this variable to False. This helps tracking the case when `peft_module_casting_to_bf16` + # has been called in order to properly call autocast if needed. + self._peft_has_been_casted_to_bf16 = False + + if not is_peft_available() and peft_config is not None: + raise ValueError( + "PEFT is not installed and you passed a `peft_config` in the trainer's kwargs, please install it to use the PEFT models" + ) + elif is_peft_available() and peft_config is not None: + if isinstance(model, PeftModel): + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first " + "merge and unload the existing adapter, save the resulting base model, and then pass that base " + "model along with the new `peft_config` to the trainer." + ) + + if getattr(model, "is_loaded_in_8bit", False) or getattr(model, "is_loaded_in_4bit", False): + _support_gc_kwargs = hasattr( + args, "gradient_checkpointing_kwargs" + ) and "gradient_checkpointing_kwargs" in list( + inspect.signature(prepare_model_for_kbit_training).parameters + ) + + prepare_model_kwargs = {"use_gradient_checkpointing": args.gradient_checkpointing} + + if _support_gc_kwargs: + prepare_model_kwargs["gradient_checkpointing_kwargs"] = args.gradient_checkpointing_kwargs + + model = prepare_model_for_kbit_training(model, **prepare_model_kwargs) + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + # get peft model with the given config + model = get_peft_model(model, peft_config) + if args.bf16 and getattr(model, "is_loaded_in_4bit", False): + peft_module_casting_to_bf16(model) + # If args.bf16 we need to explicitly call `generate` with torch amp autocast context manager + self._peft_has_been_casted_to_bf16 = True + + # For models that use gradient_checkpointing, we need to attach a hook that enables input + # to explicitly have `requires_grad=True`, otherwise training will either silently + # fail or completely fail. + elif args.gradient_checkpointing: + # For backward compatibility with older versions of transformers + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + if args.generate_during_eval and not (is_wandb_available() or is_comet_available()): + raise ValueError( + "`generate_during_eval=True` requires Weights and Biases or Comet to be installed." + " Please install `wandb` or `comet-ml` to resolve." + ) + + if model is not None: + self.is_encoder_decoder = model.config.is_encoder_decoder + elif args.is_encoder_decoder is None: + raise ValueError("When no model is provided, you need to pass the parameter is_encoder_decoder.") + else: + self.is_encoder_decoder = args.is_encoder_decoder + + if self.is_encoder_decoder: + self.decoder_start_token_id = model.config.decoder_start_token_id + self.pad_token_id = model.config.pad_token_id + + if processing_class is None: + raise ValueError("processing_class must be specified to tokenize a ORPO dataset.") + if args.max_length is None: + logger.warning( + "`max_length` is not set in the ORPOConfig's init" + " it will default to `512` by default, but you should do it yourself in the future.", + ) + max_length = 512 + else: + max_length = args.max_length + + if args.max_completion_length is None and self.is_encoder_decoder: + logger.warning( + "When using an encoder decoder architecture, you should set `max_completion_length` in the ORPOConfig's init" + " it will default to `128` by default, but you should do it yourself in the future.", + ) + self.max_completion_length = 128 + else: + self.max_completion_length = args.max_completion_length + + if data_collator is None: + data_collator = DPODataCollatorWithPadding( + pad_token_id=processing_class.pad_token_id, + is_encoder_decoder=self.is_encoder_decoder, + ) + + if args.remove_unused_columns: + args.remove_unused_columns = False + # warn users + logger.warning( + "When using DPODataCollatorWithPadding, you should set `remove_unused_columns=False` in your TrainingArguments" + " we have set it for you, but you should do it yourself in the future.", + ) + + self.use_dpo_data_collator = True + else: + self.use_dpo_data_collator = False + + # Disable dropout in the model and reference model + if args.disable_dropout: + disable_dropout_in_model(model) + + self.max_length = max_length + self.generate_during_eval = args.generate_during_eval + self.padding_value = args.padding_value if args.padding_value is not None else processing_class.pad_token_id + self.processing_class = processing_class + + self.beta = args.beta + self.aux_loss_enabled = getattr(model.config, "output_router_logits", False) + self.aux_loss_coef = getattr(model.config, "router_aux_loss_coef", 0.0) + if self.aux_loss_enabled and self.aux_loss_coef == 0.0: + logger.warning( + "You set `output_router_logits` to `True` in the model config, but `router_aux_loss_coef` is set to " + "`0.0`, meaning the auxiliary loss will not be used. Either set `router_aux_loss_coef` to a value " + "greater than `0.0`, or set `output_router_logits` to `False` if you don't want to use the auxiliary " + "loss.", + ) + + self._stored_metrics = defaultdict(lambda: defaultdict(list)) + + # Compute that only on the main process for faster data processing. + # see: https://github.com/huggingface/trl/pull/1255 + with PartialState().main_process_first(): + # Extract the prompt if needed, and apply the chat template if needed + train_dataset = train_dataset.map(maybe_extract_prompt, num_proc=args.dataset_num_proc) + train_dataset = train_dataset.map( + maybe_apply_chat_template, + fn_kwargs={"processing_class": processing_class}, + num_proc=args.dataset_num_proc, + ) + train_dataset = train_dataset.map(self.tokenize_row, num_proc=args.dataset_num_proc) + if eval_dataset is not None: + eval_dataset = eval_dataset.map(maybe_extract_prompt, num_proc=args.dataset_num_proc) + eval_dataset = eval_dataset.map( + maybe_apply_chat_template, + fn_kwargs={"processing_class": processing_class}, + num_proc=args.dataset_num_proc, + ) + eval_dataset = eval_dataset.map(self.tokenize_row, num_proc=args.dataset_num_proc) + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + model_init=model_init, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Add tags for models that have been loaded with the correct transformers version + if hasattr(self.model, "add_model_tags"): + self.model.add_model_tags(self._tag_names) + + if not hasattr(self, "accelerator"): + raise AttributeError( + "Your `Trainer` does not have an `accelerator` object. Consider upgrading `transformers`." + ) + + def build_tokenized_answer(self, prompt, answer): + """ + Llama tokenizer does satisfy `enc(a + b) = enc(a) + enc(b)`. It does ensure `enc(a + b) = enc(a) + enc(a + + b)[len(enc(a)):]`. Reference: + https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257 + """ + + full_tokenized = self.processing_class(prompt + answer, add_special_tokens=False) + prompt_input_ids = self.processing_class(prompt, add_special_tokens=False)["input_ids"] + + answer_input_ids = full_tokenized["input_ids"][len(prompt_input_ids) :] + answer_attention_mask = full_tokenized["attention_mask"][len(prompt_input_ids) :] + + # Concat tokens to form `enc(a) + enc(a + b)[len(enc(a)):]` + full_concat_input_ids = np.concatenate([prompt_input_ids, answer_input_ids]) + + # Prepare input tokens for token by token comparison + full_input_ids = np.array(full_tokenized["input_ids"]) + + if len(full_input_ids) != len(full_concat_input_ids): + raise ValueError("Prompt input ids and answer input ids should have the same length.") + + # On some tokenizers, like Llama-2 tokenizer, there are occasions where tokens + # can be merged together when tokenizing prompt+answer. This could result + # on the last token from the prompt being different when tokenized on its own + # vs when done as prompt+answer. + response_token_ids_start_idx = len(prompt_input_ids) + + # If tokenized prompt is different than both prompt+answer, then it means the + # last token has changed due to merging. + if prompt_input_ids != full_tokenized["input_ids"][:response_token_ids_start_idx]: + response_token_ids_start_idx -= 1 + + prompt_input_ids = full_tokenized["input_ids"][:response_token_ids_start_idx] + prompt_attention_mask = full_tokenized["attention_mask"][:response_token_ids_start_idx] + + if len(prompt_input_ids) != len(prompt_attention_mask): + raise ValueError("Prompt input ids and attention mask should have the same length.") + + answer_input_ids = full_tokenized["input_ids"][response_token_ids_start_idx:] + answer_attention_mask = full_tokenized["attention_mask"][response_token_ids_start_idx:] + + return dict( + prompt_input_ids=prompt_input_ids, + prompt_attention_mask=prompt_attention_mask, + input_ids=answer_input_ids, + attention_mask=answer_attention_mask, + ) + + def tokenize_row(self, feature, model: PreTrainedModel | nn.Module | None = None) -> dict: + """Tokenize a single row from a ORPO specific dataset. + + At this stage, we don't convert to PyTorch tensors yet; we just handle the truncation in case the prompt + + chosen or prompt + rejected responses is/are too long. First we truncate the prompt; if we're still too long, + we truncate the chosen/rejected. + + We also create the labels for the chosen/rejected responses, which are of length equal to the sum of the length + of the prompt and the chosen/rejected response, with `-100` for the prompt tokens. + """ + batch = {} + prompt = feature["prompt"] + chosen = feature["chosen"] + rejected = feature["rejected"] + + if not self.is_encoder_decoder: + # Check issues below for more details + # 1. https://github.com/huggingface/trl/issues/907 + # 2. https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257 + # 3. https://github.com/LianjiaTech/BELLE/issues/337 + + if not isinstance(prompt, str): + raise ValueError(f"prompt should be an str but got {type(prompt)}") + prompt_tokens = self.processing_class(prompt, add_special_tokens=False) + prompt_tokens = {f"prompt_{k}": v for k, v in prompt_tokens.items()} + + if not isinstance(chosen, str): + raise ValueError(f"chosen should be an str but got {type(chosen)}") + chosen_tokens = self.build_tokenized_answer(prompt, chosen) + + if not isinstance(rejected, str): + raise ValueError(f"rejected should be an str but got {type(rejected)}") + rejected_tokens = self.build_tokenized_answer(prompt, rejected) + + # Last prompt token might get merged by tokenizer and + # it should not be included for generation if that happens + prompt_len_input_ids = len(prompt_tokens["prompt_input_ids"]) + + chosen_prompt_len_input_ids = len(chosen_tokens["prompt_input_ids"]) + rejected_prompt_len_input_ids = len(rejected_tokens["prompt_input_ids"]) + prompt_len_input_ids = min(chosen_prompt_len_input_ids, rejected_prompt_len_input_ids) + + for k, v in prompt_tokens.items(): + prompt_tokens[k] = v[:prompt_len_input_ids] + + # Make sure prompts only have one different token at most an + # and length only differs by 1 at most + num_diff_tokens = sum( + a != b + for a, b in zip(chosen_tokens["prompt_input_ids"], rejected_tokens["prompt_input_ids"], strict=False) + ) + num_diff_len = abs(chosen_prompt_len_input_ids - rejected_prompt_len_input_ids) + if num_diff_tokens > 1 or num_diff_len > 1: + raise ValueError( + "Chosen and rejected prompt_input_ids might only differ on the " + "last token due to tokenizer merge ops." + ) + + # add BOS token to head of prompt. Avoid adding if it's already there + prompt_tokens, chosen_tokens, rejected_tokens = add_bos_token_if_needed( + self.processing_class.bos_token_id, + prompt_len_input_ids, + prompt_tokens, + chosen_prompt_len_input_ids, + chosen_tokens, + rejected_prompt_len_input_ids, + rejected_tokens, + ) + + # add EOS token to end of answer. Avoid adding if it's already there + chosen_tokens, rejected_tokens = add_eos_token_if_needed( + self.processing_class.eos_token_id, chosen_tokens, rejected_tokens + ) + + longer_response_length = max(len(chosen_tokens["input_ids"]), len(rejected_tokens["input_ids"])) + + # if combined sequence is too long, truncate the response + for answer_tokens in [chosen_tokens, rejected_tokens]: + if len(answer_tokens["prompt_input_ids"]) + longer_response_length > self.max_length: + for k in ["input_ids", "attention_mask"]: + answer_tokens[k] = answer_tokens[k][: self.max_length - longer_response_length] + + # Create labels + chosen_sequence_tokens = { + k: chosen_tokens[f"prompt_{k}"] + chosen_tokens[k] for k in ["input_ids", "attention_mask"] + } + rejected_sequence_tokens = { + k: rejected_tokens[f"prompt_{k}"] + rejected_tokens[k] for k in ["input_ids", "attention_mask"] + } + chosen_sequence_tokens["labels"] = chosen_sequence_tokens["input_ids"][:] + chosen_sequence_tokens["labels"][: len(chosen_tokens["prompt_input_ids"])] = [-100] * len( + chosen_tokens["prompt_input_ids"] + ) + rejected_sequence_tokens["labels"] = rejected_sequence_tokens["input_ids"][:] + rejected_sequence_tokens["labels"][: len(rejected_tokens["prompt_input_ids"])] = [-100] * len( + rejected_tokens["prompt_input_ids"] + ) + + for k, toks in { + "chosen_": chosen_sequence_tokens, + "rejected_": rejected_sequence_tokens, + "": prompt_tokens, + }.items(): + for type_key, tokens in toks.items(): + if type_key == "token_type_ids": + continue + batch[f"{k}{type_key}"] = tokens + + else: + chosen_tokens = self.processing_class( + chosen, truncation=True, max_length=self.max_completion_length, add_special_tokens=True + ) + rejected_tokens = self.processing_class( + rejected, truncation=True, max_length=self.max_completion_length, add_special_tokens=True + ) + prompt_tokens = self.processing_class(prompt, add_special_tokens=True) + + batch["chosen_labels"] = chosen_tokens["input_ids"] + batch["rejected_labels"] = rejected_tokens["input_ids"] + batch["prompt_input_ids"] = prompt_tokens["input_ids"] + batch["prompt_attention_mask"] = prompt_tokens["attention_mask"] + + if model is not None and hasattr(model, "prepare_decoder_input_ids_from_labels"): + batch["rejected_decoder_input_ids"] = model.prepare_decoder_input_ids_from_labels( + labels=torch.tensor(batch["rejected_labels"]) + ) + batch["chosen_decoder_input_ids"] = model.prepare_decoder_input_ids_from_labels( + labels=torch.tensor(batch["chosen_labels"]) + ) + + if is_torch_xla_available(): + # Pad the sequences to global max_length to avoid TorchXLA recompilation + for k in batch: + if "labels" in k or self.is_encoder_decoder: + pad_value = -100 + elif k.endswith("_input_ids"): + pad_value = self.padding_value + elif k.endswith("_attention_mask"): + pad_value = 0 + batch[k] = batch[k] + [pad_value] * (self.max_length - len(batch[k])) + return batch + + @staticmethod + def concatenated_inputs( + batch: dict[str, list | torch.LongTensor], + is_encoder_decoder: bool = False, + padding_value: int = 0, + device: torch.device | None = None, + ) -> dict[str, torch.LongTensor]: + """Concatenate the chosen and rejected inputs into a single tensor. + + Args: + batch: + A batch of data. Must contain the keys 'chosen_input_ids' and 'rejected_input_ids', which are tensors + of shape (batch_size, sequence_length). + is_encoder_decoder: + Whether the model is an encoder-decoder model. + padding_value: + The padding value to use for the concatenated inputs_ids. + device: + The device for the concatenated inputs. + + Returns: + A dictionary containing the concatenated inputs under the key 'concatenated_input_ids'. + """ + concatenated_batch = {} + + if is_encoder_decoder: + max_length = max(batch["chosen_labels"].shape[1], batch["rejected_labels"].shape[1]) + else: + max_length = max(batch["chosen_input_ids"].shape[1], batch["rejected_input_ids"].shape[1]) + + for k in batch: + if k.startswith("chosen") and isinstance(batch[k], torch.Tensor): + if "labels" in k or is_encoder_decoder: + pad_value = -100 + elif k.endswith("_input_ids"): + pad_value = padding_value + elif k.endswith("_attention_mask"): + pad_value = 0 + concatenated_key = k.replace("chosen", "concatenated") + concatenated_batch[concatenated_key] = pad_to_length(batch[k], max_length, pad_value=pad_value) + for k in batch: + if k.startswith("rejected") and isinstance(batch[k], torch.Tensor): + if "labels" in k or is_encoder_decoder: + pad_value = -100 + elif k.endswith("_input_ids"): + pad_value = padding_value + elif k.endswith("_attention_mask"): + pad_value = 0 + concatenated_key = k.replace("rejected", "concatenated") + concatenated_batch[concatenated_key] = torch.cat( + ( + concatenated_batch[concatenated_key], + pad_to_length(batch[k], max_length, pad_value=pad_value), + ), + dim=0, + ).to(device=device) + + if is_encoder_decoder: + concatenated_batch["concatenated_input_ids"] = batch["prompt_input_ids"].repeat(2, 1).to(device=device) + concatenated_batch["concatenated_attention_mask"] = ( + batch["prompt_attention_mask"].repeat(2, 1).to(device=device) + ) + + return concatenated_batch + + def odds_ratio_loss( + self, + policy_chosen_logps: torch.FloatTensor, + policy_rejected_logps: torch.FloatTensor, + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + """Compute ORPO's odds ratio (OR) loss for a batch of policy and reference model log probabilities. + + Args: + policy_chosen_logps: + Log probabilities of the policy model for the chosen responses. Shape: (batch_size,) + policy_rejected_logps: + Log probabilities of the policy model for the rejected responses. Shape: (batch_size,) + + Returns: + A tuple of three tensors: (losses, chosen_rewards, rejected_rewards). The losses tensor contains the ORPO + loss for each example in the batch. The chosen_rewards and rejected_rewards tensors contain the rewards for + the chosen and rejected responses, respectively. The log odds ratio of the chosen responses over the + rejected responses ratio for logging purposes. The `log(sigmoid(log_odds_chosen))` for logging purposes. + """ + + # Derived from Eqs. (4) and (7) from https://huggingface.co/papers/2403.07691 by using log identities and exp(log(P(y|x)) = P(y|x) + policy_chosen_logps = policy_chosen_logps.float() + policy_rejected_logps = policy_rejected_logps.float() + log_odds = (policy_chosen_logps - policy_rejected_logps) - ( + log1mexp(policy_chosen_logps) - log1mexp(policy_rejected_logps) + ) + ratio = F.logsigmoid(log_odds) + losses = self.beta * ratio + + chosen_rewards = self.beta * (policy_chosen_logps.to(self.accelerator.device)).detach() + rejected_rewards = self.beta * (policy_rejected_logps.to(self.accelerator.device)).detach() + + return losses, chosen_rewards, rejected_rewards, torch.mean(ratio), torch.mean(log_odds) + + @staticmethod + def get_batch_logps( + logits: torch.FloatTensor, + labels: torch.LongTensor, + average_log_prob: bool = False, + is_encoder_decoder: bool = False, + ) -> torch.FloatTensor: + """Compute the log probabilities of the given labels under the given logits. + + Args: + logits: Logits of the model (unnormalized). Shape: (batch_size, sequence_length, vocab_size) + labels: + Labels for which to compute the log probabilities. Label tokens with a value of `-100` are ignored. + Shape: (batch_size, sequence_length) + average_log_prob: + If True, return the average log probability per (non-masked) token. Otherwise, return the sum of the + log probabilities of the (non-masked) tokens. + is_encoder_decoder: Whether the model is an encoder-decoder model. + + Returns: + A tensor of shape (batch_size,) containing the average/sum log probabilities of the given labels under the + given logits. + """ + if logits.shape[:-1] != labels.shape: + raise ValueError("Logits (batch and sequence length dim) and labels must have the same shape.") + + if not is_encoder_decoder: + labels = labels[:, 1:].clone() + logits = logits[:, :-1, :] + loss_mask = labels != -100 + + # dummy token; we'll ignore the losses on these tokens later + labels = torch.where(labels == -100, 0, labels) + + per_token_logps = selective_log_softmax(logits, labels) + + if average_log_prob: + return (per_token_logps * loss_mask).sum(-1) / loss_mask.sum(-1) + else: + return (per_token_logps * loss_mask).sum(-1) + + def concatenated_forward( + self, model: nn.Module, batch: dict[str, list | torch.LongTensor] + ) -> tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]: + """Run the given model on the given batch of inputs, concatenating the chosen and rejected inputs together. + + We do this to avoid doing two forward passes, because it's faster for FSDP. + """ + concatenated_batch = self.concatenated_inputs( + batch, + is_encoder_decoder=self.is_encoder_decoder, + padding_value=self.padding_value, + device=self.accelerator.device, + ) + len_chosen = batch["chosen_labels"].shape[0] + + model_kwargs = ( + { + "decoder_input_ids": self._shift_right(concatenated_batch["concatenated_labels"]), + } + if self.is_encoder_decoder + else {} + ) + + if self.aux_loss_enabled: + model_kwargs["output_router_logits"] = True + + outputs = model( + concatenated_batch["concatenated_input_ids"], + attention_mask=concatenated_batch["concatenated_attention_mask"], + use_cache=False, + **model_kwargs, + ) + all_logits = outputs.logits + + def cross_entropy_loss(logits, labels): + if not self.is_encoder_decoder: + # Shift so that tokens < n predict n + logits = logits[..., :-1, :].contiguous() + labels = labels[..., 1:].contiguous() + # Flatten the tokens + loss_fct = nn.CrossEntropyLoss() + logits = logits.view(-1, logits.shape[-1]) + labels = labels.view(-1) + # Enable model parallelism + labels = labels.to(logits.device) + loss = loss_fct(logits, labels) + return loss + + if self.is_encoder_decoder: + labels = concatenated_batch["concatenated_labels"].clone() + else: + labels = concatenated_batch["concatenated_input_ids"].clone() + attention_mask = concatenated_batch["concatenated_attention_mask"] + labels = torch.where(attention_mask == 1, labels, -100) + # orpo chosen nll loss is computed over the full prompt and response + chosen_nll_loss = cross_entropy_loss(all_logits[:len_chosen], labels[:len_chosen]) + + all_logps = self.get_batch_logps( + all_logits, + concatenated_batch["concatenated_labels"], + average_log_prob=True, + is_encoder_decoder=self.is_encoder_decoder, + ) + + chosen_logps = all_logps[:len_chosen] + rejected_logps = all_logps[len_chosen:] + + if not self.is_encoder_decoder: + chosen_logits = all_logits[:len_chosen, :-1, :] + rejected_logits = all_logits[len_chosen:, :-1, :] + else: + chosen_logits = all_logits[:len_chosen] + rejected_logits = all_logits[len_chosen:] + + if self.aux_loss_enabled: + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, chosen_nll_loss, outputs.aux_loss) + + return (chosen_logps, rejected_logps, chosen_logits, rejected_logits, chosen_nll_loss) + + def get_batch_loss_metrics( + self, + model, + batch: dict[str, list | torch.LongTensor], + train_eval: Literal["train", "eval"] = "train", + ): + """Compute the ORPO loss and other metrics for the given batch of inputs for train or test.""" + metrics = {} + + forward_output = self.concatenated_forward(model, batch) + ( + policy_chosen_logps, + policy_rejected_logps, + policy_chosen_logits, + policy_rejected_logits, + policy_nll_loss, + ) = forward_output[:5] + if self.aux_loss_enabled: + aux_loss = forward_output[5] + + losses, chosen_rewards, rejected_rewards, log_odds_ratio, log_odds_chosen = self.odds_ratio_loss( + policy_chosen_logps, policy_rejected_logps + ) + # full ORPO loss + loss = policy_nll_loss - losses.mean() + + reward_accuracies = (chosen_rewards > rejected_rewards).float() + + prefix = "eval_" if train_eval == "eval" else "" + metrics[f"{prefix}rewards/chosen"] = self.accelerator.gather_for_metrics(chosen_rewards).mean() + metrics[f"{prefix}rewards/rejected"] = self.accelerator.gather_for_metrics(rejected_rewards).mean() + metrics[f"{prefix}rewards/accuracies"] = self.accelerator.gather_for_metrics(reward_accuracies).mean() + metrics[f"{prefix}rewards/margins"] = self.accelerator.gather_for_metrics( + chosen_rewards - rejected_rewards + ).mean() + metrics[f"{prefix}logps/rejected"] = self.accelerator.gather_for_metrics(policy_rejected_logps).detach().mean() + metrics[f"{prefix}logps/chosen"] = self.accelerator.gather_for_metrics(policy_chosen_logps).detach().mean() + metrics[f"{prefix}logits/rejected"] = self.accelerator.gather_for_metrics( + policy_rejected_logits.detach().mean() + ).mean() + metrics[f"{prefix}logits/chosen"] = self.accelerator.gather_for_metrics( + policy_chosen_logits.detach().mean() + ).mean() + metrics[f"{prefix}nll_loss"] = self.accelerator.gather_for_metrics(policy_nll_loss).detach().mean() + metrics[f"{prefix}log_odds_ratio"] = self.accelerator.gather_for_metrics(log_odds_ratio).detach().mean() + metrics[f"{prefix}log_odds_chosen"] = self.accelerator.gather_for_metrics(log_odds_chosen).detach().mean() + if is_torch_xla_available(): + xm.mark_step() # needed because .item() calls + for k, v in metrics.items(): + metrics[k] = v.item() + if self.aux_loss_enabled: + loss += self.aux_loss_coef * aux_loss + + return loss, metrics + + def compute_loss( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + return_outputs=False, + num_items_in_batch=None, + ) -> torch.Tensor | tuple[torch.Tensor, dict[str, torch.Tensor]]: + compute_loss_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with compute_loss_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs, train_eval="train") + + # Make sure to move the loss to the device the original accumulating loss is at back in the `Trainer` class: + loss = loss.to(self.args.device) + + # force log the metrics + self.store_metrics(metrics, train_eval="train") + + if return_outputs: + return (loss, metrics) + return loss + + def generate_from_model(self, model, batch: dict[str, torch.LongTensor]) -> str: + """Generate samples from the model and reference model for the given batch of inputs.""" + + # If one uses `generate_during_eval` with peft + bf16, we need to explicitly call generate with + # the torch amp context manager as some hidden states are silently casted to full precision. + generate_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with generate_context_manager: + policy_output = model.generate( + input_ids=batch["prompt_input_ids"], + attention_mask=batch["prompt_attention_mask"], + max_length=self.max_length, + do_sample=True, + pad_token_id=self.processing_class.pad_token_id, + ) + + policy_output = pad_to_length(policy_output, self.max_length, self.processing_class.pad_token_id) + policy_output_decoded = self.processing_class.batch_decode(policy_output, skip_special_tokens=True) + + return policy_output_decoded + + def prediction_step( + self, + model: PreTrainedModel | nn.Module, + inputs: dict[str, torch.Tensor | Any], + prediction_loss_only: bool, + ignore_keys: list[str] | None = None, + ): + if not self.use_dpo_data_collator: + logger.warning( + "prediction_step is only implemented for DPODataCollatorWithPadding, and you passed a datacollator that is different than " + "DPODataCollatorWithPadding - you might see unexpected behavior. Alternatively, you can implement your own prediction_step method if you are using a custom data collator" + ) + if ignore_keys is None: + if hasattr(model, "config"): + ignore_keys = getattr(model.config, "keys_to_ignore_at_inference", []) + else: + ignore_keys = [] + + prediction_context_manager = ( + autocast(self.accelerator.device.type) if self._peft_has_been_casted_to_bf16 else nullcontext() + ) + + with torch.no_grad(), prediction_context_manager: + loss, metrics = self.get_batch_loss_metrics(model, inputs, train_eval="eval") + + # force log the metrics + self.store_metrics(metrics, train_eval="eval") + + if prediction_loss_only: + return (loss.detach(), None, None) + + # logits for the chosen and rejected samples from model + logits_dict = { + "eval_logits/chosen": metrics["eval_logits/chosen"], + "eval_logits/rejected": metrics["eval_logits/rejected"], + } + logits = [v for k, v in logits_dict.items() if k not in ignore_keys] + logits = torch.tensor(logits, device=self.accelerator.device) + labels = torch.zeros(logits.shape[0], device=self.accelerator.device) + + return (loss.detach(), logits, labels) + + def store_metrics(self, metrics: dict[str, float], train_eval: Literal["train", "eval"] = "train") -> None: + for key, value in metrics.items(): + self._stored_metrics[train_eval][key].append(value) + + def evaluation_loop( + self, + dataloader: DataLoader, + description: str, + prediction_loss_only: bool | None = None, + ignore_keys: list[str] | None = None, + metric_key_prefix: str = "eval", + ) -> EvalLoopOutput: + """ + Overriding built-in evaluation loop to store metrics for each batch. Prediction/evaluation loop, shared by + `Trainer.evaluate()` and `Trainer.predict()`. + + Works both with or without labels. + """ + + # Sample and save to game log if requested (for one batch to save time) + if self.generate_during_eval: + # Generate random indices within the range of the total number of samples + num_samples = len(dataloader.dataset) + random_indices = random.sample(range(num_samples), k=self.args.eval_batch_size) + + # Use dataloader.dataset.select to get the random batch without iterating over the DataLoader + random_batch_dataset = dataloader.dataset.select(random_indices) + random_batch = self.data_collator(random_batch_dataset) + random_batch = self._prepare_inputs(random_batch) + + policy_output_decoded = self.generate_from_model(self.model, random_batch) + + table = pd.DataFrame( + columns=["Prompt", "Policy"], + data=[ + [prompt, pol[len(prompt) :]] + for prompt, pol in zip(random_batch["prompt"], policy_output_decoded, strict=True) + ], + ) + if "wandb" in self.args.report_to: + wandb.log({"game_log": wandb.Table(data=table)}) + + if "comet_ml" in self.args.report_to: + log_table_to_comet_experiment( + name="game_log.csv", + table=table, + ) + + # Base evaluation + initial_output = super().evaluation_loop( + dataloader, description, prediction_loss_only, ignore_keys, metric_key_prefix + ) + + return initial_output + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + """ + Log `logs` on the various objects watching training, including stored metrics. + + Args: + logs (`dict[str, float]`): + The values to log. + start_time (`float`, *optional*): + Start time of the training. + """ + # logs either has 'loss' or 'eval_loss' + train_eval = "train" if "loss" in logs else "eval" + # Add averaged stored metrics to logs + for key, metrics in self._stored_metrics[train_eval].items(): + logs[key] = torch.tensor(metrics).mean().item() + del self._stored_metrics[train_eval] + return super().log(logs, start_time) + + def _shift_right(self, input_ids): + if self.decoder_start_token_id is None: + raise ValueError( + "model.config.decoder_start_token_id has to be defined. It is usually set to the pad_token_id." + ) + + # shift inputs to the right + if is_torch_fx_proxy(input_ids): + # Item assignment is not supported natively for proxies. + shifted_input_ids = torch.full(input_ids.shape[:-1] + (1,), self.decoder_start_token_id) + shifted_input_ids = torch.cat([shifted_input_ids, input_ids[..., :-1]], dim=-1) + else: + shifted_input_ids = input_ids.new_zeros(input_ids.shape) + shifted_input_ids[..., 1:] = input_ids[..., :-1].clone() + shifted_input_ids[..., 0] = self.decoder_start_token_id + + if self.pad_token_id is None: + raise ValueError("model.config.pad_token_id has to be defined.") + # replace possible -100 values in labels by `pad_token_id` + shifted_input_ids.masked_fill_(shifted_input_ids == -100, self.pad_token_id) + + return shifted_input_ids + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..62fb8105cb446c197570023e388299e1bd96bbc4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from .papo_config import PAPOConfig +from .papo_trainer import PAPOTrainer diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/papo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/papo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..e142a94a9cdc3128456b6127436c3befd6bc2a93 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/papo_config.py @@ -0,0 +1,73 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass +from typing import Literal + +from ...trainer.grpo_config import GRPOConfig + + +@dataclass +class PAPOConfig(GRPOConfig): + """ + Configuration class for PAPOTrainer. + + PAPO (Perception-Aware Policy Optimization) extends GRPO/DAPO for multimodal reasoning by adding an implicit + perception loss and double entropy regularization. + + Args: + perception_loss_weight (`float`, *optional*, defaults to `0.1`): + gamma Weight coefficient for the perception loss term. This encourages the model to be sensitive to visual + changes. + + mask_ratio (`float`, *optional*, defaults to `0.3`): + Ratio of the image to mask when computing perception loss. + + mask_type (`Literal["random", "patch", "grid"]`, *optional*, defaults to `"random"`): + Type of masking strategy to use. + + der_loss_weight1 (`float`, *optional*, defaults to `0.03`): + eta1 Weight coefficient for the Double Entropy Regularization (DER) term. This term encourages confident + predictions with original images (low entropy) and uncertain predictions with masked images (high entropy). + + der_loss_weight2 (`float`, *optional*, defaults to `0.03`): + eta2 Weight coefficient for the Double Entropy Regularization (DER) term. This term encourages confident + predictions with original images (low entropy) and uncertain predictions with masked images (high entropy). + + loss_type (`Literal["grpo", "dapo"]`, inherited from GRPOConfig): + Base loss type to use. Set to "grpo" for PAPO-G or "dapo" for PAPO-D. + """ + + perception_loss_weight: float = 0.1 + mask_ratio: float = 0.3 + mask_type: Literal["random", "patch", "grid"] = "random" + + # Added for Double Entropy Regularization + der_loss_weight1: float = 0.03 + der_loss_weight2: float = 0.03 + + def __post_init__(self): + super().__post_init__() + + # Validation + if not 0.0 <= self.mask_ratio <= 1.0: + raise ValueError(f"mask_ratio must be between 0 and 1, got {self.mask_ratio}") + + if self.der_loss_weight1 < 0 or self.der_loss_weight2 < 0: + raise ValueError( + f"der_loss_weight1 and der_loss_weight2 must be non-negative, got {self.der_loss_weight1} and {self.der_loss_weight2}" + ) + + if self.mask_type not in ["random", "patch", "grid"]: + raise ValueError(f"mask_type must be one of ['random', 'patch', 'grid'], got {self.mask_type}") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/papo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/papo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..931fee3efe993e95b6564dab28987e125e8e96be --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/papo/papo_trainer.py @@ -0,0 +1,354 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import random +import textwrap + +import torch +from datasets import Dataset, IterableDataset +from transformers import PreTrainedModel, PreTrainedTokenizerBase, ProcessorMixin + +from ...trainer.grpo_trainer import GRPOTrainer, RewardFunc +from ...trainer.utils import nanmax, nanmin +from .papo_config import PAPOConfig + + +class PAPOTrainer(GRPOTrainer): + """ + Trainer for Perception-Aware Policy Optimization (PAPO). + + PAPO extends GRPO/DAPO for multimodal reasoning by adding an implicit perception loss that encourages the model to + better utilize visual information. The key innovation is computing KL divergence between model outputs on original + vs. corrupted (masked) images. + + Two variants are supported: + - PAPO-G: PAPO + GRPO (use loss_type="grpo") + - PAPO-D: PAPO + DAPO (use loss_type="dapo") + + Example: + + ```python + from datasets import load_dataset + from trl.experimental.papo import PAPOTrainer, PAPOConfig + + dataset = load_dataset("your-vlm-dataset", split="train") + + + def reward_func(completions, **kwargs): + # Your reward function for multimodal reasoning + return [compute_reward(c) for c in completions] + + + # PAPO-G + config = PAPOConfig( + loss_type="grpo", # Use GRPO as base + perception_loss_weight=0.1, + mask_ratio=0.3, + ) + + # PAPO-G + config = PAPOConfig( + loss_type="dapo", # Use DAPO as base + perception_loss_weight=0.1, + mask_ratio=0.3, + ) + + trainer = PAPOTrainer( + model="Qwen/Qwen2-VL-2B-Instruct", + reward_funcs=reward_func, + args=config, + train_dataset=dataset, + ) + + trainer.train() + ``` + + Args: + model (`Union[str, PreTrainedModel]`): + Model to be trained (must be a vision-language model). + reward_funcs (`Union[RewardFunc, list[RewardFunc]]`): + Reward functions for computing rewards (same as GRPO). + args ([`PAPOConfig`], *optional*, defaults to `None`): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. Must include "prompt" and "image" columns. + eval_dataset: Same requirements as train_dataset. + processing_class: Processing class (tokenizer/processor) for the model. + reward_processing_classes: Processing classes for reward models. + callbacks: Training callbacks. + optimizers: Optimizer and scheduler tuple. + peft_config: PEFT configuration if using parameter-efficient fine-tuning. + """ + + _tag_names = ["trl", "papo"] + _name = "PAPO" + _paper = { + "title": "Perception-Aware Policy Optimization for Multimodal Reasoning", + "id": "2507.06448", + # docstyle-ignore + "citation": textwrap.dedent( + """\ + @misc{wang2025perceptionawarepolicyoptimizationmultimodal, + title = {{Perception-Aware Policy Optimization for Multimodal Reasoning}}, + author = {Zhenhailong Wang and Xuehang Guo and Sofia Stoica and Haiyang Xu and Hongru Wang and Hyeonjeong Ha and Xiusi Chen and Yangyi Chen and Ming Yan and Fei Huang and Heng Ji}, + year = 2025, + url = {https://arxiv.org/abs/2507.06448}, + archivePrefix= {arXiv}, + eprint = {2507.06448}, + primaryClass = {cs.CL} + }""" + ), + } + + def __init__( + self, + model: str | PreTrainedModel, + reward_funcs: RewardFunc | list[RewardFunc], + args: PAPOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks=None, + optimizers=(None, None), + peft_config=None, + ): + # Initialize with default PAPO config if not provided + if args is None: + model_name = model if isinstance(model, str) else model.config._name_or_path + model_name = model_name.split("/")[-1] + args = PAPOConfig(f"{model_name}-PAPO") + + # Store PAPO-specific parameters + self.perception_loss_weight = args.perception_loss_weight + self.mask_ratio = args.mask_ratio + self.mask_type = args.mask_type + self.der_loss_weight1 = args.der_loss_weight1 + self.der_loss_weight2 = args.der_loss_weight2 + + # Initialize parent GRPO trainer + super().__init__( + model=model, + reward_funcs=reward_funcs, + args=args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=reward_processing_classes, + callbacks=callbacks, + optimizers=optimizers, + peft_config=peft_config, + ) + + def _mask_image(self, pixel_values: torch.Tensor, mask_ratio: float = None) -> torch.Tensor: + """ + Apply masking to image pixel values. + + Args: + pixel_values: Image tensor of shape (B, C, H, W) or (B, N, C, H, W) for multi-image + mask_ratio: Ratio of image to mask (defaults to self.mask_ratio) + + Returns: + Masked pixel values tensor + """ + if mask_ratio is None: + mask_ratio = self.mask_ratio + + masked_pixel_values = pixel_values.clone() + + if self.mask_type == "random": + # Random pixel masking + mask = torch.rand_like(pixel_values) > mask_ratio + masked_pixel_values = masked_pixel_values * mask + + elif self.mask_type == "patch": + # Patch-based masking (mask contiguous regions) + B = pixel_values.shape[0] + if pixel_values.ndim == 4: # (B, C, H, W) + C, H, W = pixel_values.shape[1:] + for i in range(B): + # Calculate patch size to mask + patch_h = int(H * mask_ratio**0.5) + patch_w = int(W * mask_ratio**0.5) + # Random starting position + start_h = random.randint(0, max(0, H - patch_h)) + start_w = random.randint(0, max(0, W - patch_w)) + # Apply mask + masked_pixel_values[i, :, start_h : start_h + patch_h, start_w : start_w + patch_w] = 0 + + elif pixel_values.ndim == 5: # (B, N, C, H, W) for multi-image + N, C, H, W = pixel_values.shape[1:] + for i in range(B): + for n in range(N): + patch_h = int(H * mask_ratio**0.5) + patch_w = int(W * mask_ratio**0.5) + start_h = random.randint(0, max(0, H - patch_h)) + start_w = random.randint(0, max(0, W - patch_w)) + masked_pixel_values[i, n, :, start_h : start_h + patch_h, start_w : start_w + patch_w] = 0 + + elif self.mask_type == "grid": + # Grid-based masking (mask regular grid cells) + if pixel_values.ndim == 4: + C, H, W = pixel_values.shape[1:] + grid_size = int((1 / mask_ratio) ** 0.5) + cell_h, cell_w = H // grid_size, W // grid_size + + for i in range(grid_size): + for j in range(grid_size): + if random.random() < mask_ratio: + masked_pixel_values[:, :, i * cell_h : (i + 1) * cell_h, j * cell_w : (j + 1) * cell_w] = 0 + + return masked_pixel_values + + def _compute_loss(self, model, inputs): + # >>> 1. GRPO loss + # Compute the per-token log probabilities for the model + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + + # Compute the per_token_logps and the entropy at each position in the completion + per_token_logps, entropies = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=True, + pixel_values=inputs.get("pixel_values"), + image_grid_thw=inputs.get("image_grid_thw"), + num_images=inputs.get("num_images"), + pixel_attention_mask=inputs.get("pixel_attention_mask"), + image_sizes=inputs.get("image_sizes"), + ) + + if self.top_entropy_quantile < 1.0: + entropy_mask = self.get_high_entropy_mask(entropies, completion_mask, 1 - self.top_entropy_quantile) + else: + entropy_mask = None + + # Compute the KL divergence between the model and the reference model + if self.beta != 0.0: + ref_per_token_logps = inputs["ref_per_token_logps"] + per_token_kl = ( + torch.exp(ref_per_token_logps - per_token_logps) - (ref_per_token_logps - per_token_logps) - 1 + ) + + # Compute the loss + advantages = inputs["advantages"] + # When using num_iterations == 1 and steps_per_generation <= gradient_accumulation_steps + # old_per_token_logps == per_token_logps, so we can skip it's computation + # (see _generate_and_score_completions) and use per_token_logps.detach() instead. + old_per_token_logps = inputs.get("old_per_token_logps") + old_per_token_logps = per_token_logps.detach() if old_per_token_logps is None else old_per_token_logps + + log_ratio = per_token_logps - old_per_token_logps + if self.importance_sampling_level == "token": + log_importance_weights = log_ratio + elif self.importance_sampling_level == "sequence": + log_importance_weights = (log_ratio * completion_mask).sum(-1) / completion_mask.sum(-1).clamp(min=1.0) + log_importance_weights = log_importance_weights.unsqueeze(-1) + else: + raise ValueError( + f"Unknown importance sampling level: {self.importance_sampling_level}. Possible values are 'token' " + "and 'sequence'." + ) + # From here, log_importance_weights (and all subsequent tensors, coef_1, coef_2, etc.) shape depends on + # importance_sampling_level: "token" level: (B, T); "sequence" level: (B, 1) + + coef_1 = torch.exp(log_importance_weights) + coef_2 = torch.clamp(coef_1, 1 - self.epsilon_low, 1 + self.epsilon_high) + + # Two-sided clipping + if self.args.delta is not None: + coef_1 = torch.clamp(coef_1, max=self.args.delta) + + per_token_loss1 = coef_1 * advantages.unsqueeze(1) + per_token_loss2 = coef_2 * advantages.unsqueeze(1) + per_token_loss = -torch.min(per_token_loss1, per_token_loss2) + if entropy_mask is not None: + per_token_loss = per_token_loss * entropy_mask + if self.beta != 0.0: + per_token_loss = per_token_loss + self.beta * per_token_kl + + if self.loss_type == "grpo": + loss = ((per_token_loss * completion_mask).sum(-1) / completion_mask.sum(-1).clamp(min=1.0)).mean() + loss = loss / self.current_gradient_accumulation_steps + elif self.loss_type == "dapo": + normalizer = inputs["num_items_in_batch"] / self.accelerator.num_processes + loss = (per_token_loss * completion_mask).sum() / normalizer + else: + raise ValueError(f"Unknown loss type: {self.loss_type}") + # >>> 2. Implicit Perception Loss + inputs["pixel_values"] = self._mask_image(inputs["pixel_values"], self.mask_ratio) + mask_img_per_token_logps, mask_img_entropies = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=True, + pixel_values=inputs.get("pixel_values"), + image_grid_thw=inputs.get("image_grid_thw"), + num_images=inputs.get("num_images"), + pixel_attention_mask=inputs.get("pixel_attention_mask"), + image_sizes=inputs.get("image_sizes"), + ) + perception_kl = ( + torch.exp(mask_img_per_token_logps - per_token_logps) - (mask_img_per_token_logps - per_token_logps) - 1 + ) + perception_kl = torch.clamp(perception_kl, min=0.0, max=0.2) + perception_loss = self.perception_loss_weight * perception_kl + + # >>> 3. Double Entropy Loss + der_loss = self.der_loss_weight1 * entropies + self.der_loss_weight2 * mask_img_entropies + + # PAPO Loss + loss = (loss - perception_loss + der_loss).mean() + # Log the metrics + mode = "train" if self.model.training else "eval" + + completion_token_count = completion_mask.sum().clamp(min=1.0) + + def masked_batch_mean(x): + if x.shape[1] == 1: # when importance_sampling_level == "sequence" + return x.mean() + else: + return (x * completion_mask).sum() / completion_token_count + + if self.beta != 0.0: + mean_kl = masked_batch_mean(per_token_kl) + self._metrics[mode]["kl"].append(self.accelerator.gather(mean_kl).nanmean().item()) + + mean_entropy = masked_batch_mean(entropies) + self._metrics[mode]["entropy"].append(self.accelerator.gather(mean_entropy).nanmean().item()) + + # Compute the clipped probability ratios + is_low_clipped = (coef_1 < 1 - self.epsilon_low) & (advantages.unsqueeze(1) < 0) + is_high_clipped = (coef_1 > 1 + self.epsilon_high) & (advantages.unsqueeze(1) > 0) + is_region_clipped = is_low_clipped | is_high_clipped + + low_clip = masked_batch_mean(is_low_clipped.float()) + high_clip = masked_batch_mean(is_high_clipped.float()) + clip_ratio = masked_batch_mean(is_region_clipped.float()) + + gathered_low_clip = self.accelerator.gather(low_clip) + self._metrics[mode]["clip_ratio/low_mean"].append(gathered_low_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/low_min"].append(nanmin(gathered_low_clip).item()) + gathered_high_clip = self.accelerator.gather(high_clip) + self._metrics[mode]["clip_ratio/high_mean"].append(gathered_high_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/high_max"].append(nanmax(gathered_high_clip).item()) + gathered_clip_ratio = self.accelerator.gather(clip_ratio) + self._metrics[mode]["clip_ratio/region_mean"].append(gathered_clip_ratio.nanmean().item()) + return loss diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..09451e973bea4ae1432fe16276907644cd67466c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/__init__.py @@ -0,0 +1,30 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .modeling_value_head import ( + AutoModelForCausalLMWithValueHead, + AutoModelForSeq2SeqLMWithValueHead, + PreTrainedModelWrapper, +) +from .ppo_config import PPOConfig +from .ppo_trainer import PPOTrainer + + +__all__ = [ + "AutoModelForCausalLMWithValueHead", + "AutoModelForSeq2SeqLMWithValueHead", + "PreTrainedModelWrapper", + "PPOConfig", + "PPOTrainer", +] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/modeling_value_head.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/modeling_value_head.py new file mode 100644 index 0000000000000000000000000000000000000000..b2307b7562fbd06134958676f43687caf585cc7b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/modeling_value_head.py @@ -0,0 +1,1007 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import logging +import os + +import torch +import torch.nn as nn +from accelerate import PartialState +from huggingface_hub import hf_hub_download +from huggingface_hub.utils import ( + EntryNotFoundError, + HFValidationError, + LocalEntryNotFoundError, + RepositoryNotFoundError, +) +from safetensors.torch import load_file as safe_load_file +from transformers import ( + AutoModelForCausalLM, + AutoModelForSeq2SeqLM, + PreTrainedModel, + is_torch_npu_available, + is_torch_xpu_available, +) +from transformers.utils import is_peft_available + + +if is_peft_available(): + from peft import ( + PeftConfig, + PeftModel, + PeftModelForCausalLM, + PeftModelForSeq2SeqLM, + PromptLearningConfig, + get_peft_model, + prepare_model_for_kbit_training, + ) + + +class PreTrainedModelWrapper(nn.Module): + """ + Wrapper for a [`~transformers.PreTrainedModel`] implemented as a standard PyTorch [`torch.nn.Module`]. + + This class provides a compatibility layer that preserves the key attributes and methods of the original + [`~transformers.PreTrainedModel`], while exposing a uniform interface consistent with PyTorch modules. It enables + seamless integration of pretrained Transformer models into custom training, evaluation, or inference workflows. + + Attributes: + pretrained_model ([`~transformers.PreTrainedModel`]): + The model to be wrapped. + parent_class ([`~transformers.PreTrainedModel`]): + The parent class of the model to be wrapped. + supported_args (`list`): + The list of arguments that are supported by the wrapper class. + """ + + transformers_parent_class = None + supported_args = None + supported_modules = ("v_head",) + supported_rm_modules = ("score",) + supported_pretrained_model_architectures = ( + (PreTrainedModel) + if not is_peft_available() + else (PreTrainedModel, PeftModelForCausalLM, PeftModelForSeq2SeqLM) + ) + + def __init__( + self, pretrained_model=None, score_module=None, supports_rm_adapter=False, rm_adapter_name=None, **kwargs + ): + super().__init__() + self.pretrained_model = pretrained_model + + self.config = pretrained_model.config + self.prepare_inputs_for_generation = pretrained_model.prepare_inputs_for_generation + self.is_loaded_in_8bit = getattr(pretrained_model, "is_loaded_in_8bit", False) + self.is_loaded_in_4bit = getattr(pretrained_model, "is_loaded_in_4bit", False) + self.is_sequential_parallel = False + + if hasattr(pretrained_model, "gradient_checkpointing_disable"): + self.gradient_checkpointing_disable = pretrained_model.gradient_checkpointing_disable + + if hasattr(pretrained_model, "gradient_checkpointing_enable"): + self.gradient_checkpointing_enable = pretrained_model.gradient_checkpointing_enable + + if hasattr(pretrained_model, "enable_input_require_grads"): + self.enable_input_require_grads = pretrained_model.enable_input_require_grads + + self.supports_rm_adapter = supports_rm_adapter + self.rm_adapter_name = rm_adapter_name + self.policy_adapter_name = "default" + if score_module is not None: + self.score = score_module + + @classmethod + def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): + r""" + Instantiates a new model from a pretrained model from `transformers`. The pretrained model is loaded using the + `from_pretrained` method of the [`~transformers.PreTrainedModel`] class. The arguments that are specific to the + [`~transformers.PreTrainedModel`] class are passed along this method and filtered out from the `kwargs` + argument. + + Args: + pretrained_model_name_or_path (`str` or [`~transformers.PreTrainedModel`]): + The path to the pretrained model or its name. + *model_args (`list`, *optional*): + Additional positional arguments passed along to the underlying model's `from_pretrained` method. + **kwargs (`dict`, *optional*): + Additional keyword arguments passed along to the underlying model's `from_pretrained` method. We also + pre-process the kwargs to extract the arguments that are specific to the + [`~transformers.PreTrainedModel`] class and the arguments that are specific to trl models. The kwargs + also support `prepare_model_for_kbit_training` arguments from `peft` library. + """ + if kwargs is not None: + peft_config = kwargs.pop("peft_config", None) + reward_adapter = kwargs.pop("reward_adapter", None) + reward_adapter_name = kwargs.pop("reward_adapter_name", "reward_adapter") + is_trainable = kwargs.pop("is_trainable", False) + trl_model_args, pretrained_kwargs, peft_quantization_kwargs = cls._split_kwargs(kwargs) + token = pretrained_kwargs.get("token", None) + else: + peft_config = None + is_trainable = False + trl_model_args = {} + pretrained_kwargs = {} + peft_quantization_kwargs = {} + token = None + + if reward_adapter is not None and not isinstance(reward_adapter, str): + raise ValueError( + "The `reward_adapter` argument should be a string representing the name of local path or the Hub id to the Reward Modeling adapter." + ) + + is_peft_model = False + + current_device = cls._get_current_device() + if isinstance(pretrained_model_name_or_path, str): + quantization_config = pretrained_kwargs.get("quantization_config", None) + if quantization_config is not None: + is_loaded_in_8bit = getattr(quantization_config, "load_in_8bit", False) + is_loaded_in_4bit = getattr(quantization_config, "load_in_4bit", False) + else: + is_loaded_in_8bit = pretrained_kwargs["load_in_8bit"] if "load_in_8bit" in pretrained_kwargs else False + is_loaded_in_4bit = pretrained_kwargs["load_in_4bit"] if "load_in_4bit" in pretrained_kwargs else False + else: + is_loaded_in_8bit = getattr(pretrained_model_name_or_path, "is_loaded_in_8bit", False) + is_loaded_in_4bit = getattr(pretrained_model_name_or_path, "is_loaded_in_4bit", False) + + if (is_loaded_in_8bit or is_loaded_in_4bit) and "device_map" not in pretrained_kwargs: + # warn users + logging.warning( + "The `device_map` argument is not provided. We will override the device_map argument." + " to set the entire" + " model on the current device. If you want to set the model on multiple devices, please provide" + " a custom `device_map` argument." + ) + pretrained_kwargs["device_map"] = {"": current_device} + + if is_peft_available() and peft_config is not None and not isinstance(peft_config, PeftConfig): + raise ValueError("The `peft_config` argument should be an instance of `peft.PeftConfig` class.") + + # First, load the pre-trained model using the parent-class + # either `AutoModelForCausalLM` or `AutoModelForSeq2SeqLM` + if isinstance(pretrained_model_name_or_path, str): + if is_peft_available(): + try: + # If there is a trained peft adapter in the hub, load its config. + remote_adapter_config = hf_hub_download( + pretrained_model_name_or_path, + "adapter_config.json", + token=token, + ) + except (EntryNotFoundError, LocalEntryNotFoundError, HFValidationError, RepositoryNotFoundError): + remote_adapter_config = None + else: + remote_adapter_config = None + + local_adapter_present = os.path.exists(os.path.join(pretrained_model_name_or_path, "adapter_config.json")) + + if (local_adapter_present or remote_adapter_config is not None) and is_peft_available(): + if peft_config is not None: + logging.warning( + "`peft_config` argument ignored since a peft config file was found in " + f"{pretrained_model_name_or_path}" + ) + + # Load the trained peft adapter config + if local_adapter_present: + trained_adapter_config = PeftConfig.from_pretrained(pretrained_model_name_or_path) + else: + remote_adapter_dir = os.path.dirname(remote_adapter_config) + trained_adapter_config = PeftConfig.from_pretrained(remote_adapter_dir) + + # Load the pretrained base model + pretrained_model = cls.transformers_parent_class.from_pretrained( + trained_adapter_config.base_model_name_or_path, *model_args, **pretrained_kwargs + ) + + # Wrap the pretrained model with the trained peft adapter + pretrained_model = PeftModel.from_pretrained( + pretrained_model, pretrained_model_name_or_path, is_trainable=is_trainable, token=token + ) + logging.info("Trained peft adapter loaded") + else: + pretrained_model = cls.transformers_parent_class.from_pretrained( + pretrained_model_name_or_path, *model_args, **pretrained_kwargs + ) + + if peft_config is not None: + # Initialize a new peft adapter with the given config + if is_loaded_in_8bit or is_loaded_in_4bit: + pretrained_model = prepare_model_for_kbit_training( + pretrained_model, + **peft_quantization_kwargs, + ) + pretrained_model = get_peft_model(pretrained_model, peft_config) + logging.info("peft adapter initialised") + + elif isinstance(pretrained_model_name_or_path, cls.supported_pretrained_model_architectures): + pretrained_model = pretrained_model_name_or_path + + if peft_config is not None and isinstance(pretrained_model, PreTrainedModel): + # Initialize a new peft adapter with the given config + if is_loaded_in_8bit or is_loaded_in_4bit: + pretrained_model = prepare_model_for_kbit_training( + pretrained_model, + **peft_quantization_kwargs, + ) + pretrained_model = get_peft_model(pretrained_model, peft_config) + logging.info("peft adapter initialised") + else: + raise ValueError( + "pretrained_model_name_or_path should be a string or a PreTrainedModel, " + f"but is {type(pretrained_model_name_or_path)}" + ) + + if is_peft_available(): + if isinstance(pretrained_model, PeftModel): + is_peft_model = True + # for backward compatibility + if hasattr(pretrained_model, "active_peft_config") and isinstance( + pretrained_model.active_peft_config, PromptLearningConfig + ): + raise ValueError("PromptLearningConfig is not supported for PPO training.") + + # Add reward modeling adapter if specified + if not is_peft_model and reward_adapter is not None: + raise ValueError("reward_adapter can only be used with a PeftModel. ") + elif is_peft_model and reward_adapter is not None: + score_module = cls.add_and_load_reward_modeling_adapter( + pretrained_model, reward_adapter, reward_adapter_name, token=token + ) + multi_adapter_args = { + "score_module": score_module, + "supports_rm_adapter": True, + "rm_adapter_name": reward_adapter_name, + } + else: + multi_adapter_args = {"supports_rm_adapter": False} + + # Then, create the full model by instantiating the wrapper class + model = cls(pretrained_model, **multi_adapter_args, **trl_model_args) + + # if resume_training, load the state_dict again - this is ok since the + # state_dict is removed from the model after loading it. + is_resuming_training = True + if isinstance(pretrained_model_name_or_path, str): + safe_filename = os.path.join(pretrained_model_name_or_path, "model.safetensors") + filename = os.path.join(pretrained_model_name_or_path, "pytorch_model.bin") + + sharded_index_filename = os.path.join(pretrained_model_name_or_path, "pytorch_model.bin.index.json") + safe_sharded_index_filename = os.path.join(pretrained_model_name_or_path, "model.safetensors.index.json") + is_sharded = False + use_safe = os.path.exists(safe_filename) + + if not (os.path.exists(filename) or os.path.exists(safe_filename)): + # Try with `pytorch_model.bin` + filename, files_to_download, is_sharded, is_resuming_training = cls._get_checkpoint_from_hub( + pretrained_model, + pretrained_model_name_or_path, + sharded_index_filename, + token=token, + ) + # Try with safetensors + if filename is None and files_to_download is None: + safe_filename, files_to_download, is_sharded, is_resuming_training = cls._get_checkpoint_from_hub( + pretrained_model, + pretrained_model_name_or_path, + safe_sharded_index_filename, + token=token, + model_name="model.safetensors", + model_index_name="model.safetensors.index.json", + ) + use_safe = True + else: + use_safe = False + + loading_func = safe_load_file if use_safe else torch.load + load_kwargs = {} if use_safe else {"map_location": "cpu", "weights_only": True} + + if is_resuming_training: + if is_sharded: + # download each file and add it to the state_dict + state_dict = {} + + for shard_file in files_to_download: + filename = hf_hub_download( + pretrained_model_name_or_path, + shard_file, + token=token, + ) + state_dict.update(loading_func(filename, **load_kwargs)) + else: + state_dict = loading_func(filename if not use_safe else safe_filename, **load_kwargs) + + else: + state_dict = pretrained_model_name_or_path.state_dict() + + model.is_peft_model = is_peft_model + model.current_device = current_device + + if is_resuming_training: + model.post_init(state_dict=state_dict) + + return model + + @classmethod + def _get_checkpoint_from_hub( + cls, + pretrained_model, + pretrained_model_name_or_path, + index_filename, + token=None, + model_name="pytorch_model.bin", + model_index_name="pytorch_model.bin.index.json", + ): + files_to_download = None + filename = None + is_resuming_training = True + is_sharded = False + + try: + filename = hf_hub_download( + pretrained_model_name_or_path, + model_name, + token=token, + ) + # sharded + except (EntryNotFoundError, LocalEntryNotFoundError, HFValidationError, RepositoryNotFoundError): + if os.path.exists(index_filename): + index_file_name = index_filename + else: + try: + index_file_name = hf_hub_download( + pretrained_model_name_or_path, + model_index_name, + token=token, + ) + except (EntryNotFoundError, LocalEntryNotFoundError, HFValidationError, RepositoryNotFoundError): + # not continue training, do not have v_head weight + is_resuming_training = False + logging.warning( + f"A {type(pretrained_model)} model is loaded from '{pretrained_model_name_or_path}', " + f"and no v_head weight is found. This IS expected if you are not resuming PPO training." + ) + # load json + if is_resuming_training: + with open(index_file_name) as f: + index = json.load(f) + # check filename with `v_head` or any known extra module: + files_to_download = set() + for k, v in index["weight_map"].items(): + if any(module in k for module in cls.supported_modules): + files_to_download.add(v) + is_sharded = True + + return filename, files_to_download, is_sharded, is_resuming_training + + @classmethod + def _get_current_device(cls): + r""" + Get the current device. For GPU & XPU, we return the local process index using the `accelerate.PartialState` + object to handle corner cases when running scripts in distributed environments. + + Returns: + current_device (`int | str`): + The current device. + """ + state = PartialState() + if torch.cuda.is_available() or is_torch_xpu_available(): + return state.local_process_index + elif is_torch_npu_available(): + return f"npu:{state.local_process_index}" + else: + return "cpu" + + @classmethod + def _split_kwargs(cls, kwargs): + """ + Separate the kwargs from the arguments that we support inside `supported_args` and the ones that we don't. + """ + check_peft_kwargs = False + + if is_peft_available(): + from peft import prepare_model_for_kbit_training + + check_peft_kwargs = True + + supported_kwargs = {} + unsupported_kwargs = {} + peft_kwargs = {} + + for key, value in kwargs.items(): + if key in cls.supported_args: + supported_kwargs[key] = value + else: + unsupported_kwargs[key] = value + + if check_peft_kwargs: + if key in prepare_model_for_kbit_training.__code__.co_varnames: + peft_kwargs[key] = value + if key in unsupported_kwargs: + unsupported_kwargs.pop(key) + + return supported_kwargs, unsupported_kwargs, peft_kwargs + + @classmethod + def add_and_load_reward_modeling_adapter( + cls, pretrained_model, adapter_model_id, adapter_name="reward_model_adapter", token=None + ): + r""" + Add and load a reward modeling adapter. This method can only be used if the model is a `PeftModel` and if you + have initialized the model with the `reward_modeling_adapter_id` argument, pointing to the id of the reward + modeling adapter. The latest needs also to contain the score head in order to produce the reward. + """ + pretrained_model.load_adapter(adapter_model_id, adapter_name, is_trainable=False) + pretrained_model.train() + + filename = os.path.join(adapter_model_id, "adapter_model.bin") + safe_loading = False + if not os.path.exists(filename): + try: + local_filename = hf_hub_download( + adapter_model_id, + "adapter_model.bin", + token=token, + ) + except Exception: + filename = os.path.join(adapter_model_id, "adapter_model.safetensors") + safe_loading = True + if not os.path.exists(filename): + try: + local_filename = hf_hub_download( + adapter_model_id, + "adapter_model.safetensors", + token=token, + ) + except Exception as exc: + raise ValueError( + "Could not find adapter model in the Hub, make sure you have the correct adapter model id." + ) from exc + else: + local_filename = filename + else: + local_filename = filename + + loading_func = safe_load_file if safe_loading else torch.load + load_kwargs = {} if safe_loading else {"map_location": "cpu", "weights_only": True} + + adapter_state_dict = loading_func(local_filename, **load_kwargs) + + for score_name_candidate in cls.supported_rm_modules: + if any(score_name_candidate in name for name in adapter_state_dict.keys()): + score_name = score_name_candidate + # we have found the correct head name and can break + break + + score_dict = {} + + for name, param in adapter_state_dict.items(): + if score_name in name: + key_name = ".".join(name.split(".")[-1:]) + score_dict[key_name] = param.to(cls._get_current_device()) + + num_labels, hidden_dim = score_dict["weight"].shape + has_bias = any("bias" in name for name in adapter_state_dict.keys()) + + score = nn.Linear(hidden_dim, num_labels, bias=has_bias).to( + device=cls._get_current_device(), + dtype=pretrained_model.dtype, + ) + score.load_state_dict(score_dict) + for param in score.parameters(): + param.requires_grad = False + + return score + + def push_to_hub(self, *args, **kwargs): + r""" + Push the pretrained model to the hub. This method is a wrapper around + [`~transformers.PreTrainedModel.push_to_hub`]. Please refer to the documentation of + [`~transformers.PreTrainedModel.push_to_hub`] for more information. + + Args: + *args (`list`, *optional*): + Positional arguments passed along to the underlying model's `push_to_hub` method. + **kwargs (`dict`, *optional*): + Keyword arguments passed along to the underlying model's `push_to_hub` method. + """ + raise NotImplementedError + + def save_pretrained(self, *args, **kwargs): + r""" + Save the pretrained model to a directory. This method is a wrapper around + [`~transformers.PreTrainedModel.save_pretrained`]. Please refer to the documentation of + [`~transformers.PreTrainedModel.save_pretrained`] for more information. + + Args: + *args (`list`, *optional*): + Positional arguments passed along to the underlying model's `save_pretrained` method. + **kwargs (`dict`, *optional*): + Keyword arguments passed along to the underlying model's `save_pretrained` method. + """ + state_dict = kwargs.get("state_dict") + if state_dict is None: + state_dict = self.state_dict() + kwargs["state_dict"] = state_dict + + # if it is a peft model only save the `v_head` state_dict and + # pop the `state_dict` from the kwargs to avoid silent bugs with `peft` + if self.is_peft_model: + save_path = args[0] + save_path = os.path.join(save_path, "pytorch_model.bin") + torch.save(state_dict, save_path) + _ = kwargs.pop("state_dict", None) + + return self.pretrained_model.save_pretrained(*args, **kwargs) + + def state_dict(self, *args, **kwargs): + r""" + Return the state_dict of the pretrained model. + """ + raise NotImplementedError + + def post_init(self, *args, **kwargs): + r""" + Post initialization method. This method is called after the model is instantiated and loaded from a checkpoint. + It can be used to perform additional operations such as loading the state_dict. + """ + raise NotImplementedError + + def compute_reward_score(self, input_ids, attention_mask=None, **kwargs): + r""" + Computes the reward score for a given input. The method has first to enable the adapter and then compute the + reward score. After that the model disables the reward modeling adapter and enables the default ppo adapter + again. + """ + if not self.supports_rm_adapter: + raise ValueError("This model does not support reward modeling adapter.") + + # enable rm adapter + self.pretrained_model.set_adapter(self.rm_adapter_name) + self.pretrained_model.eval() + + with torch.no_grad(): + base_model_output = self.pretrained_model( + input_ids=input_ids, + attention_mask=attention_mask, + output_hidden_states=True, + return_dict=True, + **kwargs, + ) + + last_hidden_states = base_model_output.hidden_states[-1] + scores = self.score(last_hidden_states) + + self.pretrained_model.set_adapter(self.policy_adapter_name) + self.pretrained_model.eval() + + return scores + + +class ValueHead(nn.Module): + r""" + The ValueHead class implements a head for GPT2 that returns a scalar for each output token. + """ + + def __init__(self, config, **kwargs): + super().__init__() + if not hasattr(config, "summary_dropout_prob"): + summary_dropout_prob = kwargs.pop("summary_dropout_prob", 0.1) + else: + summary_dropout_prob = config.summary_dropout_prob + + self.dropout = nn.Dropout(summary_dropout_prob) if summary_dropout_prob else nn.Identity() + + # some models such as OPT have a projection layer before the word embeddings - e.g. OPT-350m + if hasattr(config, "hidden_size"): + hidden_size = config.hidden_size + if hasattr(config, "word_embed_proj_dim"): + hidden_size = config.word_embed_proj_dim + elif hasattr(config, "is_encoder_decoder"): + if config.is_encoder_decoder and hasattr(config, "decoder"): + if hasattr(config.decoder, "hidden_size"): + hidden_size = config.decoder.hidden_size + + self.summary = nn.Linear(hidden_size, 1) + + self.flatten = nn.Flatten() + + def forward(self, hidden_states): + output = self.dropout(hidden_states) + + # For now force upcast in fp32 if needed. Let's keep the + # output in fp32 for numerical stability. + if output.dtype != self.summary.weight.dtype: + output = output.to(self.summary.weight.dtype) + + output = self.summary(output) + return output + + +class AutoModelForCausalLMWithValueHead(PreTrainedModelWrapper): + """ + An autoregressive model with a value head in addition to the language model head. This class inherits from + [`experimental.ppo.PreTrainedModelWrapper`] and wraps a [`~transformers.PreTrainedModel`] class. The wrapper class + supports classic functions such as `from_pretrained`, `push_to_hub` and `generate`. To call a method of the wrapped + model, simply manipulate the `pretrained_model` attribute of this class. + + Class attributes: + - **transformers_parent_class** ([`~transformers.PreTrainedModel`]) -- The parent class of the wrapped model. + This + should be set to `transformers.AutoModelForCausalLM` for this class. + - **supported_args** (`tuple`) -- A tuple of strings that are used to identify the arguments that are supported + by the [`ValueHead`] class. Currently, the supported args are: + - **summary_dropout_prob** (`float`, `optional`, defaults to `None`) -- The dropout probability for the + [`ValueHead`] class. + - **v_head_initializer_range** (`float`, `optional`, defaults to `0.2`) -- The initializer range for the + [`ValueHead`] if a specific initialization strategy is selected. + - **v_head_init_strategy** (`str`, `optional`, defaults to `None`) -- The initialization strategy for the + [`ValueHead`]. Currently, the supported strategies are: + - **`None`** -- Initializes the weights of the [`ValueHead`] with a random distribution. This is the + default strategy. + - **"normal"** -- Initializes the weights of the [`ValueHead`] with a normal distribution. + """ + + transformers_parent_class = AutoModelForCausalLM + supported_args = ( + "summary_dropout_prob", + "v_head_initializer_range", + "v_head_init_strategy", + ) + + def __init__(self, pretrained_model, **kwargs): + """ + Initializes the model. + + Args: + pretrained_model ([`~transformers.PreTrainedModel`]): + The model to wrap. It should be a causal language model such as GPT2. or any model mapped inside the + `AutoModelForCausalLM` class. + kwargs (`dict`, `optional`): + Additional keyword arguments, that are passed to the [`ValueHead`] class. + """ + super().__init__(pretrained_model, **kwargs) + v_head_kwargs, _, _ = self._split_kwargs(kwargs) + self.v_head = ValueHead(self.pretrained_model.config, **v_head_kwargs) + self._init_weights(**v_head_kwargs) + + def _init_weights(self, **kwargs): + r""" + Initializes the weights of the value head. The default initialization strategy is random. Users can pass a + different initialization strategy by passing the `v_head_init_strategy` argument when calling + `.from_pretrained`. Supported strategies are: + - `normal`: initializes the weights with a normal distribution. + + Args: + **kwargs (`dict`, `optional`): + Additional keyword arguments, that are passed to the [`ValueHead`] class. These arguments can contain + the `v_head_init_strategy` argument as well as the `v_head_initializer_range` argument. + """ + initializer_range = kwargs.pop("v_head_initializer_range", 0.2) + # random init by default + init_strategy = kwargs.pop("v_head_init_strategy", None) + if init_strategy is None: + # do nothing + pass + elif init_strategy == "normal": + self.v_head.summary.weight.data.normal_(mean=0.0, std=initializer_range) + self.v_head.summary.bias.data.zero_() + + def forward( + self, + input_ids=None, + past_key_values=None, + attention_mask=None, + return_past_key_values=False, + **kwargs, + ): + r""" + Applies a forward pass to the wrapped model and returns the logits of the value head. + + Args: + input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): + Indices of input sequence tokens in the vocabulary. + past_key_values (`tuple(tuple(torch.FloatTensor))`, `optional`): + Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model + (see `past_key_values` input) to speed up sequential decoding. + attention_mask (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, `optional`): + Mask to avoid performing attention on padding token indices. Mask values selected in ``[0, 1]``: + - 1 for tokens that are **not masked**, + - 0 for tokens that are **masked**. + return_past_key_values (bool): A flag indicating if the computed hidden-states should be returned. + kwargs (`dict`, `optional`): + Additional keyword arguments, that are passed to the wrapped model. + """ + kwargs["output_hidden_states"] = True # this had already been set in the LORA / PEFT examples + kwargs["past_key_values"] = past_key_values + + if self.is_peft_model and self.pretrained_model.active_peft_config.peft_type == "PREFIX_TUNING": + kwargs.pop("past_key_values") + + base_model_output = self.pretrained_model( + input_ids=input_ids, + attention_mask=attention_mask, + **kwargs, + ) + + last_hidden_state = base_model_output.hidden_states[-1] + lm_logits = base_model_output.logits + loss = base_model_output.loss + + if last_hidden_state.device != self.v_head.summary.weight.device: + last_hidden_state = last_hidden_state.to(self.v_head.summary.weight.device) + + value = self.v_head(last_hidden_state).squeeze(-1) + + # force upcast in fp32 if logits are in half-precision + if lm_logits.dtype != torch.float32: + lm_logits = lm_logits.float() + + if return_past_key_values: + return (lm_logits, loss, value, base_model_output.past_key_values) + else: + return (lm_logits, loss, value) + + def generate(self, *args, **kwargs): + r""" + A simple wrapper around the `generate` method of the wrapped model. Please refer to the + [`generate`](https://huggingface.co/docs/transformers/internal/generation_utils) method of the wrapped model + for more information about the supported arguments. + + Args: + *args (`list`, *optional*): + Positional arguments passed to the `generate` method of the wrapped model. + **kwargs (`dict`, *optional*): + Keyword arguments passed to the `generate` method of the wrapped model. + """ + return self.pretrained_model.generate(*args, **kwargs) + + def state_dict(self, *args, **kwargs): + r""" + Returns the state dictionary of the model. We add the state dictionary of the value head to the state + dictionary of the wrapped model by prepending the key with `v_head.`. + """ + if not self.is_peft_model: + pretrained_model_state_dict = self.pretrained_model.state_dict(*args, **kwargs) + else: + # if it is a peft model, only save the v_head + pretrained_model_state_dict = {} + + v_head_state_dict = self.v_head.state_dict(*args, **kwargs) + for k, v in v_head_state_dict.items(): + pretrained_model_state_dict[f"v_head.{k}"] = v + return pretrained_model_state_dict + + def push_to_hub(self, *args, **kwargs): + self.pretrained_model.v_head = self.v_head + + return self.pretrained_model.push_to_hub(*args, **kwargs) + + def post_init(self, state_dict): + r""" + We add the state dictionary of the value head to the state dictionary of the wrapped model by prepending the + key with `v_head.`. This function removes the `v_head.` prefix from the keys of the value head state + dictionary. + """ + for k in list(state_dict.keys()): + if "v_head." in k: + state_dict[k.replace("v_head.", "")] = state_dict.pop(k) + self.v_head.load_state_dict(state_dict, strict=False) + del state_dict + + if hasattr(self.pretrained_model, "hf_device_map"): + if ( + "cpu" in self.pretrained_model.hf_device_map.values() + or "disk" in self.pretrained_model.hf_device_map.values() + ): + raise ValueError( + "The model is offloaded on CPU or disk - CPU & disk offloading is not supported for ValueHead models." + ) + + first_device = list(set(self.pretrained_model.hf_device_map.values()))[0] + if isinstance(first_device, int): + if is_torch_npu_available(): + first_device = f"npu:{first_device}" + elif is_torch_xpu_available(): + first_device = f"xpu:{first_device}" + else: + first_device = f"cuda:{first_device}" + self.v_head = self.v_head.to(first_device) + + def set_device_hook(module, input, outputs): + new_output = () + for output in outputs: + if isinstance(output, torch.Tensor): + new_output += (output.to(first_device),) + else: + new_output += (output,) + return new_output + + self.register_forward_hook(set_device_hook) + + self.is_sequential_parallel = True + + +class AutoModelForSeq2SeqLMWithValueHead(PreTrainedModelWrapper): + """ + A seq2seq model with a value head in addition to the language model head. This class inherits from + [`experimental.ppo.PreTrainedModelWrapper`] and wraps a [`~transformers.PreTrainedModel`] class. The wrapper class + supports classic functions such as `from_pretrained` and `push_to_hub` and also provides some additional + functionalities such as `generate`. + + Args: + pretrained_model ([`~transformers.PreTrainedModel`]): + The model to wrap. It should be a causal language model such as GPT2. or any model mapped inside the + [`~transformers.AutoModelForSeq2SeqLM`] class. + kwargs: + Additional keyword arguments passed along to the [`ValueHead`] class. + """ + + transformers_parent_class = AutoModelForSeq2SeqLM + lm_head_namings = ["lm_head", "embed_out", "output_projection"] + supported_args = ( + "summary_dropout_prob", + "v_head_initializer_range", + "v_head_init_strategy", + ) + + def __init__(self, pretrained_model, **kwargs): + super().__init__(pretrained_model, **kwargs) + v_head_kwargs, _, _ = self._split_kwargs(kwargs) + self.is_encoder_decoder = True + + if not self._has_lm_head(): + raise ValueError("The model does not have a language model head, please use a model that has one.") + + self.v_head = ValueHead(self.pretrained_model.config, **v_head_kwargs) + + self._init_weights(**v_head_kwargs) + + def _has_lm_head(self): + # check module names of all modules inside `pretrained_model` to find the language model head + for name, _module in self.pretrained_model.named_modules(): + if any(attribute in name for attribute in self.lm_head_namings): + return True + return False + + def post_init(self, state_dict): + r""" + We add the state dictionary of the value head to the state dictionary of the wrapped model by prepending the + key with `v_head.`. This function removes the `v_head.` prefix from the keys of the value head state + dictionary. + """ + for k in list(state_dict.keys()): + if "v_head." in k: + state_dict[k.replace("v_head.", "")] = state_dict.pop(k) + self.v_head.load_state_dict(state_dict, strict=False) + del state_dict + + if hasattr(self.pretrained_model, "hf_device_map"): + if ( + "cpu" in self.pretrained_model.hf_device_map.values() + or "disk" in self.pretrained_model.hf_device_map.values() + ): + raise ValueError( + "The model is offloaded on CPU or disk - CPU & disk offloading is not supported for ValueHead models." + ) + + # get the lm_head device + for name, module in self.pretrained_model.named_modules(): + if any(attribute in name for attribute in self.lm_head_namings): + lm_head_device = module.weight.device + break + + # put v_head on the same device as the lm_head to avoid issues + self.v_head = self.v_head.to(lm_head_device) + + def set_device_hook(module, input, outputs): + r""" + A hook that sets the device of the output of the model to the device of the first parameter of the + model. + + Args: + module (`nn.Module`): + The module to which the hook is attached. + input (`tuple`): + The input to the module. + outputs (`tuple`): + The output of the module. + """ + new_output = () + for output in outputs: + if isinstance(output, torch.Tensor): + new_output += (output.to(lm_head_device),) + else: + new_output += (output,) + return new_output + + self.register_forward_hook(set_device_hook) + self.is_sequential_parallel = True + + def state_dict(self, *args, **kwargs): + r""" + Returns the state dictionary of the model. We add the state dictionary of the value head to the state + dictionary of the wrapped model by prepending the key with `v_head.`. + """ + if not self.is_peft_model: + pretrained_model_state_dict = self.pretrained_model.state_dict(*args, **kwargs) + else: + # if it is a peft model, only save the v_head + pretrained_model_state_dict = {} + + v_head_state_dict = self.v_head.state_dict(*args, **kwargs) + for k, v in v_head_state_dict.items(): + pretrained_model_state_dict[f"v_head.{k}"] = v + return pretrained_model_state_dict + + def push_to_hub(self, *args, **kwargs): + self.pretrained_model.v_head = self.v_head + + return self.pretrained_model.push_to_hub(*args, **kwargs) + + def _init_weights(self, **kwargs): + r""" + We initialize the weights of the value head. + """ + initializer_range = kwargs.pop("v_head_initializer_range", 0.2) + # random init by default + init_strategy = kwargs.pop("v_head_init_strategy", None) + if init_strategy is None: + # do nothing + pass + elif init_strategy == "normal": + self.v_head.summary.weight.data.normal_(mean=0.0, std=initializer_range) + self.v_head.summary.bias.data.zero_() + + def forward( + self, + input_ids=None, + past_key_values=None, + attention_mask=None, + return_past_key_values=False, + **kwargs, + ): + kwargs["past_key_values"] = past_key_values + if self.is_peft_model and self.pretrained_model.active_peft_config.peft_type == "PREFIX_TUNING": + kwargs.pop("past_key_values") + + base_model_output = self.pretrained_model( + input_ids=input_ids, + attention_mask=attention_mask, + output_hidden_states=True, # We force the model to output hidden states + **kwargs, + ) + + last_hidden_state = base_model_output.decoder_hidden_states[-1] + lm_logits = base_model_output.logits + loss = base_model_output.loss + + value = self.v_head(last_hidden_state).squeeze(-1) + + # force upcast in fp32 if logits are in half-precision + if lm_logits.dtype != torch.float32: + lm_logits = lm_logits.float() + + if return_past_key_values: + return (lm_logits, loss, value, base_model_output.past_key_values) + else: + return (lm_logits, loss, value) + + def generate(self, *args, **kwargs): + r""" + We call `generate` on the wrapped model. + """ + return self.pretrained_model.generate(*args, **kwargs) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/ppo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/ppo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..b96ee394734982fd82cf6ba2ae87bc6ca7be206f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/ppo_config.py @@ -0,0 +1,280 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Literal + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class PPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.ppo.PPOTrainer`]. + + This class includes only the parameters that are specific to PPO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + num_mini_batches (`int`, *optional*, defaults to `1`): + Number of minibatches to split a batch into. + total_episodes (`int`, *optional*): + Total number of episodes in the dataset. + local_rollout_forward_batch_size (`int`, *optional*, defaults to `64`): + Per rank no grad forward pass in the rollout phase. + num_sample_generations (`int`, *optional*, defaults to `10`): + Number of debugging samples generations (i.e., `generate_completions` calls) throughout training. + response_length (`int`, *optional*, defaults to `53`): + Length of the response. + stop_token (`str`, *optional*): + Specifies the stop token to use for text generation. This parameter is mutually exclusive with + `stop_token_id`. + + - `None`: No stop token is applied, unless `stop_token_id` is specified. + - `'eos'`: Uses the tokenizer's `eos_token`. + + stop_token_id (`int`, *optional*): + Specifies the ID of the stop token to use for text generation. If `None`, no stop token ID is applied, + unless `stop_token` is specified. This parameter is mutually exclusive with `stop_token`. + temperature (`float`, *optional*, defaults to `0.7`): + Sampling temperature. + missing_eos_penalty (`float`, *optional*): + Penalty applied to the score when the model fails to generate an EOS token. This is useful to encourage to + generate completions shorter than the maximum length (`max_new_tokens`). The penalty must be a positive + value. + sft_model_path (`str`, *optional*, defaults to `"EleutherAI/pythia-160m"`): + Path to the SFT model. + world_size (`int`, *optional*): + Number of processes (GPUs) to use for the training. + num_total_batches (`int`, *optional*): + Number of total batches to train. + micro_batch_size (`int`, *optional*): + Micro batch size across devices (HF's `per_device_train_batch_size` * `world_size`). + local_batch_size (`int`, *optional*): + Batch size per GPU (HF's `per_device_train_batch_size` * `gradient_accumulation_steps`). + batch_size (`int`, *optional*): + Batch size across devices (HF's `per_device_train_batch_size` * `world_size` * + `gradient_accumulation_steps`). + local_mini_batch_size (`int`, *optional*): + Mini batch size per GPU. + mini_batch_size (`int`, *optional*): + Mini batch size across GPUs. + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether to push the model to the Hub after training. + reward_model_path (`str`, *optional*, defaults to `"EleutherAI/pythia-160m"`): + Path to the reward model. + model_adapter_name (`str`, *optional*): + Name of the train target PEFT adapter, when using LoRA with multiple adapters. + ref_adapter_name (`str`, *optional*): + Name of the reference PEFT adapter, when using LoRA with multiple adapters. + num_ppo_epochs (`int`, *optional*, defaults to `4`): + Number of epochs to train. + whiten_rewards (`bool`, *optional*, defaults to `False`): + Whether to whiten the rewards. + kl_coef (`float`, *optional*, defaults to `0.05`): + KL coefficient. + kl_estimator (`Literal["k1", "k3"]`, *optional*, defaults to `"k1"`): + Which estimator for KL-Divergence to use from [Approximating KL + Divergence](http://joschu.net/blog/kl-approx.html). Defaults to "k1", a straightforward, unbiased + estimator. Can be set to "k3", an unbiased estimator with lower variance which "appears to be a strictly + better estimator". Cannot be set to "k2", as it is used for logging purposes. + cliprange (`float`, *optional*, defaults to `0.2`): + Clip range. + vf_coef (`float`, *optional*, defaults to `0.1`): + Value function coefficient. + cliprange_value (`float`, *optional*, defaults to `0.2`): + Clip range for the value function. + gamma (`float`, *optional*, defaults to `1.0`): + Discount factor. + lam (`float`, *optional*, defaults to `0.95`): + Lambda value for GAE. + ds3_gather_for_generation (`bool`, *optional*, defaults to `True`): + This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for generation, + improving generation speed. However, disabling this option allows training models that exceed the VRAM + capacity of a single GPU, albeit at the cost of slower generation. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `3e-6` instead of `5e-5`. + """ + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=3e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + num_mini_batches: int = field( + default=1, + metadata={"help": "Number of minibatches to split a batch into."}, + ) + total_episodes: int | None = field( + default=None, + metadata={"help": "Total number of episodes in the dataset."}, + ) + local_rollout_forward_batch_size: int = field( + default=64, + metadata={"help": "Per rank no grad forward pass in the rollout phase."}, + ) + num_sample_generations: int = field( + default=10, + metadata={ + "help": "Number of debugging samples generations (i.e., `generate_completions` calls) throughout training." + }, + ) + response_length: int = field( + default=53, + metadata={"help": "Length of the response."}, + ) + stop_token: Literal["eos"] | None = field( + default=None, + metadata={ + "help": "Specifies the stop token to use for text generation. This parameter is mutually exclusive with " + "`stop_token_id`." + }, + ) + stop_token_id: int | None = field( + default=None, + metadata={ + "help": "Specifies the ID of the stop token to use for text generation. If `None`, no stop token ID is " + "applied, unless `stop_token` is specified. This parameter is mutually exclusive with `stop_token`." + }, + ) + temperature: float = field( + default=0.7, + metadata={"help": "Sampling temperature."}, + ) + missing_eos_penalty: float | None = field( + default=None, + metadata={ + "help": "Penalty applied to the score when the model fails to generate an EOS token. This is useful to " + "encourage to generate completions shorter than the maximum length (`max_new_tokens`). The penalty must be " + "a positive value." + }, + ) + sft_model_path: str = field( + default="EleutherAI/pythia-160m", + metadata={"help": "Path to the SFT model."}, + ) + world_size: int | None = field( + default=None, + metadata={"help": "Number of processes (GPUs) to use for the training."}, + ) + num_total_batches: int | None = field( + default=None, + metadata={"help": "Number of total batches to train."}, + ) + micro_batch_size: int | None = field( + default=None, + metadata={"help": "Micro batch size across devices (HF's `per_device_train_batch_size` * `world_size`)."}, + ) + local_batch_size: int | None = field( + default=None, + metadata={"help": "Batch size per GPU (HF's `per_device_train_batch_size` * `gradient_accumulation_steps`)."}, + ) + batch_size: int | None = field( + default=None, + metadata={ + "help": "Batch size across devices (HF's `per_device_train_batch_size` * `world_size` * " + "`gradient_accumulation_steps`)." + }, + ) + local_mini_batch_size: int | None = field( + default=None, + metadata={"help": "Mini batch size per GPU."}, + ) + mini_batch_size: int | None = field( + default=None, + metadata={"help": "Mini batch size across GPUs."}, + ) + push_to_hub: bool = field( + default=False, + metadata={"help": "Whether to push the model to the Hub after training."}, + ) + reward_model_path: str = field( + default="EleutherAI/pythia-160m", + metadata={"help": "Path to the reward model."}, + ) + model_adapter_name: str | None = field( + default=None, + metadata={"help": "Name of the train target PEFT adapter, when using LoRA with multiple adapters."}, + ) + ref_adapter_name: str | None = field( + default=None, + metadata={"help": "Name of the reference PEFT adapter, when using LoRA with multiple adapters."}, + ) + num_ppo_epochs: int = field( + default=4, + metadata={"help": "Number of epochs to train."}, + ) + whiten_rewards: bool = field( + default=False, + metadata={"help": "Whether to whiten the rewards."}, + ) + kl_coef: float = field( + default=0.05, + metadata={"help": "KL coefficient."}, + ) + kl_estimator: Literal["k1", "k3"] = field( + default="k1", + metadata={ + "help": "Which estimator for KL-Divergence to use from Approximating KL Divergence " + "(http://joschu.net/blog/kl-approx.html). Defaults to 'k1', a straightforward, unbiased estimator. Can be " + "set to 'k3', an unbiased estimator with lower variance which 'appears to be a strictly better " + "estimator'. Cannot be set to 'k2', as it is used for logging purposes." + }, + ) + cliprange: float = field( + default=0.2, + metadata={"help": "Clip range."}, + ) + vf_coef: float = field( + default=0.1, + metadata={"help": "Value function coefficient."}, + ) + cliprange_value: float = field( + default=0.2, + metadata={"help": "Clip range for the value function."}, + ) + gamma: float = field( + default=1.0, + metadata={"help": "Discount factor."}, + ) + lam: float = field( + default=0.95, + metadata={"help": "Lambda value for GAE."}, + ) + ds3_gather_for_generation: bool = field( + default=True, + metadata={ + "help": "This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for " + "generation, improving generation speed. However, disabling this option allows training models that " + "exceed the VRAM capacity of a single GPU, albeit at the cost of slower generation." + }, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/ppo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/ppo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..6366f987ec430d89165cd607ec9bd2e3b39799c1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ppo/ppo_trainer.py @@ -0,0 +1,1031 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gc +import math +import os +import textwrap +import time +from collections import defaultdict +from contextlib import contextmanager, nullcontext +from dataclasses import dataclass +from pathlib import Path + +import numpy as np +import pandas as pd +import torch +import torch.nn as nn +import transformers +from accelerate import Accelerator, logging +from accelerate.utils import gather_object +from datasets import Dataset +from packaging.version import Version +from torch.utils.data import DataLoader +from transformers import ( + BaseImageProcessor, + DataCollatorWithPadding, + FeatureExtractionMixin, + GenerationConfig, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + TrainerControl, + TrainerState, +) +from transformers.integrations import get_reporting_integration_callbacks +from transformers.trainer import DEFAULT_CALLBACKS, DEFAULT_PROGRESS_CALLBACK +from transformers.trainer_callback import CallbackHandler, ExportableState, PrinterCallback +from transformers.utils import ModelOutput, is_peft_available, is_rich_available + +from ...models.utils import prepare_deepspeed, unwrap_model_for_generation +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import ( + disable_dropout_in_model, + log_table_to_comet_experiment, + pad, + selective_log_softmax, +) +from ..utils import ( + create_reference_model, + empty_cache, + first_true_indices, + get_reward, + peft_module_casting_to_bf16, +) +from .ppo_config import PPOConfig + + +if is_rich_available(): + from rich.console import Console + from rich.table import Table + + +logger = logging.get_logger(__name__) + +if is_peft_available(): + from peft import PeftConfig, PeftModel, get_peft_model + + +INVALID_LOGPROB = 1.0 + + +def generate( + lm_backbone: torch.nn.Module, queries: torch.Tensor, pad_token_id: int, generation_config: GenerationConfig +) -> tuple[torch.Tensor, torch.Tensor]: + """ + Generates sequences from the language model backbone in a way that does not affect padding tokens. + + Args: + lm_backbone (`torch.nn.Module`): + The language model backbone used for generation. + queries (`torch.Tensor`): + The tensor containing the input queries. + pad_token_id (`int`): + The token ID representing the pad token. + generation_config ([`~transformers.GenerationConfig`]): + The configuration for the generation process. + + Returns: + tuple: + - `generated_sequences` (`torch.Tensor`): + The concatenated tensor of input queries and generated sequences. + - `logits` (`torch.Tensor`): + The logits output from the generation process. + """ + context_length = queries.shape[1] + attention_mask = queries != pad_token_id + input_ids = torch.masked_fill(queries, ~attention_mask, 0) + output = lm_backbone.generate( + input_ids=input_ids, + attention_mask=attention_mask, + # position_ids=attention_mask.cumsum(1) - attention_mask.long(), # not needed: already adjusted in generations + # https://github.com/huggingface/transformers/blob/ac33aeeeee2a7a89b89c93c2962e6feb90daef0a/src/transformers/models/gpt2/modeling_gpt2.py#L1227-L1250 + generation_config=generation_config, + return_dict_in_generate=True, + output_scores=True, + ) + logits = torch.stack(output.scores, 1) + return torch.cat((queries, output.sequences[:, context_length:]), dim=1), logits + + +@torch.no_grad() +def batch_generation( + model: torch.nn.Module, + queries: torch.Tensor, + local_rollout_forward_batch_size: int, + pad_token_id: int, + generation_config: GenerationConfig, +): + query_responses = [] + logitss = [] + batch_size = queries.shape[0] + for i in range(0, batch_size, local_rollout_forward_batch_size): + query = queries[i : i + local_rollout_forward_batch_size] + query_response, logits = generate( + model, + query, + pad_token_id, + generation_config, + ) + query_responses.append(query_response) + logitss.append(logits) + + # padding tensors + padded_query_responses = pad(query_responses, padding_value=pad_token_id, padding_side="right") + padded_logitss = pad(logitss, padding_value=0, padding_side="right") + + # reshaping + padded_query_responses = padded_query_responses.view(-1, padded_query_responses.shape[-1])[:batch_size] + padded_logitss = padded_logitss.view(-1, *padded_logitss.shape[2:])[:batch_size] + + return padded_query_responses, padded_logitss + + +def exact_div(a, b, custom_error_message=""): + q = a // b + if a != q * b: + raise ValueError(f"{custom_error_message}, inexact division: {a} / {b} = {a / b}") + return q + + +def print_rich_table(df: pd.DataFrame) -> None: + if not is_rich_available(): + raise ImportError( + "The function `print_rich_table` requires the `rich` library. Please install it with `pip install rich`." + ) + console = Console() + table = Table(show_lines=True) + for column in df.columns: + table.add_column(column) + for _, row in df.iterrows(): + table.add_row(*row.astype(str).tolist()) + console.print(table) + + +def truncate_response(stop_token_id: int, pad_token_id: int, responses: torch.Tensor) -> torch.Tensor: + """ + Truncates the responses at the first occurrence of the stop token, filling the rest with pad tokens. + + Args: + stop_token_id (`int`): + The token ID representing the stop token where truncation occurs. + pad_token_id (`int`): + The token ID representing the pad token used to fill the truncated responses. + responses (`torch.Tensor`): + The tensor containing the responses to be truncated. + + Returns: + `torch.Tensor`: + The truncated responses tensor with pad tokens filled after the stop token. + """ + trunc_idxs = first_true_indices(responses == stop_token_id).unsqueeze(-1) + new_size = [1] * (len(responses.size()) - 1) + [responses.shape[1]] + idxs = torch.arange(responses.shape[1], device=responses.device).view(*new_size) + postprocessed_responses = torch.masked_fill(responses, idxs > trunc_idxs, pad_token_id) + return postprocessed_responses + + +def forward( + model: torch.nn.Module, + query_responses: torch.Tensor, + pad_token_id: int, +) -> ModelOutput: + """ + Performs a forward pass through the model with the given query responses and pad token ID. + + Args: + model (`torch.nn.Module`): + The model to perform the forward pass. + query_responses (`torch.Tensor`): + The tensor containing the query responses. + pad_token_id (`int`): + The token ID representing the pad token. + + Returns: + `ModelOutput`: + The output of the model, including hidden states. + """ + attention_mask = query_responses != pad_token_id + position_ids = attention_mask.cumsum(1) - attention_mask.long() + input_ids = torch.masked_fill(query_responses, ~attention_mask, 0) + return model( + input_ids=input_ids, + attention_mask=attention_mask, + position_ids=position_ids, + return_dict=True, + output_hidden_states=True, + ) + + +@dataclass +class OnlineTrainerState(TrainerState): + """ + Training state for online/on-policy trainers. + + Extends [`~transformers.TrainerState`] with an `episode` counter to track the current rollout/episode. + + Args: + episode (`int`, defaults to 0): Zero-based episode index. + """ + + episode: int = 0 + + +def masked_mean(values: torch.Tensor, mask: torch.Tensor, axis: bool | None = None) -> torch.Tensor: + """Compute mean of tensor with a masked values.""" + if axis is not None: + return (values * mask).sum(axis=axis) / mask.sum(axis=axis) + else: + return (values * mask).sum() / mask.sum() + + +def masked_var(values: torch.Tensor, mask: torch.Tensor, unbiased: bool = True) -> torch.Tensor: + """Compute variance of tensor with masked values.""" + mean = masked_mean(values, mask) + centered_values = values - mean + variance = masked_mean(centered_values**2, mask) + if unbiased: + mask_sum = mask.sum() + if mask_sum == 0: + raise ValueError( + "The sum of the mask is zero, which can happen when `mini_batch_size=1`;" + "try increase the `mini_batch_size` or `gradient_accumulation_steps`" + ) + # note that if mask_sum == 1, then there is a division by zero issue + # to avoid it you just need to use a larger minibatch_size + bessel_correction = mask_sum / (mask_sum - 1) + variance = variance * bessel_correction + return variance + + +def masked_whiten(values: torch.Tensor, mask: torch.Tensor, shift_mean: bool = True) -> torch.Tensor: + """Whiten values with masked values.""" + mean, var = masked_mean(values, mask), masked_var(values, mask) + whitened = (values - mean) * torch.rsqrt(var + 1e-8) + if not shift_mean: + whitened += mean + return whitened + + +# taken from https://github.com/OpenLMLab/MOSS-RLHF/blob/40b91eb2f2b71b16919addede0341d2bef70825d/ppo/ppo_trainer.py#L29 +# we did this we can do a single `model = accelerator.prepare(model)` +class PolicyAndValueWrapper(nn.Module): + def __init__(self, policy, value_model) -> None: + super().__init__() + self.policy = policy + self.value_model = value_model + self.critic_backbone = getattr(value_model, value_model.base_model_prefix) + self.is_gradient_checkpointing = policy.is_gradient_checkpointing + + def gradient_checkpointing_enable(self, **kwargs): + self.policy.gradient_checkpointing_enable(**kwargs) + self.is_gradient_checkpointing = True + + def gradient_checkpointing_disable(self): + self.policy.gradient_checkpointing_disable() + self.is_gradient_checkpointing = False + + def forward(self, **kwargs): + output = self.critic_backbone(**kwargs) + logits = self.value_model.score(output.hidden_states[-1]) + return self.policy(**kwargs), logits + + +class PPOTrainer(_BaseTrainer): + """Trainer for Proximal Policy Optimization (PPO). + + For details on PPO, see the paper: [Proximal Policy Optimization + Algorithms](https://huggingface.co/papers/1707.06347). + + Args: + args ([`experimental.ppo.PPOConfig`]): + Training arguments. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`]): + Class to process the data. + model (`torch.nn.Module`): + Model to be trained. This is the policy model. + ref_model (`torch.nn.Module`, *optional*): + Reference model used to compute the KL divergence. If `None`, a copy of the policy model is created. + reward_model (`torch.nn.Module`): + Reward model used to compute the rewards. + train_dataset ([`~datasets.Dataset`]): + Dataset for training. + value_model (`torch.nn.Module`): + Value model used to predict the value of a state. + data_collator ([`~transformers.DataCollatorWithPadding`], *optional*): + Data collator to batch and pad samples from the dataset. If `None`, a default data collator is created + using the `processing_class`. + eval_dataset ([`~datasets.Dataset`] or `dict` of [`~datasets.Dataset`], *optional*): + Dataset for evaluation. + optimizers (`tuple` of `torch.optim.Optimizer` and `torch.optim.lr_scheduler.LambdaLR`, *optional*, defaults to `(None, None)`): + Tuple containing the optimizer and the learning rate scheduler to use for training. If `None`, the + optimizer and the learning rate scheduler are created using the + [`~transformers.Trainer.create_optimizer_and_scheduler`] method. + callbacks (`list` of [`~transformers.TrainerCallback`], *optional*): + Callbacks to use during training. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration to use PEFT for training. If `None`, PEFT is not used. If provided, the policy `model` + will be wrapped with the specified PEFT adapter. + """ + + _tag_names = ["trl", "ppo"] + _name = "PPO" + _paper = { + "title": "Fine-Tuning Language Models from Human Preferences", + "id": "1909.08593", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{mziegler2019fine-tuning, + title = {{Fine-Tuning Language Models from Human Preferences}}, + author = {Daniel M. Ziegler and Nisan Stiennon and Jeffrey Wu and Tom B. Brown and Alec Radford and Dario Amodei and Paul F. Christiano and Geoffrey Irving}, + year = 2019, + eprint = {arXiv:1909.08593} + }"""), + } + + def __init__( + self, + args: PPOConfig, + processing_class: PreTrainedTokenizerBase | BaseImageProcessor | FeatureExtractionMixin | ProcessorMixin, + model: nn.Module, + ref_model: nn.Module | None, + reward_model: nn.Module, + train_dataset: Dataset, + value_model: nn.Module, + data_collator: DataCollatorWithPadding | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + # less commonly used + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + callbacks: list[TrainerCallback] | None = None, + peft_config: "PeftConfig | None" = None, + ) -> None: + if train_dataset is None: + raise ValueError("`train_dataset` is required") + + if ref_model is model: + raise ValueError( + "`model` and `ref_model` cannot be the same object. If you want `ref_model` to be the " + "same as `model`, you must make a copy of it, or `None` if you use peft." + ) + + self.args = args + self.processing_class = processing_class + self.policy_model = model + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + # Define the collator if not provided + if data_collator is None: + data_collator = DataCollatorWithPadding(self.processing_class) + + # Handle stop token settings: update policy model's generation_config to use provided stop token + if args.stop_token and args.stop_token_id: + raise ValueError("You cannot set both `stop_token` and `stop_token_id`.") + elif args.stop_token: + if args.stop_token == "eos": + self.policy_model.generation_config.eos_token_id = self.stop_token_id = processing_class.eos_token_id + else: + raise ValueError( + f"Unknown `stop_token` {args.stop_token}. Allowed values are: `'eos'` and `None` (no stop token)." + ) + else: + self.policy_model.generation_config.eos_token_id = self.stop_token_id = args.stop_token_id # None or int + + # Check that the kl estimator is valid + if self.args.kl_estimator not in {"k1", "k3"}: + raise ValueError( + "kl_estimator must be either 'k1' (straightforward, unbiased) or 'k3' (lower variance, unbiased, " + "appears to be a strictly better estimator). See " + "[Approximating KL Divergence](http://joschu.net/blog/kl-approx.html) for details." + ) + + # peft support + if not is_peft_available() and peft_config is not None: + raise ImportError( + "PEFT is not installed and you passed a `peft_config` in the trainer's kwargs, please install it to use the PEFT models" + ) + elif is_peft_available() and peft_config is not None: + if isinstance(self.policy_model, PeftModel): + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first " + "merge and unload the existing adapter, save the resulting base model, and then pass that base " + "model along with the new `peft_config` to the trainer." + ) + + # get peft model with the given config + self.policy_model = get_peft_model(self.policy_model, peft_config) + if args.bf16 and getattr(self.policy_model, "is_loaded_in_4bit", False): + peft_module_casting_to_bf16(self.policy_model) + + self.is_peft_model = is_peft_available() and isinstance(self.policy_model, PeftModel) + self.model_adapter_name = args.model_adapter_name + self.ref_adapter_name = args.ref_adapter_name + + if ref_model: + self.ref_model = ref_model + elif self.is_peft_model: + self.ref_model = None + else: + self.ref_model = create_reference_model(self.policy_model) + + self.reward_model = reward_model + self.train_dataset = train_dataset + self.train_dataset_len = len(train_dataset) + self.value_model = value_model + self.data_collator = data_collator + self.eval_dataset = eval_dataset + self.optimizer, self.lr_scheduler = optimizers + self.optimizer_cls_and_kwargs = None # needed for transformers >= 4.47 + + ######### + # calculate various batch sizes + ######### + if args.total_episodes is None: # allow the users to define episodes in terms of epochs. + args.total_episodes = int(args.num_train_epochs * self.train_dataset_len) + accelerator = Accelerator(gradient_accumulation_steps=args.gradient_accumulation_steps) + self.accelerator = accelerator + args.world_size = accelerator.num_processes + args.local_batch_size = args.per_device_train_batch_size * args.gradient_accumulation_steps + args.micro_batch_size = int(args.per_device_train_batch_size * args.world_size) + args.batch_size = int(args.local_batch_size * args.world_size) + args.mini_batch_size = exact_div( + args.batch_size, args.num_mini_batches, "`batch_size` must be a multiple of `num_mini_batches`" + ) + args.local_mini_batch_size = exact_div( + args.local_batch_size, args.num_mini_batches, "`local_batch_size` must be a multiple of `num_mini_batches`" + ) + if args.whiten_rewards: + assert args.local_mini_batch_size >= 8, ( + f"Per-rank minibatch size {args.local_mini_batch_size} is insufficient for whitening" + ) + # `per_rank_rollout_batch_size` is our `args.local_batch_size` + # `per_rank_minibatch_size` is our `args.local_mini_batch_size` + args.num_total_batches = math.ceil( + args.total_episodes / args.batch_size + ) # we may train for more than `total_episodes` + self.local_seed = args.seed + accelerator.process_index * 100003 # Prime + if args.num_sample_generations > 0: + self.sample_generations_freq = max(1, args.num_total_batches // args.num_sample_generations) + self.local_dataloader_batch_size = args.local_batch_size + + ######### + # setup model, optimizer, and others + ######### + for module in [self.policy_model, self.ref_model, self.value_model, self.reward_model]: + if module is not None: + disable_dropout_in_model(module) + self.model = PolicyAndValueWrapper(self.policy_model, self.value_model) + self.model.config = self.policy_model.config # needed for pushing to hub + self.create_optimizer_and_scheduler( + num_training_steps=args.num_total_batches + ) # note that we are calling `self.lr_scheduler.step()` manually only at the batch level + + ######### + # trainer specifics + ######### + default_callbacks = DEFAULT_CALLBACKS + get_reporting_integration_callbacks(self.args.report_to) + self.callbacks = default_callbacks if callbacks is None else default_callbacks + callbacks + self.callback_handler = CallbackHandler( + self.callbacks, self.model, self.processing_class, self.optimizer, self.lr_scheduler + ) + self.add_callback(PrinterCallback if self.args.disable_tqdm else DEFAULT_PROGRESS_CALLBACK) + self.control = TrainerControl() + self.state = OnlineTrainerState( + is_local_process_zero=self.is_local_process_zero(), + is_world_process_zero=self.is_world_process_zero(), + stateful_callbacks=[ + cb for cb in self.callback_handler.callbacks + [self.control] if isinstance(cb, ExportableState) + ], + ) + self.current_flos = 0 + self.hp_search_backend = None + self.is_deepspeed_enabled = getattr(self.accelerator.state, "deepspeed_plugin", None) is not None + self.is_fsdp_enabled = getattr(self.accelerator.state, "fsdp_plugin", None) is not None + # Create distant repo and output directory if needed + self.hub_model_id = None + if self.args.push_to_hub: + self.init_hf_repo() + if self.args.should_save: + os.makedirs(self.args.output_dir, exist_ok=True) + + # Add tags for models that have been loaded with the correct transformers version + if hasattr(self.model, "add_model_tags"): + self.model.add_model_tags(self._tag_names) + + ######### + # setup dataloader + ######### + self.dataloader = DataLoader( + self.train_dataset, + batch_size=self.local_dataloader_batch_size, + shuffle=True, + collate_fn=self.data_collator, + drop_last=True, # needed; otherwise the last batch will be of ragged shape + ) + # sync random states for DataLoader(shuffle=True) before `accelerator.prepare` + # see https://gist.github.com/vwxyzjn/2581bff1e48e185e0b85b6dfe1def79c + torch.manual_seed(args.seed) + self.model, self.optimizer, self.dataloader = accelerator.prepare(self.model, self.optimizer, self.dataloader) + torch.manual_seed(self.local_seed) # reset the local seed again + + self.eval_dataloader = DataLoader( + self.eval_dataset, + batch_size=args.per_device_eval_batch_size, + collate_fn=self.data_collator, + drop_last=True, + ) # no need to shuffle eval dataset + self.eval_dataloader = accelerator.prepare(self.eval_dataloader) + + if self.is_deepspeed_enabled: + self.reward_model = prepare_deepspeed(self.reward_model, accelerator) + + if self.ref_model is None: + if not self.is_peft_model: + raise ValueError("No reference model and model is not a Peft model.") + else: + self.ref_model = prepare_deepspeed(self.ref_model, accelerator) + else: + if self.ref_model is None: + if not self.is_peft_model: + raise ValueError("No reference model and model is not a Peft model.") + else: + self.ref_model = self.ref_model.to(self.accelerator.device) + self.reward_model = self.reward_model.to(self.accelerator.device) + + def get_train_dataloader(self) -> DataLoader: + return self.dataloader + + def get_eval_dataloader(self) -> DataLoader: + return self.eval_dataloader + + @contextmanager + def null_ref_context(self): + """Context manager for handling null reference model (that is, peft adapter manipulation).""" + with ( + self.accelerator.unwrap_model(self.model.policy).disable_adapter() + if self.is_peft_model and not self.ref_adapter_name + else nullcontext() + ): + if self.ref_adapter_name: + self.model.policy.set_adapter(self.ref_adapter_name) + yield + if self.ref_adapter_name: + self.model.policy.set_adapter(self.model_adapter_name or "default") + + def save_model(self, output_dir: str | None = None, _internal_call: bool = False): + backup_model = self.model + if hasattr(self.model, "policy"): + self.model = self.model.policy # save only the policy for inference + if self.is_deepspeed_enabled: + backup_deepspeed = self.deepspeed + self.deepspeed = self.model + + super().save_model(output_dir, _internal_call) + + self.model = backup_model + if self.is_deepspeed_enabled: + self.deepspeed = backup_deepspeed + + def train(self): + args = self.args + accelerator = self.accelerator + optimizer = self.optimizer + model = self.model + ref_policy = self.ref_model + reward_model = self.reward_model + processing_class = self.processing_class + dataloader = self.dataloader + device = accelerator.device + + def repeat_generator(): + while True: + yield from dataloader + + iter_dataloader = iter(repeat_generator()) + generation_kwargs = { + "max_new_tokens": args.response_length, + "temperature": (args.temperature + 1e-7), + "top_k": 0.0, + "top_p": 1.0, + "do_sample": True, + } + generation_config = GenerationConfig(**generation_kwargs) + + accelerator.print("===training policy===") + start_time = time.time() + stats_shape = (args.num_ppo_epochs, args.num_mini_batches, args.gradient_accumulation_steps) + approxkl_stats = torch.zeros(stats_shape, device=device) + pg_clipfrac_stats = torch.zeros(stats_shape, device=device) + pg_loss_stats = torch.zeros(stats_shape, device=device) + vf_loss_stats = torch.zeros(stats_shape, device=device) + vf_clipfrac_stats = torch.zeros(stats_shape, device=device) + entropy_stats = torch.zeros(stats_shape, device=device) + ratio_stats = torch.zeros(stats_shape, device=device) + model.train() + + # trainer state initialization + self.state.global_step = 0 + self.state.episode = 0 + self.state.max_steps = args.num_total_batches + self.state.num_train_epochs = args.total_episodes / self.train_dataset_len + # Compute absolute values for logging, eval, and save if given as ratio + if args.logging_steps is not None: + if args.logging_steps < 1: + self.state.logging_steps = math.ceil(self.state.max_steps * args.logging_steps) + else: + self.state.logging_steps = args.logging_steps + if args.eval_steps is not None: + if args.eval_steps < 1: + self.state.eval_steps = math.ceil(self.state.max_steps * args.eval_steps) + else: + self.state.eval_steps = args.eval_steps + if args.save_steps is not None: + if args.save_steps < 1: + self.state.save_steps = math.ceil(self.state.max_steps * args.save_steps) + else: + self.state.save_steps = args.save_steps + self.control = self.callback_handler.on_train_begin(args, self.state, self.control) + + # backward compatibility + if self.is_deepspeed_enabled: + self.deepspeed = self.model + self.model_wrapped = self.model + + for update in range(1, args.num_total_batches + 1): + self.state.episode += 1 * args.batch_size + data = next(iter_dataloader) + with torch.no_grad(): + queries = data["input_ids"].to(device) + context_length = queries.shape[1] + responses = [] + postprocessed_responses = [] + logprobs = [] + ref_logprobs = [] + scores = [] + sequence_lengths = [] + values = [] + with ( + unwrap_model_for_generation( + self.model, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + generation_kwargs=generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model + ): + query_responses, logitss = batch_generation( + unwrapped_model.policy, + queries, + args.local_rollout_forward_batch_size, + processing_class.pad_token_id, + generation_config, + ) + + for i in range(0, queries.shape[0], args.local_rollout_forward_batch_size): + query = queries[i : i + args.local_rollout_forward_batch_size] + query_response = query_responses[i : i + args.local_rollout_forward_batch_size] + response = query_response[:, context_length:] + logits = logitss[i : i + args.local_rollout_forward_batch_size] + logprob = selective_log_softmax(logits, response) + del logits + empty_cache() + + if ref_policy is None: + with self.null_ref_context(): + ref_output = forward(model.policy, query_response, processing_class.pad_token_id) + else: + ref_output = forward(ref_policy, query_response, processing_class.pad_token_id) + ref_logits = ref_output.logits[:, context_length - 1 : -1] + ref_logits /= args.temperature + 1e-7 + ref_logprob = selective_log_softmax(ref_logits, response) + del ref_output, ref_logits + empty_cache() + + # Response Processing 1. truncate response after the first occurrence of `stop_token_id` + postprocessed_response = response + if self.stop_token_id is not None: # handle the edge case when stop_token_id exists but is 0 + postprocessed_response = truncate_response( + self.stop_token_id, processing_class.pad_token_id, response + ) + + # Response Processing 2. run reward model on the truncated responses + postprocessed_query_response = torch.cat((query, postprocessed_response), 1) + sequence_length = first_true_indices(postprocessed_response == processing_class.pad_token_id) - 1 + unwrapped_value_model = accelerator.unwrap_model(model).value_model + full_value, _, _ = get_reward( + unwrapped_value_model, query_response, processing_class.pad_token_id, context_length + ) + value = full_value[:, context_length - 1 : -1].squeeze(-1) + _, score, _ = get_reward( + reward_model, postprocessed_query_response, processing_class.pad_token_id, context_length + ) + + responses.append(response) + postprocessed_responses.append(postprocessed_response) + logprobs.append(logprob) + ref_logprobs.append(ref_logprob) + sequence_lengths.append(sequence_length) + scores.append(score) + values.append(value) + responses = torch.cat(responses, 0) + postprocessed_responses = torch.cat(postprocessed_responses, 0) + logprobs = torch.cat(logprobs, 0) + ref_logprobs = torch.cat(ref_logprobs, 0) + sequence_lengths = torch.cat(sequence_lengths, 0) + scores = torch.cat(scores, 0) + values = torch.cat(values, 0) + del (logprob, ref_logprob, full_value, value, score, unwrapped_model) + empty_cache() + gc.collect() + + # Response Processing 3. Filter completion. Ensure that the sample contains stop_token_id + # Completions not passing that filter will receive a lower score. + contain_eos_token = torch.any(postprocessed_responses == self.processing_class.eos_token_id, dim=-1) + if self.args.missing_eos_penalty is not None: + scores[~contain_eos_token] -= self.args.missing_eos_penalty + # accelerator.print(f"{scores=}, {(contain_eos_token.sum() / len(contain_eos_token))=}") + + # be very careful with `padding_mask_p1`; see https://excalidraw.com/#json=LWnzG4w2k5DjF_EOL_xPt,e2w3a-hFJ_gX5vOfeyXGTw + response_idxs = torch.arange(responses.shape[1], device=responses.device).repeat(responses.shape[0], 1) + padding_mask = response_idxs > sequence_lengths.unsqueeze(1) + logprobs = torch.masked_fill(logprobs, padding_mask, INVALID_LOGPROB) + ref_logprobs = torch.masked_fill(ref_logprobs, padding_mask, INVALID_LOGPROB) + sequence_lengths_p1 = sequence_lengths + 1 + padding_mask_p1 = response_idxs > (sequence_lengths_p1.unsqueeze(1)) + values = torch.masked_fill(values, padding_mask_p1, 0) + + # 4. compute rewards + # Formula used by http://joschu.net/blog/kl-approx.html for the k1 and k3 estimators + logr = ref_logprobs - logprobs + kl = -logr if args.kl_estimator == "k1" else (logr.exp() - 1) - logr # Else statement is k3 + non_score_reward = -args.kl_coef * kl + rewards = non_score_reward.clone() + actual_start = torch.arange(rewards.size(0), device=rewards.device) + actual_end = torch.where(sequence_lengths_p1 < rewards.size(1), sequence_lengths_p1, sequence_lengths) + rewards[actual_start, actual_end] += scores + + # 5. whiten rewards + if args.whiten_rewards: + rewards = masked_whiten(rewards, mask=~padding_mask_p1, shift_mean=False) + rewards = torch.masked_fill(rewards, padding_mask_p1, 0) + + # 6. compute advantages and returns + lastgaelam = 0 + advantages_reversed = [] + gen_length = responses.shape[1] + for t in reversed(range(gen_length)): + nextvalues = values[:, t + 1] if t < gen_length - 1 else 0.0 + delta = rewards[:, t] + args.gamma * nextvalues - values[:, t] + lastgaelam = delta + args.gamma * args.lam * lastgaelam + advantages_reversed.append(lastgaelam) + advantages = torch.stack(advantages_reversed[::-1], axis=1) + returns = advantages + values + advantages = masked_whiten(advantages, ~padding_mask) + advantages = torch.masked_fill(advantages, padding_mask, 0) + empty_cache() + + # Do multiple epochs of PPO training, with a fresh random shuffle in each epoch + for ppo_epoch_idx in range(args.num_ppo_epochs): + b_inds = np.random.permutation(args.local_batch_size) + minibatch_idx = 0 + for mini_batch_start in range(0, args.local_batch_size, args.local_mini_batch_size): + mini_batch_end = mini_batch_start + args.local_mini_batch_size + mini_batch_inds = b_inds[mini_batch_start:mini_batch_end] + gradient_accumulation_idx = 0 + for micro_batch_start in range(0, args.local_mini_batch_size, args.per_device_train_batch_size): + with accelerator.accumulate(model): + micro_batch_end = micro_batch_start + args.per_device_train_batch_size + micro_batch_inds = mini_batch_inds[micro_batch_start:micro_batch_end] + mb_advantage = advantages[micro_batch_inds] + mb_responses = responses[micro_batch_inds] + mb_query_responses = query_responses[micro_batch_inds] + mb_logprobs = logprobs[micro_batch_inds] + mb_return = returns[micro_batch_inds] + mb_values = values[micro_batch_inds] + + output, vpred_temp = forward(model, mb_query_responses, processing_class.pad_token_id) + logits = output.logits[:, context_length - 1 : -1] + logits /= args.temperature + 1e-7 + new_logprobs = selective_log_softmax(logits, mb_responses) + new_logprobs = torch.masked_fill( + new_logprobs, padding_mask[micro_batch_inds], INVALID_LOGPROB + ) + vpred = vpred_temp[:, context_length - 1 : -1].squeeze(-1) + vpred = torch.masked_fill(vpred, padding_mask_p1[micro_batch_inds], 0) + vpredclipped = torch.clamp( + vpred, + mb_values - args.cliprange_value, + mb_values + args.cliprange_value, + ) + vf_losses1 = torch.square(vpred - mb_return) + vf_losses2 = torch.square(vpredclipped - mb_return) + vf_loss_max = torch.max(vf_losses1, vf_losses2) + vf_loss = 0.5 * masked_mean(vf_loss_max, ~padding_mask_p1[micro_batch_inds]) + vf_clipfrac = masked_mean( + (vf_losses2 > vf_losses1).float(), ~padding_mask_p1[micro_batch_inds] + ) + logprobs_diff = new_logprobs - mb_logprobs + ratio = torch.exp(logprobs_diff) + pg_losses = -mb_advantage * ratio + pg_losses2 = -mb_advantage * torch.clamp(ratio, 1.0 - args.cliprange, 1.0 + args.cliprange) + pg_loss_max = torch.max(pg_losses, pg_losses2) + pg_loss = masked_mean(pg_loss_max, ~padding_mask[micro_batch_inds]) + loss = pg_loss + args.vf_coef * vf_loss + accelerator.backward(loss) + optimizer.step() + optimizer.zero_grad() + with torch.no_grad(): + pg_clipfrac = masked_mean( + (pg_losses2 > pg_losses).float(), ~padding_mask[micro_batch_inds] + ) + prob_dist = torch.nn.functional.softmax(logits, dim=-1) + entropy = torch.logsumexp(logits, dim=-1) - torch.sum(prob_dist * logits, dim=-1) + approxkl = 0.5 * (logprobs_diff**2).mean() + approxkl_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = approxkl + pg_clipfrac_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = ( + pg_clipfrac + ) + pg_loss_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = pg_loss + vf_loss_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = vf_loss + vf_clipfrac_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = ( + vf_clipfrac + ) + entropy_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = entropy.mean() + ratio_stats[ppo_epoch_idx, minibatch_idx, gradient_accumulation_idx] = ratio.mean() + gradient_accumulation_idx += 1 + minibatch_idx += 1 + # del everything and empty cache + # fmt: off + del ( + output, vpred_temp, logits, new_logprobs, vpred, vpredclipped, + vf_losses1, vf_losses2, vf_loss, vf_clipfrac, logprobs_diff, ratio, pg_losses, pg_losses2, pg_loss_max, + pg_loss, loss, pg_clipfrac, prob_dist, entropy, approxkl, mb_return, + mb_advantage, mb_values, mb_responses, mb_query_responses, mb_logprobs, + ) + # fmt: on + empty_cache() + with torch.no_grad(): + mean_kl = kl.sum(1).mean() + mean_entropy = (-logprobs).sum(1).mean() + mean_non_score_reward = non_score_reward.sum(1).mean() + rlhf_reward = mean_non_score_reward + scores.mean() + eps = int(self.state.episode / (time.time() - start_time)) + metrics = {} + metrics["eps"] = eps + metrics["objective/kl"] = self.accelerator.gather_for_metrics(mean_kl).mean().item() + metrics["objective/entropy"] = self.accelerator.gather_for_metrics(mean_entropy).mean().item() + metrics["objective/non_score_reward"] = ( + self.accelerator.gather_for_metrics(mean_non_score_reward).mean().item() + ) + metrics["objective/rlhf_reward"] = self.accelerator.gather_for_metrics(rlhf_reward).mean().item() + metrics["objective/scores"] = self.accelerator.gather_for_metrics(scores.mean()).mean().item() + metrics["policy/approxkl_avg"] = self.accelerator.gather_for_metrics(approxkl_stats).mean().item() + metrics["policy/clipfrac_avg"] = self.accelerator.gather_for_metrics(pg_clipfrac_stats).mean().item() + metrics["loss/policy_avg"] = self.accelerator.gather_for_metrics(pg_loss_stats).mean().item() + metrics["loss/value_avg"] = self.accelerator.gather_for_metrics(vf_loss_stats).mean().item() + metrics["val/clipfrac_avg"] = self.accelerator.gather_for_metrics(vf_clipfrac_stats).mean().item() + metrics["policy/entropy_avg"] = self.accelerator.gather_for_metrics(entropy_stats).mean().item() + metrics["val/ratio"] = self.accelerator.gather_for_metrics(ratio_stats).mean().item() + metrics["val/ratio_var"] = self.accelerator.gather_for_metrics(ratio_stats).var().item() + metrics["val/num_eos_tokens"] = (responses == processing_class.eos_token_id).sum().item() + metrics["lr"] = self.lr_scheduler.get_last_lr()[0] + metrics["episode"] = self.state.episode + self.state.epoch = self.state.episode / self.train_dataset_len # used by self.log + self.state.global_step += 1 + self.log(metrics) + + self.lr_scheduler.step() + self.control = self.callback_handler.on_step_end(args, self.state, self.control) + if self.control.should_save: + self._save_checkpoint(model, trial=None) + self.control = self.callback_handler.on_save(self.args, self.state, self.control) + del kl, mean_kl, mean_entropy, mean_non_score_reward, scores, metrics, non_score_reward + empty_cache() + gc.collect() + + if args.num_sample_generations > 0 and (update - 1) % self.sample_generations_freq == 0: + self.generate_completions(sampling=True) + empty_cache() + del ( + query_responses, + responses, + postprocessed_responses, + logprobs, + ref_logprobs, + values, + sequence_lengths, + contain_eos_token, + sequence_lengths_p1, + response_idxs, + padding_mask, + padding_mask_p1, + rewards, + actual_start, + actual_end, + advantages, + returns, + ) + empty_cache() + + # HF trainer specifics + self.control = self.callback_handler.on_train_end(args, self.state, self.control) + if self.control.should_save: + self._save_checkpoint(model, trial=None) + self.control = self.callback_handler.on_save(self.args, self.state, self.control) + + def generate_completions(self, sampling: bool = False): + if self.eval_dataset is None: + return # no eval set to sample from (pass eval_dataset and eval_strategy != "no" for sample generations) + args = self.args + processing_class = self.processing_class + generation_kwargs = { + "max_new_tokens": args.response_length, + "temperature": (0.01 + 1e-7), + "top_k": 0.0, + "top_p": 1.0, + "do_sample": True, + } + generation_config = GenerationConfig(**generation_kwargs) + + table = defaultdict(list) + with ( + unwrap_model_for_generation( + self.model, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + generation_kwargs=generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model + ): + for batch in self.eval_dataloader: + query = batch["input_ids"] + with torch.no_grad(): + context_length = query.shape[1] + query_response, _ = batch_generation( + unwrapped_model.policy, + query, + query.shape[0], + processing_class.pad_token_id, + generation_config, + ) + response = query_response[:, context_length:] + postprocessed_response = response + if self.stop_token_id is not None: # handle the edge case when stop_token_id exists but is 0 + postprocessed_response = truncate_response( + self.stop_token_id, processing_class.pad_token_id, response + ) + table["query"].extend( + gather_object(processing_class.batch_decode(query, skip_special_tokens=True)) + ) + table["model response"].extend( + gather_object(processing_class.batch_decode(postprocessed_response)) + ) + + postprocessed_query_response = torch.cat((query, postprocessed_response), 1) + _, score, _ = get_reward( + self.reward_model, postprocessed_query_response, processing_class.pad_token_id, context_length + ) + table["score"].extend(self.accelerator.gather_for_metrics(score).float().cpu().numpy()) + + if sampling: + break + df = pd.DataFrame(table) + + if self.accelerator.is_main_process: + if is_rich_available(): + print_rich_table(df.iloc[0 : 0 + 5]) + if "wandb" in args.report_to: + import wandb + + if wandb.run is not None: + wandb.log({"completions": wandb.Table(dataframe=df)}) + + if "comet_ml" in args.report_to: + log_table_to_comet_experiment( + name="completions.csv", + table=df, + ) + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..210c474aa459261c71906d4e1b11994a08dddd4c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .prm_config import PRMConfig +from .prm_trainer import PRMTrainer + + +__all__ = ["PRMConfig", "PRMTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/prm_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/prm_config.py new file mode 100644 index 0000000000000000000000000000000000000000..b6150c01b2e4739e027ee3072080c5f057478841 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/prm_config.py @@ -0,0 +1,88 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class PRMConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.prm.PRMTrainer`]. + + This class includes only the parameters that are specific to PRM training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the sequences (prompt + completion) used for truncation. + max_completion_length (`int`, *optional*): + Maximum length of the completion used for truncation. The completion is the concatenation of the steps. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + step_separator (`str`, *optional*, defaults to `"\n"`): + Separator used to separate each step of the reasoning process. + train_on_last_step_only (`bool`, *optional*, defaults to `False`): + Whether to train only on the last step. + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-5` instead of `5e-5`. + """ + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-5, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + max_length: int | None = field( + default=1024, + metadata={"help": "Maximum length of the sequences (prompt + completion) used for truncation."}, + ) + max_completion_length: int | None = field( + default=None, + metadata={ + "help": "Maximum length of the completion used for truncation. The completion is the concatenation of the " + "steps." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model and reference model."}, + ) + step_separator: str = field( + default="\n", + metadata={"help": "Separator used to separate each step of the reasoning process."}, + ) + train_on_last_step_only: bool = field( + default=False, + metadata={"help": "Whether to train only on the last step."}, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/prm_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/prm_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..7b26b69bd824059e7428df2940d2a2f0bb80df55 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/prm/prm_trainer.py @@ -0,0 +1,357 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import textwrap +from collections.abc import Callable +from itertools import chain +from pathlib import Path + +import numpy as np +import torch +import torch.nn as nn +import transformers +from accelerate import PartialState, logging +from datasets import Dataset, features +from packaging.version import Version +from transformers import ( + BaseImageProcessor, + DataCollator, + DataCollatorForTokenClassification, + FeatureExtractionMixin, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import EvalPrediction +from transformers.utils import is_peft_available + +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import disable_dropout_in_model +from ..utils import prepare_peft_model +from .prm_config import PRMConfig + + +if is_peft_available(): + from peft import PeftModel + +logger = logging.get_logger(__name__) + + +def compute_accuracy(eval_pred: EvalPrediction) -> dict[str, float]: + predictions, labels = eval_pred + if predictions.ndim == 3: + # Token classification task. Shapes are (batch_size, seq_len, num_labels) and (batch_size, seq_len) + # Used to compute the accuracy in the prm_trainer. + predictions = np.argmax(predictions, axis=2) + + # Flatten the predictions and labels to remove the ignored tokens. + predictions = np.array( + [ + p + for prediction, label in zip(predictions, labels, strict=True) + for (p, lbl) in zip(prediction, label, strict=True) + if lbl != -100 + ] + ) + labels = np.array([lbl for label in labels for lbl in label if lbl != -100]) + + else: + # Here, predictions is rewards_chosen and rewards_rejected. Shapes are (batch_size, 2) and (batch_size,) + # We want to see how much of the time rewards_chosen > rewards_rejected. + equal_mask = predictions[:, 0] == predictions[:, 1] + equal_predictions_count = int(equal_mask.sum()) + + if equal_predictions_count > 0: + # Before using the logger, the accelerate state must be initialized. It'susually the case when using this + # function inside a Trainer, but it may not be the case otherwise, in particular when unit testing. + PartialState() + + logger.warning( + f"There are {equal_predictions_count} out of {len(predictions[:, 0])} instances where the predictions " + "for both options are equal. These instances are ignored in the accuracy computation.", + ) + + # Filter out equal predictions + predictions = predictions[~equal_mask] + labels = labels[~equal_mask] + + # Use the remaining predictions for accuracy calculation + predictions = np.argmax(predictions, axis=1) + + accuracy = np.array(predictions == labels, dtype=float).mean().item() + return {"accuracy": accuracy} + + +class PRMTrainer(_BaseTrainer): + """ + Initialize PRMTrainer. + + Args: + model ([`~transformers.PreTrainedModel`]): + The model to train, preferably an `AutoModelForTokenClassification`. + args ([`experimental.prm.PRMConfig`]): + The arguments to use for training. + data_collator ([`~transformers.DataCollator`]): + The data collator to use for training. If None is specified, the default data collator + ([`~transformers.DataCollatorForTokenClassification`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + train_dataset ([`~datasets.Dataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`]): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + model_init (`Callable[[], transformers.PreTrainedModel]`): + The model initializer to use for training. If None is specified, the default model initializer will be + used. + compute_metrics (`Callable[[transformers.EvalPrediction], dict]`, *optional* defaults to `compute_accuracy`): + The metrics to use for evaluation. If no metrics are specified, the default metric (`compute_accuracy`) + will be used. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + peft_config (`dict`, defaults to `None`): + The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in + a PEFT model. + """ + + _tag_names = ["trl", "prm"] + _name = "PRM" + _paper = { + "title": "Solving math word problems with process-and outcome-based feedback", + "id": "2211.14275", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{uesato2022solving, + title = {{Solving Math Word Problems With Process- and Outcome-Based Feedback}}, + author = {Uesato, Jonathan and Kushman, Nate and Kumar, Ramana and Song, Francis and Siegel, Noah and Wang, Lisa and Creswell, Antonia and Irving, Geoffrey and Higgins, Irina}, + year = 2022, + journal = {arXiv preprint arXiv:2211.14275} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module | None = None, + args: PRMConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + model_init: Callable[[], PreTrainedModel] | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = ( + None, + None, + ), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: dict | None = None, + ): + if train_dataset is None: + raise ValueError("`train_dataset` is required") + + if peft_config is not None or (is_peft_available() and isinstance(model, PeftModel)): + model = prepare_peft_model(model, peft_config, args) + + # Disable dropout in the model + if args.disable_dropout: + disable_dropout_in_model(model) + + if compute_metrics is None: + compute_metrics = compute_accuracy + + if data_collator is None: + if processing_class is None: + raise ValueError( + "A processing_class must be specified when using the default DataCollatorForTokenClassification" + ) + data_collator = DataCollatorForTokenClassification(processing_class) + + if "input_ids" not in train_dataset.column_names: + with PartialState().main_process_first(): + fn_kwargs = { + "tokenizer": processing_class, + "step_separator": args.step_separator, + "max_length": args.max_length, + "max_completion_length": args.max_completion_length, + "train_on_last_step_only": args.train_on_last_step_only, + } + train_fn_kwargs = {**fn_kwargs, "is_eval": False} + train_dataset = train_dataset.map( + self.tokenize_row, + fn_kwargs=train_fn_kwargs, + num_proc=args.dataset_num_proc, + remove_columns=train_dataset.features, + desc="Tokenizing train dataset", + features=features.Features( # needed to avoid map to cast labels to bool + { + "labels": features.Sequence(features.Value("int64")), + "input_ids": features.Sequence(features.Value("int64")), + } + ), + ) + + eval_fn_kwargs = {**fn_kwargs, "is_eval": True} + if eval_dataset is not None: + eval_dataset = eval_dataset.map( + self.tokenize_row, + fn_kwargs=eval_fn_kwargs, + num_proc=args.dataset_num_proc, + remove_columns=eval_dataset.features, + desc="Tokenizing eval dataset", + features=features.Features( # needed to avoid map to cast labels to bool + { + "labels": features.Sequence(features.Value("int64")), + "input_ids": features.Sequence(features.Value("int64")), + } + ), + ) + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + model_init=model_init, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # Add tags for models that have been loaded with the correct transformers version + if hasattr(self.model, "add_model_tags"): + self.model.add_model_tags(self._tag_names) + + @staticmethod + def tokenize_row( + features, + tokenizer, + step_separator, + max_length, + max_completion_length, + train_on_last_step_only, + is_eval, + ): + r""" + Tokenize a row of the dataset. + + Args: + features (`dict[str, str]`): + Row of the dataset, should contain the keys `"prompt"`, `"completions"`, and `"labels"`. + tokenizer ([`~transformers.PreTrainedTokenizerBase`]): + Tokenizer used to process the data. + step_separator (`str`): + Separator between steps in the completion. + max_length (`int` or `None`): + Maximum length of the sequences (prompt + completion). If `None`, the sequences are not truncated. + max_completion_length (`int` or `None`): + Maximum length of the completion sequences. If `None`, the completion sequences are not truncated. + train_on_last_step_only (`bool`): + Whether to train only on the last step. If `True`, the labels are `-100` for all tokens except the last + token of the completion. + is_eval (`bool`): + Whether the function is used to tokenize samples from a training or an evaluation dataset. Used only if + `train_on_last_step_only` is set to `True`. + + Returns: + `dict[str, list[int]]`: + Tokenized sequences with the keys `"input_ids"`, and `"labels". + + Example: + ```python + >>> from transformers import AutoTokenizer + + >>> tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B") + >>> features = { + ... "prompt": "Which number is larger, 9.8 or 9.11?", + ... "completions": ["11 is greater than 8.", "Hence, 9.11 > 9.8."], + ... "labels": [True, False], + ... } + >>> PRMTrainer.tokenize_row( + ... features, tokenizer, "\n", max_completion_length=None, train_on_last_step_only=False, is_eval=False + ... ) + {'input_ids': [23085, 1372, 374, 8131, 11, 220, 24, 13, 23, 476, 220, 24, 13, 16, 16, 30, 16, 16, 374, 7046, 1091, 220, 23, 13, 198, 39, 763, 11, 220, 24, 13, 16, 16, 861, 220, 24, 13, 23, 13, 198], + 'labels': [-100, -100, -100, -100, -100, -100, -100, -100, 1, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, 0]} + ``` + """ + # Tokenize the prompt and completions + prompt_ids = tokenizer(features["prompt"], add_special_tokens=False)["input_ids"] + completions_ids = [ + tokenizer(completion, add_special_tokens=False)["input_ids"] for completion in features["completions"] + ] + if train_on_last_step_only and not is_eval: + labels = [-100] * (len(features["labels"]) - 1) + [int(features["labels"][-1])] + else: + labels = [int(label) for label in features["labels"]] + + # Get the ID of the separator token and add it to the completions + separator_ids = tokenizer.encode(step_separator, add_special_tokens=False) + completions_ids = [completion + separator_ids for completion in completions_ids] + + # Create the label + labels = [ + [-100] * (len(completion) - 1) + [label] for completion, label in zip(completions_ids, labels, strict=True) + ] + + # Join the completions and labels steps + completion_ids = list(chain(*completions_ids)) + labels = list(chain(*labels)) + + if tokenizer.bos_token_id is not None: + prompt_ids = [tokenizer.bos_token_id] + prompt_ids + + # Truncate completion sequences + if max_completion_length is not None: + completion_ids = completion_ids[:max_completion_length] + labels = labels[:max_completion_length] + + input_ids = prompt_ids + completion_ids + labels = [-100] * len(prompt_ids) + labels + + if max_length is not None: + input_ids = input_ids[:max_length] + labels = labels[:max_length] + + return {"input_ids": input_ids, "labels": labels} + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..85a7818ae5c8b83264ffec56a58c52f344fa5c26 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .sdft_config import SDFTConfig +from .sdft_trainer import SDFTTrainer + + +__all__ = ["SDFTConfig", "SDFTTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft.py new file mode 100644 index 0000000000000000000000000000000000000000..958a24fc683cc01b0f9c11ce1a1059a258abad10 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft.py @@ -0,0 +1,454 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +""" +Small-scale SDFT training with Qwen/Qwen3.5-0.8B. + +Expected dataset formats: + +1. Native TRL self-distillation format: + - `prompt` + - `privileged_context` containing only the extra teacher-only information + +2. Demonstration-based format: + - `prompt` + - `golden_response` + +Example: + +```bash +python trl/experimental/sdft/sdft.py \ + --model_name_or_path Qwen/Qwen3.5-0.8B \ + --dataset_name your-org/your-dataset \ + --output_dir outputs/sdft-qwen3.5-0.8b \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 16 \ + --learning_rate 2e-5 \ + --max_prompt_length 1024 \ + --max_completion_length 512 \ + --generate_from_teacher \ + --sync_ref_model \ + --ref_model_sync_steps 1 \ + --ref_model_mixup_alpha 0.01 \ + --eval_strategy steps \ + --eval_steps 50 \ + --report_to wandb +``` +""" + +import json +import os +import re +from dataclasses import dataclass, field +from string import Template +from typing import Any + +import torch +from datasets import DatasetDict, load_dataset, load_from_disk +from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.data_utils import maybe_apply_chat_template +from trl.experimental.sdft import SDFTConfig, SDFTTrainer +from trl.models import unwrap_model_for_generation + + +DEFAULT_DEMONSTRATION_TEMPLATE = Template("""Example response: $output_text""") + + +@dataclass +class SDFTScriptArguments(ScriptArguments): + ref_model_name_or_path: str | None = field( + default=None, + metadata={"help": "Reference teacher model. Optional for PEFT runs, where the base model is used as teacher."}, + ) + dataset_path: str | None = field( + default=None, + metadata={"help": "Optional local dataset path to load with `load_from_disk`. Overrides `dataset_name`."}, + ) + privileged_context_column: str = field( + default="privileged_context", + metadata={"help": "Column containing precomputed privileged context for SDFT."}, + ) + golden_response_column: str = field( + default="golden_response", + metadata={"help": "Column containing demonstration responses used to build privileged context."}, + ) + eval_num_prompts: int | None = field( + default=8, + metadata={"help": "Number of prompts to log during evaluation. Set to 0 to disable completion logging."}, + ) + demonstration_template: str = field( + default=DEFAULT_DEMONSTRATION_TEMPLATE.template, + metadata={"help": "Template used to build privileged context from demonstration content."}, + ) + tool_eval_num_examples: int | None = field( + default=None, + metadata={ + "help": "Optional number of eval examples to score for tool-use metrics. Defaults to the full eval split." + }, + ) + tool_eval_max_new_tokens: int = field( + default=256, + metadata={"help": "Maximum completion length for task evaluation generation."}, + ) + + +@dataclass +class ExampleSDFTConfig(SDFTConfig): + scale_rewards: str = field( + default="group", + metadata={"help": "Reward normalization mode. Supported: `group`, `batch`, `none`."}, + ) + + +def _extract_prompt_text(prompt: Any) -> str: + if isinstance(prompt, str): + return prompt + if isinstance(prompt, list) and prompt and isinstance(prompt[0], dict): + for message in reversed(prompt): + if message.get("role") == "user": + content = message.get("content", "") + if isinstance(content, list): + return " ".join(part.get("text", "") for part in content if part.get("type") == "text") + return content + return str(prompt) + + +def _stringify_golden_response(response: Any) -> str: + if isinstance(response, str): + return response + if isinstance(response, list): + return "\n".join(_stringify_golden_response(item) for item in response) + return str(response) + + +def _build_privileged_context( + example: dict[str, Any], privileged_context_column: str, golden_response_column: str, template: Template +): + if privileged_context_column in example and example[privileged_context_column] is not None: + privileged_context = example[privileged_context_column] + elif golden_response_column in example: + privileged_context = template.safe_substitute( + orig_content=_extract_prompt_text(example["prompt"]), + output_text=_stringify_golden_response(example[golden_response_column]), + ) + elif "teacher_prompt" in example: + raise ValueError( + "Datasets for `trl.experimental.sdft` should provide `privileged_context` or `golden_response`, not " + "`teacher_prompt`." + ) + else: + raise ValueError("Dataset must contain either `privileged_context` or `golden_response` alongside `prompt`.") + + return { + "prompt": example["prompt"], + "privileged_context": privileged_context, + } + + +def _prepare_split(dataset, script_args: SDFTScriptArguments): + template = Template(script_args.demonstration_template) + return dataset.map( + lambda example: _build_privileged_context( + example, + privileged_context_column=script_args.privileged_context_column, + golden_response_column=script_args.golden_response_column, + template=template, + ), + remove_columns=dataset.column_names, + ) + + +def _can_prepare_privileged_context(dataset) -> bool: + columns = set(dataset.column_names) + return "prompt" in columns and ("privileged_context" in columns or "golden_response" in columns) + + +def _extract_action_and_input(text: str) -> tuple[str | None, str | None]: + action_match = re.search(r"Action:\s*([^\n]+)", text) + action_input_match = re.search(r"Action Input:\s*(.*)", text, flags=re.DOTALL) + action = action_match.group(1).strip() if action_match else None + action_input = action_input_match.group(1).strip() if action_input_match else None + return action, action_input + + +def _parse_json_object(text: str | None) -> tuple[bool, Any]: + if text is None: + return False, None + text = text.strip() + if text.startswith("```"): + text = re.sub(r"^```(?:json)?\s*", "", text) + text = re.sub(r"\s*```$", "", text) + try: + return True, json.loads(text) + except Exception: + return False, None + + +def _normalize_gold_answer(example: dict[str, Any]) -> tuple[str | None, Any]: + answers = example.get("golden_answer") or [] + if not answers: + return None, None + answer = answers[0] + action = answer.get("Action") + valid_json, action_input = _parse_json_object(answer.get("Action_Input")) + return action, action_input if valid_json else answer.get("Action_Input") + + +def _apply_prompt_template(tokenizer, prompt: Any) -> str: + return maybe_apply_chat_template({"prompt": prompt}, tokenizer)["prompt"] + + +def _run_tooluse_eval( + trainer: SDFTTrainer, + eval_dataset, + max_new_tokens: int, + num_examples: int | None = None, + metric_prefix: str = "tool_eval", +) -> dict[str, float]: + if num_examples is not None: + eval_dataset = eval_dataset.select(range(min(num_examples, len(eval_dataset)))) + + prompts = eval_dataset["prompt"] + prompt_texts = [_apply_prompt_template(trainer.processing_class, prompt) for prompt in prompts] + tokenized = trainer.processing_class( + text=prompt_texts, + return_tensors="pt", + padding=True, + padding_side="left", + truncation=True, + max_length=trainer.max_prompt_length, + add_special_tokens=False, + ) + tokenized = {key: value.to(trainer.accelerator.device) for key, value in tokenized.items()} + + with ( + unwrap_model_for_generation( + trainer.model_wrapped, + trainer.accelerator, + gather_deepspeed3_params=trainer.args.ds3_gather_for_generation, + ) as unwrapped_model, + torch.no_grad(), + ): + generated = unwrapped_model.generate( + **tokenized, + max_new_tokens=max_new_tokens, + do_sample=False, + pad_token_id=trainer.processing_class.pad_token_id, + eos_token_id=trainer.processing_class.eos_token_id, + ) + + prompt_length = tokenized["input_ids"].shape[1] + completions = trainer.processing_class.batch_decode(generated[:, prompt_length:], skip_special_tokens=True) + + action_correct = 0 + json_valid = 0 + full_match = 0 + parsed_action_present = 0 + records = [] + + for example, completion in zip(eval_dataset, completions, strict=True): + pred_action, pred_action_input_text = _extract_action_and_input(completion) + if pred_action is not None: + parsed_action_present += 1 + pred_json_valid, pred_action_input = _parse_json_object(pred_action_input_text) + if pred_json_valid: + json_valid += 1 + + gold_action, gold_action_input = _normalize_gold_answer(example) + is_action_correct = pred_action == gold_action and gold_action is not None + if is_action_correct: + action_correct += 1 + is_full_match = is_action_correct and pred_json_valid and pred_action_input == gold_action_input + if is_full_match: + full_match += 1 + + records.append( + { + "prompt": _extract_prompt_text(example["prompt"]), + "completion": completion, + "pred_action": pred_action, + "pred_action_input_text": pred_action_input_text, + "gold_action": gold_action, + "gold_action_input": gold_action_input, + "action_correct": is_action_correct, + "json_valid": pred_json_valid, + "full_match": is_full_match, + } + ) + + total = max(len(eval_dataset), 1) + metrics = { + f"{metric_prefix}/action_present_rate": parsed_action_present / total, + f"{metric_prefix}/valid_json_rate": json_valid / total, + f"{metric_prefix}/action_accuracy": action_correct / total, + f"{metric_prefix}/tool_call_accuracy": full_match / total, + } + + sample_path = os.path.join(trainer.args.output_dir, f"{metric_prefix}_samples.json") + os.makedirs(trainer.args.output_dir, exist_ok=True) + with open(sample_path, "w") as f: + json.dump(records[: min(20, len(records))], f, indent=2) + + return metrics + + +if __name__ == "__main__": + parser = TrlParser((SDFTScriptArguments, ExampleSDFTConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + if model_args.model_name_or_path is None: + raise ValueError("`model_name_or_path` is required.") + if script_args.ref_model_name_or_path is None and not model_args.use_peft: + script_args.ref_model_name_or_path = model_args.model_name_or_path + + if model_args.dtype in ["auto", None]: + if training_args.bf16: + dtype = torch.bfloat16 + elif training_args.fp16: + dtype = torch.float16 + else: + dtype = "auto" + else: + dtype = getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + training_args.model_init_kwargs = model_kwargs + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + padding_side="left", + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + if script_args.dataset_path is not None: + dataset = load_from_disk(script_args.dataset_path) + else: + dataset = load_dataset( + script_args.dataset_name, + name=script_args.dataset_config, + streaming=script_args.dataset_streaming, + ) + + if not isinstance(dataset, DatasetDict): + raise ValueError("SDFT example expects a dataset with named splits.") + + train_dataset = _prepare_split(dataset[script_args.dataset_train_split], script_args) + raw_eval_dataset = dataset[script_args.dataset_test_split] if script_args.dataset_test_split in dataset else None + eval_dataset = None + if ( + training_args.eval_strategy != "no" + and raw_eval_dataset is not None + and _can_prepare_privileged_context(raw_eval_dataset) + ): + eval_dataset = _prepare_split(raw_eval_dataset, script_args) + + model = AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path, **model_kwargs) + ref_model = None + if script_args.ref_model_name_or_path is not None: + ref_model = AutoModelForCausalLM.from_pretrained(script_args.ref_model_name_or_path, **model_kwargs) + model.config.use_cache = False if training_args.gradient_checkpointing else True + if ref_model is not None: + ref_model.config.use_cache = True + + trainer = SDFTTrainer( + model=model, + ref_model=ref_model, + args=training_args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + if eval_dataset is not None and script_args.eval_num_prompts: + generation_config = GenerationConfig( + max_new_tokens=training_args.max_completion_length, + do_sample=True, + temperature=training_args.temperature, + ) + trainer.add_callback( + LogCompletionsCallback(trainer, generation_config, num_prompts=script_args.eval_num_prompts) + ) + + pretrain_metrics = None + if raw_eval_dataset is not None and "golden_answer" in raw_eval_dataset.column_names: + pretrain_metrics = _run_tooluse_eval( + trainer, + raw_eval_dataset, + max_new_tokens=script_args.tool_eval_max_new_tokens, + num_examples=script_args.tool_eval_num_examples, + metric_prefix="tool_eval_before", + ) + trainer.log(pretrain_metrics) + trainer.log_metrics("eval", pretrain_metrics) + trainer.save_metrics("eval", pretrain_metrics) + + trainer.train() + + trainer.save_model(training_args.output_dir) + if eval_dataset is not None: + metrics = trainer.evaluate() + trainer.log_metrics("eval", metrics) + trainer.save_metrics("eval", metrics) + if raw_eval_dataset is not None and "golden_answer" in raw_eval_dataset.column_names: + post_metrics = _run_tooluse_eval( + trainer, + raw_eval_dataset, + max_new_tokens=script_args.tool_eval_max_new_tokens, + num_examples=script_args.tool_eval_num_examples, + metric_prefix="tool_eval_after", + ) + if pretrain_metrics is not None: + for key, value in pretrain_metrics.items(): + after_key = key.replace("tool_eval_before/", "tool_eval_after/") + if after_key in post_metrics: + delta_name = after_key.replace("tool_eval_after/", "tool_eval_delta/") + post_metrics[delta_name] = post_metrics[after_key] - value + trainer.log(post_metrics) + trainer.log_metrics("eval", post_metrics) + trainer.save_metrics("eval", post_metrics) + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name or script_args.dataset_path) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft_config.py new file mode 100644 index 0000000000000000000000000000000000000000..84227e43cbfaf0519be315bfc70e0fb3914e5088 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft_config.py @@ -0,0 +1,68 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ..self_distillation.self_distillation_config import SelfDistillationConfig + + +@dataclass +class SDFTConfig(SelfDistillationConfig): + r""" + Configuration class for [`SDFTTrainer`]. + + This adapts the official SDFT implementation to the TRL trainer API while reusing the common self-distillation + configuration shared with SDPO. + + Parameters: + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the student and teacher models. + generate_from_teacher (`bool`, *optional*, defaults to `False`): + Whether on-policy generation should use the teacher-conditioned prompt instead of the student prompt. + teacher_prompt_template (`str`, *optional*, defaults to `"{prompt}\n\n{privileged_context}"`): + Template used to combine the student prompt and privileged context into the teacher prompt. + num_loss_tokens_to_skip (`int`, *optional*, defaults to `0`): + Number of initial completion tokens to exclude from the distillation loss. + """ + + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the student and teacher models."}, + ) + generate_from_teacher: bool = field( + default=False, + metadata={"help": "Whether on-policy generation should use the teacher-conditioned prompt."}, + ) + teacher_prompt_template: str = field( + default="{prompt}\n\n{privileged_context}", + metadata={ + "help": "Template used to combine the student prompt and privileged context into the teacher prompt." + }, + ) + num_loss_tokens_to_skip: int = field( + default=0, + metadata={"help": "Number of initial completion tokens to exclude from the distillation loss."}, + ) + + def __post_init__(self): + super().__post_init__() + if ( + "{prompt}" not in self.teacher_prompt_template + or "{privileged_context}" not in self.teacher_prompt_template + ): + raise ValueError( + "teacher_prompt_template must contain both `{prompt}` and `{privileged_context}` placeholders" + ) + if self.num_loss_tokens_to_skip < 0: + raise ValueError("num_loss_tokens_to_skip must be non-negative") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..5bf6095c2a0d556a2c768719add043a9fc751c9b --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdft/sdft_trainer.py @@ -0,0 +1,486 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +import copy +import inspect +import textwrap +from collections import defaultdict +from functools import partial +from typing import Any + +import datasets +import torch +from accelerate.logging import get_logger +from accelerate.utils import is_peft_model +from datasets import Dataset, IterableDataset +from torch import nn +from torch.utils.data import DataLoader, Sampler +from transformers import ( + AutoProcessor, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import seed_worker +from transformers.utils import is_datasets_available, is_peft_available + +from ...models import prepare_deepspeed, prepare_fsdp, unwrap_model_for_generation +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.callbacks import SyncRefModelCallback +from ...trainer.utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + get_config_model_id, + identity, + pad, + split_tensor_dict, + use_adapter, +) +from ..self_distillation.self_distillation_mixin import SelfDistillationMixin +from ..self_distillation.teacher_context import PromptTokenizer, extract_last_user_text +from ..utils import prepare_peft_model +from .sdft_config import SDFTConfig + + +if is_peft_available(): + from peft import PeftConfig + from peft.peft_model import PeftModel + + from ..self_distillation.peft_adapter_ema_callback import PEFTAdapterEMACallback + + +logger = get_logger(__name__) + + +class DemonstrationTeacherContextBuilder: + """Builds student and teacher contexts from prompts plus privileged context, as in SDFT.""" + + def __init__(self, trainer): + self.trainer = trainer + self.prompt_tokenizer = PromptTokenizer(trainer) + + def _stringify_privileged_context(self, privileged_context: Any) -> str: + if privileged_context is None: + raise ValueError( + "`privileged_context` must not be None for self-distillation teacher prompt construction." + ) + if isinstance(privileged_context, str): + return privileged_context + if isinstance(privileged_context, list) and privileged_context and isinstance(privileged_context[0], dict): + chunks = [] + for message in privileged_context: + content = message.get("content", "") + if isinstance(content, list): + text = " ".join(part.get("text", "") for part in content if part.get("type") == "text") + else: + text = str(content) + if text: + chunks.append(text) + return "\n".join(chunks) + return str(privileged_context) + + def _compose_teacher_prompt(self, prompt: Any, privileged_context: Any) -> Any: + privileged_text = self._stringify_privileged_context(privileged_context) + if isinstance(prompt, list): + system_messages = prompt[:-1] + prompt_text = extract_last_user_text(prompt) + teacher_text = self.trainer.args.teacher_prompt_template.format( + prompt=prompt_text, + privileged_context=privileged_text, + ) + return system_messages + [{"role": "user", "content": teacher_text}] + return self.trainer.args.teacher_prompt_template.format(prompt=prompt, privileged_context=privileged_text) + + def select_generation_prompts(self, prompts: list[Any], privileged_contexts: list[Any]) -> list[Any]: + if not self.trainer.generate_from_teacher: + return prompts + return [ + self._compose_teacher_prompt(prompt, privileged_context) + for prompt, privileged_context in zip(prompts, privileged_contexts, strict=True) + ] + + def build( + self, + prompts: list[Any], + privileged_contexts: list[Any], + completion_ids: torch.Tensor, + completion_mask: torch.Tensor, + ) -> dict[str, torch.Tensor]: + student_batch = self.prompt_tokenizer.tokenize_prompts(prompts) + teacher_prompts = [ + self._compose_teacher_prompt(prompt, privileged_context) + for prompt, privileged_context in zip(prompts, privileged_contexts, strict=True) + ] + teacher_batch = self.prompt_tokenizer.tokenize_prompts(teacher_prompts) + teacher_input_ids = torch.cat([teacher_batch.prompt_ids, completion_ids], dim=1) + teacher_attention_mask = torch.cat([teacher_batch.prompt_mask, completion_mask], dim=1) + return { + "prompt_ids": student_batch.prompt_ids, + "prompt_mask": student_batch.prompt_mask, + "teacher_input_ids": teacher_input_ids, + "teacher_attention_mask": teacher_attention_mask, + } + + +class SDFTTrainer(SelfDistillationMixin, _BaseTrainer): + """Trainer for SDFT-style on-policy self-distillation with explicit teacher prompts.""" + + _tag_names = ["trl", "sdft"] + _name = "SDFT" + config_cls = SDFTConfig + # docstyle-ignore + _paper = { + "title": "Self-Training with On-Policy Self-Distillation for Language Model Alignment", + "id": "2601.19897", + "citation": textwrap.dedent("""\ + @article{hubotter2026selftraining, + title = {{Self-Training with On-Policy Self-Distillation for Language Model Alignment}}, + author = {Jonas H\\"ubotter and Frederike L\\"ubeck and Lejs Behric and Anton Baumann and Marco Bagatella and Daniel Marta and Ido Hakimi and Idan Shenfeld and Thomas Kleine Buening and Carlos Guestrin and Andreas Krause}, + year = 2026, + eprint = {arXiv:2601.19897} + }"""), + } + + def __init__( + self, + model: str | PreTrainedModel | nn.Module, + args: SDFTConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: PeftConfig | None = None, + ): + if train_dataset is None: + raise ValueError("`train_dataset` is required") + if isinstance(train_dataset, IterableDataset): + raise NotImplementedError("Iterable datasets are not yet supported in SDFTTrainer.") + if isinstance(eval_dataset, IterableDataset) or ( + isinstance(eval_dataset, dict) and any(isinstance(ds, IterableDataset) for ds in eval_dataset.values()) + ): + raise NotImplementedError("Iterable eval datasets are not yet supported in SDFTTrainer.") + if args.use_vllm: + raise NotImplementedError("SDFTTrainer does not support `use_vllm=True` yet.") + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + elif args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to `SDFTConfig`, but `model` is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + + self.model_kwarg_keys = ( + inspect.signature(model.forward).parameters.keys() + if not hasattr(model, "get_base_model") + else inspect.signature(model.get_base_model().forward).parameters.keys() + ) + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to SDFTTrainer. Pass either a base " + "model with `peft_config`, or a pre-wrapped PEFT model." + ) + if peft_config is not None or (is_peft_available() and getattr(model, "peft_config", None) is not None): + model = prepare_peft_model(model, peft_config, args) + + if processing_class is None: + processing_class = AutoProcessor.from_pretrained( + get_config_model_id(model.config), truncation_side="left", padding_side="left" + ) + + if isinstance(processing_class, ProcessorMixin): + tokenizer = processing_class.tokenizer + elif isinstance(processing_class, PreTrainedTokenizerBase): + tokenizer = processing_class + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + self.pad_token_id = tokenizer.pad_token_id + self.eos_token_id = tokenizer.eos_token_id + self.max_prompt_length = args.max_prompt_length + self.max_completion_length = args.max_completion_length + self.num_generations = args.num_generations + self.num_iterations = args.num_iterations + self.temperature = args.temperature + self.loss_type = args.loss_type + self.shuffle_dataset = args.shuffle_dataset + self.generate_from_teacher = args.generate_from_teacher + self.num_loss_tokens_to_skip = args.num_loss_tokens_to_skip + self.chat_template_kwargs = args.chat_template_kwargs or {} + self._step = 0 + self._buffered_inputs = None + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self.prompt_tokenizer = PromptTokenizer(self) + self.teacher_context_builder = DemonstrationTeacherContextBuilder(self) + + generation_kwargs = { + "max_new_tokens": self.max_completion_length, + "do_sample": True, + "pad_token_id": tokenizer.pad_token_id, + "bos_token_id": tokenizer.bos_token_id, + "eos_token_id": tokenizer.eos_token_id, + "temperature": args.temperature, + "top_p": args.top_p, + "top_k": args.top_k, + "min_p": args.min_p, + "repetition_penalty": args.repetition_penalty, + "cache_implementation": args.cache_implementation, + } + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + self.generation_config = GenerationConfig(**generation_kwargs, disable_compile=True) + + if hasattr(model, "warnings_issued"): + model.warnings_issued["estimate_tokens"] = True + + super().__init__( + model=model, + args=args, + data_collator=identity, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + callbacks=callbacks, + optimizers=optimizers, + compute_loss_func="non-None value to disable scaling", + ) + + if args.disable_dropout: + disable_dropout_in_model(self.model) + + self.model.add_model_tags(self._tag_names) + + # In self-distillation the teacher is always derived from the student: + # - PEFT: base model with adapter disabled (or EMA teacher adapter when sync_ref_model=True) + # - Non-PEFT: same model (or deep-copied EMA model when sync_ref_model=True) + self.teacher_model = None + + if args.sync_ref_model: + if is_peft_available() and is_peft_model(self.model): + self.add_callback( + PEFTAdapterEMACallback( + model=self.model, + teacher_adapter_name="teacher", + update_rate=args.ref_model_mixup_alpha, + sync_steps=args.ref_model_sync_steps, + accelerator=self.accelerator, + ) + ) + else: + student_model = self.accelerator.unwrap_model(self.model) + self.teacher_model = copy.deepcopy(student_model) + self.teacher_model.requires_grad_(False) + self.teacher_model.eval() + if self.is_deepspeed_enabled: + self.teacher_model = prepare_deepspeed(self.teacher_model, self.accelerator) + elif self.is_fsdp_enabled: + self.teacher_model = prepare_fsdp(self.teacher_model, self.accelerator) + else: + self.teacher_model = self.accelerator.prepare_model(self.teacher_model, evaluation_mode=True) + self.add_callback(SyncRefModelCallback(ref_model=self.teacher_model, accelerator=self.accelerator)) + + self.model_accepts_loss_kwargs = False + + def get_train_dataloader(self): + if self.train_dataset is None: + raise ValueError("Trainer: training requires a train_dataset.") + + train_dataset = self.train_dataset + data_collator = self.data_collator + if is_datasets_available() and isinstance(train_dataset, datasets.Dataset): + train_dataset = self._remove_unused_columns(train_dataset, description="training") + else: + data_collator = self._get_collator_with_removed_columns(data_collator, description="training") + + dataloader_params = { + "batch_size": self._train_batch_size * self.args.steps_per_generation, + "collate_fn": data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "persistent_workers": self.args.dataloader_persistent_workers, + } + if not isinstance(train_dataset, torch.utils.data.IterableDataset): + dataloader_params["sampler"] = self._get_train_sampler() + dataloader_params["drop_last"] = self.args.dataloader_drop_last + dataloader_params["worker_init_fn"] = partial( + seed_worker, num_workers=self.args.dataloader_num_workers, rank=self.args.process_index + ) + dataloader_params["prefetch_factor"] = self.args.dataloader_prefetch_factor + return self.accelerator.prepare(DataLoader(train_dataset, **dataloader_params)) + + def _get_train_sampler(self, dataset=None) -> Sampler: + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size // self.num_generations, + repeat_count=self.num_iterations * self.args.steps_per_generation, + shuffle=self.shuffle_dataset, + seed=self.args.seed, + ) + + def _get_eval_sampler(self, eval_dataset) -> Sampler: + return RepeatSampler( + data_source=eval_dataset, + mini_repeat_count=self.num_generations, + seed=self.args.seed, + ) + + def training_step(self, model, inputs, num_items_in_batch): + output = super().training_step(model, inputs, num_items_in_batch) + self._step += 1 + return output + + def _prepare_inputs(self, generation_batch): + mode = "train" if self.model.training else "eval" + if mode == "train": + generate_every = self.args.steps_per_generation * self.num_iterations + if self._step % generate_every == 0 or self._buffered_inputs is None: + generation_batch = self._build_buffered_batch(generation_batch) + self._buffered_inputs = split_tensor_dict(generation_batch, self.args.steps_per_generation) + self._dispatch_self_distillation_callback( + "on_generation_batch_built", + generate_every=generate_every, + steps_per_generation=self.args.steps_per_generation, + ) + return self._buffered_inputs[self._step % self.args.steps_per_generation] + return self._build_buffered_batch(generation_batch) + + def _generate_completion_ids(self, prompts: list[Any]) -> tuple[torch.Tensor, torch.Tensor]: + generate_inputs = self.processing_class( + text=self.prompt_tokenizer.apply_prompt_template(prompts), + return_tensors="pt", + padding=True, + padding_side="left", + max_length=self.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + # This generation helper builds tokenized model inputs directly, so use the base Trainer tensor preparation + # instead of re-entering the buffered outer training hook. + generate_inputs = _BaseTrainer._prepare_inputs(self, generate_inputs) + + with ( + unwrap_model_for_generation( + self.model_wrapped, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + ) as unwrapped_model, + torch.no_grad(), + ): + prompt_completion_ids = unwrapped_model.generate( + **generate_inputs, generation_config=self.generation_config + ) + + prompt_length = generate_inputs["input_ids"].size(1) + completion_ids = prompt_completion_ids[:, prompt_length:] + is_eos = completion_ids == self.eos_token_id + eos_idx = torch.full((is_eos.size(0),), is_eos.size(1), dtype=torch.long, device=completion_ids.device) + eos_idx[is_eos.any(dim=1)] = is_eos.int().argmax(dim=1)[is_eos.any(dim=1)] + seq_idx = torch.arange(is_eos.size(1), device=completion_ids.device).expand(is_eos.size(0), -1) + completion_mask = (seq_idx <= eos_idx.unsqueeze(1)).long() + + completion_ids_list = [c[m].tolist() for c, m in zip(completion_ids, completion_mask.bool(), strict=True)] + completion_ids = [torch.tensor(ids, device=self.accelerator.device) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + return ( + pad(completion_ids, padding_value=self.pad_token_id, padding_side="right"), + pad(completion_mask, padding_value=0, padding_side="right"), + ) + + def _build_buffered_batch(self, inputs: list[dict[str, Any]]) -> dict[str, torch.Tensor | Any]: + prompts, privileged_contexts = self._split_prompt_and_privileged_context(inputs) + generation_prompts = self.teacher_context_builder.select_generation_prompts(prompts, privileged_contexts) + generation_prompt_text = self.prompt_tokenizer.apply_prompt_template(generation_prompts) + self._dispatch_self_distillation_callback( + "on_generation_prompts_selected", + generation_prompts=generation_prompts, + generation_prompt_text=generation_prompt_text, + ) + completion_ids, completion_mask = self._generate_completion_ids(generation_prompts) + + teacher_batch = self.teacher_context_builder.build( + prompts, privileged_contexts, completion_ids, completion_mask + ) + + prompt_completion_ids = torch.cat([teacher_batch["prompt_ids"], completion_ids], dim=1) + attention_mask = torch.cat([teacher_batch["prompt_mask"], completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) + + with torch.no_grad(): + generate_every = self.args.steps_per_generation * self.num_iterations + if not self.generate_from_teacher and self.args.gradient_accumulation_steps % generate_every != 0: + old_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + compute_entropy=False, + ) + else: + old_per_token_logps = None + + self._dispatch_self_distillation_callback( + "on_self_distillation_batch_prepared", + old_per_token_logps=old_per_token_logps, + prompt_ids=teacher_batch["prompt_ids"], + completion_ids=completion_ids, + ) + output = { + "prompt_ids": teacher_batch["prompt_ids"], + "prompt_mask": teacher_batch["prompt_mask"], + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "teacher_input_ids": teacher_batch["teacher_input_ids"], + "teacher_attention_mask": teacher_batch["teacher_attention_mask"], + } + if old_per_token_logps is not None: + output["old_per_token_logps"] = old_per_token_logps + return output + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if return_outputs: + raise ValueError("The SDFTTrainer does not support returning outputs") + + if self.num_loss_tokens_to_skip > 0: + inputs = dict(inputs) + completion_mask = inputs["completion_mask"].clone() + token_positions = torch.arange(completion_mask.size(1), device=completion_mask.device).unsqueeze(0) + completion_mask = completion_mask * (token_positions >= self.num_loss_tokens_to_skip).long() + inputs["completion_mask"] = completion_mask + + loss = self._compute_self_distillation_loss(model, inputs) + accumulation_scale = self.current_gradient_accumulation_steps if self.model.training else 1.0 + return loss / accumulation_scale + + def _get_teacher_context_for_self_distillation(self, model): + if is_peft_available() and isinstance(self.model, PeftModel): + model = self.accelerator.unwrap_model(self.model) + if self.args.sync_ref_model and "teacher" in model.peft_config: + return use_adapter(model, adapter_name="teacher") + return use_adapter(model, adapter_name=None) + return super()._get_teacher_context_for_self_distillation(model) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f50a54cf7c8d3dcc907361da9caa07e53cd21d9f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .sdpo_config import SDPOConfig +from .sdpo_trainer import SDPOTrainer + + +__all__ = ["SDPOConfig", "SDPOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo.py new file mode 100644 index 0000000000000000000000000000000000000000..7a65a00cc5d305e5c91968cb1ea048d1bf507b31 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo.py @@ -0,0 +1,390 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "math-verify", +# "latex2sympy2_extended", +# "trackio", +# "kernels", +# ] +# /// + +""" +Usage: + +```bash +python trl/experimental/sdpo/sdpo.py \ + --model_name_or_path Qwen/Qwen2.5-Math-1.5B-Instruct \ + --dataset_name openai/gsm8k \ + --dataset_config main \ + --output_dir outputs/sdpo-qwen35-2b-gsm8k \ + --learning_rate 5e-5 \ + --dtype bfloat16 \ + --bf16 true \ + --max_completion_length 128 \ + --use_peft \ + --lora_target_modules q_proj k_proj v_proj o_proj gate_proj up_proj down_proj \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 2 \ + --num_generations 8 \ + --generation_batch_size 32 \ + --distillation_alpha 1.0 \ + --full_logit_distillation false \ + --sdpo_policy_loss_mode hybrid \ + --report_to none \ + --eval_strategy steps \ + --eval_steps 1000 \ + --save_strategy no \ + --eval_num_prompts 0 \ + --accuracy_eval_num_examples 64 \ + --max_train_examples 256 \ + --max_eval_examples 128 +``` + +This example uses verifiable math rewards and reports answer accuracy before and after training. If your dataset +already contains textual environment feedback, pass the column name via `--feedback_column`; it will be forwarded as +`privileged_context` for SDPO reprompting. +""" + +import re +from dataclasses import dataclass, field +from typing import Any + +import torch +from datasets import DatasetDict, load_dataset, load_from_disk +from transformers import AutoTokenizer, GenerationConfig + +from trl import ( + LogCompletionsCallback, + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.data_utils import maybe_apply_chat_template +from trl.experimental.sdpo import SDPOConfig, SDPOTrainer + + +SYSTEM_PROMPT = ( + "A conversation between user and assistant. The user asks a question, and the assistant solves it. The assistant " + "first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning " + "must be enclosed within tags, and the final answer must be on its own line in the format " + "`#### `." +) + + +@dataclass +class SDPOScriptArguments(ScriptArguments): + dataset_path: str | None = field( + default=None, + metadata={"help": "Optional local dataset path to load with `load_from_disk`. Overrides `dataset_name`."}, + ) + feedback_column: str | None = field( + default=None, + metadata={ + "help": "Optional dataset column containing textual environment feedback to pass as `privileged_context`." + }, + ) + eval_num_prompts: int | None = field( + default=8, + metadata={"help": "Number of prompts to log during evaluation. Set to 0 to disable completion logging."}, + ) + accuracy_eval_num_examples: int | None = field( + default=128, + metadata={"help": "Optional number of eval examples to score for answer accuracy. Defaults to 128."}, + ) + accuracy_eval_max_new_tokens: int = field( + default=128, + metadata={"help": "Maximum completion length for answer-accuracy evaluation generation."}, + ) + feedback_from_solution: str | None = field( + default=None, + metadata={ + "help": "Optional synthesized feedback source when the dataset has no feedback column. Supported: " + "`final_answer`, `full_solution`." + }, + ) + max_train_examples: int | None = field( + default=None, + metadata={"help": "Optional cap on the number of training examples loaded from the selected train split."}, + ) + max_eval_examples: int | None = field( + default=None, + metadata={"help": "Optional cap on the number of evaluation examples loaded from the selected eval split."}, + ) + dataset_shuffle_seed: int = field( + default=42, + metadata={"help": "Random seed used before applying `max_train_examples` or `max_eval_examples`."}, + ) + + +@dataclass +class ExampleSDPOConfig(SDPOConfig): + scale_rewards: str = field( + default="group", + metadata={"help": "Reward normalization mode. Supported: `group`, `batch`, `none`."}, + ) + + +def _make_solution_feedback(final_answer: str, worked_solution: str, feedback_from_solution: str | None) -> str | None: + if feedback_from_solution is None: + return None + if feedback_from_solution == "final_answer": + return ( + "Your previous answer was incorrect. The correct final answer is:\n\n" + f"#### {final_answer}\n\n" + "Revise your reasoning and end with the same final answer format." + ) + if feedback_from_solution == "full_solution": + return ( + "Your previous answer was incorrect. Here is a correct worked solution:\n\n" + f"{worked_solution}\n\n" + "Use it to solve the original question correctly." + ) + raise ValueError("feedback_from_solution must be one of: `final_answer`, `full_solution`.") + + +def _make_conversation( + example: dict[str, Any], feedback_column: str | None, feedback_from_solution: str | None +) -> dict[str, Any]: + prompt = example.get("prompt") + if prompt is None and "problem" in example: + prompt = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["problem"]}, + ] + if prompt is None and "question" in example: + prompt = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": example["question"]}, + ] + + if prompt is None: + raise ValueError("Each example must provide one of: `prompt`, `problem`, or `question`.") + + output = {"prompt": prompt} + + solution = None + if "solution" in example: + solution = example["solution"] + elif "answer" in example: + solution = _normalize_gsm8k_answer(example["answer"]) + + if solution is not None: + output["solution"] = solution + + if feedback_column is not None and feedback_column in example: + output["privileged_context"] = example[feedback_column] + elif "privileged_context" in example: + output["privileged_context"] = example["privileged_context"] + elif solution is not None: + worked_solution = example.get("solution") + if worked_solution is None and "answer" in example: + worked_solution = example["answer"].strip() + if worked_solution is None: + worked_solution = f"#### {solution}" + synthesized_feedback = _make_solution_feedback(solution, worked_solution, feedback_from_solution) + if synthesized_feedback is not None: + output["privileged_context"] = synthesized_feedback + + return output + + +def _normalize_gsm8k_answer(answer_text: str) -> str: + if "####" not in answer_text: + return answer_text.strip() + return answer_text.split("####", 1)[1].strip().replace(",", "") + + +def _extract_predicted_answer(completion_text: str) -> str | None: + match = re.search(r"####\s*([^\n]+)", completion_text) + if match: + return match.group(1).strip().replace(",", "") + + matches = re.findall(r"(-?\$?[0-9][0-9,]*(?:\.[0-9]+)?)", completion_text) + if not matches: + return None + return matches[-1].replace("$", "").replace(",", "").strip() + + +def _gsm8k_accuracy_reward(completions, solution, **kwargs) -> list[float]: + rewards = [] + for completion, gold in zip(completions, solution, strict=True): + content = completion[0]["content"] if isinstance(completion, list) else completion + pred = _extract_predicted_answer(content) + rewards.append(1.0 if pred is not None and pred == gold else 0.0) + return rewards + + +def _gsm8k_soft_format_reward(completions, **kwargs) -> list[float]: + pattern = r".*?\s*####\s*[^\n]+" + rewards = [] + for completion in completions: + content = completion[0]["content"] if isinstance(completion, list) else completion + rewards.append(0.25 if re.match(pattern, content, flags=re.DOTALL) else 0.0) + return rewards + + +def _run_accuracy_eval( + trainer: SDPOTrainer, eval_dataset, max_new_tokens: int, num_examples: int | None, metric_prefix: str = "math_eval" +) -> dict[str, float]: + if num_examples is not None: + eval_dataset = eval_dataset.select(range(min(num_examples, len(eval_dataset)))) + + prompts = eval_dataset["prompt"] + prompt_texts = [ + maybe_apply_chat_template({"prompt": prompt}, trainer.processing_class)["prompt"] for prompt in prompts + ] + tokenized = trainer.processing_class( + text=prompt_texts, + return_tensors="pt", + padding=True, + padding_side="left", + truncation=True, + max_length=trainer.max_prompt_length, + add_special_tokens=False, + ) + tokenized = {key: value.to(trainer.accelerator.device) for key, value in tokenized.items()} + model = trainer.accelerator.unwrap_model(trainer.model) + was_training = model.training + model.eval() + with torch.no_grad(): + generated = model.generate( + **tokenized, + max_new_tokens=max_new_tokens, + do_sample=False, + pad_token_id=trainer.processing_class.pad_token_id, + eos_token_id=trainer.processing_class.eos_token_id, + ) + if was_training: + model.train() + + prompt_length = tokenized["input_ids"].shape[1] + completions = trainer.processing_class.batch_decode(generated[:, prompt_length:], skip_special_tokens=True) + completion_messages = [[{"role": "assistant", "content": completion}] for completion in completions] + rewards = _gsm8k_accuracy_reward(completion_messages, solution=eval_dataset["solution"]) + total = max(len(rewards), 1) + return { + f"{metric_prefix}/accuracy": sum(rewards) / total, + f"{metric_prefix}/num_scored": float(len(rewards)), + } + + +if __name__ == "__main__": + parser = TrlParser((SDPOScriptArguments, ExampleSDPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + training_args.model_init_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + training_args.model_init_kwargs["device_map"] = get_kbit_device_map() + training_args.model_init_kwargs["quantization_config"] = quantization_config + + if script_args.dataset_path is not None: + dataset = load_from_disk(script_args.dataset_path) + else: + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + if not isinstance(dataset, DatasetDict): + raise ValueError("SDPO example expects a dataset with named splits.") + + train_split = dataset[script_args.dataset_train_split] + if script_args.max_train_examples is not None: + train_split = train_split.shuffle(seed=script_args.dataset_shuffle_seed).select( + range(min(script_args.max_train_examples, len(train_split))) + ) + + train_dataset = train_split.map( + lambda example: _make_conversation(example, script_args.feedback_column, script_args.feedback_from_solution), + remove_columns=train_split.column_names, + ) + eval_dataset = None + if training_args.eval_strategy != "no": + eval_split = dataset[script_args.dataset_test_split] + if script_args.max_eval_examples is not None: + eval_split = eval_split.shuffle(seed=script_args.dataset_shuffle_seed).select( + range(min(script_args.max_eval_examples, len(eval_split))) + ) + + eval_dataset = eval_split.map( + lambda example: _make_conversation( + example, script_args.feedback_column, script_args.feedback_from_solution + ), + remove_columns=eval_split.column_names, + ) + + reward_funcs = [_gsm8k_soft_format_reward, _gsm8k_accuracy_reward] + + tokenizer = AutoTokenizer.from_pretrained(model_args.model_name_or_path) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + trainer = SDPOTrainer( + model=model_args.model_name_or_path, + args=training_args, + reward_funcs=reward_funcs, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + peft_config=get_peft_config(model_args), + processing_class=tokenizer, + ) + + if eval_dataset is not None and script_args.eval_num_prompts: + generation_config = GenerationConfig( + max_new_tokens=training_args.max_completion_length, + do_sample=True, + temperature=training_args.temperature, + ) + trainer.add_callback( + LogCompletionsCallback(trainer, generation_config, num_prompts=script_args.eval_num_prompts) + ) + + if eval_dataset is not None: + pre_metrics = _run_accuracy_eval( + trainer, + eval_dataset, + max_new_tokens=script_args.accuracy_eval_max_new_tokens, + num_examples=script_args.accuracy_eval_num_examples, + ) + trainer.log_metrics("eval", {f"before_{k}": v for k, v in pre_metrics.items()}) + trainer.save_metrics("eval", {f"before_{k}": v for k, v in pre_metrics.items()}) + + trainer.train() + + trainer.save_model(training_args.output_dir) + if eval_dataset is not None: + post_metrics = _run_accuracy_eval( + trainer, + eval_dataset, + max_new_tokens=script_args.accuracy_eval_max_new_tokens, + num_examples=script_args.accuracy_eval_num_examples, + ) + after_metrics = {f"after_{k}": v for k, v in post_metrics.items()} + delta_metrics = { + f"delta_{k.split('/', 1)[1]}": after_metrics[f"after_{k}"] - pre_metrics[k] for k in pre_metrics + } + trainer.log_metrics("eval", after_metrics | delta_metrics) + trainer.save_metrics("eval", after_metrics | delta_metrics) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name or script_args.dataset_path) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..1cc8c1510b7dc781682e44fdde1710b347da6ebc --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo_config.py @@ -0,0 +1,148 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ..self_distillation import SelfDistillationConfig + + +@dataclass +class SDPOConfig(SelfDistillationConfig): + r""" + Configuration class for the [`SDPOTrainer`]. + + This class extends [`experimental.self_distillation.SelfDistillationConfig`] with the online teacher-construction + parameters used by Self-Distillation Policy Optimization (SDPO). + + Parameters: + > Parameters that control the SDPO loss + + sdpo_policy_loss_mode (`str`, *optional*, defaults to `"distillation_only"`): + How SDPO combines the online policy loss and self-distillation loss. Supported: `distillation_only`, + `hybrid`. + distillation_alpha (`float`, *optional*, defaults to `1.0`): + Divergence interpolation coefficient. Token-level SDPO requires the official reverse-KL setting + `distillation_alpha=1.0`. + distillation_topk (`int` or `None`, *optional*): + Top-k approximation for logit-level SDPO. Requires `full_logit_distillation=True`. + + > Parameters that control the teacher + + teacher_regularization (`str`, *optional*, defaults to `"ema"`): + Teacher update strategy. Supported: `ema`, `none`. + teacher_update_rate (`float` or `None`, *optional*): + EMA update rate used when `teacher_regularization="ema"`. + ema_update_rate (`float`, *optional*, defaults to `0.05`): + Deprecated alias for `teacher_update_rate`. + + > Parameters that control reprompting + + use_successful_as_teacher (`bool`, *optional*, defaults to `True`): + Whether successful rollouts are turned into teacher demonstrations. + success_reward_threshold (`float`, *optional*, defaults to `1.0`): + Minimum reward for a rollout to count as successful. + include_environment_feedback (`bool`, *optional*, defaults to `False`): + Whether `privileged_context` is injected into teacher reprompts when available. + """ + + dont_reprompt_on_self_success: bool = field( + default=True, + metadata={"help": "Skip reprompting when model generates correct response."}, + ) + distillation_alpha: float = field( + default=1.0, + metadata={ + "help": "KL divergence direction for SDPO. Token-level SDPO requires reverse KL (`distillation_alpha=1.0`)." + }, + ) + distillation_topk: int | None = field( + default=None, + metadata={"help": "Top-K approximation for logit-level SDPO. Requires `full_logit_distillation=True`."}, + ) + sdpo_policy_loss_mode: str = field( + default="distillation_only", + metadata={"help": "SDPO policy loss mode. Supported: `distillation_only`, `hybrid`."}, + ) + teacher_regularization: str = field( + default="ema", + metadata={"help": "Teacher regularization mode. Supported: `ema`, `none`."}, + ) + teacher_update_rate: float | None = field( + default=None, + metadata={"help": "Teacher update rate used for EMA teacher synchronization."}, + ) + ema_update_rate: float = field( + default=0.05, + metadata={"help": "Deprecated alias for `teacher_update_rate`."}, + ) + max_reprompt_len: int = field( + default=10240, + metadata={"help": "Maximum length for reprompting in self-distillation."}, + ) + use_successful_as_teacher: bool = field( + default=True, + metadata={"help": "Use successful rollouts as implicit feedback for self-distillation."}, + ) + success_reward_threshold: float = field( + default=1.0, + metadata={"help": "Minimum reward for a rollout to be considered a successful demonstration."}, + ) + reprompt_template: str = field( + default="{prompt}{solution}{feedback}\n\nCorrectly solve the original question.\n", + metadata={"help": "Template for reprompting the teacher with a successful demonstration."}, + ) + solution_template: str = field( + default="\nCorrect solution:\n\n{successful_previous_attempt}\n\n", + metadata={"help": "Template for formatting the successful demonstration text."}, + ) + feedback_template: str = field( + default="\nThe following is feedback from your unsuccessful earlier attempt:\n\n{feedback_raw}\n\n", + metadata={"help": "Template for formatting environment feedback for reprompting."}, + ) + include_environment_feedback: bool = field( + default=False, + metadata={"help": "Whether to include environment feedback in teacher reprompts when available."}, + ) + environment_feedback_only_without_solution: bool = field( + default=False, + metadata={"help": "Whether to use feedback only when no successful solution is available."}, + ) + remove_thinking_from_demonstration: bool = field( + default=False, + metadata={"help": "Whether to remove ... blocks from the demonstration text."}, + ) + + def __post_init__(self): + super().__post_init__() + + if self.teacher_update_rate is None: + self.teacher_update_rate = self.ema_update_rate + + if self.teacher_regularization not in {"ema", "none"}: + raise ValueError("teacher_regularization must be one of: 'ema', 'none'") + if not 0.0 <= self.teacher_update_rate <= 1.0: + raise ValueError("teacher_update_rate must be in [0, 1]") + if self.sdpo_policy_loss_mode not in {"distillation_only", "hybrid"}: + raise ValueError("sdpo_policy_loss_mode must be one of: 'distillation_only', 'hybrid'") + if self.sdpo_policy_loss_mode == "distillation_only" and self.distillation_weight <= 0: + raise ValueError("distillation_only mode requires `distillation_weight > 0`.") + if self.max_reprompt_len <= 0: + raise ValueError("max_reprompt_len must be positive") + if not self.full_logit_distillation and self.distillation_alpha != 1.0: + raise ValueError( + "SDPO token-level distillation requires `distillation_alpha=1.0`. " + "Set `full_logit_distillation=True` to use other divergence settings." + ) + if self.distillation_topk is not None and not self.full_logit_distillation: + raise ValueError("SDPO `distillation_topk` requires `full_logit_distillation=True`.") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..ef84a17a44c2cf6555b27c846e72350e77fd0dec --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/sdpo/sdpo_trainer.py @@ -0,0 +1,387 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +import re +import textwrap +from typing import Any + +import torch +from accelerate.utils import gather_object +from datasets import Dataset, IterableDataset +from torch import nn +from transformers import PreTrainedModel, PreTrainedTokenizerBase, ProcessorMixin, TrainerCallback + +from ...trainer.callbacks import SyncRefModelCallback +from ...trainer.utils import pad +from ..self_distillation.base_self_distillation_trainer import BaseSelfDistillationTrainer +from ..self_distillation.teacher_context import TokenizedPromptBatch, extract_last_user_text +from .sdpo_config import SDPOConfig + + +class EMATeacherSyncCallback(SyncRefModelCallback): + """Synchronize an EMA teacher model with the student model on each step.""" + + def __init__(self, teacher_model, update_rate: float, accelerator=None): + super().__init__(ref_model=teacher_model, accelerator=accelerator) + self.update_rate = update_rate + + def on_step_end(self, args, state, control, **kwargs): + model = kwargs["model"] + if self.accelerator is not None: + model = self.accelerator.unwrap_model(model) + self.sync_target_model(model, self.ref_model, self.update_rate) + + +class SuccessfulRolloutTeacherContextBuilder: + """Builds SDPO teacher contexts from successful rollouts, following the official online implementation.""" + + def __init__(self, trainer): + self.trainer = trainer + self.last_metrics: dict[str, float] = {} + + def _build_reprompt_text(self, prompt_text: str, solution_text: str, feedback_text: str) -> str: + return self.trainer.args.reprompt_template.format( + prompt=prompt_text, + solution=solution_text, + feedback=feedback_text, + ) + + def _tokenize_teacher_messages( + self, teacher_messages_list: list[str | list[dict[str, Any]]] + ) -> TokenizedPromptBatch: + teacher_prompt_ids_list = [] + device = self.trainer.accelerator.device + chat_template_kwargs = getattr(self.trainer, "chat_template_kwargs", {}) + for msg in teacher_messages_list: + if isinstance(msg, list) and isinstance(msg[0], dict): + tokenized = self.trainer.processing_class.apply_chat_template( + msg, + tokenize=True, + add_generation_prompt=True, + return_tensors="pt", + **chat_template_kwargs, + ) + if isinstance(tokenized, torch.Tensor): + ids = tokenized.squeeze(0) + else: + ids = tokenized["input_ids"].squeeze(0) + else: + ids = self.trainer.processing_class.encode(msg, return_tensors="pt").squeeze(0) + + if ids.shape[0] > self.trainer.args.max_reprompt_len: + ids = ids[-self.trainer.args.max_reprompt_len :] + teacher_prompt_ids_list.append(ids) + + teacher_prompt_ids = [ids.to(device) for ids in teacher_prompt_ids_list] + teacher_prompt_mask = [torch.ones(len(ids), dtype=torch.long, device=device) for ids in teacher_prompt_ids] + return TokenizedPromptBatch( + prompt_ids=pad(teacher_prompt_ids, padding_value=self.trainer.pad_token_id, padding_side="left"), + prompt_mask=pad(teacher_prompt_mask, padding_value=0, padding_side="left"), + ) + + def build( + self, + output: dict[str, torch.Tensor | Any], + prompts: list[Any], + rewards: torch.Tensor, + feedbacks: list[Any] | None = None, + ) -> dict[str, torch.Tensor]: + device = self.trainer.accelerator.device + mode = "train" if self.trainer.model.training else "eval" + num_generations = self.trainer.num_generations if mode == "train" else self.trainer.num_generations_eval + completion_ids = output["completion_ids"] + completion_mask = output["completion_mask"] + + num_local = len(prompts) + process_start = self.trainer.accelerator.process_index * num_local + process_slice = slice(process_start, process_start + num_local) + + # Rewards arrive already locally sliced (per-process) from the rollout mixin; re-gather them so + # the mining loop can find successful rollouts across all processes within each generation group. + all_rewards = self.trainer.accelerator.gather(rewards) + # Completion tensors are padded to the local max length per rank; align shapes before gathering. + # Use separate variables so the original completion_ids/completion_mask stay unpadded for the + # teacher concat (they must match the student's sequence length for logits_to_keep alignment). + padded_completion_ids = self.trainer.accelerator.pad_across_processes( + completion_ids, dim=1, pad_index=self.trainer.pad_token_id + ) + all_completion_ids = self.trainer.accelerator.gather(padded_completion_ids) + all_prompts = gather_object(prompts) + total_samples = all_rewards.shape[0] + all_feedbacks = gather_object(feedbacks) if feedbacks is not None else [None] * total_samples + + threshold = self.trainer.args.success_reward_threshold + dont_reprompt_self = self.trainer.args.dont_reprompt_on_self_success + feedback_only_without_solution = self.trainer.args.environment_feedback_only_without_solution + self_distillation_mask = torch.zeros(total_samples, device=device) + num_with_solution = 0 + num_with_feedback_available = 0 + num_with_feedback_used = 0 + success_group_count = 0 + successful_demo_indices: list[int | None] = [None] * total_samples + use_feedback_flags: list[bool] = [False] * total_samples + has_solution_flags: list[bool] = [False] * total_samples + + for i in range(total_samples): + group_start = (i // num_generations) * num_generations + group_end = group_start + num_generations + + successful = [] + if self.trainer.args.use_successful_as_teacher: + for j in range(group_start, group_end): + if dont_reprompt_self and j == i: + continue + if all_rewards[j].item() >= threshold: + successful.append(j) + + if i % num_generations == 0: + # Count groups with any successful rollout, ignoring self-exclusion which only + # affects per-sample teacher assignment, not whether the group has successes. + group_has_success = any(all_rewards[j].item() >= threshold for j in range(group_start, group_end)) + if group_has_success: + success_group_count += 1 + + raw_feedback = all_feedbacks[i] + has_feedback = isinstance(raw_feedback, str) and raw_feedback.strip() != "" + if has_feedback: + num_with_feedback_available += 1 + + has_solution = len(successful) > 0 + has_solution_flags[i] = has_solution + if has_solution: + successful_demo_indices[i] = successful[0] + use_feedback = ( + self.trainer.args.include_environment_feedback + and has_feedback + and (not feedback_only_without_solution or not has_solution) + ) + use_feedback_flags[i] = use_feedback + if use_feedback: + num_with_feedback_used += 1 + if has_solution or use_feedback: + self_distillation_mask[i] = 1.0 + if has_solution: + num_with_solution += 1 + + local_teacher_messages = [] + local_self_distillation_mask = self_distillation_mask[process_slice] + for global_idx in range(process_start, process_start + num_local): + original_prompt = all_prompts[global_idx] + raw_feedback = all_feedbacks[global_idx] + has_solution = has_solution_flags[global_idx] + use_feedback = use_feedback_flags[global_idx] + + if not has_solution and not use_feedback: + local_teacher_messages.append(original_prompt) + continue + + solution_text = "" + if has_solution: + demo_idx = successful_demo_indices[global_idx] + if demo_idx is None: + raise RuntimeError("Expected a successful demonstration index for an active SDPO teacher prompt.") + demo_ids = all_completion_ids[demo_idx] + demo_ids = demo_ids[demo_ids != self.trainer.processing_class.pad_token_id] + demo_text = self.trainer.processing_class.decode(demo_ids, skip_special_tokens=True) + + if self.trainer.args.remove_thinking_from_demonstration: + demo_text = re.sub(r".*?", "", demo_text, flags=re.DOTALL).strip() + + solution_text = self.trainer.args.solution_template.format(successful_previous_attempt=demo_text) + + feedback_text = "" + if use_feedback: + feedback_text = self.trainer.args.feedback_template.format(feedback_raw=raw_feedback) + + if isinstance(original_prompt, list): + system_messages = original_prompt[:-1] + prompt_text = extract_last_user_text(original_prompt) + reprompt_text = self._build_reprompt_text(prompt_text, solution_text, feedback_text) + local_teacher_messages.append(system_messages + [{"role": "user", "content": reprompt_text}]) + else: + local_teacher_messages.append(self._build_reprompt_text(original_prompt, solution_text, feedback_text)) + + teacher_batch = self._tokenize_teacher_messages(local_teacher_messages) + teacher_input_ids = torch.cat([teacher_batch.prompt_ids, completion_ids], dim=1) + teacher_attention_mask = torch.cat([teacher_batch.prompt_mask, completion_mask], dim=1) + + batch_size = total_samples if total_samples > 0 else 1 + num_groups = max(1, total_samples // max(1, num_generations)) + self.last_metrics = { + "self_distillation/success_group_fraction": success_group_count / num_groups, + "self_distillation/success_sample_fraction": num_with_solution / batch_size, + "self_distillation/feedback_available_fraction": num_with_feedback_available / batch_size, + "self_distillation/feedback_used_fraction": num_with_feedback_used / batch_size, + "self_distillation/reprompt_sample_fraction": self_distillation_mask.float().mean().item(), + } + + return { + "teacher_input_ids": teacher_input_ids, + "teacher_attention_mask": teacher_attention_mask, + "self_distillation_mask": local_self_distillation_mask, + } + + +class SDPOTrainer(BaseSelfDistillationTrainer): + """ + Trainer for Self-Distillation Policy Optimization (SDPO). + + SDPO augments on-policy optimization with self-distillation from the model's own high-reward trajectories. It + converts tokenized feedback into a dense learning signal without any external teacher or explicit reward model. + SDPO treats the current model conditioned on feedback as a self-teacher and distills its feedback-informed + next-token predictions back into the policy. + """ + + config_cls = SDPOConfig + _tag_names = ["trl", "sdpo"] + _name = "SDPO" + # docstyle-ignore + _paper = { + "title": "Reinforcement Learning via Self-Distillation", + "id": "2601.20802", + "citation": textwrap.dedent("""\ + @article{hubotter2026sdpo, + title = {{Reinforcement Learning via Self-Distillation}}, + author = {Jonas H\\"ubotter and Frederike L\\"ubeck and Lejs Behric and Anton Baumann and Marco Bagatella and Daniel Marta and Ido Hakimi and Idan Shenfeld and Thomas Kleine Buening and Carlos Guestrin and Andreas Krause}, + year = 2026, + eprint = {arXiv:2601.20802} + }"""), + } + + def __init__( + self, + model: str | PreTrainedModel | nn.Module, + reward_funcs: Any | list[Any] | None = None, + args: SDPOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config=None, + ): + if reward_funcs is None or (isinstance(reward_funcs, list) and len(reward_funcs) == 0): + raise ValueError("`reward_funcs` is required for SDPOTrainer because SDPO must score rollouts.") + super().__init__( + model=model, + reward_funcs=reward_funcs, + args=args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=reward_processing_classes, + callbacks=callbacks, + optimizers=optimizers, + peft_config=peft_config, + ) + self.teacher_context_builder = SuccessfulRolloutTeacherContextBuilder(self) + if self.args.teacher_regularization == "ema": + # `self.model` may already be accelerator-wrapped after the shared base constructor. Build the EMA + # teacher from the unwrapped student model first, then prepare it as an auxiliary eval-only module. + student_model = self.accelerator.unwrap_model(self.model) + self.teacher_model = copy.deepcopy(student_model) + self.teacher_model.requires_grad_(False) + self.teacher_model.eval() + self.teacher_model = self._prepare_auxiliary_model_for_eval(self.teacher_model) + self.add_callback( + EMATeacherSyncCallback( + teacher_model=self.teacher_model, + update_rate=self.args.teacher_update_rate, + accelerator=self.accelerator, + ) + ) + + def _allow_topk_without_full_logit_distillation(self) -> bool: + return False + + def _generate_and_score_completions( + self, inputs: list[dict[str, torch.Tensor | Any]] + ) -> dict[str, torch.Tensor | Any]: + prompts, privileged_contexts = self._split_prompt_and_privileged_context(inputs) + + output = super()._generate_and_score_completions(inputs) + output.update( + self.teacher_context_builder.build(output, prompts, output["rewards"], feedbacks=privileged_contexts) + ) + + mode = "train" if self.model.training else "eval" + for key, value in self.teacher_context_builder.last_metrics.items(): + self._metrics[mode][key].append(value) + self._warn_on_inactive_self_distillation(mode) + + self._dispatch_self_distillation_callback( + "on_teacher_context_built", + teacher_input_ids=output["teacher_input_ids"], + teacher_attention_mask=output["teacher_attention_mask"], + completion_mask=output["completion_mask"], + self_distillation_mask=output["self_distillation_mask"], + ) + + return output + + def _warn_on_inactive_self_distillation(self, mode: str) -> None: + metrics = self.teacher_context_builder.last_metrics + tolerance = self.args.diagnostics_flat_tolerance + + reprompt_fraction = metrics.get("self_distillation/reprompt_sample_fraction", 0.0) + success_fraction = metrics.get("self_distillation/success_group_fraction", 0.0) + + if reprompt_fraction <= tolerance: + self._warn_on_degenerate_diagnostics( + mode=mode, + counter_key="inactive_self_distillation", + message=( + "SDPO self-distillation is inactive because no reprompted samples were constructed. " + "This usually means no rollout exceeded `success_reward_threshold` and no usable privileged " + "feedback was available." + ), + ) + else: + self._diagnostic_counters[mode]["inactive_self_distillation"] = 0 + + if success_fraction <= tolerance: + self._warn_on_degenerate_diagnostics( + mode=mode, + counter_key="no_successful_rollouts", + message=( + "SDPO did not find any successful rollouts in the current generation groups. " + "If this persists, reduce task difficulty, adjust reward shaping, or lower " + "`success_reward_threshold`." + ), + ) + else: + self._diagnostic_counters[mode]["no_successful_rollouts"] = 0 + + def _compute_loss( + self, + model, + inputs, + ) -> torch.Tensor: + accumulation_scale = self.current_gradient_accumulation_steps if self.model.training else 1.0 + + if self.args.sdpo_policy_loss_mode == "hybrid": + base_policy_loss = super()._compute_loss(model, inputs) + if self.args.distillation_weight <= 0.0: + return base_policy_loss + + sdpo_loss = self._compute_self_distillation_loss(model, inputs) / accumulation_scale + return base_policy_loss + self.args.distillation_weight * sdpo_loss + + if self.args.distillation_weight <= 0.0: + return super()._compute_loss(model, inputs) + + sdpo_loss = self._compute_self_distillation_loss(model, inputs) / accumulation_scale + return self.args.distillation_weight * sdpo_loss diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1449db2f7a37e2ed76e3fad00d808689163dd5db --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .self_distillation_config import SelfDistillationConfig +from .self_distillation_mixin import SelfDistillationMixin + + +__all__ = ["SelfDistillationConfig", "SelfDistillationMixin"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/base_self_distillation_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/base_self_distillation_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..bd9abb9516425dedb78efbfe8678e11665dae837 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/base_self_distillation_trainer.py @@ -0,0 +1,355 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Shared online self-distillation trainer scaffold. + +This base combines the generic Trainer setup for self-distillation with the online rollout utilities used by SDPO-like +methods. Offline methods such as SDFT stay on `_BaseTrainer` directly and only reuse the shared distillation mixin. +""" + +from __future__ import annotations + +import inspect +from collections import defaultdict +from functools import partial +from typing import Any + +import datasets +import torch +from accelerate.logging import get_logger +from datasets import Dataset, IterableDataset +from torch import nn +from torch.utils.data import DataLoader, Sampler +from transformers import ( + AutoModelForSequenceClassification, + AutoProcessor, + AutoTokenizer, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import seed_worker +from transformers.utils import is_datasets_available, is_peft_available + +from ...models import prepare_deepspeed, prepare_fsdp +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + get_config_model_id, + identity, + split_tensor_dict, +) +from ..utils import prepare_peft_model +from .online_rollout_mixin import OnlineRolloutMixin +from .self_distillation_config import SelfDistillationConfig +from .self_distillation_mixin import SelfDistillationMixin + + +if is_peft_available(): + from peft import PeftConfig + + +logger = get_logger(__name__) + + +class BaseSelfDistillationTrainer(OnlineRolloutMixin, SelfDistillationMixin, _BaseTrainer): + """Shared scaffold for experimental self-distillation trainers without GRPO inheritance.""" + + def __init__( + self, + model: str | PreTrainedModel | nn.Module, + reward_funcs: Any | list[Any] | None = None, + args: SelfDistillationConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: PeftConfig | None = None, + ): + if train_dataset is None: + raise ValueError("`train_dataset` is required") + self.use_vllm = args.use_vllm + + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + elif args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the self-distillation config, but `model` is already " + "instantiated. The `model_init_kwargs` will be ignored." + ) + + self.model_kwarg_keys = ( + inspect.signature(model.forward).parameters.keys() + if not hasattr(model, "get_base_model") + else inspect.signature(model.get_base_model().forward).parameters.keys() + ) + + if peft_config is not None or (is_peft_available() and getattr(model, "peft_config", None) is not None): + model = prepare_peft_model(model, peft_config, args) + + if processing_class is None: + processing_class = AutoProcessor.from_pretrained( + get_config_model_id(model.config), truncation_side="left", padding_side="left" + ) + + if isinstance(processing_class, ProcessorMixin): + tokenizer = processing_class.tokenizer + elif isinstance(processing_class, PreTrainedTokenizerBase): + tokenizer = processing_class + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + self.pad_token_id = tokenizer.pad_token_id + self.eos_token_id = tokenizer.eos_token_id + self.temperature = args.temperature + self.max_prompt_length = args.max_prompt_length + self.max_completion_length = args.max_completion_length + self.num_generations = args.num_generations + self.num_generations_eval = args.num_generations_eval or args.num_generations + self.num_iterations = args.num_iterations + self.shuffle_dataset = args.shuffle_dataset + self.loss_type = args.loss_type + self.importance_sampling_level = args.importance_sampling_level + self.scale_rewards = args.scale_rewards + self.epsilon_low = args.epsilon + self.epsilon_high = args.epsilon_high + self.beta = args.beta + self.mask_truncated_completions = args.mask_truncated_completions + self.chat_template_kwargs = args.chat_template_kwargs or {} + self._step = 0 + self._last_loaded_step = 0 + self._buffered_inputs = None + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._diagnostic_counters = { + "train": defaultdict(int), + "eval": defaultdict(int), + } + + generation_kwargs = { + "max_new_tokens": self.max_completion_length, + "do_sample": True, + "pad_token_id": tokenizer.pad_token_id, + "bos_token_id": tokenizer.bos_token_id, + "eos_token_id": tokenizer.eos_token_id, + "temperature": args.temperature, + "top_p": args.top_p, + "top_k": args.top_k, + "min_p": args.min_p, + "repetition_penalty": args.repetition_penalty, + "cache_implementation": args.cache_implementation, + } + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + self.generation_config = GenerationConfig(**generation_kwargs, disable_compile=True) + + if hasattr(model, "warnings_issued"): + model.warnings_issued["estimate_tokens"] = True + + super().__init__( + model=model, + args=args, + data_collator=identity, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + callbacks=callbacks, + optimizers=optimizers, + compute_loss_func="non-None value to disable scaling", + ) + + if self.use_vllm: + from ...generation.vllm_generation import VLLMGeneration + + self.vllm_generation = VLLMGeneration( + model=self.model, + accelerator=self.accelerator, + is_fsdp_enabled=self.is_fsdp_enabled, + processing_class=self.processing_class, + mode=args.vllm_mode, + server_base_url=args.vllm_server_base_url, + server_host=args.vllm_server_host, + server_port=args.vllm_server_port, + group_port=args.vllm_group_port, + server_timeout=args.vllm_server_timeout, + tensor_parallel_size=args.vllm_tensor_parallel_size, + gpu_memory_utilization=args.vllm_gpu_memory_utilization, + max_model_length=args.vllm_max_model_length, + max_num_seqs=args.per_device_train_batch_size + * args.vllm_tensor_parallel_size + * args.steps_per_generation, + enable_sleep_mode=args.vllm_enable_sleep_mode, + model_impl=args.vllm_model_impl, + repetition_penalty=args.repetition_penalty, + temperature=self.temperature, + top_p=args.top_p, + top_k=args.top_k, + min_p=args.min_p, + max_completion_length=self.max_completion_length, + logprobs=None, + generation_kwargs=args.generation_kwargs, + ) + self._last_loaded_step = -1 # tag to avoid useless loading during grad accumulation + + if reward_funcs is None: + reward_funcs = [] + if not isinstance(reward_funcs, list): + reward_funcs = [reward_funcs] + self.reward_func_names = [] + for i, reward_func in enumerate(reward_funcs): + if isinstance(reward_func, str): + reward_model_init_kwargs = args.model_init_kwargs or {} + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + reward_model_init_kwargs["device_map"] = None + reward_funcs[i] = AutoModelForSequenceClassification.from_pretrained( + reward_func, + num_labels=1, + **reward_model_init_kwargs, + ) + if isinstance(reward_funcs[i], nn.Module): + self.reward_func_names.append(get_config_model_id(reward_funcs[i].config).split("/")[-1]) + else: + self.reward_func_names.append(reward_funcs[i].__name__) + self.reward_funcs = reward_funcs + + if args.reward_weights is not None: + if len(args.reward_weights) != len(self.reward_funcs): + raise ValueError("Number of reward weights must match number of reward functions") + self.reward_weights = torch.tensor(args.reward_weights, dtype=torch.float32) + else: + self.reward_weights = torch.ones(len(self.reward_funcs), dtype=torch.float32) + + if reward_processing_classes is None: + reward_processing_classes = [None] * len(self.reward_funcs) + elif not isinstance(reward_processing_classes, list): + reward_processing_classes = [reward_processing_classes] + if len(reward_processing_classes) != len(self.reward_funcs): + raise ValueError("Number of reward processing classes must match number of reward functions") + + for i, (reward_processing_class, reward_func) in enumerate( + zip(reward_processing_classes, self.reward_funcs, strict=True) + ): + if isinstance(reward_func, PreTrainedModel): + if reward_processing_class is None: + reward_processing_class = AutoTokenizer.from_pretrained(get_config_model_id(reward_func.config)) + if reward_processing_class.pad_token_id is None: + reward_processing_class.pad_token = reward_processing_class.eos_token + reward_func.config.pad_token_id = reward_processing_class.pad_token_id + reward_processing_classes[i] = reward_processing_class + self.reward_processing_classes = reward_processing_classes + + if args.disable_dropout: + disable_dropout_in_model(self.model) + + for i, reward_func in enumerate(self.reward_funcs): + if isinstance(reward_func, nn.Module): + if self.is_deepspeed_enabled: + self.reward_funcs[i] = prepare_deepspeed(reward_func, self.accelerator) + elif self.is_fsdp_enabled: + self.reward_funcs[i] = prepare_fsdp(reward_func, self.accelerator) + else: + self.reward_funcs[i] = self.accelerator.prepare_model(reward_func, evaluation_mode=True) + + self.model.add_model_tags(self._tag_names) + self.model_accepts_loss_kwargs = False + self.ref_model = None + self.teacher_model = None + if args.sync_ref_model: + raise ValueError( + "sync_ref_model is not supported on the shared online self-distillation base without `ref_model`." + ) + + def get_train_dataloader(self): + if self.train_dataset is None: + raise ValueError("Trainer: training requires a train_dataset.") + + train_dataset = self.train_dataset + data_collator = self.data_collator + if is_datasets_available() and isinstance(train_dataset, datasets.Dataset): + train_dataset = self._remove_unused_columns(train_dataset, description="training") + else: + data_collator = self._get_collator_with_removed_columns(data_collator, description="training") + + dataloader_params = { + "batch_size": self._train_batch_size * self.args.steps_per_generation, + "collate_fn": data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "persistent_workers": self.args.dataloader_persistent_workers, + } + if not isinstance(train_dataset, torch.utils.data.IterableDataset): + dataloader_params["sampler"] = self._get_train_sampler() + dataloader_params["drop_last"] = self.args.dataloader_drop_last + dataloader_params["worker_init_fn"] = partial( + seed_worker, num_workers=self.args.dataloader_num_workers, rank=self.args.process_index + ) + dataloader_params["prefetch_factor"] = self.args.dataloader_prefetch_factor + return self.accelerator.prepare(DataLoader(train_dataset, **dataloader_params)) + + def _get_train_sampler(self, dataset=None) -> Sampler: + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size // self.num_generations, + repeat_count=self.num_iterations * self.args.steps_per_generation, + shuffle=self.shuffle_dataset, + seed=self.args.seed, + ) + + def _get_eval_sampler(self, eval_dataset) -> Sampler: + return RepeatSampler( + data_source=eval_dataset, + mini_repeat_count=getattr(self, "num_generations_eval", self.num_generations), + seed=self.args.seed, + ) + + def training_step(self, model, inputs, num_items_in_batch): + output = super().training_step(model, inputs, num_items_in_batch) + self._step += 1 + return output + + def _prepare_inputs(self, generation_batch): + mode = "train" if self.model.training else "eval" + if mode == "train": + generate_every = self.args.steps_per_generation * self.num_iterations + if self._step % generate_every == 0 or self._buffered_inputs is None: + generation_batch = self._build_buffered_batch(generation_batch) + self._buffered_inputs = split_tensor_dict(generation_batch, self.args.steps_per_generation) + self._dispatch_self_distillation_callback( + "on_generation_batch_built", + generate_every=generate_every, + steps_per_generation=self.args.steps_per_generation, + ) + return self._buffered_inputs[self._step % self.args.steps_per_generation] + return self._build_buffered_batch(generation_batch) + + def _prepare_auxiliary_model_for_eval(self, aux_model: nn.Module): + if self.is_deepspeed_enabled: + return prepare_deepspeed(aux_model, self.accelerator) + if self.is_fsdp_enabled: + return prepare_fsdp(aux_model, self.accelerator) + return self.accelerator.prepare_model(aux_model, evaluation_mode=True) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/online_rollout_mixin.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/online_rollout_mixin.py new file mode 100644 index 0000000000000000000000000000000000000000..490724582dca23fdcfeccaa74ac3c9610b4b7156 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/online_rollout_mixin.py @@ -0,0 +1,385 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Online rollout helpers for experimental self-distillation trainers. + +This mixin owns generation, reward scoring, grouped reward normalization, and online policy-loss plumbing. It is paired +with `BaseSelfDistillationTrainer` for SDPO-style methods and intentionally kept separate from the generic distillation +loss logic in `self_distillation_mixin.py`. +""" + +from __future__ import annotations + +import torch +from torch import nn +from transformers.utils import logging + +from ...data_utils import apply_chat_template, is_conversational, maybe_apply_chat_template +from ...models import unwrap_model_for_generation +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import pad + + +logger = logging.get_logger(__name__) + + +class OnlineRolloutMixin: + """Online rollout, reward, and policy-loss utilities shared by SDPO-like trainers.""" + + def _apply_prompt_template(self, prompts): + return [ + maybe_apply_chat_template({"prompt": prompt}, self.processing_class, **self.chat_template_kwargs)["prompt"] + for prompt in prompts + ] + + def _build_buffered_batch(self, generation_batch): + return self._generate_and_score_completions(generation_batch) + + def _generate(self, prompts): + if self.use_vllm: + return self._generate_vllm(prompts) + return self._generate_transformers(prompts) + + def _generate_vllm(self, prompts): + # Sync weights if training step changed + if self.state.global_step != self._last_loaded_step: + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + # Tokenize prompts to token IDs + prompts_text = self._apply_prompt_template(prompts) + tokenized = self.processing_class( + text=prompts_text, + return_tensors=None, + padding=False, + max_length=self.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + prompt_ids = tokenized["input_ids"] # list of list[int] + + # Generate via vLLM — it deduplicates repeated prompts from RepeatSampler internally + mode = "train" if self.model.training else "eval" + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + prompt_ids_out, completion_ids_list, _, _ = self.vllm_generation.generate( + prompts=prompt_ids, + images=None, + num_generations=num_generations, + ) + return prompt_ids_out, completion_ids_list + + def _generate_transformers(self, prompts): + # Keep the generation path aligned with the reference trainers: generate from left-padded prompts, + # then recover completion token spans by trimming prompt tokens and stopping at the first EOS. + prompts_text = self._apply_prompt_template(prompts) + generate_inputs = self.processing_class( + text=prompts_text, + return_tensors="pt", + padding=True, + padding_side="left", + max_length=self.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + # This path already receives tokenized model inputs. Bypass the buffered trainer hook and use the plain + # tensor/device preparation from `_BaseTrainer`. + generate_inputs = _BaseTrainer._prepare_inputs(self, generate_inputs) + with ( + unwrap_model_for_generation( + self.model_wrapped, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + ) as unwrapped_model, + torch.no_grad(), + ): + prompt_completion_ids = unwrapped_model.generate( + **generate_inputs, generation_config=self.generation_config + ) + prompt_ids = generate_inputs["input_ids"] + prompt_mask = generate_inputs["attention_mask"] + prompt_length = prompt_ids.size(1) + completion_ids = prompt_completion_ids[:, prompt_length:] + is_eos = completion_ids == self.eos_token_id + eos_idx = torch.full((is_eos.size(0),), is_eos.size(1), dtype=torch.long, device=completion_ids.device) + eos_idx[is_eos.any(dim=1)] = is_eos.int().argmax(dim=1)[is_eos.any(dim=1)] + seq_idx = torch.arange(is_eos.size(1), device=completion_ids.device).expand(is_eos.size(0), -1) + completion_mask = (seq_idx <= eos_idx.unsqueeze(1)).int() + prompt_ids_list = [p[m].tolist() for p, m in zip(prompt_ids, prompt_mask.bool(), strict=False)] + completion_ids_list = [c[m].tolist() for c, m in zip(completion_ids, completion_mask.bool(), strict=False)] + return prompt_ids_list, completion_ids_list + + def _calculate_rewards(self, inputs, prompts, completions, completion_ids_list): + device = self.accelerator.device + if len(self.reward_funcs) == 0: + return torch.zeros((len(prompts), 0), device=device) + + rewards_per_func = torch.zeros(len(prompts), len(self.reward_funcs), device=device) + keys = [key for key in inputs[0] if key not in ["prompt", "completion", "completion_ids"]] + reward_kwargs = {key: [example[key] for example in inputs] for key in keys} + reward_kwargs["trainer_state"] = self.state + + for i, (reward_func, reward_processing_class) in enumerate( + zip(self.reward_funcs, self.reward_processing_classes, strict=True) + ): + if isinstance(reward_func, nn.Module): + if is_conversational(inputs[0]): + messages = [{"messages": p + c} for p, c in zip(prompts, completions, strict=True)] + texts = [ + apply_chat_template(x, reward_processing_class, **self.chat_template_kwargs)["text"] + for x in messages + ] + else: + texts = [p + c for p, c in zip(prompts, completions, strict=True)] + reward_inputs = reward_processing_class( + text=texts, + return_tensors="pt", + padding=True, + padding_side="right", + add_special_tokens=False, + ) + # Reward functions operate on tokenized tensors too, so they need the base Trainer input preparation + # rather than the outer buffered generation hook. + reward_inputs = _BaseTrainer._prepare_inputs(self, reward_inputs) + with torch.inference_mode(): + rewards_per_func[:, i] = reward_func(**reward_inputs).logits[:, 0] + else: + output_reward_func = reward_func( + prompts=prompts, + completions=completions, + completion_ids=completion_ids_list, + **reward_kwargs, + ) + output_reward_func = [reward if reward is not None else torch.nan for reward in output_reward_func] + rewards_per_func[:, i] = torch.tensor(output_reward_func, dtype=torch.float32, device=device) + + return self.accelerator.gather(rewards_per_func) + + def _generate_and_score_completions(self, inputs): + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + prompts = [x["prompt"] for x in inputs] + prompt_ids_list, completion_ids_list = self._generate(prompts) + + prompt_ids = [torch.tensor(ids) for ids in prompt_ids_list] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + prompt_ids = pad(prompt_ids, padding_value=self.pad_token_id, padding_side="left").to(device=device) + prompt_mask = pad(prompt_mask, padding_value=0, padding_side="left").to(device=device) + completion_ids = [torch.tensor(ids) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + completion_ids = pad(completion_ids, padding_value=self.pad_token_id, padding_side="right").to(device=device) + completion_mask = pad(completion_mask, padding_value=0, padding_side="right").to(device=device) + + if self.mask_truncated_completions: + eos_and_pad = [self.eos_token_id, self.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + completion_mask = completion_mask * (~is_truncated).unsqueeze(1).int() + + prompt_completion_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) + + with torch.no_grad(): + generate_every = self.args.steps_per_generation * self.num_iterations + if self.args.gradient_accumulation_steps % generate_every != 0: + old_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + compute_entropy=False, + ) + else: + old_per_token_logps = None + + if is_conversational({"prompt": prompts[0]}): + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + completions = [[{"role": "assistant", "content": content}] for content in completions_text] + else: + completions = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + rewards_per_func = self._calculate_rewards(inputs, prompts, completions, completion_ids_list) + if rewards_per_func.numel() == 0: + rewards = torch.zeros(self.accelerator.num_processes * len(prompts), device=device) + else: + rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + mean_grouped_rewards = rewards.view(-1, num_generations).mean(dim=1).repeat_interleave(num_generations, dim=0) + if self.scale_rewards == "batch": + std_rewards = rewards.std().expand_as(rewards) if rewards.numel() > 1 else torch.zeros_like(rewards) + group_std_rewards = rewards.view(-1, num_generations).std(dim=1) + elif self.scale_rewards == "none": + std_rewards = torch.ones_like(rewards) + group_std_rewards = torch.ones(rewards.numel() // num_generations, device=device, dtype=rewards.dtype) + else: + group_std_rewards = rewards.view(-1, num_generations).std(dim=1) + std_rewards = group_std_rewards.repeat_interleave(num_generations, dim=0) + advantages = (rewards - mean_grouped_rewards) / (std_rewards + 1e-4) + self._record_reward_diagnostics(mode, rewards, rewards_per_func, group_std_rewards) + + local_batch_size = completion_ids.size(0) + process_start = self.accelerator.process_index * local_batch_size + process_slice = slice(process_start, process_start + local_batch_size) + rewards = rewards[process_slice] + advantages = advantages[process_slice] + + agg_completion_lengths = self.accelerator.gather( + torch.tensor([len(ids) for ids in completion_ids_list], device=device) + ) + self._metrics[mode]["completions/mean_length"].append(agg_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_length"].append(agg_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_length"].append(agg_completion_lengths.float().max().item()) + + eos_and_pad = [self.eos_token_id, self.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + agg_is_truncated = self.accelerator.gather(is_truncated) + self._metrics[mode]["completions/clipped_ratio"].append(agg_is_truncated.float().mean().item()) + term_completion_lengths = agg_completion_lengths[~agg_is_truncated] + if len(term_completion_lengths) == 0: + term_completion_lengths = torch.zeros(1, device=device) + self._metrics[mode]["completions/mean_terminated_length"].append(term_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_terminated_length"].append(term_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_terminated_length"].append(term_completion_lengths.float().max().item()) + + output = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "rewards": rewards, + "advantages": advantages, + "num_items_in_batch": completion_mask.sum().detach(), + } + if old_per_token_logps is not None: + output["old_per_token_logps"] = old_per_token_logps + + self._dispatch_self_distillation_callback( + "on_self_distillation_batch_prepared", + old_per_token_logps=old_per_token_logps, + prompt_ids=prompt_ids, + completion_ids=completion_ids, + ) + return output + + def _record_reward_diagnostics( + self, + mode: str, + rewards: torch.Tensor, + rewards_per_func: torch.Tensor, + group_std_rewards: torch.Tensor, + ) -> None: + tolerance = self.args.diagnostics_flat_tolerance + + reward_mean = rewards.mean() if rewards.numel() > 0 else torch.tensor(0.0, device=self.accelerator.device) + reward_std = rewards.std() if rewards.numel() > 1 else torch.tensor(0.0, device=self.accelerator.device) + reward_min = rewards.min() if rewards.numel() > 0 else torch.tensor(0.0, device=self.accelerator.device) + reward_max = rewards.max() if rewards.numel() > 0 else torch.tensor(0.0, device=self.accelerator.device) + flat_group_fraction = ( + (group_std_rewards <= tolerance).float().mean() + if group_std_rewards.numel() > 0 + else torch.tensor(1.0, device=self.accelerator.device) + ) + + self._metrics[mode]["self_distillation/reward_mean"].append(self.accelerator.gather(reward_mean).mean().item()) + self._metrics[mode]["self_distillation/reward_std"].append(self.accelerator.gather(reward_std).mean().item()) + self._metrics[mode]["self_distillation/reward_min"].append(self.accelerator.gather(reward_min).min().item()) + self._metrics[mode]["self_distillation/reward_max"].append(self.accelerator.gather(reward_max).max().item()) + self._metrics[mode]["self_distillation/group_reward_std_mean"].append( + self.accelerator.gather(group_std_rewards.mean() if group_std_rewards.numel() > 0 else reward_std) + .mean() + .item() + ) + self._metrics[mode]["self_distillation/flat_group_fraction"].append( + self.accelerator.gather(flat_group_fraction).mean().item() + ) + + if rewards_per_func.numel() > 0: + reward_func_means = rewards_per_func.nanmean(dim=0) + gathered_means = self.accelerator.gather(reward_func_means).view(-1, reward_func_means.numel()).mean(dim=0) + for reward_name, reward_func_mean in zip(self.reward_func_names, gathered_means.tolist(), strict=True): + self._metrics[mode][f"self_distillation/rewards/{reward_name}"].append(reward_func_mean) + + reward_is_flat = reward_std.item() <= tolerance + grouped_rewards_are_flat = flat_group_fraction.item() >= 1.0 - tolerance + if reward_is_flat and grouped_rewards_are_flat: + self._warn_on_degenerate_diagnostics( + mode=mode, + counter_key="flat_rewards", + message=( + "Observed flat SDPO rewards across all sampled generations. " + "Policy advantages will collapse to zero, and SDPO will not learn. " + "Check reward density, reward shaping, or `success_reward_threshold`." + ), + ) + else: + self._diagnostic_counters[mode]["flat_rewards"] = 0 + + def _warn_on_degenerate_diagnostics(self, mode: str, counter_key: str, message: str) -> None: + interval = self.args.diagnostics_warning_interval + if interval == 0: + return + + self._diagnostic_counters[mode][counter_key] += 1 + count = self._diagnostic_counters[mode][counter_key] + if count == 1 or count % interval == 0: + logger.warning("%s Consecutive degenerate steps: %s.", message, count) + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if return_outputs: + raise ValueError(f"The {self.__class__.__name__} does not support returning outputs") + return self._compute_loss(model, inputs) + + def prediction_step(self, model, inputs, prediction_loss_only, ignore_keys=None): + if not isinstance(inputs, dict): + inputs = self._prepare_inputs(inputs) + with torch.no_grad(): + with self.compute_loss_context_manager(): + loss = self.compute_loss(model, inputs) + return loss.detach(), None, None + + def _compute_loss(self, model, inputs): + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) + per_token_logps, _ = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=False, + ) + old_per_token_logps = inputs.get("old_per_token_logps") + old_per_token_logps = per_token_logps.detach() if old_per_token_logps is None else old_per_token_logps + advantages = inputs["advantages"] + if advantages.dim() == 1: + advantages = advantages.unsqueeze(1) + log_ratio = per_token_logps - old_per_token_logps + if self.importance_sampling_level == "sequence": + log_ratio = (log_ratio * completion_mask).sum(-1, keepdim=True) / completion_mask.sum( + -1, keepdim=True + ).clamp(min=1.0) + coef_1 = torch.exp(log_ratio) + coef_2 = torch.clamp(coef_1, 1 - self.epsilon_low, 1 + self.epsilon_high) + per_token_loss = -torch.min(coef_1 * advantages, coef_2 * advantages) + + loss = self._aggregate_self_distillation_loss(per_token_loss, completion_mask) + + mode = "train" if self.model.training else "eval" + self._metrics[mode]["self_distillation/policy_loss"].append( + self.accelerator.gather(loss.detach()).mean().item() + ) + + accumulation_scale = self.current_gradient_accumulation_steps if mode == "train" else 1.0 + return loss / accumulation_scale diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/peft_adapter_ema_callback.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/peft_adapter_ema_callback.py new file mode 100644 index 0000000000000000000000000000000000000000..e252bb512a4b9a50064f62321d96644b2ba771b9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/peft_adapter_ema_callback.py @@ -0,0 +1,145 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +import torch +from transformers import ( + TrainerCallback, + TrainerControl, + TrainerState, + TrainingArguments, +) + + +logger = logging.getLogger(__name__) + + +class PEFTAdapterEMACallback(TrainerCallback): + """ + Callback that maintains an EMA copy of PEFT adapter weights for use as a teacher model in self-distillation. + + The callback creates a secondary adapter ("teacher") with zero-initialized weights and maintains shadow weights + that are updated via exponential moving average: `teacher_weight = (1-α) * teacher_weight + α * student_weight` + + Usage: + ```python + trainer.add_callback( + PEFTAdapterEMACallback( + model=model, + teacher_adapter_name="teacher", + update_rate=0.05, + ) + ) + ``` + """ + + def __init__( + self, + model, + teacher_adapter_name: str = "teacher", + update_rate: float = 0.05, + sync_steps: int = 1, + accelerator=None, + ): + self.model = model + self.teacher_adapter_name = teacher_adapter_name + self.update_rate = update_rate + self.sync_steps = sync_steps + self.accelerator = accelerator + self.shadow_weights: dict[str, torch.Tensor] | None = None + self.teacher_adapter_config = None + self._initialized = False + + def _get_student_state_dict(self): + """Get student adapter state dict using PEFT keys (without adapter name).""" + from peft import get_peft_model_state_dict + + if self.accelerator is not None: + model = self.accelerator.unwrap_model(self.model) + else: + model = self.model + return get_peft_model_state_dict(model) + + def _initialize_teacher_adapter(self): + """Create teacher adapter with zero weights initialized from student adapter.""" + from peft import get_peft_model_state_dict, set_peft_model_state_dict + + if self._initialized: + return + + if self.accelerator is not None: + model = self.accelerator.unwrap_model(self.model) + else: + model = self.model + + adapter_name = model.active_adapter + if adapter_name is None: + adapter_name = "default" + + self.teacher_adapter_config = model.peft_config.get(adapter_name) + + student_state = get_peft_model_state_dict(model) + + teacher_state = {k: torch.zeros_like(v) for k, v in student_state.items()} + + model.add_adapter(self.teacher_adapter_name, self.teacher_adapter_config) + + model.set_adapter(self.teacher_adapter_name) + set_peft_model_state_dict(model, teacher_state, adapter_name=self.teacher_adapter_name) + + model.set_adapter(adapter_name) + + self.shadow_weights = {k: v.clone().zero_() for k, v in teacher_state.items()} + + self._initialized = True + logger.info(f"Initialized PEFT adapter EMA teacher with adapter name: {self.teacher_adapter_name}") + + @torch.no_grad() + def on_step_end(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs): + if state.global_step % self.sync_steps != 0: + return + + if not self._initialized: + self._initialize_teacher_adapter() + + if self.shadow_weights is None: + return + + if self.accelerator is None and "accelerator" in kwargs: + self.accelerator = kwargs["accelerator"] + + student_state = self._get_student_state_dict() + + for key, student_param in student_state.items(): + if key in self.shadow_weights: + shadow = self.shadow_weights[key] + shadow.data = (1 - self.update_rate) * shadow.data + self.update_rate * student_param.data + + from peft import set_peft_model_state_dict + + if self.accelerator is not None: + unwrapped_model = self.accelerator.unwrap_model(self.model) + else: + unwrapped_model = self.model + + original_adapter = unwrapped_model.active_adapter + unwrapped_model.set_adapter(self.teacher_adapter_name) + set_peft_model_state_dict(unwrapped_model, self.shadow_weights, adapter_name=self.teacher_adapter_name) + unwrapped_model.set_adapter(original_adapter) + + def on_train_begin(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs): + if self.accelerator is None and "accelerator" in kwargs: + self.accelerator = kwargs["accelerator"] + self._initialize_teacher_adapter() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/self_distillation_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/self_distillation_config.py new file mode 100644 index 0000000000000000000000000000000000000000..c28c0f6be0b138c70105a30ad9e1e69cbde1f353 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/self_distillation_config.py @@ -0,0 +1,350 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from transformers import TrainingArguments + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class SelfDistillationConfig(_BaseConfig): + r""" + Shared configuration for experimental self-distillation trainers. + + This class contains only the arguments that are specific to the shared self-distillation stack. For the full set of + generic training arguments, refer to [`~transformers.TrainingArguments`] via + [`trl.trainer.base_config._BaseConfig`]. + + Parameters: + > Parameters that control generation and rollout reuse + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments used when the `model` argument is passed as a string. + max_prompt_length (`int` or `None`, *optional*, defaults to `512`): + Maximum prompt length. Longer prompts are truncated from the left. + num_generations (`int`, *optional*, defaults to `8`): + Number of sampled generations per prompt. + generation_batch_size (`int` or `None`, *optional*): + Global batch size used for generation. Mutually exclusive with `steps_per_generation`. + steps_per_generation (`int` or `None`, *optional*): + Number of optimizer steps that reuse one generated batch. Mutually exclusive with `generation_batch_size`. + + > Parameters that control the online policy objective + + beta (`float`, *optional*, defaults to `0.0`): + Reference-model KL coefficient for online policy optimization. + loss_type (`str`, *optional*, defaults to `"dapo"`): + Policy-loss aggregation mode. Supported: `grpo`, `bnpo`, `dr_grpo`, `dapo`. + scale_rewards (`str` or `bool`, *optional*, defaults to `"group"`): + Reward normalization mode. Supported: `group`, `batch`, `none`. + + > Parameters that control self-distillation + + distillation_alpha (`float`, *optional*, defaults to `0.5`): + Divergence interpolation coefficient using the official SDPO/SDFT convention: `0.0=forward KL`, `0.5=JSD`, + `1.0=reverse KL`. + distillation_topk (`int` or `None`, *optional*, defaults to `100`): + Number of top tokens to keep for top-k distillation. If `None`, all logits are used. + full_logit_distillation (`bool`, *optional*, defaults to `False`): + Whether to use full-logit distillation instead of token-level distillation. + distillation_is_clip (`float` or `None`, *optional*, defaults to `2.0`): + Importance-sampling clip used by the official SDPO-style correction. `None` disables clipping. + distillation_weight (`float`, *optional*, defaults to `1.0`): + Weight applied to the self-distillation loss term. + + > Parameters that control diagnostics + + diagnostics_warning_interval (`int`, *optional*, defaults to `10`): + Emit repeated trainer diagnostics every N consecutive degenerate steps. Set to `0` to disable. + diagnostics_flat_tolerance (`float`, *optional*, defaults to `1e-8`): + Tolerance used to decide whether reward variance or reprompt activity is effectively zero. + """ + + _VALID_DICT_FIELDS = TrainingArguments._VALID_DICT_FIELDS + ["model_init_kwargs"] + + model_init_kwargs: dict[str, Any] | None = field( + default=None, + metadata={"help": "Keyword arguments for model initialization when `model` is passed as a string."}, + ) + disable_dropout: bool = field( + default=False, + metadata={"help": "Whether to disable dropout in the student model."}, + ) + remove_unused_columns: bool = field( + default=False, + metadata={"help": "Whether to drop dataset columns unused by the trainer."}, + ) + max_prompt_length: int | None = field( + default=512, + metadata={"help": "Maximum prompt length. Longer prompts are truncated from the left."}, + ) + num_generations: int = field( + default=8, + metadata={"help": "Number of sampled generations per prompt."}, + ) + num_generations_eval: int | None = field( + default=None, + metadata={"help": "Number of sampled generations per prompt during evaluation."}, + ) + max_completion_length: int | None = field( + default=256, + metadata={"help": "Maximum generated completion length."}, + ) + ds3_gather_for_generation: bool = field( + default=True, + metadata={"help": "Whether to gather ZeRO-3 weights for generation."}, + ) + shuffle_dataset: bool = field( + default=True, + metadata={"help": "Whether to shuffle the training dataset."}, + ) + generation_batch_size: int | None = field( + default=None, + metadata={"help": "Global batch size used for generation. Mutually exclusive with `steps_per_generation`."}, + ) + steps_per_generation: int | None = field( + default=None, + metadata={"help": "Number of optimizer steps that reuse one generated batch."}, + ) + temperature: float = field( + default=1.0, + metadata={"help": "Sampling temperature."}, + ) + top_p: float = field( + default=1.0, + metadata={"help": "Top-p sampling parameter."}, + ) + top_k: int = field( + default=0, + metadata={"help": "Top-k sampling parameter. `0` disables top-k filtering."}, + ) + min_p: float | None = field( + default=None, + metadata={"help": "Minimum token probability for sampling."}, + ) + generation_kwargs: dict[str, Any] | None = field( + default=None, + metadata={"help": "Extra generation kwargs passed to `GenerationConfig`."}, + ) + chat_template_kwargs: dict[str, Any] | None = field( + default=None, + metadata={"help": "Extra kwargs forwarded to chat template application."}, + ) + repetition_penalty: float = field( + default=1.0, + metadata={"help": "Repetition penalty used during generation."}, + ) + cache_implementation: str | None = field( + default=None, + metadata={"help": "Cache implementation used by transformers generation."}, + ) + use_vllm: bool = field( + default=False, + metadata={"help": "Whether to use vLLM for generation."}, + ) + vllm_mode: str = field( + default="colocate", + metadata={"help": "vLLM mode: 'colocate' (shared GPU) or 'server' (separate vLLM server)."}, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={"help": "Model implementation for vLLM: 'vllm' or 'transformers'."}, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={"help": "Whether to enable sleep mode for colocated vLLM engine."}, + ) + vllm_server_base_url: str | None = field( + default=None, + metadata={ + "help": "Base URL for the vLLM server. If provided, vllm_server_host and vllm_server_port are ignored." + }, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": "Host of the vLLM server (server mode only)."}, + ) + vllm_server_port: int = field( + default=8000, + metadata={"help": "Port of the vLLM server (server mode only)."}, + ) + vllm_group_port: int = field( + default=51216, + metadata={"help": "Port for the weight update group (server mode only)."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={"help": "Timeout in seconds to wait for the vLLM server."}, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={"help": "Tensor parallel size for colocated vLLM."}, + ) + vllm_gpu_memory_utilization: float = field( + default=0.3, + metadata={"help": "GPU memory utilization ratio for colocated vLLM."}, + ) + vllm_max_model_length: int | None = field( + default=None, + metadata={"help": "Model context length for vLLM. Inferred from model config if not set."}, + ) + beta: float = field( + default=0.0, + metadata={"help": "Reference-model KL coefficient for online policy optimization."}, + ) + num_iterations: int = field( + default=1, + metadata={"help": "Number of optimization iterations per generated batch."}, + ) + epsilon: float = field( + default=0.2, + metadata={"help": "Lower clipping coefficient for GRPO-style policy loss."}, + ) + epsilon_high: float | None = field( + default=None, + metadata={"help": "Upper clipping coefficient. Defaults to `epsilon` when unset."}, + ) + importance_sampling_level: str = field( + default="token", + metadata={"help": "Importance-sampling granularity. Supported: `token`, `sequence`."}, + ) + reward_weights: list[float] | None = field( + default=None, + metadata={"help": "Optional weights for multiple reward functions."}, + ) + scale_rewards: str | bool = field( + default="group", + metadata={"help": "Reward normalization mode. Supported: `group`, `batch`, `none`."}, + ) + loss_type: str = field( + default="dapo", + metadata={"help": "Policy loss aggregation. Supported: `grpo`, `bnpo`, `dr_grpo`, `dapo`."}, + ) + mask_truncated_completions: bool = field( + default=False, + metadata={"help": "Whether to exclude truncated completions from the loss."}, + ) + sync_ref_model: bool = field( + default=False, + metadata={"help": "Whether to synchronize the reference model with the student model."}, + ) + ref_model_mixup_alpha: float = field( + default=0.6, + metadata={"help": "EMA mix coefficient used when syncing the reference model."}, + ) + ref_model_sync_steps: int = field( + default=512, + metadata={"help": "How often to synchronize the reference model."}, + ) + top_entropy_quantile: float = field( + default=1.0, + metadata={"help": "Reserved for entropy-based token filtering."}, + ) + distillation_alpha: float = field( + default=0.5, + metadata={"help": "KL divergence direction: 0.0=forward KL, 0.5=JSD, 1.0=reverse KL."}, + ) + distillation_topk: int | None = field( + default=100, + metadata={"help": "Number of top tokens for top-k distillation. If None, uses all tokens."}, + ) + full_logit_distillation: bool = field( + default=False, + metadata={"help": "Whether to use full-logit distillation instead of token-level distillation."}, + ) + distillation_is_clip: float | None = field( + default=2.0, + metadata={"help": "Clipping coefficient for importance sampling in self-distillation."}, + ) + distillation_add_tail: bool = field( + default=False, + metadata={"help": "Whether to add a tail bucket for non-top-k probability mass."}, + ) + distillation_weight: float = field( + default=1.0, + metadata={"help": "Weight applied to the self-distillation loss term."}, + ) + diagnostics_warning_interval: int = field( + default=10, + metadata={ + "help": "Emit repeated trainer diagnostics every N consecutive degenerate steps. Set to 0 to disable." + }, + ) + diagnostics_flat_tolerance: float = field( + default=1e-8, + metadata={ + "help": "Tolerance used to decide whether reward variance or reprompt activity is effectively zero." + }, + ) + + def __post_init__(self): + super().__post_init__() + + self.scale_rewards = {True: "group", False: "none"}.get(self.scale_rewards, self.scale_rewards) + if self.scale_rewards not in ["group", "batch", "none"]: + raise ValueError("scale_rewards must be one of: 'group', 'batch', 'none'") + + if self.importance_sampling_level not in ["token", "sequence"]: + raise ValueError("importance_sampling_level must be either 'token' or 'sequence'") + if self.loss_type not in ["grpo", "bnpo", "dr_grpo", "dapo"]: + raise ValueError("loss_type must be one of: 'grpo', 'bnpo', 'dr_grpo', 'dapo'") + if self.num_generations < 1: + raise ValueError("num_generations must be at least 1") + if not 0.0 <= self.distillation_alpha <= 1.0: + raise ValueError("distillation_alpha must be in [0, 1]") + if self.distillation_topk is not None and self.distillation_topk <= 0: + raise ValueError("distillation_topk must be positive when provided") + if self.distillation_is_clip is not None and self.distillation_is_clip <= 0: + raise ValueError("distillation_is_clip must be positive when provided") + if self.distillation_weight < 0: + raise ValueError("distillation_weight must be non-negative") + if self.diagnostics_warning_interval < 0: + raise ValueError("diagnostics_warning_interval must be non-negative") + if self.diagnostics_flat_tolerance < 0: + raise ValueError("diagnostics_flat_tolerance must be non-negative") + + num_processes = self.world_size + if self.generation_batch_size is None and self.steps_per_generation is None: + self.steps_per_generation = self.gradient_accumulation_steps + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + elif self.generation_batch_size is not None and self.steps_per_generation is None: + global_batch_size = self.per_device_train_batch_size * num_processes + if self.generation_batch_size % global_batch_size != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by the global batch size ({global_batch_size})." + ) + self.steps_per_generation = self.generation_batch_size // global_batch_size + elif self.generation_batch_size is None and self.steps_per_generation is not None: + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + else: + raise ValueError("'generation_batch_size' and 'steps_per_generation' can not both be configured") + + if self.generation_batch_size % self.num_generations != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by num_generations ({self.num_generations})." + ) + + if self.do_eval and self.eval_strategy != "no": + num_generations_eval = self.num_generations_eval or self.num_generations + if (self.per_device_eval_batch_size * num_processes) % num_generations_eval != 0: + raise ValueError( + f"The global eval batch size ({self.per_device_eval_batch_size} * {num_processes}) must be " + f"divisible by the number of generations used for evaluation ({num_generations_eval})." + ) + + if self.epsilon_high is None: + self.epsilon_high = self.epsilon diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/self_distillation_mixin.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/self_distillation_mixin.py new file mode 100644 index 0000000000000000000000000000000000000000..fb2a8808de102b47fef5169a457048193906482a --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/self_distillation_mixin.py @@ -0,0 +1,295 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Shared self-distillation loss utilities used by experimental trainers. + +This module intentionally holds only the reusable distillation mechanics: callback dispatch, common prompt/context +helpers, and the student-vs-teacher loss computation. Trainer lifecycle and online rollout concerns live in the trainer +classes or their online-specific base. +""" + +from __future__ import annotations + +from contextlib import nullcontext +from typing import Any + +import torch +import torch.nn.functional as F + +from ...trainer.utils import entropy_from_logits, selective_log_softmax +from .self_distillation_config import SelfDistillationConfig + + +class SelfDistillationMixin: + """Reusable self-distillation helpers shared across experimental trainers.""" + + config_cls = SelfDistillationConfig + + def _set_signature_columns_if_needed(self): + if self._signature_columns is None: + self._signature_columns = ["prompt", "privileged_context"] + + def _dispatch_self_distillation_callback(self, event_name: str, **payload) -> None: + for callback in self.callback_handler.callbacks: + callback_fn = getattr(callback, event_name, None) + if callback_fn is not None: + callback_fn( + args=self.args, + state=self.state, + control=self.control, + model=self.model, + processing_class=self.processing_class, + **payload, + ) + + @staticmethod + def _split_prompt_and_privileged_context(inputs: list[dict[str, Any]]) -> tuple[list[Any], list[Any]]: + prompts = [example["prompt"] for example in inputs] + privileged_contexts = [example.get("privileged_context") for example in inputs] + return prompts, privileged_contexts + + def _allow_topk_without_full_logit_distillation(self) -> bool: + return True + + def _get_per_token_logps_and_entropies( + self, + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=False, + ): + model_inputs = {"input_ids": input_ids, "attention_mask": attention_mask, "use_cache": False} + if "logits_to_keep" in self.model_kwarg_keys: + model_inputs["logits_to_keep"] = logits_to_keep + 1 + logits = model(**model_inputs).logits + logits = logits[:, :-1, :] + logits = logits[:, -logits_to_keep:, :] + logits = logits / self.temperature + completion_ids = input_ids[:, -logits_to_keep:] + selected_logps = selective_log_softmax(logits, completion_ids) + entropies = entropy_from_logits(logits) if compute_entropy else None + return selected_logps, entropies + + def _compute_self_distillation_loss( + self, + model, + inputs: dict[str, Any], + ) -> torch.Tensor: + # Expected batch contract: + # - required: `prompt_ids`, `prompt_mask`, `completion_ids`, `completion_mask`, + # `teacher_input_ids`, `teacher_attention_mask` + # - optional: `self_distillation_mask` to zero-out samples without teacher supervision, + # `old_per_token_logps` to enable IS clipping when generation and optimization are misaligned + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + logits_to_keep = completion_ids.size(1) + + self_distillation_mask = inputs.get("self_distillation_mask") + if self_distillation_mask is not None: + response_mask = completion_mask * self_distillation_mask.unsqueeze(1) + else: + response_mask = completion_mask + + if response_mask.sum() == 0: + mode = "train" if model.training else "eval" + self._log_self_distillation_metric(mode, "distillation_loss", 0.0) + return torch.tensor(0.0, device=completion_ids.device, requires_grad=True) + + student_input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + student_attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + student_model_inputs = { + "input_ids": student_input_ids, + "attention_mask": student_attention_mask, + "use_cache": False, + } + if "logits_to_keep" in self.model_kwarg_keys: + student_model_inputs["logits_to_keep"] = logits_to_keep + 1 + + student_logits = model(**student_model_inputs).logits + student_logits = student_logits[:, :-1, :] + student_logits = student_logits[:, -logits_to_keep:, :] + student_logits = student_logits / self.temperature + + teacher_input_ids = inputs["teacher_input_ids"] + teacher_attention_mask = inputs["teacher_attention_mask"] + teacher_model_inputs = { + "input_ids": teacher_input_ids, + "attention_mask": teacher_attention_mask, + "use_cache": False, + } + if "logits_to_keep" in self.model_kwarg_keys: + teacher_model_inputs["logits_to_keep"] = logits_to_keep + 1 + + teacher_model = self._get_teacher_model_for_self_distillation(model) + with torch.no_grad(), self._get_teacher_context_for_self_distillation(model): + teacher_logits = teacher_model(**teacher_model_inputs).logits + teacher_logits = teacher_logits[:, :-1, :] + teacher_logits = teacher_logits[:, -logits_to_keep:, :] + teacher_logits = teacher_logits / self.temperature + + use_topk_distillation = self.args.distillation_topk is not None and ( + self.args.full_logit_distillation or self._allow_topk_without_full_logit_distillation() + ) + if use_topk_distillation: + student_logsumexp = torch.logsumexp(student_logits, dim=-1, keepdim=True) + topk_student_logits, topk_indices = torch.topk(student_logits, k=self.args.distillation_topk, dim=-1) + topk_student_log_probs = topk_student_logits - student_logsumexp + + teacher_logsumexp = torch.logsumexp(teacher_logits, dim=-1, keepdim=True) + topk_teacher_logits = torch.gather(teacher_logits, dim=-1, index=topk_indices) + topk_teacher_log_probs = topk_teacher_logits - teacher_logsumexp + + if self.args.distillation_add_tail: + topk_student_log_probs = self._add_tail(topk_student_log_probs) + topk_teacher_log_probs = self._add_tail(topk_teacher_log_probs) + else: + topk_student_log_probs = self._renorm_topk_log_probs(topk_student_log_probs) + topk_teacher_log_probs = self._renorm_topk_log_probs(topk_teacher_log_probs) + + per_token_loss = self._compute_divergence( + topk_student_log_probs, topk_teacher_log_probs, self.args.distillation_alpha + ) + elif self.args.full_logit_distillation: + student_log_probs = F.log_softmax(student_logits, dim=-1) + teacher_log_probs = F.log_softmax(teacher_logits, dim=-1) + per_token_loss = self._compute_divergence( + student_log_probs, teacher_log_probs, self.args.distillation_alpha + ) + else: + if self.args.distillation_alpha != 1.0: + raise ValueError( + "Only reverse KL (alpha=1.0) is supported for token-level distillation when " + "`full_logit_distillation=False`, " + f"got alpha={self.args.distillation_alpha}" + ) + student_logsumexp = torch.logsumexp(student_logits, dim=-1, keepdim=True) + teacher_logsumexp = torch.logsumexp(teacher_logits, dim=-1, keepdim=True) + idx = completion_ids.unsqueeze(-1) + student_per_token_logps = (torch.gather(student_logits, dim=-1, index=idx) - student_logsumexp).squeeze(-1) + teacher_per_token_logps = (torch.gather(teacher_logits, dim=-1, index=idx) - teacher_logsumexp).squeeze(-1) + per_token_loss = self._compute_token_level_distillation_loss( + student_per_token_logps, teacher_per_token_logps + ) + + if self.args.distillation_is_clip is not None: + old_log_probs = inputs.get("old_per_token_logps") + if old_log_probs is not None: + with torch.no_grad(): + student_lse = torch.logsumexp(student_logits, dim=-1, keepdim=True) + idx = completion_ids.unsqueeze(-1) + student_per_token_logps = (torch.gather(student_logits, dim=-1, index=idx) - student_lse).squeeze( + -1 + ) + per_token_loss = self._apply_importance_sampling_clipping( + per_token_loss, student_per_token_logps, old_log_probs, self.args.distillation_is_clip + ) + + loss = self._aggregate_self_distillation_loss(per_token_loss, response_mask) + + mode = "train" if model.training else "eval" + mean_distill_loss = (per_token_loss * response_mask).sum() / response_mask.sum().clamp(min=1.0) + self._log_self_distillation_metric( + mode, + "distillation_loss", + self.accelerator.gather(mean_distill_loss).mean().item(), + ) + + return loss + + def _get_teacher_model_for_self_distillation(self, model): + teacher_model = getattr(self, "teacher_model", None) + if teacher_model is None: + return model + return teacher_model + + def _get_teacher_context_for_self_distillation(self, model): + return nullcontext() + + def _log_self_distillation_metric(self, mode: str, metric_name: str, value: float) -> None: + metric_prefix = getattr(self, "_name", "self_distillation").lower().replace(" ", "_") + self._metrics[mode][f"self_distillation/{metric_name}"].append(value) + self._metrics[mode][f"{metric_prefix}/{metric_name}"].append(value) + + @staticmethod + def _compute_divergence( + student_log_probs: torch.Tensor, + teacher_log_probs: torch.Tensor, + alpha: float, + ) -> torch.Tensor: + if alpha == 0.0: + kl = F.kl_div(student_log_probs, teacher_log_probs, reduction="none", log_target=True) + elif alpha == 1.0: + kl = F.kl_div(teacher_log_probs, student_log_probs, reduction="none", log_target=True) + else: + alpha_t = torch.tensor(alpha, dtype=student_log_probs.dtype, device=student_log_probs.device) + mixture = torch.logsumexp( + torch.stack([student_log_probs + torch.log(1 - alpha_t), teacher_log_probs + torch.log(alpha_t)]), + dim=0, + ) + kl_teacher = F.kl_div(mixture, teacher_log_probs, reduction="none", log_target=True) + kl_student = F.kl_div(mixture, student_log_probs, reduction="none", log_target=True) + kl = torch.lerp(kl_student, kl_teacher, alpha) + return kl.sum(-1) + + @staticmethod + def _add_tail(log_probs: torch.Tensor) -> torch.Tensor: + log_s = torch.logsumexp(log_probs, dim=-1, keepdim=True) + log_s = torch.clamp(log_s, max=-1e-7) + tail_log = torch.log(-torch.expm1(log_s)) + return torch.cat([log_probs, tail_log], dim=-1) + + @staticmethod + def _renorm_topk_log_probs(log_probs: torch.Tensor) -> torch.Tensor: + return log_probs - torch.logsumexp(log_probs, dim=-1, keepdim=True) + + @staticmethod + def _compute_token_level_distillation_loss( + student_log_probs: torch.Tensor, + teacher_log_probs: torch.Tensor, + ) -> torch.Tensor: + # This is the token-level reverse-KL surrogate used by the official SDPO implementation for + # `full_logit_distillation=False`. It intentionally treats the teacher log-probs as fixed targets + # and keeps only the score-function term for the sampled student tokens. + log_ratio = student_log_probs - teacher_log_probs + return log_ratio.detach() * student_log_probs + + @staticmethod + def _apply_importance_sampling_clipping( + per_token_loss: torch.Tensor, + student_log_probs: torch.Tensor, + old_log_probs: torch.Tensor, + clip_coeff: float, + ) -> torch.Tensor: + negative_approx_kl = (student_log_probs - old_log_probs).detach() + negative_approx_kl = torch.clamp(negative_approx_kl, min=-20.0, max=20.0) + ratio = torch.exp(negative_approx_kl).clamp(max=clip_coeff) + return per_token_loss * ratio + + def _aggregate_self_distillation_loss( + self, + per_token_loss: torch.Tensor, + response_mask: torch.Tensor, + ) -> torch.Tensor: + loss_type = self.loss_type + if loss_type == "grpo": + loss = (per_token_loss * response_mask).sum(-1) / response_mask.sum(-1).clamp(min=1.0) + return loss.mean() + if loss_type == "bnpo": + return (per_token_loss * response_mask).sum() / response_mask.sum().clamp(min=1.0) + if loss_type == "dr_grpo": + return (per_token_loss * response_mask).sum() / (per_token_loss.size(0) * self.max_completion_length) + if loss_type in ["dapo", "luspo", "cispo", "sapo"]: + return (per_token_loss * response_mask).sum() / response_mask.sum().clamp(min=1.0) + raise ValueError(f"Unsupported loss_type for self-distillation: {loss_type}") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/teacher_context.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/teacher_context.py new file mode 100644 index 0000000000000000000000000000000000000000..5e1020c91a7c503ffc4c17c7e46938009e19beaf --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/self_distillation/teacher_context.py @@ -0,0 +1,85 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Any + +import torch + +from ...data_utils import maybe_apply_chat_template +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import pad + + +def extract_last_user_text(prompt: list[dict[str, Any]]) -> str: + """Extract the text content from the last user message in a conversational prompt.""" + last_message = prompt[-1] + if last_message.get("role") != "user": + raise ValueError( + f"Self-distillation teacher prompt construction expects the conversation to end with a user turn, " + f"but the last message has role '{last_message.get('role')}'. " + f"Prompts ending with assistant prefills or tool turns are not supported." + ) + content = last_message.get("content", "") + if isinstance(content, list): + return " ".join(part.get("text", "") for part in content if part.get("type") == "text") + return content + + +@dataclass +class TokenizedPromptBatch: + prompt_ids: torch.Tensor + prompt_mask: torch.Tensor + + +class PromptTokenizer: + """Internal helper to tokenize prompt-like inputs consistently across self-distillation trainers.""" + + def __init__(self, trainer): + self.trainer = trainer + + def apply_prompt_template(self, prompts: list[Any]) -> list[str]: + return [ + maybe_apply_chat_template( + {"prompt": prompt}, + self.trainer.processing_class, + **getattr(self.trainer, "chat_template_kwargs", {}), + )["prompt"] + for prompt in prompts + ] + + def tokenize_prompts(self, prompts: list[Any]) -> TokenizedPromptBatch: + prompt_text = self.apply_prompt_template(prompts) + prompt_inputs = self.trainer.processing_class( + text=prompt_text, + return_tensors="pt", + padding=True, + padding_side="left", + max_length=self.trainer.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + prompt_inputs = super(_BaseTrainer, self.trainer)._prepare_inputs(prompt_inputs) + prompt_ids = [ + p[m].tolist() + for p, m in zip(prompt_inputs["input_ids"], prompt_inputs["attention_mask"].bool(), strict=False) + ] + prompt_ids = [torch.tensor(ids, device=self.trainer.accelerator.device) for ids in prompt_ids] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + return TokenizedPromptBatch( + prompt_ids=pad(prompt_ids, padding_value=self.trainer.pad_token_id, padding_side="left"), + prompt_mask=pad(prompt_mask, padding_value=0, padding_side="left"), + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d62e42ef96cc9cd6e4ff4de23ce39460420e34b7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .ssd_config import SSDConfig +from .ssd_trainer import SSDTrainer + + +__all__ = ["SSDConfig", "SSDTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd.py new file mode 100644 index 0000000000000000000000000000000000000000..0359c3aa6fc76168f667c3ff991ccd525e7d144e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd.py @@ -0,0 +1,170 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +""" +Simple Self-Distillation (SSD) training for code generation. + +Implements the method from "Embarrassingly Simple Self-Distillation Improves Code Generation" (Zhang et al., 2026): +sample completions from the model at a training-time temperature and truncation, then fine-tune on those raw, +unverified samples with standard cross-entropy loss. No reward model, verifier, teacher, or RL needed. + +The dataset only requires a ``prompt`` column containing coding problem prompts. + +Example: + +```bash +python trl/experimental/ssd/ssd.py \ + --model_name_or_path Qwen/Qwen3-4B-Instruct-2507 \ + --dataset_name microsoft/rStar-Coder \ + --dataset_config seed_sft \ + --prompt_column question \ + --output_dir outputs/ssd-qwen3-4b \ + --per_device_train_batch_size 1 \ + --gradient_accumulation_steps 32 \ + --learning_rate 5e-6 \ + --lr_scheduler_type cosine \ + --max_prompt_length 1024 \ + --max_completion_length 65536 \ + --temperature 1.6 \ + --top_k 20 \ + --top_p 0.8 \ + --num_train_epochs 1 \ + --bf16 \ + --report_to trackio +``` +""" + +from dataclasses import dataclass, field + +import torch +from datasets import DatasetDict, load_dataset, load_from_disk +from transformers import AutoModelForCausalLM, AutoTokenizer + +from trl import ( + ModelConfig, + ScriptArguments, + TrlParser, + get_kbit_device_map, + get_peft_config, + get_quantization_config, +) +from trl.experimental.ssd import SSDConfig, SSDTrainer + + +@dataclass +class SSDScriptArguments(ScriptArguments): + dataset_path: str | None = field( + default=None, + metadata={"help": "Optional local dataset path to load with `load_from_disk`. Overrides `dataset_name`."}, + ) + prompt_column: str = field( + default="prompt", + metadata={"help": "Column containing the problem prompts."}, + ) + + +if __name__ == "__main__": + parser = TrlParser((SSDScriptArguments, SSDConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_and_config() + + if model_args.model_name_or_path is None: + raise ValueError("`model_name_or_path` is required.") + + if model_args.dtype in ["auto", None]: + if training_args.bf16: + dtype = torch.bfloat16 + elif training_args.fp16: + dtype = torch.float16 + else: + dtype = "auto" + else: + dtype = getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + training_args.model_init_kwargs = model_kwargs + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + padding_side="left", + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + # Load dataset + if script_args.dataset_path is not None: + dataset = load_from_disk(script_args.dataset_path) + else: + dataset = load_dataset( + script_args.dataset_name, + name=script_args.dataset_config, + streaming=script_args.dataset_streaming, + ) + + # Ensure the dataset has a `prompt` column + def _prepare_split(ds): + if script_args.prompt_column != "prompt" and script_args.prompt_column in ds.column_names: + ds = ds.rename_column(script_args.prompt_column, "prompt") + return ds.select_columns(["prompt"]) + + if isinstance(dataset, DatasetDict): + train_dataset = _prepare_split(dataset[script_args.dataset_train_split]) + eval_dataset = None + if script_args.dataset_test_split in dataset: + eval_dataset = _prepare_split(dataset[script_args.dataset_test_split]) + else: + train_dataset = _prepare_split(dataset) + eval_dataset = None + + model = AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path, **model_kwargs) + model.config.use_cache = False if training_args.gradient_checkpointing else True + + trainer = SSDTrainer( + model=model, + args=training_args, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + trainer.train() + + trainer.save_model(training_args.output_dir) + if eval_dataset is not None: + metrics = trainer.evaluate() + trainer.log_metrics("eval", metrics) + trainer.save_metrics("eval", metrics) + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name or script_args.dataset_path) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_config.py new file mode 100644 index 0000000000000000000000000000000000000000..e86057eab8d962487ff2a5992acf8ad06ce11bb6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_config.py @@ -0,0 +1,253 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from transformers import TrainingArguments + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class SSDConfig(_BaseConfig): + r""" + Configuration class for [`SSDTrainer`]. + + Implements Simple Self-Distillation (SSD) from [*Embarrassingly Simple Self-Distillation Improves Code + Generation*](https://huggingface.co/papers/2604.01193). SSD samples completions from the model at a training-time + temperature and truncation configuration, then fine-tunes on those raw, unverified samples with standard + cross-entropy loss. + + The `temperature`, `top_k`, and `top_p` parameters control the training-time sampling configuration (T_train, + rho_train in the paper). The evaluation-time configuration (T_eval, rho_eval) is set independently at inference + time. + + Parameters: + > Parameters that control generation and rollout reuse + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments used when the `model` argument is passed as a string. + max_prompt_length (`int` or `None`, *optional*, defaults to `512`): + Maximum prompt length. Longer prompts are truncated from the left. + max_completion_length (`int` or `None`, *optional*, defaults to `256`): + Maximum generated completion length. + generation_batch_size (`int` or `None`, *optional*): + Global batch size used for generation. Mutually exclusive with `steps_per_generation`. + steps_per_generation (`int` or `None`, *optional*): + Number of optimizer steps that reuse one generated batch. Mutually exclusive with `generation_batch_size`. + + > Parameters that control sampling + + temperature (`float`, *optional*, defaults to `1.0`): + Sampling temperature (T_train in the paper). + top_k (`int`, *optional*, defaults to `0`): + Top-k sampling parameter. `0` disables top-k filtering. + top_p (`float`, *optional*, defaults to `1.0`): + Top-p (nucleus) sampling parameter. + min_p (`float` or `None`, *optional*): + Minimum token probability for sampling. + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Repetition penalty used during generation. + generation_kwargs (`dict[str, Any]` or `None`, *optional*): + Extra generation kwargs passed to `GenerationConfig`. + + > Parameters that control vLLM generation + + use_vllm (`bool`, *optional*, defaults to `False`): + Whether to use vLLM for generation instead of the training model. + vllm_mode (`str`, *optional*, defaults to `"colocate"`): + vLLM mode: `"colocate"` (shared GPU) or `"server"` (separate vLLM server). + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation for vLLM: `"vllm"`, `"transformers"`, or `"auto"`. + vllm_server_base_url (`str` or `None`, *optional*): + Base URL for the vLLM server. If provided, `vllm_server_host` and `vllm_server_port` are ignored. + vllm_server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the vLLM server (server mode only). + vllm_server_port (`int`, *optional*, defaults to `8000`): + Port of the vLLM server (server mode only). + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Timeout in seconds to wait for the vLLM server. + vllm_group_port (`int`, *optional*, defaults to `51216`): + Port for the weight update group (server mode only). + vllm_tensor_parallel_size (`int`, *optional*, defaults to `1`): + Tensor parallel size for colocated vLLM. + vllm_gpu_memory_utilization (`float`, *optional*, defaults to `0.3`): + GPU memory utilization ratio for colocated vLLM. + vllm_max_model_length (`int` or `None`, *optional*): + Model context length for vLLM. Inferred from model config if not set. + vllm_enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Whether to enable sleep mode for colocated vLLM engine. + + > Parameters that control training behavior + + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model during training. + filter_empty (`bool`, *optional*, defaults to `True`): + Whether to filter out empty or single-line stub completions from the generated data. + num_iterations (`int`, *optional*, defaults to `1`): + Number of optimization iterations per generated batch. + shuffle_dataset (`bool`, *optional*, defaults to `True`): + Whether to shuffle the training dataset. + ds3_gather_for_generation (`bool`, *optional*, defaults to `True`): + Whether to gather ZeRO-3 weights for generation. + cache_implementation (`str` or `None`, *optional*): + Cache implementation used by transformers generation. + chat_template_kwargs (`dict[str, Any]` or `None`, *optional*): + Extra kwargs forwarded to chat template application. + """ + + _VALID_DICT_FIELDS = TrainingArguments._VALID_DICT_FIELDS + ["model_init_kwargs"] + + model_init_kwargs: dict[str, Any] | None = field( + default=None, + metadata={"help": "Keyword arguments for model initialization when `model` is passed as a string."}, + ) + max_prompt_length: int | None = field( + default=512, + metadata={"help": "Maximum prompt length. Longer prompts are truncated from the left."}, + ) + max_completion_length: int | None = field( + default=256, + metadata={"help": "Maximum generated completion length."}, + ) + generation_batch_size: int | None = field( + default=None, + metadata={"help": "Global batch size used for generation. Mutually exclusive with `steps_per_generation`."}, + ) + steps_per_generation: int | None = field( + default=None, + metadata={"help": "Number of optimizer steps that reuse one generated batch."}, + ) + temperature: float = field( + default=1.0, + metadata={"help": "Sampling temperature (T_train in the paper)."}, + ) + top_k: int = field( + default=0, + metadata={"help": "Top-k sampling parameter. `0` disables top-k filtering."}, + ) + top_p: float = field( + default=1.0, + metadata={"help": "Top-p (nucleus) sampling parameter."}, + ) + min_p: float | None = field( + default=None, + metadata={"help": "Minimum token probability for sampling."}, + ) + repetition_penalty: float = field( + default=1.0, + metadata={"help": "Repetition penalty used during generation."}, + ) + generation_kwargs: dict[str, Any] | None = field( + default=None, + metadata={"help": "Extra generation kwargs passed to `GenerationConfig`."}, + ) + cache_implementation: str | None = field( + default=None, + metadata={"help": "Cache implementation used by transformers generation."}, + ) + chat_template_kwargs: dict[str, Any] | None = field( + default=None, + metadata={"help": "Extra kwargs forwarded to chat template application."}, + ) + use_vllm: bool = field( + default=False, + metadata={"help": "Whether to use vLLM for generation."}, + ) + vllm_mode: str = field( + default="colocate", + metadata={"help": "vLLM mode: 'colocate' (shared GPU) or 'server' (separate vLLM server)."}, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={"help": "Model implementation for vLLM: 'vllm', 'transformers', or 'auto'."}, + ) + vllm_server_base_url: str | None = field( + default=None, + metadata={ + "help": "Base URL for the vLLM server. If provided, vllm_server_host and vllm_server_port are ignored." + }, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": "Host of the vLLM server (server mode only)."}, + ) + vllm_server_port: int = field( + default=8000, + metadata={"help": "Port of the vLLM server (server mode only)."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={"help": "Timeout in seconds to wait for the vLLM server."}, + ) + vllm_group_port: int = field( + default=51216, + metadata={"help": "Port for the weight update group (server mode only)."}, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={"help": "Tensor parallel size for colocated vLLM."}, + ) + vllm_gpu_memory_utilization: float = field( + default=0.3, + metadata={"help": "GPU memory utilization ratio for colocated vLLM."}, + ) + vllm_max_model_length: int | None = field( + default=None, + metadata={"help": "Model context length for vLLM. Inferred from model config if not set."}, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={"help": "Whether to enable sleep mode for colocated vLLM engine."}, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model during training."}, + ) + filter_empty: bool = field( + default=True, + metadata={"help": "Whether to filter out empty or single-line stub completions."}, + ) + num_iterations: int = field( + default=1, + metadata={"help": "Number of optimization iterations per generated batch."}, + ) + shuffle_dataset: bool = field( + default=True, + metadata={"help": "Whether to shuffle the training dataset."}, + ) + ds3_gather_for_generation: bool = field( + default=True, + metadata={"help": "Whether to gather ZeRO-3 weights for generation."}, + ) + + def __post_init__(self): + super().__post_init__() + + num_processes = self.world_size + if self.generation_batch_size is None and self.steps_per_generation is None: + self.steps_per_generation = self.gradient_accumulation_steps + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + elif self.generation_batch_size is not None and self.steps_per_generation is None: + global_batch_size = self.per_device_train_batch_size * num_processes + if self.generation_batch_size % global_batch_size != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by the global batch size ({global_batch_size})." + ) + self.steps_per_generation = self.generation_batch_size // global_batch_size + elif self.generation_batch_size is None and self.steps_per_generation is not None: + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + else: + raise ValueError("'generation_batch_size' and 'steps_per_generation' can not both be configured") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_eval.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_eval.py new file mode 100644 index 0000000000000000000000000000000000000000..cb3f6d24995cad889062c4b2bc3889b978a61a37 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_eval.py @@ -0,0 +1,260 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "vllm", +# "huggingface_hub", +# "livecodebench @ git+https://github.com/LiveCodeBench/LiveCodeBench.git", +# ] +# /// + +""" +LiveCodeBench v6 evaluation script. + +Generates completions with vLLM at a configurable decoding setting and scores them with LiveCodeBench's official +``codegen_metrics`` (pass@k via sandboxed test execution). The default decoding configuration matches Table 3 of +*Embarrassingly Simple Self-Distillation Improves Code Generation* (Zhang et al., 2026), making this script suitable +for evaluating SSD-trained checkpoints alongside their base models. + +Example — evaluate the base Qwen3-4B-Instruct-2507 on the v6 delta (the new problems released in v6): + +```bash +python trl/experimental/ssd/ssd_eval.py \\ + --model_name_or_path Qwen/Qwen3-4B-Instruct-2507 \\ + --temperature 1.1 \\ + --top_k 20 \\ + --top_p 0.8 \\ + --n 1 \\ + --output_file outputs/qwen3_4b_base_lcb_v6.json +``` + +Evaluate an SSD-trained checkpoint with the same decoding configuration: + +```bash +python trl/experimental/ssd/ssd_eval.py \\ + --model_name_or_path outputs/ssd-qwen3-4b-instruct \\ + --temperature 1.1 \\ + --top_k 20 \\ + --top_p 0.8 \\ + --n 5 \\ + --output_file outputs/qwen3_4b_ssd_lcb_v6.json +``` +""" + +# ruff: noqa: T201 + +from __future__ import annotations + +import json +import re +from dataclasses import dataclass, field +from datetime import datetime + +from huggingface_hub import hf_hub_download +from lcb_runner.benchmarks.code_generation import CodeGenerationProblem +from lcb_runner.evaluation.compute_code_generation_metrics import codegen_metrics +from transformers import AutoTokenizer +from vllm import LLM, SamplingParams + +from trl import TrlParser + + +# LiveCodeBench stores new problems added in each release version in a separate JSONL file: +# ``test.jsonl`` = v1, ``test2.jsonl`` = v2, …, ``test6.jsonl`` = v6 (the delta added in release v6). +# The paper's "LCB v6" refers to exactly this delta. +LCB_REPO = "livecodebench/code_generation_lite" +LCB_V6_FILE = "test6.jsonl" + + +SYSTEM_MESSAGE = ( + "You are an expert Python programmer. You will be given a question (problem specification) and will " + "generate a correct Python program that matches the specification and passes all tests." +) +FORMATTING_WITHOUT_STARTER = ( + "Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on " + "the sample inputs). Enclose your code within delimiters as follows. Ensure that when the python " + "program runs, it reads the inputs, runs the algorithm and writes output to STDOUT." +) +FORMATTING_WITH_STARTER = ( + "You will use the following starter code to write the solution to the problem and enclose your code " + "within delimiters." +) + +CODE_FENCE_RE = re.compile(r"```(?:python)?\s*\n(.*?)```", re.DOTALL) + + +@dataclass +class SSDEvalArguments: + model_name_or_path: str = field(metadata={"help": "Model path or Hub repo id to evaluate."}) + output_file: str = field(metadata={"help": "Path to write generations + metrics JSON."}) + temperature: float = field(default=1.1, metadata={"help": "Evaluation-time sampling temperature (T_eval)."}) + top_k: int = field(default=20, metadata={"help": "Evaluation-time top-k truncation."}) + top_p: float = field(default=0.8, metadata={"help": "Evaluation-time top-p (nucleus) truncation."}) + n: int = field(default=1, metadata={"help": "Number of samples per problem (pass@1 uses 1, pass@5 uses 5)."}) + max_tokens: int = field(default=32768, metadata={"help": "Maximum tokens to generate per completion."}) + max_model_len: int = field(default=65536, metadata={"help": "vLLM max model length."}) + gpu_memory_utilization: float = field(default=0.9, metadata={"help": "vLLM GPU memory ratio."}) + tensor_parallel_size: int = field(default=1, metadata={"help": "vLLM tensor parallel size."}) + dtype: str = field(default="bfloat16", metadata={"help": "vLLM model dtype."}) + start_date: str | None = field( + default=None, metadata={"help": "Keep only problems with contest_date >= YYYY-MM-DD."} + ) + end_date: str | None = field( + default=None, metadata={"help": "Keep only problems with contest_date <= YYYY-MM-DD."} + ) + max_problems: int | None = field( + default=None, metadata={"help": "Evaluate at most N problems (useful for quick smoke tests)."} + ) + difficulty: str | None = field( + default=None, metadata={"help": "Filter to a single difficulty: 'easy', 'medium', or 'hard'."} + ) + timeout: int = field(default=6, metadata={"help": "Per-test execution timeout in seconds."}) + num_process_evaluate: int = field(default=8, metadata={"help": "Parallel processes for sandboxed evaluation."}) + seed: int = field(default=0, metadata={"help": "vLLM sampling seed."}) + + +def _build_prompt(tokenizer, question_content: str, starter_code: str) -> str: + """Build the LCB prompt and apply the model's chat template.""" + body = f"### Question:\n{question_content}\n\n" + if starter_code: + body += f"### Format: {FORMATTING_WITH_STARTER}\n" + body += f"```python\n{starter_code}\n```\n\n" + else: + body += f"### Format: {FORMATTING_WITHOUT_STARTER}\n" + body += "```python\n# YOUR CODE HERE\n```\n\n" + body += "### Answer: (use the provided format with backticks)\n\n" + messages = [ + {"role": "system", "content": SYSTEM_MESSAGE}, + {"role": "user", "content": body}, + ] + return tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) + + +def _extract_code(text: str) -> str: + """Extract the first Python code fence from a model completion.""" + match = CODE_FENCE_RE.search(text) + if match: + return match.group(1).strip() + # Fallback: if the model returned bare code without a fence, return the whole thing. + return text.strip() + + +def _load_lcb_v6_problems(args: SSDEvalArguments): + """Load LiveCodeBench v6 problems, filter by date/difficulty/count, and return as a list.""" + jsonl_path = hf_hub_download(repo_id=LCB_REPO, filename=LCB_V6_FILE, repo_type="dataset") + with open(jsonl_path) as f: + problems = [CodeGenerationProblem(**json.loads(line)) for line in f] + + if args.start_date is not None: + start = datetime.fromisoformat(args.start_date) + problems = [p for p in problems if p.contest_date >= start] + if args.end_date is not None: + end = datetime.fromisoformat(args.end_date) + problems = [p for p in problems if p.contest_date <= end] + if args.difficulty is not None: + problems = [p for p in problems if p.difficulty.value == args.difficulty] + if args.max_problems is not None: + problems = problems[: args.max_problems] + + return problems + + +def main(): + parser = TrlParser(SSDEvalArguments) + (args,) = parser.parse_args_and_config() + + problems = _load_lcb_v6_problems(args) + print(f"Evaluating {len(problems)} problems from LiveCodeBench v6") + + tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path) + prompts = [_build_prompt(tokenizer, p.question_content, p.starter_code) for p in problems] + + llm = LLM( + model=args.model_name_or_path, + dtype=args.dtype, + tensor_parallel_size=args.tensor_parallel_size, + max_model_len=args.max_model_len, + gpu_memory_utilization=args.gpu_memory_utilization, + ) + sampling_params = SamplingParams( + n=args.n, + temperature=args.temperature, + top_k=args.top_k, + top_p=args.top_p, + max_tokens=args.max_tokens, + seed=args.seed, + ) + outputs = llm.generate(prompts, sampling_params) + + generations_list = [] + for out in outputs: + code_list = [_extract_code(o.text) for o in out.outputs] + generations_list.append(code_list) + + samples_list = [p.get_evaluation_sample() for p in problems] + k_list = [1] if args.n == 1 else [1, args.n] + metrics, results, _metadata = codegen_metrics( + samples_list, + generations_list, + k_list=k_list, + num_process_evaluate=args.num_process_evaluate, + timeout=args.timeout, + ) + + # Break down pass@1 by difficulty for easier comparison with the paper's tables. `codegen_metrics` + # returns a nested `detail` dict keyed by problem index. + per_problem_pass1 = metrics["detail"]["pass@1"] + per_difficulty = {} + for difficulty in ("easy", "medium", "hard"): + idxs = [i for i, p in enumerate(problems) if p.difficulty.value == difficulty] + if not idxs: + continue + per_difficulty[difficulty] = { + "num_problems": len(idxs), + "pass@1": sum(per_problem_pass1[i] for i in idxs) / len(idxs), + } + + summary = { + "model": args.model_name_or_path, + "num_problems": len(problems), + "temperature": args.temperature, + "top_k": args.top_k, + "top_p": args.top_p, + "n": args.n, + "metrics": {k: float(v) for k, v in metrics.items() if k != "detail"}, + "per_difficulty": per_difficulty, + } + + detail = [ + { + "question_id": p.question_id, + "difficulty": p.difficulty.value, + "code_list": code_list, + "pass@1": per_problem_pass1[i], + } + for i, (p, code_list) in enumerate(zip(problems, generations_list, strict=False)) + ] + + with open(args.output_file, "w") as f: + json.dump({"summary": summary, "detail": detail}, f, indent=2) + + print("\n=== Summary ===") + print(json.dumps(summary, indent=2)) + print(f"\nFull results written to {args.output_file}") + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..ea3787536532651f006ecd73e4c5180fa68fee58 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/ssd/ssd_trainer.py @@ -0,0 +1,519 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Trainer for Simple Self-Distillation (SSD). + +Implements the method from *Embarrassingly Simple Self-Distillation Improves Code Generation* (Zhang et al., 2026): +sample completions from the frozen model at a training-time temperature and truncation configuration, then fine-tune on +those raw, unverified samples with standard cross-entropy loss. No reward model, verifier, teacher model, or +reinforcement learning is needed. +""" + +from __future__ import annotations + +import inspect +import math +import textwrap +from collections import defaultdict +from functools import partial +from typing import Any + +import datasets +import torch +from accelerate.logging import get_logger +from accelerate.utils import is_peft_model +from datasets import Dataset, IterableDataset +from torch import nn +from torch.utils.data import DataLoader, Sampler +from transformers import ( + AutoProcessor, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import seed_worker +from transformers.utils import is_datasets_available, is_peft_available + +from ...data_utils import maybe_apply_chat_template +from ...models import unwrap_model_for_generation +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + get_config_model_id, + identity, + pad, + selective_log_softmax, + split_tensor_dict, +) +from ..utils import prepare_peft_model +from .ssd_config import SSDConfig + + +if is_peft_available(): + from peft import PeftConfig + + +logger = get_logger(__name__) + + +class SSDTrainer(_BaseTrainer): + """Trainer for SSD-style on-policy self-distillation with cross-entropy loss. + + SSD generates completions from the model at a specified training-time temperature and truncation configuration, + then fine-tunes on those raw, unverified samples using standard cross-entropy loss. The dataset only requires a + ``prompt`` column. + """ + + _tag_names = ["trl", "ssd"] + _name = "SSD" + config_cls = SSDConfig + # docstyle-ignore + _paper = { + "title": "Embarrassingly Simple Self-Distillation Improves Code Generation", + "id": "2604.01193", + "citation": textwrap.dedent("""\ + @article{zhang2026ssd, + title = {{Embarrassingly Simple Self-Distillation Improves Code Generation}}, + author = {Ruixiang Zhang and Richard He Bai and Huangjie Zheng and Navdeep Jaitly and Ronan Collobert and Yizhe Zhang}, + year = 2026, + eprint = {arXiv:2604.01193} + }"""), + } + + def __init__( + self, + model: str | PreTrainedModel | nn.Module, + args: SSDConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: PeftConfig | None = None, + ): + if train_dataset is None: + raise ValueError("`train_dataset` is required") + if isinstance(train_dataset, IterableDataset): + raise NotImplementedError("Iterable datasets are not yet supported in SSDTrainer.") + if isinstance(eval_dataset, IterableDataset) or ( + isinstance(eval_dataset, dict) and any(isinstance(ds, IterableDataset) for ds in eval_dataset.values()) + ): + raise NotImplementedError("Iterable eval datasets are not yet supported in SSDTrainer.") + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = SSDConfig(f"{model_name}-SSD") + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + elif args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to `SSDConfig`, but `model` is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + + self.model_kwarg_keys = ( + inspect.signature(model.forward).parameters.keys() + if not hasattr(model, "get_base_model") + else inspect.signature(model.get_base_model().forward).parameters.keys() + ) + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to SSDTrainer. Pass either a base " + "model with `peft_config`, or a pre-wrapped PEFT model." + ) + if peft_config is not None or (is_peft_available() and getattr(model, "peft_config", None) is not None): + model = prepare_peft_model(model, peft_config, args) + + if processing_class is None: + processing_class = AutoProcessor.from_pretrained( + get_config_model_id(model.config), truncation_side="left", padding_side="left" + ) + + if isinstance(processing_class, ProcessorMixin): + tokenizer = processing_class.tokenizer + elif isinstance(processing_class, PreTrainedTokenizerBase): + tokenizer = processing_class + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + self.pad_token_id = tokenizer.pad_token_id + self.eos_token_id = tokenizer.eos_token_id + self.max_prompt_length = args.max_prompt_length + self.max_completion_length = args.max_completion_length + # SSD always samples a single completion per prompt (N=1 in the paper). + self.num_generations = 1 + self.num_iterations = args.num_iterations + self.temperature = args.temperature + self.shuffle_dataset = args.shuffle_dataset + self.filter_empty = args.filter_empty + self.use_vllm = args.use_vllm + self.chat_template_kwargs = args.chat_template_kwargs or {} + self._step = 0 + self._buffered_inputs = None + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + + generation_kwargs = { + "max_new_tokens": self.max_completion_length, + "do_sample": True, + "pad_token_id": tokenizer.pad_token_id, + "bos_token_id": tokenizer.bos_token_id, + "eos_token_id": tokenizer.eos_token_id, + "temperature": args.temperature, + "top_p": args.top_p, + "top_k": args.top_k, + "min_p": args.min_p, + "repetition_penalty": args.repetition_penalty, + "cache_implementation": args.cache_implementation, + } + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + self.generation_config = GenerationConfig(**generation_kwargs, disable_compile=True) + + if hasattr(model, "warnings_issued"): + model.warnings_issued["estimate_tokens"] = True + + super().__init__( + model=model, + args=args, + data_collator=identity, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + callbacks=callbacks, + optimizers=optimizers, + compute_loss_func="non-None value to disable scaling", + ) + + if args.disable_dropout: + disable_dropout_in_model(self.model) + + self.model.add_model_tags(self._tag_names) + + self.model_accepts_loss_kwargs = False + + if self.use_vllm: + from ...generation.vllm_generation import VLLMGeneration + + self.vllm_generation = VLLMGeneration( + model=self.model, + accelerator=self.accelerator, + is_fsdp_enabled=self.is_fsdp_enabled, + processing_class=self.processing_class, + mode=args.vllm_mode, + server_base_url=args.vllm_server_base_url, + server_host=args.vllm_server_host, + server_port=args.vllm_server_port, + group_port=args.vllm_group_port, + server_timeout=args.vllm_server_timeout, + tensor_parallel_size=args.vllm_tensor_parallel_size, + gpu_memory_utilization=args.vllm_gpu_memory_utilization, + max_model_length=args.vllm_max_model_length, + max_num_seqs=args.per_device_train_batch_size + * args.vllm_tensor_parallel_size + * args.steps_per_generation, + enable_sleep_mode=args.vllm_enable_sleep_mode, + model_impl=args.vllm_model_impl, + repetition_penalty=args.repetition_penalty, + temperature=self.temperature, + top_p=args.top_p, + top_k=args.top_k, + min_p=args.min_p, + max_completion_length=self.max_completion_length, + logprobs=None, + generation_kwargs=args.generation_kwargs, + ) + self._last_loaded_step = -1 + + def _set_signature_columns_if_needed(self): + if self._signature_columns is None: + self._signature_columns = ["prompt"] + + def _apply_prompt_template(self, prompts): + return [ + maybe_apply_chat_template({"prompt": prompt}, self.processing_class, **self.chat_template_kwargs)["prompt"] + for prompt in prompts + ] + + # ------------------------------------------------------------------ + # DataLoader + # ------------------------------------------------------------------ + + def get_train_dataloader(self): + if self.train_dataset is None: + raise ValueError("Trainer: training requires a train_dataset.") + + train_dataset = self.train_dataset + data_collator = self.data_collator + if is_datasets_available() and isinstance(train_dataset, datasets.Dataset): + train_dataset = self._remove_unused_columns(train_dataset, description="training") + else: + data_collator = self._get_collator_with_removed_columns(data_collator, description="training") + + dataloader_params = { + "batch_size": self._train_batch_size * self.args.steps_per_generation, + "collate_fn": data_collator, + "num_workers": self.args.dataloader_num_workers, + "pin_memory": self.args.dataloader_pin_memory, + "persistent_workers": self.args.dataloader_persistent_workers, + } + if not isinstance(train_dataset, torch.utils.data.IterableDataset): + dataloader_params["sampler"] = self._get_train_sampler() + dataloader_params["drop_last"] = self.args.dataloader_drop_last + dataloader_params["worker_init_fn"] = partial( + seed_worker, num_workers=self.args.dataloader_num_workers, rank=self.args.process_index + ) + dataloader_params["prefetch_factor"] = self.args.dataloader_prefetch_factor + return self.accelerator.prepare(DataLoader(train_dataset, **dataloader_params)) + + def _get_train_sampler(self, dataset=None) -> Sampler: + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size // self.num_generations, + repeat_count=self.num_iterations * self.args.steps_per_generation, + shuffle=self.shuffle_dataset, + seed=self.args.seed, + ) + + def _get_eval_sampler(self, eval_dataset) -> Sampler: + return RepeatSampler( + data_source=eval_dataset, + mini_repeat_count=self.num_generations, + seed=self.args.seed, + ) + + # ------------------------------------------------------------------ + # Training step management + # ------------------------------------------------------------------ + + def training_step(self, model, inputs, num_items_in_batch): + output = super().training_step(model, inputs, num_items_in_batch) + self._step += 1 + return output + + def _prepare_inputs(self, generation_batch): + mode = "train" if self.model.training else "eval" + if mode == "train": + generate_every = self.args.steps_per_generation * self.num_iterations + if self._step % generate_every == 0 or self._buffered_inputs is None: + generation_batch = self._build_buffered_batch(generation_batch) + self._buffered_inputs = split_tensor_dict(generation_batch, self.args.steps_per_generation) + return self._buffered_inputs[self._step % self.args.steps_per_generation] + return self._build_buffered_batch(generation_batch) + + # ------------------------------------------------------------------ + # Generation + # ------------------------------------------------------------------ + + def _generate_completion_ids(self, prompts: list[Any]) -> tuple[torch.Tensor, torch.Tensor]: + """Generate completions from the model at the configured training-time temperature and truncation.""" + if self.use_vllm: + return self._generate_completion_ids_vllm(prompts) + return self._generate_completion_ids_transformers(prompts) + + def _generate_completion_ids_vllm(self, prompts: list[Any]) -> tuple[torch.Tensor, torch.Tensor]: + """Generate completions using vLLM.""" + if self.state.global_step != self._last_loaded_step: + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + prompts_text = self._apply_prompt_template(prompts) + tokenized = self.processing_class( + text=prompts_text, + return_tensors=None, + padding=False, + max_length=self.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + prompt_ids = tokenized["input_ids"] + + _, completion_ids_list, _, _ = self.vllm_generation.generate( + prompts=prompt_ids, + images=None, + num_generations=self.num_generations, + ) + + device = self.accelerator.device + completion_ids = [torch.tensor(ids, device=device) for ids in completion_ids_list] + completion_mask = [torch.ones(len(ids), dtype=torch.long, device=device) for ids in completion_ids_list] + return ( + pad(completion_ids, padding_value=self.pad_token_id, padding_side="right"), + pad(completion_mask, padding_value=0, padding_side="right"), + ) + + def _generate_completion_ids_transformers(self, prompts: list[Any]) -> tuple[torch.Tensor, torch.Tensor]: + """Generate completions using the training model with transformers.""" + generate_inputs = self.processing_class( + text=self._apply_prompt_template(prompts), + return_tensors="pt", + padding=True, + padding_side="left", + max_length=self.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + # Use the base Trainer tensor preparation instead of re-entering the buffered outer training hook. + generate_inputs = _BaseTrainer._prepare_inputs(self, generate_inputs) + + with ( + unwrap_model_for_generation( + self.model_wrapped, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + ) as unwrapped_model, + torch.no_grad(), + ): + prompt_completion_ids = unwrapped_model.generate( + **generate_inputs, generation_config=self.generation_config + ) + + prompt_length = generate_inputs["input_ids"].size(1) + completion_ids = prompt_completion_ids[:, prompt_length:] + is_eos = completion_ids == self.eos_token_id + eos_idx = torch.full((is_eos.size(0),), is_eos.size(1), dtype=torch.long, device=completion_ids.device) + eos_idx[is_eos.any(dim=1)] = is_eos.int().argmax(dim=1)[is_eos.any(dim=1)] + seq_idx = torch.arange(is_eos.size(1), device=completion_ids.device).expand(is_eos.size(0), -1) + completion_mask = (seq_idx <= eos_idx.unsqueeze(1)).long() + + completion_ids_list = [c[m].tolist() for c, m in zip(completion_ids, completion_mask.bool(), strict=True)] + completion_ids = [torch.tensor(ids, device=self.accelerator.device) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + return ( + pad(completion_ids, padding_value=self.pad_token_id, padding_side="right"), + pad(completion_mask, padding_value=0, padding_side="right"), + ) + + # ------------------------------------------------------------------ + # Batch construction + # ------------------------------------------------------------------ + + def _build_buffered_batch(self, inputs: list[dict[str, Any]]) -> dict[str, torch.Tensor | Any]: + """Generate completions and build the training batch.""" + prompts = [example["prompt"] for example in inputs] + completion_ids, completion_mask = self._generate_completion_ids(prompts) + + # Optionally filter empty or single-line stub completions (the paper applies minimal syntactic filtering) + if self.filter_empty: + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + keep = torch.ones(len(completions_text), dtype=torch.bool, device=completion_ids.device) + for i, text in enumerate(completions_text): + stripped = text.strip() + if len(stripped) == 0 or stripped.count("\n") == 0 and len(stripped) < 10: + keep[i] = False + completion_mask = completion_mask * keep.unsqueeze(1).long() + + # Tokenize prompts for the training forward pass + prompt_text = self._apply_prompt_template(prompts) + prompt_inputs = self.processing_class( + text=prompt_text, + return_tensors="pt", + padding=True, + padding_side="left", + max_length=self.max_prompt_length, + truncation=True, + add_special_tokens=False, + ) + prompt_inputs = _BaseTrainer._prepare_inputs(self, prompt_inputs) + prompt_ids = prompt_inputs["input_ids"] + prompt_mask = prompt_inputs["attention_mask"] + + # Log completion statistics + mode = "train" if self.model.training else "eval" + completion_lengths = completion_mask.sum(dim=1).float() + agg_lengths = self.accelerator.gather(completion_lengths) + self._metrics[mode]["completions/mean_length"].append(agg_lengths.mean().item()) + self._metrics[mode]["completions/min_length"].append(agg_lengths.min().item()) + self._metrics[mode]["completions/max_length"].append(agg_lengths.max().item()) + active_ratio = (completion_mask.sum(dim=1) > 0).float().mean() + self._metrics[mode]["ssd/active_sample_ratio"].append(self.accelerator.gather(active_ratio).mean().item()) + + return { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + } + + # ------------------------------------------------------------------ + # Loss computation + # ------------------------------------------------------------------ + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if return_outputs: + raise ValueError("The SSDTrainer does not support returning outputs") + + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) + + # Forward pass + model_inputs = {"input_ids": input_ids, "attention_mask": attention_mask, "use_cache": False} + if "logits_to_keep" in self.model_kwarg_keys: + model_inputs["logits_to_keep"] = logits_to_keep + 1 + logits = model(**model_inputs).logits + logits = logits[:, :-1, :] + logits = logits[:, -logits_to_keep:, :] + + # Standard cross-entropy loss: -log p(y_t | x, y None: + mode = "train" if self.model.training else "eval" + metrics = {} + for key, val in self._metrics[mode].items(): + valid = [v for v in val if not math.isnan(v)] + metrics[key] = sum(valid) / len(valid) if valid else None + + # When called in evaluation, the keys in `logs` start with "eval_". We need to add the prefix "eval_" to the + # keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e07ec04eb1b9f4d8a0cfeef4b64460f3c991c1fc --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .tpo_config import TPOConfig +from .tpo_trainer import TPOTrainer + + +__all__ = ["TPOConfig", "TPOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo.py new file mode 100644 index 0000000000000000000000000000000000000000..e755ecf1a08150f99ee54373db4331f343b45ba8 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo.py @@ -0,0 +1,215 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl[peft]", +# "trackio", +# "kernels", +# ] +# /// + +""" +Triple Preference Optimization (TPO) training. + +TPO requires a *triple-preference* dataset where each example contains a `chosen`, a `rejected` and a `reference` +(gold) completion for the same prompt. Two dataset paths are supported out of the box: + +- Use the published + [`tpo-alignment/triple-preference-ultrafeedback-40K`](https://huggingface.co/datasets/tpo-alignment/triple-preference-ultrafeedback-40K) + dataset directly. It already has the `prompt` / `reference` / `chosen` / `rejected` schema. +- Pass `--dataset_name openbmb/UltraFeedback` and the script automatically builds the triple-preference dataset as + described in the TPO paper (Saeidi et al., 2025): the response with the highest `overall_score` becomes `reference`, + the second-highest becomes `chosen`, and the lowest becomes `rejected`. + +In both cases, if the dataset is in standard (plain-string) format it is auto-wrapped into the conversational format so +that the model's chat template is applied — this matches how Instruct models like `Qwen/Qwen3-0.6B` are trained. + +Usage: + +Full training: + +```bash +python trl/experimental/tpo/tpo.py \ + --dataset_name tpo-alignment/triple-preference-ultrafeedback-40K \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --learning_rate 5e-7 \ + --gradient_accumulation_steps 8 \ + --beta 0.01 \ + --tpo_alpha 1.0 \ + --output_dir Qwen3-0.6B-TPO \ + --no_remove_unused_columns +``` + +TPO-L (length-normalized variant with target reward margin): + +```bash +python trl/experimental/tpo/tpo.py \ + --dataset_name tpo-alignment/triple-preference-ultrafeedback-40K \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --learning_rate 5e-7 \ + --gradient_accumulation_steps 8 \ + --beta 0.01 \ + --tpo_alpha 1.0 \ + --loss_type tpo-l \ + --tpo_l_gamma 0.5 \ + --output_dir Qwen3-0.6B-TPO-L \ + --no_remove_unused_columns +``` + +LoRA: + +```bash +python trl/experimental/tpo/tpo.py \ + --dataset_name tpo-alignment/triple-preference-ultrafeedback-40K \ + --model_name_or_path Qwen/Qwen3-0.6B \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --learning_rate 5e-6 \ + --gradient_accumulation_steps 8 \ + --output_dir Qwen3-0.6B-TPO-LoRA \ + --no_remove_unused_columns \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 +``` +""" + +import torch +from datasets import load_dataset +from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser + +from trl import ModelConfig, ScriptArguments, get_kbit_device_map, get_peft_config, get_quantization_config +from trl.experimental.tpo import TPOConfig, TPOTrainer + + +def build_triple_preference_from_ultrafeedback(example): + """ + Build a TPO triple-preference example from a raw UltraFeedback row. + + Following the TPO paper (Saeidi et al., 2025), completions are sorted by `overall_score` and we pick: + - the highest-scored response as the gold `reference`, + - the second-highest as `chosen`, + - the lowest as `rejected`. + + Emits the *conversational* format so that [`TPOTrainer`] applies the model's chat template automatically (see + `trl.data_utils.is_conversational`). Completions with a missing `overall_score` or `response` are filtered out; if + fewer than 3 valid completions remain, the returned example contains `None` values and should be filtered out + downstream. + """ + scored = [c for c in example["completions"] if c.get("overall_score") is not None and c.get("response")] + if len(scored) < 3: + return {"prompt": None, "reference": None, "chosen": None, "rejected": None} + scored.sort(key=lambda c: c["overall_score"], reverse=True) + return { + "prompt": [{"role": "user", "content": example["instruction"]}], + "reference": [{"role": "assistant", "content": scored[0]["response"]}], + "chosen": [{"role": "assistant", "content": scored[1]["response"]}], + "rejected": [{"role": "assistant", "content": scored[-1]["response"]}], + } + + +def to_conversational(example): + """ + Wrap a standard-format triple-preference example (plain strings) in the *conversational* format, so that + [`TPOTrainer`] applies the model's chat template automatically. This is the format expected by Instruct models; for + non-Instruct base models the standard format can be used directly. + """ + return { + "prompt": [{"role": "user", "content": example["prompt"]}], + "reference": [{"role": "assistant", "content": example["reference"]}], + "chosen": [{"role": "assistant", "content": example["chosen"]}], + "rejected": [{"role": "assistant", "content": example["rejected"]}], + } + + +if __name__ == "__main__": + parser = HfArgumentParser((ScriptArguments, TPOConfig, ModelConfig)) + script_args, training_args, model_args = parser.parse_args_into_dataclasses() + + ################ + # Model & Tokenizer + ################ + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + ################ + # Dataset + ################ + dataset = load_dataset(script_args.dataset_name, name=script_args.dataset_config) + + # Auto-build the triple-preference schema from raw UltraFeedback. + first_example = next(iter(dataset[script_args.dataset_train_split])) + if "completions" in first_example and "instruction" in first_example: + dataset = dataset.map( + build_triple_preference_from_ultrafeedback, + remove_columns=list(first_example.keys()), + ) + dataset = dataset.filter(lambda ex: ex["reference"] is not None) + first_example = next(iter(dataset[script_args.dataset_train_split])) + + # Auto-wrap standard-format triple-preference data (plain strings) into conversational messages so the + # model's chat template gets applied. This matches how Instruct models are trained and is what the TPO + # paper's data preparation produces. + if {"prompt", "chosen", "rejected", "reference"}.issubset(first_example) and isinstance( + first_example["prompt"], str + ): + dataset = dataset.map(to_conversational) + + ################ + # Training + ################ + trainer = TPOTrainer( + model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + # train and save the model + trainer.train() + + # Run a final evaluation pass and persist the metrics + if training_args.eval_strategy != "no": + metrics = trainer.evaluate() + trainer.log_metrics("eval", metrics) + trainer.save_metrics("eval", metrics) + + # Save and push to hub + trainer.save_model(training_args.output_dir) + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..f2b4c4a30fa5a61bdcb9afab1c328697e876bdfe --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo_config.py @@ -0,0 +1,163 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field +from typing import Any + +from ...trainer.base_config import _BaseConfig + + +@dataclass +class TPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`experimental.tpo.TPOTrainer`]. + + This class includes only the parameters that are specific to TPO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`experimental.tpo.TPOTrainer`] is provided as a string. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + + > Parameters that control the data preprocessing + + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from the left or + right depending on the `truncation_mode`. If `None`, no truncation is applied. + truncation_mode (`str`, *optional*, defaults to `"keep_start"`): + Truncation mode to use when the sequence exceeds `max_length`. Possible values are `"keep_start"` and + `"keep_end"`. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + + > Parameters that control the training + + loss_type (`str`, *optional*, defaults to `"sigmoid"`): + Type of loss to use. Possible values are: + + - `"sigmoid"`: sigmoid loss from the original [TPO](https://huggingface.co/papers/2405.16681) paper. + - `"hinge"`: hinge loss on the normalized likelihood from the + [SLiC](https://huggingface.co/papers/2305.10425) paper. + - `"ipo"`: IPO loss from the [IPO](https://huggingface.co/papers/2310.12036) paper. + - `"tpo-l"`: length-normalized TPO variant from the + [TPO](https://huggingface.co/papers/2405.16681) paper, which adds a target reward margin + `tpo_l_gamma` to the Bradley-Terry objective. + + beta (`float`, *optional*, defaults to `0.01`): + Parameter controlling the temperature of the TPO loss. For the IPO loss (`loss_type="ipo"`), β is the + regularization parameter denoted by τ in the [paper](https://huggingface.co/papers/2310.12036). + label_smoothing (`float`, *optional*, defaults to `0.0`): + Label smoothing factor. + tpo_alpha (`float`, *optional*, defaults to `1.0`): + Weight of the supervised negative log-likelihood term computed on the gold (`reference`) response in TPO + training. Setting `tpo_alpha=0.0` disables the NLL term and skips the corresponding forward pass. + tpo_l_gamma (`float`, *optional*, defaults to `0.5`): + Target reward margin γ for the TPO-L loss, used only when `loss_type="tpo-l"`. + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `5e-7` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=5e-7, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument of " + "the `TPOTrainer` is provided as a string." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model."}, + ) + + # Parameters that control the data preprocessing + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + max_length: int | None = field( + default=1024, + metadata={ + "help": "Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from " + "the left or right depending on the `truncation_mode`. If `None`, no truncation is applied." + }, + ) + truncation_mode: str = field( + default="keep_start", + metadata={ + "help": "Truncation mode to use when the sequence exceeds `max_length`.", + "choices": ["keep_end", "keep_start"], + }, + ) + pad_to_multiple_of: int | None = field( + default=None, + metadata={"help": "If set, the sequences will be padded to a multiple of this value."}, + ) + + # Parameters that control the training + loss_type: str = field( + default="sigmoid", + metadata={ + "help": "Type of loss to use.", + "choices": ["sigmoid", "hinge", "ipo", "tpo-l"], + }, + ) + beta: float = field( + default=0.01, + metadata={ + "help": "Parameter controlling the temperature of the TPO loss. For the IPO loss (`loss_type='ipo'`), this " + "value is the regularization parameter denoted by τ in the IPO paper." + }, + ) + label_smoothing: float = field( + default=0.0, + metadata={"help": "Label smoothing factor."}, + ) + tpo_alpha: float = field( + default=1.0, + metadata={ + "help": "Weight of the supervised NLL term computed on the gold (`reference`) response in TPO training. " + "Setting `tpo_alpha=0.0` disables the NLL term and skips the corresponding forward pass." + }, + ) + tpo_l_gamma: float = field( + default=0.5, + metadata={"help": "Target reward margin γ for the TPO-L loss, used only when `loss_type='tpo-l'`."}, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..544c0674cca3ba79286174c4e563e4c259700780 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/tpo/tpo_trainer.py @@ -0,0 +1,777 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import textwrap +from collections import defaultdict +from collections.abc import Callable +from dataclasses import dataclass +from pathlib import Path +from typing import Any + +import torch +import torch.nn.functional as F +import transformers +from accelerate import PartialState +from accelerate.logging import get_logger +from accelerate.utils import is_peft_model +from datasets import Dataset, IterableDataset +from packaging.version import Version +from transformers import ( + AutoProcessor, + DataCollator, + PreTrainedModel, + PreTrainedTokenizerBase, +) +from transformers.data.data_collator import DataCollatorMixin +from transformers.trainer_callback import TrainerCallback +from transformers.trainer_utils import EvalPrediction +from transformers.utils import is_peft_available + +from ...data_utils import extract_prompt, is_conversational +from ...trainer.base_trainer import _BaseTrainer +from ...trainer.utils import ( + create_model_from_path, + disable_dropout_in_model, + entropy_from_logits, + get_config_model_id, + pad, + selective_log_softmax, +) +from .tpo_config import TPOConfig + + +if is_peft_available(): + from peft import PeftConfig, PeftModel, get_peft_model + + +logger = get_logger(__name__) + + +def _extract_triple_prompt(example: dict) -> dict: + """Extract the shared prompt from `chosen`/`rejected` and also strip it from `reference`. + + Wraps [`~trl.data_utils.extract_prompt`] — which only rewrites `chosen` and `rejected` — and additionally strips + the extracted prompt prefix from the `reference` (gold) completion. This is specific to TPO and assumes that the + `reference` completion shares the same implicit prompt prefix as `chosen` and `rejected`. If it does not, a + `ValueError` is raised asking the caller to provide an explicit `prompt` column. + """ + extracted = extract_prompt(example) + prompt = extracted["prompt"] + reference = example["reference"] + if reference[: len(prompt)] != prompt: + raise ValueError( + "The `reference` completion does not start with the implicit prompt extracted from `chosen`/`rejected`. " + "Either provide an explicit `prompt` column, or make sure the `reference` completion shares the same " + "prompt prefix as the `chosen` and `rejected` completions." + ) + extracted["reference"] = reference[len(prompt) :] + return extracted + + +@dataclass +class DataCollatorForTriplePreference(DataCollatorMixin): + """ + Data collator used for triple-preference data. Inputs are dynamically padded to the maximum length of a batch. + + This collator expects each example in the input list to be a dictionary containing the keys `"prompt_ids"`, + `"chosen_ids"` and `"rejected_ids"`. When `include_reference=True` (the default) each example must additionally + contain `"reference_ids"`. The collator returns a dictionary containing the following keys: + - `"input_ids"`: Tensor of input IDs, padded to the maximum length of the batch. When + `include_reference=True`, the first third of the batch corresponds to the `"chosen_ids"`, the second third to + the `"rejected_ids"` and the last third to the `"reference_ids"`. When `include_reference=False`, the first + half corresponds to the `"chosen_ids"` and the second half to the `"rejected_ids"` (matching the layout of + [`~trl.trainer.dpo_trainer.DataCollatorForPreference`]). + - `"attention_mask"`: Tensor of attention mask, padded to the maximum length of the batch. + - `"completion_mask"`: Tensor indicating the positions of the completion tokens, padded to the maximum length of + the batch. + + Args: + pad_token_id (`int`): + Token ID to use for padding. + max_length (`int`, *optional*): + Maximum length of the sequences after concatenation. Sequences longer than `max_length` are truncated + before padding, which avoids allocating oversized tensors for batches containing very long sequences. + truncation_mode (`str`, *optional*, defaults to `"keep_start"`): + Truncation mode when a concatenated sequence exceeds `max_length`. Possible values are `"keep_end"` and + `"keep_start"`. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + return_tensors (`str`, *optional*, defaults to `"pt"`): + Type of Tensor to return. Only `"pt"` is currently supported. + include_reference (`bool`, *optional*, defaults to `True`): + Whether to include the `"reference_ids"` branch in the collated batch. When `False`, the collator emits + only the chosen/rejected halves and skips the gold-response sequences entirely, which matches the behavior + expected when `tpo_alpha=0.0` (no NLL term). + + Examples: + ```python + >>> from trl.experimental.tpo.tpo_trainer import DataCollatorForTriplePreference + + >>> collator = DataCollatorForTriplePreference(pad_token_id=0) + >>> examples = [ + ... {"prompt_ids": [1, 2, 3], "chosen_ids": [4, 5], "rejected_ids": [6], "reference_ids": [7, 8]}, + ... {"prompt_ids": [9, 10], "chosen_ids": [11], "rejected_ids": [12, 13], "reference_ids": [14]}, + ... ] + >>> collator(examples) + {'input_ids': tensor([[ 1, 2, 3, 4, 5], + [ 9, 10, 11, 0, 0], + [ 1, 2, 3, 6, 0], + [ 9, 10, 12, 13, 0], + [ 1, 2, 3, 7, 8], + [ 9, 10, 14, 0, 0]]), + 'attention_mask': tensor([[1, 1, 1, 1, 1], + [1, 1, 1, 0, 0], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 1], + [1, 1, 1, 0, 0]]), + 'completion_mask': tensor([[0, 0, 0, 1, 1], + [0, 0, 1, 0, 0], + [0, 0, 0, 1, 0], + [0, 0, 1, 1, 0], + [0, 0, 0, 1, 1], + [0, 0, 1, 0, 0]])} + ``` + """ + + pad_token_id: int + max_length: int | None = None + truncation_mode: str = "keep_start" + pad_to_multiple_of: int | None = None + return_tensors: str = "pt" + include_reference: bool = True + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + prompt_chosen_ids = [example["prompt_ids"] + example["chosen_ids"] for example in examples] + prompt_rejected_ids = [example["prompt_ids"] + example["rejected_ids"] for example in examples] + chosen_mask = [[0] * len(example["prompt_ids"]) + [1] * len(example["chosen_ids"]) for example in examples] + rejected_mask = [[0] * len(example["prompt_ids"]) + [1] * len(example["rejected_ids"]) for example in examples] + if self.include_reference: + prompt_reference_ids = [example["prompt_ids"] + example["reference_ids"] for example in examples] + reference_mask = [ + [0] * len(example["prompt_ids"]) + [1] * len(example["reference_ids"]) for example in examples + ] + + if self.max_length is not None: + if self.truncation_mode == "keep_start": + sl = slice(None, self.max_length) + elif self.truncation_mode == "keep_end": + sl = slice(-self.max_length, None) + else: + raise ValueError( + f"Unsupported truncation mode: {self.truncation_mode}, expected 'keep_start' or 'keep_end'" + ) + prompt_chosen_ids = [ids[sl] for ids in prompt_chosen_ids] + prompt_rejected_ids = [ids[sl] for ids in prompt_rejected_ids] + chosen_mask = [m[sl] for m in chosen_mask] + rejected_mask = [m[sl] for m in rejected_mask] + if self.include_reference: + prompt_reference_ids = [ids[sl] for ids in prompt_reference_ids] + reference_mask = [m[sl] for m in reference_mask] + + chosen_attention_mask = [[1] * len(ids) for ids in prompt_chosen_ids] + rejected_attention_mask = [[1] * len(ids) for ids in prompt_rejected_ids] + input_ids = prompt_chosen_ids + prompt_rejected_ids + attention_mask = chosen_attention_mask + rejected_attention_mask + completion_mask = chosen_mask + rejected_mask + if self.include_reference: + reference_attention_mask = [[1] * len(ids) for ids in prompt_reference_ids] + input_ids = input_ids + prompt_reference_ids + attention_mask = attention_mask + reference_attention_mask + completion_mask = completion_mask + reference_mask + + # Convert to tensor + input_ids = [torch.tensor(ids) for ids in input_ids] + attention_mask = [torch.tensor(m, dtype=torch.long) for m in attention_mask] + completion_mask = [torch.tensor(m, dtype=torch.long) for m in completion_mask] + + # Pad + output = {} + output["input_ids"] = pad( + input_ids, + padding_value=self.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + output["attention_mask"] = pad( + attention_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + output["completion_mask"] = pad( + completion_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + return output + + +class TPOTrainer(_BaseTrainer): + """ + Trainer for Triple Preference Optimization (TPO) method. This algorithm was initially proposed in the paper [Triple + Preference Optimization: Achieving Better Alignment using a Single Step + Optimization](https://huggingface.co/papers/2405.16681). This class is a wrapper around the + [`~transformers.Trainer`] class and inherits all of its attributes and methods. + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + args ([`experimental.tpo.TPOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + data_collator ([`~transformers.DataCollator`], *optional*): + Function to use to form a batch from a list of elements of the processed `train_dataset` or `eval_dataset`. + Will default to [`~trl.experimental.tpo.tpo_trainer.DataCollatorForTriplePreference`]. Custom collators + must truncate sequences before padding; the trainer does not apply post-collation truncation. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. TPO requires a *triple-preference* dataset: each sample must contain a + `"chosen"`, a `"rejected"` and a `"reference"` (gold) completion. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], *optional*): + Processing class used to process the data. If `None`, the processing class is loaded from the model's name + with [`~transformers.AutoProcessor.from_pretrained`]. A padding token, `tokenizer.pad_token`, must be set. + If the processing class has not set a padding token, `tokenizer.eos_token` will be used as the default. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function that will be used to compute metrics at evaluation. Must take a + [`~transformers.EvalPrediction`] and return a dictionary string to metric values. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + """ + + _tag_names = ["trl", "tpo"] + _name = "TPO" + _paper = { + "title": "Triple Preference Optimization: Achieving Better Alignment using a Single Step Optimization", + "id": "2405.16681", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @misc{saeidi2025triplepreferenceoptimizationachieving, + title = {{Triple Preference Optimization: Achieving Better Alignment using a Single Step Optimization}}, + author = {Amir Saeidi and Shivanshu Verma and Aswin RRV and Kashif Rasul and Chitta Baral}, + year = 2025, + eprint = {2405.16681}, + archivePrefix= {arXiv}, + primaryClass = {cs.CL}, + url = {https://arxiv.org/abs/2405.16681}, + }"""), + } + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + args: TPOConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: "PeftConfig | None" = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = TPOConfig(f"{model_name}-TPO") + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif isinstance(train_dataset, IterableDataset): + # IterableDataset requires dispatch_batches=False because Accelerate's dispatch mode may try to concatenate + # batches from multiple processes, leading to mismatch errors. + if args.accelerator_config.dispatch_batches is True: + logger.warning( + "You are using an `IterableDataset` for training with `dispatch_batches=True`. `dispatch_batches` " + "is forced to `False` when using an `IterableDataset`. To remove this warning, unset " + "`dispatch_batches` in `TPOConfig` or set it to `False`." + ) + args.accelerator_config.dispatch_batches = False + + # Model + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the `TPOConfig`, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + + # Processing class + if processing_class is None: + processing_class = AutoProcessor.from_pretrained(get_config_model_id(model.config)) + if not isinstance(processing_class, PreTrainedTokenizerBase): + raise TypeError( + "The `processing_class` must be a `PreTrainedTokenizerBase`. `TPOTrainer` does not currently " + "support vision-language models." + ) + tokenizer = processing_class + + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + + # Create PEFT model + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # When using gradient checkpointing with PEFT, we need to enable input gradients. transformers.Trainer normally + # handles this, but a bug currently prevents it; see https://github.com/huggingface/transformers/issues/42489 + if is_peft_available() and isinstance(model, PeftModel) and args.gradient_checkpointing: + model.enable_input_require_grads() + + # Data collator. When `tpo_alpha=0.0`, the NLL term on the gold response is disabled, so we can drop the + # reference branch from the batch entirely — this spares the model from computing logits for a third of + # each step. + if data_collator is None: + data_collator = DataCollatorForTriplePreference( + pad_token_id=tokenizer.pad_token_id, + max_length=args.max_length, + truncation_mode=args.truncation_mode, + pad_to_multiple_of=args.pad_to_multiple_of, + include_reference=args.tpo_alpha != 0.0, + ) + + # Training arguments + self.beta = args.beta + self.loss_type = args.loss_type + self.label_smoothing = args.label_smoothing + self.tpo_alpha = args.tpo_alpha + self.tpo_l_gamma = args.tpo_l_gamma + if self.loss_type in ["hinge", "ipo"] and self.label_smoothing > 0: + logger.warning( + f"You are using the {self.loss_type} loss type that does not support label smoothing. The " + "`label_smoothing` parameter will be ignored. Set `label_smoothing` to `0.0` to remove this warning." + ) + + # Dataset + train_dataset = self._prepare_dataset(train_dataset, processing_class, args, "train") + if eval_dataset is not None: + if isinstance(eval_dataset, dict): + eval_dataset = { + key: self._prepare_dataset(dataset, processing_class, args, key) + for key, dataset in eval_dataset.items() + } + else: + eval_dataset = self._prepare_dataset(eval_dataset, processing_class, args, "eval") + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + ) + + # Disable dropout in the model + if args.disable_dropout: + disable_dropout_in_model(model) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + def _tokenize( + self, + processing_class: PreTrainedTokenizerBase, + input: str | list, + **kwargs, + ) -> dict[str, list]: + """Tokenize a single example for dataset preprocessing. + + Dispatches to `apply_chat_template` for conversational input (list of message dicts) and to `__call__` for + non-conversational input (str). + + Args: + processing_class ([`~transformers.PreTrainedTokenizerBase`]): + The tokenizer to use. + input (`str` or `list`): + A string for non-conversational input, or a list of message dicts for conversational input. + **kwargs: + Forwarded to `apply_chat_template` (e.g. `add_generation_prompt`). + + Returns: + `dict` with at least an `"input_ids"` key mapping to a flat `list[int]`. + """ + if isinstance(input, list): # conversational: list of message dicts + return processing_class.apply_chat_template(input, tokenize=True, return_dict=True, **kwargs) + # non-conversational: plain text string + return processing_class(text=input) + + def _prepare_dataset( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase, + args: TPOConfig, + dataset_name: str, + ) -> Dataset | IterableDataset: + # Validate that the triple-preference columns are present + first_example = next(iter(dataset)) + if "chosen" not in first_example or "rejected" not in first_example: + raise ValueError( + "TPO requires a triple-preference dataset with `chosen`, `rejected` and `reference` columns, but the " + f"dataset is missing `chosen` or `rejected`. Got columns: {list(first_example.keys())}." + ) + if "reference" not in first_example: + raise ValueError( + "TPO requires a triple-preference dataset with `chosen`, `rejected` and `reference` columns, but the " + f"dataset is missing the `reference` (gold) column. Got columns: {list(first_example.keys())}." + ) + + # Build the kwargs for the `map` function + map_kwargs = {} + if isinstance(dataset, Dataset): # IterableDataset does not support num_proc + map_kwargs["num_proc"] = args.dataset_num_proc + + with PartialState().main_process_first(): + # Extract the prompt if needed. Unlike DPO, we must also strip the extracted prompt from the reference + # column (see `_extract_triple_prompt`), which assumes the reference shares the same implicit prompt. + first_example = next(iter(dataset)) + if "prompt" not in first_example: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Extracting prompt from {dataset_name} dataset" + dataset = dataset.map(_extract_triple_prompt, **map_kwargs) + + # Add EOS to completions for non-conversational data + first_example = next(iter(dataset)) + if not is_conversational(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Adding EOS to {dataset_name} dataset" + + def add_eos(example, eos_token): + if not example["chosen"].endswith(eos_token): + example["chosen"] = example["chosen"] + eos_token + if not example["rejected"].endswith(eos_token): + example["rejected"] = example["rejected"] + eos_token + if not example["reference"].endswith(eos_token): + example["reference"] = example["reference"] + eos_token + return example + + dataset = dataset.map(add_eos, fn_kwargs={"eos_token": processing_class.eos_token}, **map_kwargs) + + # Tokenize the dataset + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Tokenizing {dataset_name} dataset" + + def tokenize_fn(example, processing_class): + tools = example.get("tools") + tools = json.loads(tools) if isinstance(tools, str) else tools + output = {} + if is_conversational(example): + prompt_ids = self._tokenize( + processing_class, + example["prompt"], + tools=tools, + add_generation_prompt=True, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + prompt_chosen_ids = self._tokenize( + processing_class, + example["prompt"] + example["chosen"], + tools=tools, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + prompt_rejected_ids = self._tokenize( + processing_class, + example["prompt"] + example["rejected"], + tools=tools, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + prompt_reference_ids = self._tokenize( + processing_class, + example["prompt"] + example["reference"], + tools=tools, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + else: + prompt_ids = self._tokenize(processing_class, example["prompt"])["input_ids"] + prompt_chosen_ids = self._tokenize(processing_class, example["prompt"] + example["chosen"])[ + "input_ids" + ] + prompt_rejected_ids = self._tokenize(processing_class, example["prompt"] + example["rejected"])[ + "input_ids" + ] + prompt_reference_ids = self._tokenize(processing_class, example["prompt"] + example["reference"])[ + "input_ids" + ] + + # Check if the tokenized prompt starts with the tokenized prompt+completion + if not prompt_chosen_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+chosen. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + if not prompt_rejected_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+rejected. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + if not prompt_reference_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+reference. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + + output["prompt_ids"] = prompt_ids + output["chosen_ids"] = prompt_chosen_ids[len(prompt_ids) :] + output["rejected_ids"] = prompt_rejected_ids[len(prompt_ids) :] + output["reference_ids"] = prompt_reference_ids[len(prompt_ids) :] + return output + + dataset = dataset.map(tokenize_fn, fn_kwargs={"processing_class": processing_class}, **map_kwargs) + + return dataset + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). + if self._signature_columns is None: + self._signature_columns = ["prompt_ids", "chosen_ids", "rejected_ids", "reference_ids"] + + def _compute_loss(self, model, inputs, return_outputs): + mode = "train" if self.model.training else "eval" + + # When `tpo_alpha=0.0` the NLL term is disabled and the collator drops the reference branch, so the batch + # is laid out as `[chosen, rejected]` (n_branches=2). Otherwise it is `[chosen, rejected, reference]` + # (n_branches=3). + n_branches = 3 if self.tpo_alpha != 0.0 else 2 + + _non_model_keys = {"completion_mask"} + model_kwargs = {k: v for k, v in inputs.items() if k not in _non_model_keys} + model_kwargs["use_cache"] = False + outputs = model(**model_kwargs) + + input_ids = inputs["input_ids"] + completion_mask = inputs["completion_mask"] + shift_logits = outputs.logits[..., :-1, :].contiguous() + shift_labels = input_ids[..., 1:].contiguous() + shift_completion_mask = completion_mask[..., 1:].contiguous() + per_token_logps = selective_log_softmax(shift_logits, shift_labels) + per_token_logps[shift_completion_mask == 0] = 0.0 # mask out non-completion tokens + + # Length-normalized for IPO and TPO-L (matches the SimPO-style implicit reward used by the TPO paper); + # summed otherwise. + if self.loss_type in ("ipo", "tpo-l"): + completion_lengths = shift_completion_mask.sum(dim=1).clamp(min=1) + logps = per_token_logps.sum(dim=1) / completion_lengths + else: + logps = per_token_logps.sum(dim=1) + logps_chunks = logps.chunk(n_branches, dim=0) + chosen_logps, rejected_logps = logps_chunks[0], logps_chunks[1] + + # Contrastive loss between chosen and rejected. Unlike DPO, TPO does not subtract reference-model log-probs: + # the "reference" in TPO is a gold response used in the NLL term below, not a separate reference policy. + delta_score = chosen_logps - rejected_logps + + if self.loss_type == "sigmoid": + per_sequence_loss = ( + -F.logsigmoid(self.beta * delta_score) * (1 - self.label_smoothing) + - F.logsigmoid(-self.beta * delta_score) * self.label_smoothing + ) + + elif self.loss_type == "hinge": + per_sequence_loss = torch.relu(1 - self.beta * delta_score) + + elif self.loss_type == "ipo": + # (Eq. 17) of the IPO paper where beta is the regularization parameter for the IPO loss, denoted by τ. + per_sequence_loss = (delta_score - 1 / (2 * self.beta)) ** 2 + + elif self.loss_type == "tpo-l": + # Length-normalized TPO-L variant: subtract a target reward margin γ/β before the sigmoid. + gamma_logratios = self.tpo_l_gamma / self.beta + shifted_delta = delta_score - gamma_logratios + per_sequence_loss = ( + -F.logsigmoid(self.beta * shifted_delta) * (1 - self.label_smoothing) + - F.logsigmoid(-self.beta * shifted_delta) * self.label_smoothing + ) + + else: + raise ValueError( + f"Unknown loss type: {self.loss_type}. Should be one of ['sigmoid', 'hinge', 'ipo', 'tpo-l']" + ) + + loss = per_sequence_loss.mean() + + # NLL loss on the gold (`reference`) response. Mirrors the `"sft"` loss branch of `DPOTrainer._compute_loss`: + # we restrict the cross-entropy to the completion tokens of the reference sequence and let `F.cross_entropy` + # average over them. The NLL contribution is folded into the main `loss` (matching DPO/SFT convention: the + # individual NLL term is not logged separately). + if n_branches == 3: + _, _, ref_logits = shift_logits.chunk(3, dim=0) + _, _, ref_labels = shift_labels.chunk(3, dim=0) + _, _, ref_mask = shift_completion_mask.chunk(3, dim=0) + ref_mask = ref_mask.bool() + nll_loss = F.cross_entropy(ref_logits[ref_mask], ref_labels[ref_mask]) + loss = loss + self.tpo_alpha * nll_loss + + # Log the metrics + # Entropy + per_token_entropy = entropy_from_logits(shift_logits.detach()) + entropy = per_token_entropy[shift_completion_mask.bool()].mean() + entropy = self.accelerator.gather_for_metrics(entropy).mean().item() + self._metrics[mode]["entropy"].append(entropy) + + # Number of tokens + if mode == "train": + num_tokens_in_batch = self.accelerator.gather_for_metrics(inputs["attention_mask"].sum()).sum().item() + self._total_train_tokens += num_tokens_in_batch + self._metrics[mode]["num_tokens"] = [self._total_train_tokens] + + # Average logits for chosen and rejected completions + logits_chunks = shift_logits.detach().chunk(n_branches, dim=0) + mask_chunks = shift_completion_mask.chunk(n_branches, dim=0) + labels_chunks = shift_labels.chunk(n_branches, dim=0) + chosen_logits, rejected_logits = logits_chunks[0], logits_chunks[1] + chosen_mask, rejected_mask = mask_chunks[0], mask_chunks[1] + chosen_labels = labels_chunks[0] + total_chosen_logits = chosen_logits[chosen_mask.bool()].mean(-1).sum() + total_chosen_tokens = chosen_mask.sum() + total_rejected_logits = rejected_logits[rejected_mask.bool()].mean(-1).sum() + total_rejected_tokens = rejected_mask.sum() + total_chosen_logits = self.accelerator.gather_for_metrics(total_chosen_logits).sum().item() + total_chosen_tokens = self.accelerator.gather_for_metrics(total_chosen_tokens).sum().item() + total_rejected_logits = self.accelerator.gather_for_metrics(total_rejected_logits).sum().item() + total_rejected_tokens = self.accelerator.gather_for_metrics(total_rejected_tokens).sum().item() + avg_chosen_logits = total_chosen_logits / total_chosen_tokens if total_chosen_tokens > 0 else 0.0 + avg_rejected_logits = total_rejected_logits / total_rejected_tokens if total_rejected_tokens > 0 else 0.0 + self._metrics[mode]["logits/chosen"].append(avg_chosen_logits) + self._metrics[mode]["logits/rejected"].append(avg_rejected_logits) + + # Token accuracy for the chosen completions + predictions = chosen_logits.argmax(dim=-1) + chosen_bool_mask = chosen_mask.bool() + correct_predictions = (predictions == chosen_labels) & chosen_bool_mask + total_tokens = chosen_bool_mask.sum() + correct_tokens = correct_predictions.sum() + correct_tokens = self.accelerator.gather_for_metrics(correct_tokens) + total_tokens = self.accelerator.gather_for_metrics(total_tokens) + total_sum = total_tokens.sum() + accuracy = (correct_tokens.sum() / total_sum).item() if total_sum > 0 else 0.0 + self._metrics[mode]["mean_token_accuracy"].append(accuracy) + + # Rewards for chosen and rejected completions (β · log π_θ as in the SimPO/TPO implicit reward) + chosen_rewards = self.beta * chosen_logps.detach() + rejected_rewards = self.beta * rejected_logps.detach() + agg_chosen_rewards = self.accelerator.gather(chosen_rewards) + agg_rejected_rewards = self.accelerator.gather(rejected_rewards) + self._metrics[mode]["rewards/chosen"].append(agg_chosen_rewards.mean().item()) + self._metrics[mode]["rewards/rejected"].append(agg_rejected_rewards.mean().item()) + + # Reward accuracy + reward_accuracies = (chosen_rewards > rejected_rewards).float() + agg_reward_accuracies = self.accelerator.gather(reward_accuracies) + self._metrics[mode]["rewards/accuracies"].append(agg_reward_accuracies.mean().item()) + + # Reward margins + margins = chosen_rewards - rejected_rewards + agg_margins = self.accelerator.gather(margins) + self._metrics[mode]["rewards/margins"].append(agg_margins.mean().item()) + + # Average log probabilities for chosen and rejected completions + self._metrics[mode]["logps/chosen"].append(self.accelerator.gather(chosen_logps).mean().item()) + self._metrics[mode]["logps/rejected"].append(self.accelerator.gather(rejected_logps).mean().item()) + + return (loss, outputs) if return_outputs else loss + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + return self._compute_loss(model, inputs, return_outputs) + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + metrics = {key: sum(val) / len(val) for key, val in self._metrics[mode].items()} # average the metrics + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + # During eval, Trainer calls prediction_step. If no labels are present in the inputs, it only runs forward and + # returns logits. We override prediction_step to force compute_loss, because this trainer doesn't involve labels. + def prediction_step(self, model, inputs, prediction_loss_only, ignore_keys: list[str] | None = None): + inputs = self._prepare_inputs(inputs) + with torch.no_grad(), self.compute_loss_context_manager(): + if prediction_loss_only: + loss = self.compute_loss(model, inputs, return_outputs=False) + logits, labels = None, None + else: + loss, outputs = self.compute_loss(model, inputs, return_outputs=True) + logits, labels = outputs.logits, inputs["input_ids"] + return loss, logits, labels + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..e8e2353c0c78601e38adb0e4579d15adc8d10e43 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/utils.py @@ -0,0 +1,696 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file contains utility classes and functions that are used across more than one experimental trainer or feature. + +import inspect +import logging +from copy import deepcopy +from dataclasses import dataclass +from typing import Any + +import pyarrow as pa +import pyarrow.types +import torch +from accelerate.utils import is_peft_model +from packaging.version import Version +from pyarrow import compute as pc +from torch import nn +from torch.nn.utils.rnn import pad_sequence +from transformers import PreTrainedModel, PreTrainedTokenizerBase, TrainingArguments +from transformers.integrations.deepspeed import is_deepspeed_zero3_enabled +from transformers.utils import ( + is_peft_available, + is_torch_mlu_available, + is_torch_npu_available, + is_torch_xpu_available, +) + +from ..data_utils import DatasetType, _get_dataset_format +from ..trainer.utils import pad + + +if is_peft_available(): + import peft + from peft import PeftConfig, PeftModel, get_peft_model + + +@dataclass +class DPODataCollatorWithPadding: + r""" + DPO DataCollator class that pads the tokenized inputs to the maximum length of the batch. + + Args: + pad_token_id (`int` defaults to 0): + The tokenizer's pad_token_id. + is_encoder_decoder (`bool` or `None`, `optional`, defaults to `None`): + Whether you model has an encoder_decoder architecture. + """ + + pad_token_id: int = 0 + is_encoder_decoder: bool | None = False + + def __call__(self, features: list[dict[str, Any]]) -> dict[str, Any]: + # first, pad everything to the same length + padded_batch = {} + for k in features[0].keys(): + if k.endswith(("_input_ids", "_attention_mask", "_labels", "_pixel_values")): + if self.is_encoder_decoder: + to_pad = [torch.LongTensor(ex[k]) for ex in features] + + if (k.startswith("prompt")) and (k.endswith("input_ids")): + if self.pad_token_id is None: + raise ValueError( + "Padding is enabled, but the tokenizer is not configured with a padding token." + " Explicitly set `tokenizer.pad_token` (e.g. `tokenizer.pad_token = tokenizer.eos_token`)" + " before calling the trainer." + ) + padding_value = self.pad_token_id + elif k.endswith("_attention_mask"): + padding_value = 0 + elif k.startswith(("chosen", "rejected", "completion")) or ("decoder" in k): + padding_value = -100 + else: + raise ValueError(f"Unexpected key in batch '{k}'") + padded_batch[k] = pad_sequence(to_pad, batch_first=True, padding_value=padding_value) + else: + # Set padding value based on the key + if k.endswith("_input_ids"): + if self.pad_token_id is None: + raise ValueError( + "Padding is enabled, but the tokenizer is not configured with a padding token." + " Explicitly set `tokenizer.pad_token` (e.g. `tokenizer.pad_token = tokenizer.eos_token`)" + " before calling the trainer." + ) + padding_value = self.pad_token_id + elif k.endswith("_labels"): + padding_value = -100 + elif k.endswith("_attention_mask"): + padding_value = 0 + elif k.endswith("_pixel_values"): + padding_value = 0 # TODO: check if this is correct + else: + raise ValueError(f"Unexpected key in batch '{k}'") + + # Set padding side based on the key + if k in ["prompt_input_ids", "prompt_attention_mask"]: + padding_side = "left" + else: + padding_side = "right" + + # Set the dtype + if k.endswith("_pixel_values"): + dtype = torch.float32 # will be downcasted if necessary by the Trainer + else: + dtype = torch.int64 + + # Convert to tensor and pad + to_pad = [torch.tensor(ex[k], dtype=dtype) for ex in features] + padded_batch[k] = pad(to_pad, padding_value=padding_value, padding_side=padding_side) + elif k.endswith("_logps"): + # the cached reference model logprobs + padded_batch[k] = torch.tensor([ex[k] for ex in features]) + else: + padded_batch[k] = [ex[k] for ex in features] + + return padded_batch + + +@dataclass +class DataCollatorForChatML: + """ + Data collator for ChatML format datasets. + """ + + tokenizer: PreTrainedTokenizerBase + ignore_index: int = -100 + max_length: int = None + prompt_key: str = "prompt" + messages_key: str = "messages" + + def __post_init__(self): + if self.tokenizer.pad_token_id is None: + raise ValueError("The tokenizer does not have a pad token. Please set `pad_token_id` in the tokenizer.") + if self.max_length is None: + # set a sensible default + self.max_length = min(self.tokenizer.model_max_length, 1024) + + def __call__(self, examples: list[dict[str, Any]]) -> dict[str, torch.Tensor]: + input_ids = [] + attention_mask = [] + prompts_input_ids = [] + prompt_attention_mask = [] + labels = [] + + for example in examples: + formatted_prompt = example.get(self.prompt_key, None) + if formatted_prompt is None: + prompt = example[self.messages_key][:-1] + formatted_prompt = self.tokenizer.apply_chat_template( + prompt, add_generation_prompt=True, tokenize=False + ) + + if "input_ids" not in example: + message = example[self.messages_key] + formatted_message = self.tokenizer.apply_chat_template( + message, add_generation_prompt=False, tokenize=False + ) + + tokenized_message = self.tokenizer( + formatted_message, + truncation=False, + padding=False, + return_tensors=None, + add_special_tokens=False, + return_offsets_mapping=True, + ) + message_input_ids_full = tokenized_message["input_ids"] + offsets = tokenized_message.get("offset_mapping") + + if offsets is not None: + prompt_char_len = len(formatted_prompt) + completion_start_idx_full = next( + (idx for idx, (start, _) in enumerate(offsets) if start >= prompt_char_len), + len(message_input_ids_full), + ) + else: + tokenized_prompt_full = self.tokenizer( + formatted_prompt, + truncation=False, + padding=False, + return_tensors=None, + add_special_tokens=False, + ) + completion_start_idx_full = len(tokenized_prompt_full["input_ids"]) + + prompt_tokens_full = message_input_ids_full[:completion_start_idx_full] + completion_input_ids_full = message_input_ids_full[completion_start_idx_full:] + + if self.max_length is not None and len(message_input_ids_full) > self.max_length: + completion_ids = completion_input_ids_full + if len(completion_ids) >= self.max_length: + completion_ids = completion_ids[-self.max_length :] + prompt_ids = [] + else: + max_prompt_tokens = self.max_length - len(completion_ids) + prompt_ids = prompt_tokens_full[-max_prompt_tokens:] if max_prompt_tokens > 0 else [] + message_input_ids = prompt_ids + completion_ids + else: + message_input_ids = message_input_ids_full + prompt_ids = prompt_tokens_full + + input_ids.append(message_input_ids) + attention_mask.append([1] * len(message_input_ids)) + current_prompt_ids = prompt_ids + else: + message_input_ids = example["input_ids"] + input_ids.append(message_input_ids) + if "attention_mask" in example: + attention_mask.append(example["attention_mask"]) + else: + attention_mask.append([1] * len(message_input_ids)) + + tokenized_prompt = self.tokenizer( + formatted_prompt, + truncation=True, + max_length=len(message_input_ids), + padding=False, + return_tensors=None, + add_special_tokens=False, + ) + current_prompt_ids = tokenized_prompt["input_ids"] + + prompts_input_ids.append(current_prompt_ids) + prompt_attention_mask.append([1] * len(current_prompt_ids)) + + label = [self.ignore_index] * len(input_ids[-1]) + completion_start_idx = len(current_prompt_ids) + label[completion_start_idx:] = input_ids[-1][completion_start_idx:] + labels.append(label) + + # convert to list of tensors and pad + input_ids = [torch.tensor(ids, dtype=torch.long) for ids in input_ids] + attention_mask = [torch.tensor(mask, dtype=torch.long) for mask in attention_mask] + labels = [torch.tensor(label, dtype=torch.long) for label in labels] + input_ids = pad(input_ids, padding_side="left", padding_value=self.tokenizer.pad_token_id) + attention_mask = pad(attention_mask, padding_side="left", padding_value=0) + labels = pad(labels, padding_side="left", padding_value=self.ignore_index) + + prompts_input_ids = [torch.tensor(ids, dtype=torch.long) for ids in prompts_input_ids] + prompt_attention_mask = [torch.tensor(mask, dtype=torch.long) for mask in prompt_attention_mask] + prompts_input_ids = pad(prompts_input_ids, padding_side="left", padding_value=self.tokenizer.pad_token_id) + prompt_attention_mask = pad(prompt_attention_mask, padding_side="left", padding_value=0) + + return { + "input_ids": input_ids, + "attention_mask": attention_mask, + "labels": labels, + "prompts": prompts_input_ids, + "prompt_attention_mask": prompt_attention_mask, + } + + +def truncate_right( + input_ids: torch.Tensor, stop_token_id: int, pad_token_id: int +) -> tuple[torch.Tensor, torch.Tensor]: + """ + Truncates the input tensor from the right side after the first occurrence of the stop token. + + Args: + input_ids (`torch.Tensor`): + The tensor containing the responses to be truncated + stop_token_id (`int`): + The token ID representing the stop token where truncation occurs + pad_token_id (`int`): + The token ID representing the pad token used to fill the truncated responses + + Returns: + tuple: + - `output_ids` (`torch.Tensor`): + The truncated responses tensor with pad tokens filled after the stop token + - `mask` (`torch.Tensor`): + The mask tensor to indicate the padding tokens + """ + trunc_idxs = first_true_indices(input_ids == stop_token_id).unsqueeze(-1) + new_size = [1] * (len(input_ids.size()) - 1) + [input_ids.shape[1]] + idxs = torch.arange(input_ids.shape[1], device=input_ids.device).view(*new_size) + output_ids = torch.masked_fill(input_ids, idxs > trunc_idxs, pad_token_id) + mask = torch.masked_fill(torch.ones_like(input_ids), idxs > trunc_idxs, 0) + return output_ids, mask + + +def add_bos_token_if_needed( + bos_token_id: int | None, + prompt_len_input_ids: int, + prompt_tokens: dict[str, list[int]], + chosen_prompt_len_input_ids: int, + chosen_tokens: dict[str, list[int]], + rejected_prompt_len_input_ids: int, + rejected_tokens: dict[str, list[int]], +): + if bos_token_id is not None: + if prompt_len_input_ids == 0 or bos_token_id != prompt_tokens["prompt_input_ids"][0]: + prompt_tokens["prompt_input_ids"] = [bos_token_id] + prompt_tokens["prompt_input_ids"] + prompt_tokens["prompt_attention_mask"] = [1] + prompt_tokens["prompt_attention_mask"] + if chosen_prompt_len_input_ids == 0 or bos_token_id != chosen_tokens["prompt_input_ids"][0]: + chosen_tokens["prompt_input_ids"] = [bos_token_id] + chosen_tokens["prompt_input_ids"] + chosen_tokens["prompt_attention_mask"] = [1] + chosen_tokens["prompt_attention_mask"] + if rejected_prompt_len_input_ids == 0 or bos_token_id != rejected_tokens["prompt_input_ids"][0]: + rejected_tokens["prompt_input_ids"] = [bos_token_id] + rejected_tokens["prompt_input_ids"] + rejected_tokens["prompt_attention_mask"] = [1] + rejected_tokens["prompt_attention_mask"] + return prompt_tokens, chosen_tokens, rejected_tokens + + +def add_eos_token_if_needed( + eos_token_id: int, chosen_tokens: dict[str, list[int]], rejected_tokens: dict[str, list[int]] +): + if len(chosen_tokens["input_ids"]) == 0 or eos_token_id != chosen_tokens["input_ids"][-1]: + chosen_tokens["input_ids"].append(eos_token_id) + chosen_tokens["attention_mask"].append(1) + if len(rejected_tokens["input_ids"]) == 0 or eos_token_id != rejected_tokens["input_ids"][-1]: + rejected_tokens["input_ids"].append(eos_token_id) + rejected_tokens["attention_mask"].append(1) + return chosen_tokens, rejected_tokens + + +def first_true_indices(bools: torch.Tensor, dtype=torch.long) -> torch.Tensor: + """ + Takes an N-dimensional bool tensor and returns an (N-1)-dimensional tensor of integers giving the position of the + first True in each "row". + + Returns the length of the rows (bools.size(-1)) if no element is True in a given row. + + Args: + bools (`torch.Tensor`): + An N-dimensional boolean tensor. + dtype (`torch.dtype`, optional): + The desired data type of the output tensor. Defaults to `torch.long`. + + Returns: + `torch.Tensor`: + An (N-1)-dimensional tensor of integers indicating the position of the first True in each row. If no True + value is found in a row, returns the length of the row. + """ + row_len = bools.size(-1) + zero_or_index = row_len * (~bools).type(dtype) + torch.arange(row_len, dtype=dtype, device=bools.device) + return torch.min(zero_or_index, dim=-1).values + + +def get_reward( + model: torch.nn.Module, query_responses: torch.Tensor, pad_token_id: int, context_length: int +) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]: + """ + Computes the reward logits and the rewards for a given model and query responses. + + Args: + model (`torch.nn.Module`): + The model used to compute the reward logits. + query_responses (`torch.Tensor`): + The tensor containing the query responses. + pad_token_id (`int`): + The token ID representing the pad token. + context_length (`int`): + The length of the context in the query responses. + + Returns: + tuple: + - `reward_logits` (`torch.Tensor`): + The logits for the reward model. + - `final_rewards` (`torch.Tensor`): + The final rewards for each query response. + - `sequence_lengths` (`torch.Tensor`): + The lengths of the sequences in the query responses. + """ + attention_mask = query_responses != pad_token_id + position_ids = attention_mask.cumsum(1) - attention_mask.long() # exclusive cumsum + lm_backbone = getattr(model, model.base_model_prefix) + input_ids = torch.masked_fill(query_responses, ~attention_mask, 0) + output = lm_backbone( + input_ids=input_ids, + attention_mask=attention_mask, + position_ids=position_ids, + return_dict=True, + output_hidden_states=True, + use_cache=False, # otherwise mistral-based RM would error out + ) + reward_logits = model.score(output.hidden_states[-1]) + sequence_lengths = first_true_indices(query_responses[:, context_length:] == pad_token_id) - 1 + context_length + # https://github.com/huggingface/transformers/blob/dc68a39c8111217683bf49a4912d0c9018bab33d/src/transformers/models/gpt2/modeling_gpt2.py#L1454 + return ( + reward_logits, + reward_logits[ + torch.arange(reward_logits.size(0), device=reward_logits.device), + sequence_lengths, + ].squeeze(-1), + sequence_lengths, + ) + + +def prepare_model_for_kbit_training(model, use_gradient_checkpointing=True, gradient_checkpointing_kwargs=None): + r""" + Prepare a k-bit quantized transformers model for training (PEFT/QLoRA). + """ + loaded_in_kbit = getattr(model, "is_loaded_in_8bit", False) or getattr(model, "is_loaded_in_4bit", False) + quant_methods = ["gptq", "aqlm", "eetq", "torchao", "hqq"] + is_quantized = getattr(model, "quantization_method", None) in quant_methods or getattr( + model, "hqq_quantized", False + ) + + if gradient_checkpointing_kwargs is None: + gradient_checkpointing_kwargs = {} + + for _, param in model.named_parameters(): + # freeze all parameters + param.requires_grad = False + + # Enable gradient checkpointing if needed + if (loaded_in_kbit or is_quantized) and use_gradient_checkpointing: + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + # backward-compatible hook + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + supports_gc_kwargs = "gradient_checkpointing_kwargs" in list( + inspect.signature(model.gradient_checkpointing_enable).parameters + ) + gc_kwargs = {"gradient_checkpointing_kwargs": gradient_checkpointing_kwargs} if supports_gc_kwargs else {} + model.gradient_checkpointing_enable(**gc_kwargs) + + return model + + +def enable_gradient_checkpointing( + model: PreTrainedModel, gradient_checkpointing_kwargs: dict | None +) -> PreTrainedModel: + """Enables gradient checkpointing for the model.""" + # Enable gradient checkpointing on the base model for PEFT + if is_peft_model(model): + model.base_model.gradient_checkpointing_enable() + # Enable gradient checkpointing for non-PEFT models + else: + model.gradient_checkpointing_enable() + + gradient_checkpointing_kwargs = gradient_checkpointing_kwargs or {} + use_reentrant = ( + "use_reentrant" not in gradient_checkpointing_kwargs or gradient_checkpointing_kwargs["use_reentrant"] + ) + + if use_reentrant: + if hasattr(model, "enable_input_require_grads"): + model.enable_input_require_grads() + else: + + def make_inputs_require_grad(module, input, output): + output.requires_grad_(True) + + model.get_input_embeddings().register_forward_hook(make_inputs_require_grad) + + return model + + +def prepare_peft_model( + model: PreTrainedModel, peft_config: "PeftConfig | None", args: TrainingArguments +) -> PreTrainedModel: + """Prepares a model for PEFT training.""" + if not is_peft_available(): + raise ImportError("PEFT is required to use a peft model. Run `pip install peft`.") + + if isinstance(model, PeftModel) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge and " + "unload the existing adapter, save the resulting base model, and then pass that base model along with the " + "new `peft_config` to the trainer." + ) + + # Handle quantized models (QLoRA) + is_qlora = getattr(model, "is_loaded_in_4bit", False) or getattr(model, "is_loaded_in_8bit", False) + + is_sharded_qlora = False + if getattr(model, "is_loaded_in_4bit", False): + # Check if model is sharded (FSDP/DS-Zero3) + for _, param in model.named_parameters(): + if param.__class__.__name__ == "Params4bit": + is_sharded_qlora = param.data.device.type in {"cpu", "meta"} + break + + # Prepare model for kbit training if needed + if is_qlora and not is_sharded_qlora and not isinstance(model, PeftModel): + model = prepare_model_for_kbit_training( + model, + use_gradient_checkpointing=args.gradient_checkpointing, + gradient_checkpointing_kwargs=args.gradient_checkpointing_kwargs or {}, + ) + # Disable gradient checkpointing as it's handled by prepare_model_for_kbit_training + args.gradient_checkpointing = False + elif args.gradient_checkpointing: + model = enable_gradient_checkpointing(model, args.gradient_checkpointing_kwargs) + + # Create PEFT model + if peft_config is not None: + if ( + Version(peft.__version__) >= Version("0.12") # autocast_adapter_dtype introduced in 0.12 + and getattr(model, "is_loaded_in_4bit", False) + and is_sharded_qlora + ): + model = get_peft_model(model, peft_config, autocast_adapter_dtype=False) + else: + model = get_peft_model(model, peft_config) + + # Handle bf16 casting for 4-bit models + if args.bf16 and getattr(model, "is_loaded_in_4bit", False) and not is_sharded_qlora: + peft_module_casting_to_bf16(model) + + return model + + +def pad_to_length(tensor: torch.Tensor, length: int, pad_value: int | float, dim: int = -1) -> torch.Tensor: + if tensor.size(dim) >= length: + return tensor + else: + pad_size = list(tensor.shape) + pad_size[dim] = length - tensor.size(dim) + return torch.cat( + [ + tensor, + pad_value * torch.ones(*pad_size, dtype=tensor.dtype, device=tensor.device), + ], + dim=dim, + ) + + +def empty_cache() -> None: + """Empties the cache of the available torch device. + + This function checks for the availability of different torch devices (XPU, MLU, NPU, CUDA) and empties the cache of + the first available device it finds. + + If none of the specific devices are available, it defaults to emptying the CUDA cache. + """ + if is_torch_xpu_available(): + torch.xpu.empty_cache() + elif is_torch_mlu_available(): + torch.mlu.empty_cache() + elif is_torch_npu_available(): + torch.npu.empty_cache() + else: + torch.cuda.empty_cache() + + +def peft_module_casting_to_bf16(model): + for name, module in model.named_modules(): + if isinstance(module, torch.nn.LayerNorm) or "norm" in name: + module = module.to(torch.float32) + elif any(x in name for x in ["lm_head", "embed_tokens", "wte", "wpe"]): + if hasattr(module, "weight"): + if module.weight.dtype == torch.float32: + module = module.to(torch.bfloat16) + + +LAYER_PATTERNS = [ + "transformer.h.{layer}", + "model.decoder.layers.{layer}", + "gpt_neox.layers.{layer}", + "model.layers.{layer}", +] + + +def create_reference_model( + model: nn.Module, num_shared_layers: int | None = None, pattern: str | None = None +) -> nn.Module: + """ + Creates a static reference copy of a model. Note that model will be in `.eval()` mode. + + Args: + model ([`nn.Module`]): The model to be copied. + num_shared_layers (`int`, *optional*): + The number of initial layers that are shared between both models and kept frozen. + pattern (`str`, *optional*): The shared layers are selected with a string pattern + (e.g. "transformer.h.{layer}" for GPT2) and if a custom pattern is necessary it can be passed here. + + Returns: + [`nn.Module`] + """ + if is_deepspeed_zero3_enabled(): + raise ValueError( + "DeepSpeed ZeRO-3 is enabled and is not compatible with `create_reference_model()`. Please instantiate your reference model directly with `AutoModelForCausalLM.from_pretrained()`." + ) + + parameter_names = [n for n, _ in model.named_parameters()] + ref_model = deepcopy(model) + + # if no layers are shared, return copy of model + if num_shared_layers is None: + for param_name in parameter_names: + param = ref_model.get_parameter(param_name) + param.requires_grad = False + return ref_model.eval() + + # identify layer name pattern + if pattern is not None: + pattern = pattern.format(layer=num_shared_layers) + else: + for pattern_candidate in LAYER_PATTERNS: + pattern_candidate = pattern_candidate.format(layer=num_shared_layers) + if any(pattern_candidate in name for name in parameter_names): + pattern = pattern_candidate + break + + if pattern is None: + raise ValueError("Layer pattern could not be matched.") + + # divide parameters in shared and unshared parameter lists + shared_param_list = [] + unshared_param_list = [] + + shared_parameter = True + for name, _param in model.named_parameters(): + if pattern in name: + shared_parameter = False + if shared_parameter: + shared_param_list.append(name) + else: + unshared_param_list.append(name) + + # create reference of the original parameter if they are shared + for param_name in shared_param_list: + param = model.get_parameter(param_name) + param.requires_grad = False + + _ref_param = ref_model.get_parameter(param_name) + + # for all other parameters just make sure they don't use gradients + for param_name in unshared_param_list: + param = ref_model.get_parameter(param_name) + param.requires_grad = False + + if pattern is not None and len(unshared_param_list) == 0: + logging.warning("Pattern passed or found, but no layers matched in the model. Check for a typo.") + + return ref_model.eval() + + +def truncate_dataset( + dataset: DatasetType, + max_length: int, + map_kwargs: dict[str, Any] | None = None, +) -> DatasetType: + r""" + Truncate sequences in a dataset to a specified `max_length`. + + Args: + dataset ([`~datasets.Dataset`] or [`~datasets.DatasetDict`]): + Dataset to truncate. + max_length (`int`): + Maximum sequence length to truncate to. + map_kwargs (`dict`, *optional*): + Additional keyword arguments to pass to the dataset's map method when truncating examples. + + Returns: + [`~datasets.Dataset`] or [`~datasets.DatasetDict`]: The dataset with truncated sequences. + + Example: + ```python + >>> from datasets import Dataset + + >>> examples = { + ... "input_ids": [[1, 2, 3], [4, 5, 6, 7], [8]], + ... "attention_mask": [[0, 1, 1], [0, 0, 1, 1], [1]], + ... } + >>> dataset = Dataset.from_dict(examples) + >>> truncated_dataset = truncate_dataset(dataset, max_length=2) + >>> truncated_dataset[:] + {'input_ids': [[1, 2], [4, 5], [8]], + 'attention_mask': [[0, 1], [0, 0], [1]]} + ``` + """ + if map_kwargs is None: + map_kwargs = {} + + def truncate(examples): + truncated_columns = [] + for column in examples.columns: + if pyarrow.types.is_list(column.type) or pyarrow.types.is_large_list(column.type): + column = pc.list_slice(column, 0, max_length) + truncated_columns.append(column) + return pa.Table.from_arrays(truncated_columns, names=examples.column_names) + + format = _get_dataset_format(dataset) + dataset = dataset.with_format("arrow") + dataset = dataset.map(truncate, batched=True, **map_kwargs) + dataset = dataset.with_format(**format) + return dataset diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..2fc35384cd4246001ac14d1bd126430cce00b122 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .xpo_config import XPOConfig +from .xpo_trainer import XPOTrainer + + +__all__ = ["XPOConfig", "XPOTrainer"] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/xpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/xpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..243545084617bdc8f384289cb76883d22fcfaf54 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/xpo_config.py @@ -0,0 +1,44 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from ..online_dpo import OnlineDPOConfig + + +@dataclass +class XPOConfig(OnlineDPOConfig): + r""" + Configuration class for the [`experimental.xpo.XPOTrainer`]. + + Subclass of [`experimental.online_dpo.OnlineDPOConfig`] we can use all its arguments and add the following: + + Parameters: + alpha (`float` or `list[float]`, *optional*, defaults to `1e-5`): + Weight of the XPO loss term. If a list of floats is provided then the alpha is selected for each new epoch + and the last alpha is used for the rest of the epochs. + """ + + alpha: list[float] = field( + default_factory=lambda: [1e-5], + metadata={ + "help": "Weight of the XPO loss term. If a list of floats is provided then the alpha is selected for each " + "new epoch and the last alpha is used for the rest of the epochs." + }, + ) + + def __post_init__(self): + super().__post_init__() + if hasattr(self.alpha, "__len__") and len(self.alpha) == 1: + self.alpha = self.alpha[0] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/xpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/xpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..f88125e2916b3f5419c2b4e32e7a491c3f211895 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/experimental/xpo/xpo_trainer.py @@ -0,0 +1,498 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import textwrap +from collections.abc import Callable +from typing import Any + +import torch +import torch.nn as nn +import torch.nn.functional as F +from datasets import Dataset, IterableDataset +from transformers import ( + BaseImageProcessor, + FeatureExtractionMixin, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, +) +from transformers.trainer_utils import EvalPrediction +from transformers.training_args import OptimizerNames +from transformers.utils import is_peft_available + +from ...data_utils import maybe_apply_chat_template +from ...models.utils import unwrap_model_for_generation +from ...trainer.utils import selective_log_softmax +from ..online_dpo import OnlineDPOTrainer +from ..utils import empty_cache, get_reward, truncate_right +from .xpo_config import XPOConfig + + +if is_peft_available(): + from peft import PeftModel + + +class XPOTrainer(OnlineDPOTrainer): + """ + Trainer for Exploratory Preference Optimization (XPO). + + It is implemented as a subclass of [`experimental.online_dpo.OnlineDPOTrainer`]. + + Args: + model ([`~transformers.PreTrainedModel`]): + The model to train, preferably an `AutoModelForCausalLM`. + ref_model ([`~transformers.PreTrainedModel`]): + Hugging Face transformer model with a casual language modelling head. Used for implicit reward computation + and loss. If no reference model is provided, the trainer will create a reference model with the same + architecture as the model to be optimized. + reward_funcs ([`~transformers.PreTrainedModel`]): + The reward model to score completions with, preferably an + [`~transformers.AutoModelForSequenceClassification`]. + args ([`experimental.xpo.XPOConfig`]): + The XPO config arguments to use for training. + data_collator ([`~transformers.DataCollator`]): + The data collator to use for training. If None is specified, the default data collator + ([`experimental.utils.DPODataCollatorWithPadding`]) will be used which will pad the sequences to the + maximum length of the sequences in the batch, given a dataset of paired sequences. + train_dataset ([`~datasets.Dataset`]): + The dataset to use for training. + eval_dataset ([`~datasets.Dataset`]): + The dataset to use for evaluation. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.BaseImageProcessor`], [`~transformers.FeatureExtractionMixin`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If provided, will be used to automatically process the inputs + for the model, and it will be saved along the model to make it easier to rerun an interrupted training or + reuse the fine-tuned model. + peft_config (`dict`): + The peft config to use for training. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function to use to compute the metrics. Must take a `EvalPrediction` and return a dictionary string to + metric values. + callbacks (`list[transformers.TrainerCallback]`): + The callbacks to use for training. + optimizers (`tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]`): + The optimizer and scheduler to use for training. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`): + The function to use to preprocess the logits before computing the metrics. + """ + + _tag_names = ["trl", "xpo"] + _name = "XPO" + _paper = { + "title": "Exploratory Preference Optimization: Harnessing Implicit Q*-Approximation for Sample-Efficient RLHF", + "id": "2405.21046", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{jung2024binary, + title = {{Exploratory Preference Optimization: Harnessing Implicit Q*-Approximation for Sample-Efficient RLHF}}, + author = {Tengyang Xie and Dylan J. Foster and Akshay Krishnamurthy and Corby Rosset and Ahmed Awadallah and Alexander Rakhlin}, + year = 2024, + eprint = {arXiv:2405.21046} + }"""), + } + + def __init__( + self, + model: PreTrainedModel | nn.Module = None, + ref_model: PreTrainedModel | nn.Module = None, + reward_funcs: nn.Module | None = None, + args: XPOConfig | None = None, + data_collator: Callable | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | dict[str, Dataset] | None = None, + processing_class: PreTrainedTokenizerBase + | BaseImageProcessor + | FeatureExtractionMixin + | ProcessorMixin + | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + peft_config: dict | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + ) -> None: + super().__init__( + model=model, + ref_model=ref_model, + reward_funcs=reward_funcs, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + reward_processing_classes=reward_processing_classes, + peft_config=peft_config, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + self._alpha = self.args.alpha + + # Overwrite the stats dictionary to include XPO specific statistics + self.stats = { + # Remove "non_score_reward", "rlhf_reward", "scores" + # Add "loss/dpo", "loss/xpo" + "loss/dpo": [], + "loss/xpo": [], + "objective/kl": [], + "objective/entropy": [], + "rewards/chosen": [], + "rewards/rejected": [], + "rewards/accuracies": [], + "rewards/margins": [], + "logps/chosen": [], + "logps/rejected": [], + # Replace "contain_eos_token" by "model_contain_eos_token" and "ref_contain_eos_token" + "val/model_contain_eos_token": [], + "val/ref_contain_eos_token": [], + "objective/model_scores": [], + "objective/ref_scores": [], + "objective/scores_margin": [], + "alpha": [], + "beta": [], + } + if len(self.reward_funcs) != 1: + raise ValueError("XPOTrainer only supports one reward function/model.") + self.reward_funcs = self.reward_funcs[0] + + @property + def alpha(self): + if isinstance(self._alpha, list): + epoch = self.state.epoch + return self._alpha[epoch] if epoch < len(self._alpha) else self._alpha[-1] + else: + return self._alpha + + def _generate_completions(self, prompts, model): + with ( + unwrap_model_for_generation( + model, + self.accelerator, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_policy_model_for_gen, + ): + model_output = unwrapped_policy_model_for_gen.generate( + input_ids=prompts["input_ids"], + attention_mask=prompts["attention_mask"], + generation_config=self.generation_config, + ) + + actual_model_for_ref_generation: torch.nn.Module + if self.ref_model is None: + unwrapped_main_model_for_ref_logic = self.accelerator.unwrap_model(model) + + if is_peft_available() and isinstance(unwrapped_main_model_for_ref_logic, PeftModel): + actual_model_for_ref_generation = unwrapped_main_model_for_ref_logic.get_base_model() + else: + actual_model_for_ref_generation = unwrapped_main_model_for_ref_logic + else: + actual_model_for_ref_generation = self.accelerator.unwrap_model(self.ref_model) + + with ( + unwrap_model_for_generation( + actual_model_for_ref_generation, + self.accelerator, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as final_ref_model_for_gen, + ): + ref_output = final_ref_model_for_gen.generate( + input_ids=prompts["input_ids"], + attention_mask=prompts["attention_mask"], + generation_config=self.generation_config, + ) + + return model_output, ref_output + + def _process_completions(self, model_output, ref_output, prompts): + context_length = prompts["input_ids"].shape[1] + + # Process model completions + model_completion_ids = model_output[:, context_length:] + model_completion_ids, model_completion_mask = truncate_right( + model_completion_ids, self.processing_class.eos_token_id, self.processing_class.pad_token_id + ) + model_data = { + "input_ids": torch.cat((prompts["input_ids"], model_completion_ids), dim=1), + "attention_mask": torch.cat((prompts["attention_mask"], model_completion_mask), dim=1), + "raw": prompts["raw"], + } + + # Process reference model completions + ref_completion_ids = ref_output[:, context_length:] + ref_completion_ids, ref_completion_mask = truncate_right( + ref_completion_ids, self.processing_class.eos_token_id, self.processing_class.pad_token_id + ) + ref_data = { + "input_ids": torch.cat((prompts["input_ids"], ref_completion_ids), dim=1), + "attention_mask": torch.cat((prompts["attention_mask"], ref_completion_mask), dim=1), + "raw": prompts["raw"], + } + + return model_data, ref_data + + def _compute_rewards(self, model_data, ref_data, context_length): + with torch.no_grad(): + _, model_scores, _ = get_reward( + self.reward_funcs, model_data["input_ids"], self.processing_class.pad_token_id, context_length + ) + _, ref_scores, _ = get_reward( + self.reward_funcs, ref_data["input_ids"], self.processing_class.pad_token_id, context_length + ) + + # Apply EOS penalty if needed + if self.args.missing_eos_penalty is not None: + model_contain_eos = torch.any(model_data["input_ids"] == self.processing_class.eos_token_id, dim=-1) + ref_contain_eos = torch.any(ref_data["input_ids"] == self.processing_class.eos_token_id, dim=-1) + model_scores[~model_contain_eos] -= self.args.missing_eos_penalty + ref_scores[~ref_contain_eos] -= self.args.missing_eos_penalty + + return model_scores, ref_scores + + def _compute_logprobs(self, model, model_data, ref_data, context_length): + def compute_logprobs_for_data(m, data): + output = m(data["input_ids"], attention_mask=data["attention_mask"]) + logits = output.logits[:, context_length - 1 : -1] + token_logprobs = selective_log_softmax(logits, data["input_ids"][:, context_length:]) + return token_logprobs + + # Compute logprobs for model completions + model_logprobs_model_data = compute_logprobs_for_data(model, model_data) + # Compute logprobs for model on reference completions (for XPO loss) + model_logprobs_ref_data = compute_logprobs_for_data(model, ref_data) + + # Compute logprobs for reference model completions + with torch.no_grad(): + if self.ref_model is None: + with model.disable_adapter(): + ref_logprobs_model_data = compute_logprobs_for_data(model, model_data) + ref_logprobs_ref_data = compute_logprobs_for_data(model, ref_data) + else: + ref_logprobs_model_data = compute_logprobs_for_data(self.ref_model, model_data) + ref_logprobs_ref_data = compute_logprobs_for_data(self.ref_model, ref_data) + + # Mask padding tokens + model_padding_mask = model_data["attention_mask"][:, context_length:] == 0 + ref_padding_mask = ref_data["attention_mask"][:, context_length:] == 0 + model_logprobs_model_data = model_logprobs_model_data.masked_fill(model_padding_mask, 0.0) + model_logprobs_ref_data = model_logprobs_ref_data.masked_fill(ref_padding_mask, 0.0) + ref_logprobs_ref_data = ref_logprobs_ref_data.masked_fill(ref_padding_mask, 0.0) + ref_logprobs_model_data = ref_logprobs_model_data.masked_fill(model_padding_mask, 0.0) + + return model_logprobs_model_data, model_logprobs_ref_data, ref_logprobs_ref_data, ref_logprobs_model_data + + def _compute_losses( + self, + model_logprobs_model_data, + model_logprobs_ref_data, + ref_logprobs_ref_data, + ref_logprobs_model_data, + chosen_mask, + ): + # Compute log probs + model_logprobs_model_data_sum = model_logprobs_model_data.sum(1) + model_logprobs_ref_data_sum = model_logprobs_ref_data.sum(1) + ref_logprobs_ref_data_sum = ref_logprobs_ref_data.sum(1) + ref_logprobs_model_data_sum = ref_logprobs_model_data.sum(1) + + chosen_model_logprobs = torch.where(chosen_mask, model_logprobs_model_data_sum, model_logprobs_ref_data_sum) + chosen_ref_logprobs = torch.where(chosen_mask, ref_logprobs_model_data_sum, ref_logprobs_ref_data_sum) + chosen_log_ratios = chosen_model_logprobs - chosen_ref_logprobs + + rejected_model_logprobs = torch.where(~chosen_mask, model_logprobs_model_data_sum, model_logprobs_ref_data_sum) + rejected_ref_logprobs = torch.where(~chosen_mask, ref_logprobs_model_data_sum, ref_logprobs_ref_data_sum) + rejected_log_ratios = rejected_model_logprobs - rejected_ref_logprobs + + # Compute logits as the difference between chosen and rejected log ratios + logits = chosen_log_ratios - rejected_log_ratios + + if self.args.loss_type == "sigmoid": + dpo_losses = -F.logsigmoid(self.beta * logits) + elif self.args.loss_type == "ipo": + dpo_losses = (logits - 1 / (2 * self.beta)) ** 2 + else: + raise NotImplementedError(f"invalid loss type {self.args.loss_type}") + + # Compute XPO specific loss + xpo_losses = self.alpha * model_logprobs_ref_data_sum + + # Total loss + loss = (dpo_losses + xpo_losses).mean() + + return loss, dpo_losses, xpo_losses + + def _log_statistics( + self, + model_data, + ref_data, + model_logprobs_model_data, + model_logprobs_ref_data, + ref_logprobs_ref_data, + ref_logprobs_model_data, + chosen_mask, + dpo_losses, + xpo_losses, + context_length, + model_scores, + ref_scores, + ): + # Helper function to gather and compute mean + def gather_mean(tensor): + return self.accelerator.gather_for_metrics(tensor).mean().item() + + # Log losses + self.stats["loss/dpo"].append(gather_mean(dpo_losses)) + self.stats["loss/xpo"].append(gather_mean(xpo_losses)) + + # Log scores + self.stats["objective/model_scores"].append(gather_mean(model_scores)) + self.stats["objective/ref_scores"].append(gather_mean(ref_scores)) + self.stats["objective/scores_margin"].append(gather_mean(model_scores - ref_scores)) + + # Log logprobs + model_logprobs_model_data_sum = model_logprobs_model_data.sum(1) + model_logprobs_ref_data_sum = model_logprobs_ref_data.sum(1) + ref_logprobs_ref_data_sum = ref_logprobs_ref_data.sum(1) + ref_logprobs_model_data_sum = ref_logprobs_model_data.sum(1) + + chosen_model_logprobs = torch.where(chosen_mask, model_logprobs_model_data_sum, model_logprobs_ref_data_sum) + chosen_ref_logprobs = torch.where(chosen_mask, ref_logprobs_model_data_sum, ref_logprobs_ref_data_sum) + chosen_log_ratios = chosen_model_logprobs - chosen_ref_logprobs + + rejected_model_logprobs = torch.where(~chosen_mask, model_logprobs_model_data_sum, model_logprobs_ref_data_sum) + rejected_ref_logprobs = torch.where(~chosen_mask, ref_logprobs_model_data_sum, ref_logprobs_ref_data_sum) + rejected_log_ratios = rejected_model_logprobs - rejected_ref_logprobs + + self.stats["logps/chosen"].append(gather_mean(chosen_model_logprobs.mean() + chosen_ref_logprobs.mean())) + self.stats["logps/rejected"].append(gather_mean(rejected_model_logprobs.mean() + rejected_ref_logprobs.mean())) + + # Log rewards + # Compute various statistics + chosen_rewards = chosen_log_ratios * self.beta + rejected_rewards = rejected_log_ratios * self.beta + self.stats["rewards/chosen"].append(gather_mean(chosen_rewards.mean())) + self.stats["rewards/rejected"].append(gather_mean(rejected_rewards.mean())) + + # Calculate KL divergence for model and ref data + kl_model_data = model_logprobs_model_data - ref_logprobs_model_data + kl_ref_data = model_logprobs_ref_data - ref_logprobs_ref_data + mean_kl = (kl_model_data.sum(1) + kl_ref_data.sum(1)).mean() / 2 + self.stats["objective/kl"].append(gather_mean(mean_kl)) + + # Calculate entropy for model and ref data + entropy_model_data = -model_logprobs_model_data.sum(1) + entropy_ref_data = -model_logprobs_ref_data.sum(1) + mean_entropy = (entropy_model_data.mean() + entropy_ref_data.mean()) / 2 + self.stats["objective/entropy"].append(gather_mean(mean_entropy)) + + # Calculate margins + margin = chosen_rewards - rejected_rewards + self.stats["rewards/margins"].append(gather_mean(margin.mean())) + + # Calculate accuracy + accuracy = (margin > 0).float() + self.stats["rewards/accuracies"].append(gather_mean(accuracy.mean())) + + # Log EOS token statistics + model_eos = (model_data["input_ids"][:, context_length:] == self.processing_class.eos_token_id).any(dim=1) + ref_eos = (ref_data["input_ids"][:, context_length:] == self.processing_class.eos_token_id).any(dim=1) + self.stats["val/model_contain_eos_token"].append(gather_mean(model_eos.float())) + self.stats["val/ref_contain_eos_token"].append(gather_mean(ref_eos.float())) + + # Log alpha and beta + self.stats["alpha"].append(self.alpha) + self.stats["beta"].append(self.beta) + + def training_step( + self, model: nn.Module, inputs: dict[str, torch.Tensor | Any], num_items_in_batch: int | None = None + ) -> torch.Tensor: + model.train() + + # Apply chat template and tokenize the input + batch_size = len(next(iter(inputs.values()))) + prompts = inputs["prompt"] + inputs = [{k: v[i] for k, v in inputs.items()} for i in range(batch_size)] + inputs = [maybe_apply_chat_template(x, self.processing_class) for x in inputs] + inputs = [self.tokenize_row(x, self.model.config.is_encoder_decoder, self.processing_class) for x in inputs] + inputs = self.data_collator(inputs) + + # need the prompt_ only + inputs = self._prepare_inputs(inputs) + context_length = inputs["prompt_input_ids"].shape[1] + prompts = { + "input_ids": inputs["prompt_input_ids"], + "attention_mask": inputs["prompt_attention_mask"], + "raw": prompts, + } + del inputs + + # Sample completions from both the model and the reference model + model_output, ref_output = self._generate_completions(prompts, model) + + # Process model completions + model_data, ref_data = self._process_completions(model_output, ref_output, prompts) + + # Compute rewards + model_scores, ref_scores = self._compute_rewards(model_data, ref_data, context_length) + chosen_mask = model_scores >= ref_scores + + # Compute logprobs + model_logprobs_model_data, model_logprobs_ref_data, ref_logprobs_ref_data, ref_logprobs_model_data = ( + self._compute_logprobs(model, model_data, ref_data, context_length) + ) + + # Compute loss + loss, dpo_losses, xpo_losses = self._compute_losses( + model_logprobs_model_data, + model_logprobs_ref_data, + ref_logprobs_ref_data, + ref_logprobs_model_data, + chosen_mask, + ) + + # Log everything + self._log_statistics( + model_data, + ref_data, + model_logprobs_model_data.detach(), + model_logprobs_ref_data.detach(), + ref_logprobs_ref_data, + ref_logprobs_model_data, + chosen_mask, + dpo_losses.detach(), + xpo_losses.detach(), + context_length, + model_scores, + ref_scores, + ) + + if ( + self.args.torch_empty_cache_steps is not None + and self.state.global_step % self.args.torch_empty_cache_steps == 0 + ): + empty_cache() + + kwargs = {} + # For LOMO optimizers you need to explicitly use the learning rate + if self.args.optim in [OptimizerNames.LOMO, OptimizerNames.ADALOMO]: + kwargs["learning_rate"] = self._get_learning_rate() + + if self.args.n_gpu > 1: + loss = loss.mean() # mean() to average on multi-gpu parallel training + + self.accelerator.backward(loss, **kwargs) + + return loss.detach() / self.args.gradient_accumulation_steps diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d2777dd0eb21a0ea67dce8775337a27ea8499da2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/dataset_formatting.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/dataset_formatting.py new file mode 100644 index 0000000000000000000000000000000000000000..6dd89493a33263bda1506f67f661947ac69a3690 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/dataset_formatting.py @@ -0,0 +1,32 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import datasets +from datasets import Value +from packaging.version import Version + + +if Version(datasets.__version__) >= Version("4.0.0"): + from datasets import List + + FORMAT_MAPPING = { + "chatml": List({"content": Value(dtype="string", id=None), "role": Value(dtype="string", id=None)}), + "instruction": {"completion": Value(dtype="string", id=None), "prompt": Value(dtype="string", id=None)}, + } +else: + FORMAT_MAPPING = { + "chatml": [{"content": Value(dtype="string", id=None), "role": Value(dtype="string", id=None)}], + "instruction": {"completion": Value(dtype="string", id=None), "prompt": Value(dtype="string", id=None)}, + } diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/profiling.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/profiling.py new file mode 100644 index 0000000000000000000000000000000000000000..e051935c86da8babde4d3ed15c827ecc80665996 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/extras/profiling.py @@ -0,0 +1,217 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import functools +import time +from collections.abc import Callable + +from transformers import Trainer +from transformers.integrations import is_mlflow_available, is_wandb_available + + +if is_wandb_available(): + import wandb + +if is_mlflow_available(): + import mlflow + + +class ProfilingContext: + """ + Context manager for profiling code blocks with configurable logging. + + This class handles timing of code execution and logging metrics to various backends (Weights & Biases, MLflow) + without being coupled to the Trainer class. + + Args: + name (`str`): + Name of the profiling context. Used in the metric name. + report_to (`list` of `str`): + List of integrations to report metrics to (e.g., ["wandb", "mlflow"]). + is_main_process (`bool`, *optional*, defaults to `True`): + Whether this is the main process in distributed training. Metrics are only logged from the main process. + step (`int` or `None`, *optional*): + Training step to associate with the logged metrics. + metric_prefix (`str`, *optional*, defaults to `"profiling/Time taken"`): + Prefix for the metric name in logs. + + Example: + ```python + # Direct usage + from trl.extras.profiling import ProfilingContext + + with ProfilingContext( + name="MyClass.expensive_operation", + report_to=["wandb"], + is_main_process=True, + step=100, + ): + # Code to profile + result = expensive_computation() + + # With Trainer (backwards compatible via profiling_context function) + from transformers import Trainer + from trl.extras.profiling import profiling_context + + + class MyTrainer(Trainer): + def some_method(self): + with profiling_context(self, "matrix_multiplication"): + result = matrix_multiply() + ``` + """ + + def __init__( + self, + name: str, + report_to: list[str], + is_main_process: bool = True, + step: int | None = None, + metric_prefix: str = "profiling/Time taken", + ): + self.name = name + self.report_to = report_to + self.is_main_process = is_main_process + self.step = step + self.metric_prefix = metric_prefix + self._start_time = None + + def __enter__(self): + """Start timing when entering the context.""" + self._start_time = time.perf_counter() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + """Stop timing and log metrics when exiting the context.""" + if self._start_time is not None: + duration = time.perf_counter() - self._start_time + self._log_metrics(duration) + return False + + def _log_metrics(self, duration: float) -> None: + """ + Log profiling metrics to configured backends. + + Args: + duration (`float`): + Execution time in seconds. + """ + if not self.is_main_process: + return + + metric_name = f"{self.metric_prefix}: {self.name}" + metrics = {metric_name: duration} + + # Log to Weights & Biases if configured + if "wandb" in self.report_to and is_wandb_available() and wandb.run is not None: + wandb.log(metrics) + + # Log to MLflow if configured + if "mlflow" in self.report_to and is_mlflow_available() and mlflow.active_run() is not None: + mlflow.log_metrics(metrics, step=self.step) + + +def profiling_context(trainer: Trainer, name: str) -> ProfilingContext: + """ + Factory function to create a ProfilingContext from a Trainer instance. + + This function maintains backwards compatibility with existing code while using the decoupled ProfilingContext class + internally. + + Args: + trainer (`~transformers.Trainer`): + Trainer object containing configuration for logging. + name (`str`): + Name of the block to be profiled. Will be prefixed with the trainer class name. + + Returns: + `ProfilingContext`: A configured profiling context manager. + + Example: + ```python + from transformers import Trainer + from trl.extras.profiling import profiling_context + + + class MyTrainer(Trainer): + def some_method(self): + A = np.random.rand(1000, 1000) + B = np.random.rand(1000, 1000) + with profiling_context(self, "matrix_multiplication"): + # Code to profile: simulate a computationally expensive operation + result = A @ B # Matrix multiplication + ``` + """ + context_name = f"{trainer.__class__.__name__}.{name}" + step = trainer.state.global_step + + return ProfilingContext( + name=context_name, + report_to=trainer.args.report_to, + is_main_process=trainer.accelerator.is_main_process, + step=step, + ) + + +def profiling_decorator(func: Callable) -> Callable: + """ + Decorator to profile a function and log execution time using [`extras.profiling.profiling_context`]. + + This decorator works with methods that have access to a trainer instance (typically as `self`). For non-Trainer + objects that have an `accelerator` attribute, it will use that for logging configuration. + + Args: + func (`Callable`): + Function to be profiled. + + Returns: + `Callable`: Wrapped function that profiles execution time. + + Example: + ```python + from transformers import Trainer + from trl.extras.profiling import profiling_decorator + + + class MyTrainer(Trainer): + @profiling_decorator + def some_method(self): + A = np.random.rand(1000, 1000) + B = np.random.rand(1000, 1000) + # Code to profile: simulate a computationally expensive operation + result = A @ B + ``` + """ + + @functools.wraps(func) + def wrapper(self, *args, **kwargs): + # Check if self is a Trainer-like object with required attributes + if hasattr(self, "state") and hasattr(self, "args"): + with profiling_context(self, func.__name__): + return func(self, *args, **kwargs) + # For non-Trainer objects (e.g., VLLMGeneration), use ProfilingContext directly + elif hasattr(self, "accelerator"): + context_name = f"{self.__class__.__name__}.{func.__name__}" + with ProfilingContext( + name=context_name, + report_to=[], # No reporting for non-Trainer objects without args + is_main_process=self.accelerator.is_main_process, + step=None, + ): + return func(self, *args, **kwargs) + else: + # No profiling available, just run the function + return func(self, *args, **kwargs) + + return wrapper diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..22e7cf6d88463c5b6774725e2b66ee1496bddd22 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/__init__.py @@ -0,0 +1,25 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Generation backends for TRL trainers.""" + +from ..import_utils import is_vllm_available + + +__all__ = [] + +if is_vllm_available(): + from .vllm_generation import VLLMGeneration + + __all__.append("VLLMGeneration") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/vllm_client.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/vllm_client.py new file mode 100644 index 0000000000000000000000000000000000000000..cb05ae5a551365f76b97f0edd54337bc976c57a3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/vllm_client.py @@ -0,0 +1,764 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import atexit +import base64 +import copy +import logging +import socket +import time +from io import BytesIO +from urllib.parse import urlparse + +import torch +import torch.distributed.distributed_c10d as c10d +from requests.adapters import HTTPAdapter +from torch import nn +from transformers import is_torch_xpu_available +from transformers.utils import get_json_schema +from urllib3.util.retry import Retry + +from ..import_utils import is_requests_available, is_vllm_ascend_available, is_vllm_available + + +if is_requests_available(): + import requests + from requests import ConnectionError + + +if is_vllm_available(): + from vllm.distributed.device_communicators.pynccl import PyNcclCommunicator + from vllm.distributed.utils import StatelessProcessGroup + + if is_vllm_ascend_available(): + from vllm_ascend.distributed.device_communicators.pyhccl import PyHcclCommunicator as PyNcclCommunicator + + +logger = logging.getLogger(__name__) + + +def pil_to_base64(image): + buffer = BytesIO() + image.save(buffer, format="PNG") + img_bytes = buffer.getvalue() + return base64.b64encode(img_bytes).decode("utf-8") + + +class VLLMClient: + """ + A client class to interact with a vLLM server. + + This class provides methods to generate completions, initialize and manage weight update groups, and update model + weights in a distributed setting. Before using it, start the vLLM server with `trl vllm-serve`. + + Args: + base_url (`str`, *optional*): + Base URL for the vLLM server (e.g., `"http://localhost:8000"`). If provided, `host` and `server_port` are + ignored. + host (`str`, *optional*, defaults to `"0.0.0.0"`): + IP address of the vLLM server. Ignored if `base_url` is provided. + server_port (`int`, *optional*, defaults to `8000`): + Port number of the vLLM server. Ignored if `base_url` is provided. + group_port (`int`, *optional*, defaults to `51216`): + Port number for the weight update group. + connection_timeout (`float`, *optional*, defaults to `0.0`): + Total timeout duration in seconds to wait for the server to be up. If the server is not up after the + timeout, a `ConnectionError` is raised. + + Examples: + Run the vLLM server with the model `Qwen/Qwen2.5-7B`: + + ``` + $ trl vllm-serve --model Qwen/Qwen2.5-7B + ... + INFO: Application startup complete. + INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) + ``` + + Use the client to generate completions and update model weights: + + ```python + >>> from trl.generation.vllm_client import VLLMClient + + >>> client = VLLMClient() + >>> client.generate(["Hello, AI!", "Tell me a joke"]) + {'prompt_ids': [[9707, 11, 15235, 0], + [40451, 752, 264, 21646]], + 'completion_ids': [[2980, 498, 1492, 752, 448, 264, 13027, 8645, 30, 358, 2776, 4460, 311, 3270, 264, 2025], + [911, 98072, 2142, 624, 45, 51426, 2142, 374, 279, 16396, 429, 4302, 702, 36988, 7290, 476]], + 'logprobs': [[[-1.6612], [-0.0081], [-1.5189], [-0.0123], [-1.2045], [-0.6227], [-2.9791], [-2.8387], [-0.1267], [-0.0366], [-2.6528], [-0.3197], [-0.0001], [-1.8174], [-0.0251], [-1.473]], + [[-0.018], [-10.7331], [-0.1605], [-0.891], [-3.7945], [-0.0127], [-0.3073], [-1.1648], [-1.8025], [-0.409], [-0.0256], [-1.6127], [-2.2935], [-4.1785], [-0.6531], [-0.2629]]], + 'logprob_token_ids': [[[2980], [498], [1492], [752], [448], [264], [13027], [8645], [30], [358], [2776], [4460], [311], [3270], [264], [2025]], + [[911], [98072], [2142], [624], [45], [51426], [2142], [374], [279], [16396], [429], [4302], [702], [36988], [7290], [476]]]} + + >>> from transformers import AutoModelForCausalLM + + >>> model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B", device_map="cuda") + >>> client.init_communicator(device="cuda") + >>> client.update_model_params(model) + ``` + + There are several ways to initialize the client: + + ```python + VLLMClient(base_url="http://localhost:8000") + VLLMClient(base_url="http://192.168.1.100:8000") + VLLMClient(host="localhost", server_port=8000) + VLLMClient(host="192.168.1.100", server_port=8000) + ``` + """ + + def __init__( + self, + base_url: str | None = None, + host: str = "0.0.0.0", + server_port: int = 8000, + group_port: int = 51216, + connection_timeout: float = 0.0, + ): + if not is_requests_available(): + raise ImportError("requests is not installed. Please install it with `pip install requests`.") + if not is_vllm_available(): + raise ImportError("vLLM is not installed. Please install it with `pip install trl[vllm]`.") + + self.session = requests.Session() + + # Configure retries for HTTP requests made through this session. + # This is not strictly required for correctness, but it helps make training more robust to rare, transient + # failures (network hiccups, temporary 5xx errors, overloaded servers). Without this, such failures could cause + # an otherwise healthy training run to fail. + retry_strategy = Retry( + total=5, # global cap on the total number of retries across all failure types + connect=5, # retry connection-level failures (DNS issues, refused connections, etc) + read=5, # retry failures while reading the response after the connection was successfully established + status=3, # retry a limited number of times when we receive certain HTTP error responses from the server + status_forcelist=[500, 502, 503], # only retry on server-side errors that are usually temporary + backoff_factor=2, # exponential backoff between retries (2s, 4s, 8s, ...) + allowed_methods=["POST", "GET"], # allow POST as well, even though we're not sure it's safe here + ) + + adapter = HTTPAdapter(max_retries=retry_strategy) + self.session.mount("http://", adapter) + self.session.mount("https://", adapter) + + if base_url is not None: + # Parse the base_url to extract host and port + parsed_url = urlparse(base_url) + self.host = socket.gethostbyname(parsed_url.hostname) + scheme = parsed_url.scheme or "http" + self.base_url = f"{scheme}://{parsed_url.netloc}{parsed_url.path}" + else: + self.host = host + self.server_port = server_port + self.base_url = f"http://{self.host}:{self.server_port}" + self.group_port = group_port + self.check_server(connection_timeout) # check server and fail after timeout + + def check_server(self, total_timeout: float = 0.0, retry_interval: float = 2.0): + """ + Check server availability with retries on failure, within a total timeout duration. If the server is not up + after the total timeout duration, raise a `ConnectionError`. + + Args: + retry_interval (`float`, *optional*, defaults to `2.0`): + Interval in seconds between retries. + total_timeout (`float`, *optional*, defaults to `0.0`): + Total timeout duration in seconds. + """ + url = f"{self.base_url}/health/" + start_time = time.time() # Record the start time + + while True: + try: + response = requests.get(url) + except requests.exceptions.RequestException as exc: + # Check if the total timeout duration has passed + elapsed_time = time.time() - start_time + if elapsed_time >= total_timeout: + raise ConnectionError( + f"The vLLM server can't be reached at {self.base_url} after {total_timeout} seconds. Make " + "sure the server is running by running `trl vllm-serve`." + ) from exc + else: + if response.status_code == 200: + if "X-Forwarded-For" in response.headers: + self.host = response.headers["X-Forwarded-For"] + logger.info("Server is up!") + return None + + # Retry logic: wait before trying again + logger.info(f"Server is not up yet. Retrying in {retry_interval} seconds...") + time.sleep(retry_interval) + + def generate( + self, + prompts: list[str] | list[list[int]], + images: list | None = None, + n: int = 1, + repetition_penalty: float = 1.0, + temperature: float = 1.0, + top_p: float = 1.0, + top_k: int = 0, + min_p: float = 0.0, + max_tokens: int = 16, + logprobs: int | None = 0, + structured_outputs_regex: str | None = None, + generation_kwargs: dict | None = None, + ) -> dict[str, list[list[int]]]: + """ + Generates model completions for the provided prompts. + + Args: + prompts (`list[str]` or `list[list[int]]`): + List of text prompts or list of token ID lists for which the model will generate completions. + images (`list[list[PIL.Image] | None]`, *optional*): + List of image lists for VLM support. Each element is a list of PIL images for the corresponding prompt, + or `None` if no images for that prompt. + n (`int`, *optional*, defaults to `1`): + Number of completions to generate for each prompt. + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Parameter for repetition penalty. 1.0 means no penalty. + temperature (`float`, *optional*, defaults to `1.0`): + Temperature parameter for sampling. Higher values increase diversity. + top_p (`float`, *optional*, defaults to `1.0`): + Top-p sampling parameter.`1.0` means no truncation. + top_k (`int`, *optional*, defaults to `0`): + Top-k sampling parameter. `0` means no truncation. + min_p (`float`, *optional*, defaults to `0.0`): + Minimum probability for sampling. + max_tokens (`int`, *optional*, defaults to `16`): + Maximum number of tokens to generate for each prompt. + logprobs (`int` or `None`, *optional*, defaults to `0`): + Number of top logprobs to return per token. When 0, only the sampled token's logprob is returned. When + N>0, returns up to N+1 logprobs sorted by descending probability, because vLLM always includes the + sampled token's logprob (which may fall outside the top-N). + structured_outputs_regex (`str`, *optional*): + Regular expression to guide the decoding process. + generation_kwargs (`dict`, *optional*): + Additional generation parameters to pass to the vLLM `SamplingParams`. This can include parameters like + `seed`, `frequency_penalty`, etc. If it contains keys that conflict with the other parameters, they + will override them. + + Returns: + `dict` with keys: + - `prompt_ids` (`list[list[int]]`): + List of lists of token IDs representing the tokenized input prompts. + - `completion_ids` (`list[list[int]]`): + List of lists of token IDs representing the model-generated completions for each prompt. + - `logprobs` (`list[list[list[float]]]`): + Per-token logprobs of shape (num_sequences, seq_len, num_logprobs), sorted by descending + probability. + - `logprob_token_ids` (`list[list[list[int]]]`): + Token IDs corresponding to each logprob, same shape as `logprobs`. + """ + url = f"{self.base_url}/generate/" + + # Convert PIL images to base64 strings. Each element is a list of images for the corresponding prompt, + # or None if no images for that prompt. + if images: + images = [ + [pil_to_base64(img) for img in img_list] if img_list is not None else None for img_list in images + ] + + response = self.session.post( + url, + json={ + "prompts": prompts, + "images": images, + "n": n, + "repetition_penalty": repetition_penalty, + "temperature": temperature, + "top_p": top_p, + "top_k": top_k, + "min_p": min_p, + "max_tokens": max_tokens, + "logprobs": logprobs, + "structured_outputs_regex": structured_outputs_regex, + "generation_kwargs": generation_kwargs or {}, + }, + ) + if response.status_code == 200: + json_response = response.json() + return { + "prompt_ids": json_response["prompt_ids"], + "completion_ids": json_response["completion_ids"], + "logprobs": json_response["logprobs"], + "logprob_token_ids": json_response["logprob_token_ids"], + } + else: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + def chat( + self, + messages: list[list[dict]], + n: int = 1, + repetition_penalty: float = 1.0, + temperature: float = 1.0, + top_p: float = 1.0, + top_k: int = 0, + min_p: float = 0.0, + max_tokens: int = 16, + logprobs: int | None = 0, + structured_outputs_regex: str | None = None, + generation_kwargs: dict | None = None, + chat_template_kwargs: dict | None = None, + tools: list | None = None, + chat_template: str | None = None, + ) -> dict[str, list[list[int]]]: + """ + Generates model completions for the provided chat messages. + + Args: + messages (`list[list[dict]]`): + List of message lists for which the model will generate completions. Each message is a dictionary with + keys like "role" and "content". + n (`int`, *optional*, defaults to `1`): + Number of completions to generate for each message list. + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Parameter for repetition penalty. 1.0 means no penalty. + temperature (`float`, *optional*, defaults to `1.0`): + Temperature parameter for sampling. Higher values increase diversity. + top_p (`float`, *optional*, defaults to `1.0`): + Top-p sampling parameter.`1.0` means no truncation. + top_k (`int`, *optional*, defaults to `0`): + Top-k sampling parameter. `0` means no truncation. + min_p (`float`, *optional*, defaults to `0.0`): + Minimum probability for sampling. + max_tokens (`int`, *optional*, defaults to `16`): + Maximum number of tokens to generate for each message list. + logprobs (`int` or `None`, *optional*, defaults to `0`): + Number of top logprobs to return per token. When 0, only the sampled token's logprob is returned. When + N>0, returns up to N+1 logprobs sorted by descending probability, because vLLM always includes the + sampled token's logprob (which may fall outside the top-N). + structured_outputs_regex (`str`, *optional*): + Regular expression to guide the decoding process. + generation_kwargs (`dict`, *optional*): + Additional generation parameters to pass to the vLLM `SamplingParams`. This can include parameters like + `seed`, `frequency_penalty`, etc. If it contains keys that conflict with the other parameters, they + will override them. + chat_template_kwargs (`dict`, *optional*): + Additional keyword arguments to customize the chat template used by the model. + tools (`list[dict | Callable]`, *optional*): + List of tool functions available for tool calling during chat generation. + chat_template (`str`, *optional*): + Template to use for structuring the chat. If not provided, the model's default chat template will be + used. + + Returns: + `dict` with keys: + - `prompt_ids` (`list[list[int]]`): + List of lists of token IDs representing the tokenized input messages. + - `completion_ids` (`list[list[int]]`): + List of lists of token IDs representing the model-generated completions for each message list. + - `logprobs` (`list[list[list[float]]]`): + Per-token logprobs of shape (num_sequences, seq_len, num_logprobs), sorted by descending + probability. + - `logprob_token_ids` (`list[list[list[int]]]`): + Token IDs corresponding to each logprob, same shape as `logprobs`. + """ + if chat_template is not None: + raise NotImplementedError("Custom chat templates are not yet implemented in VLLMClient.chat().") + + url = f"{self.base_url}/chat/" + + # Convert PIL images to base64 strings + messages = copy.deepcopy(messages) # avoid modifying the original messages + for message_list in messages: + for message in message_list: + if isinstance(message["content"], list): + for part in message["content"]: + if part["type"] == "image_pil": + part["image_pil"] = pil_to_base64(part["image_pil"]) + + if isinstance(tools, list) and len(tools) > 0: + tools = [get_json_schema(tool) if callable(tool) else tool for tool in tools] + + response = self.session.post( + url, + json={ + "messages": messages, + "n": n, + "repetition_penalty": repetition_penalty, + "temperature": temperature, + "top_p": top_p, + "top_k": top_k, + "min_p": min_p, + "max_tokens": max_tokens, + "logprobs": logprobs, + "structured_outputs_regex": structured_outputs_regex, + "generation_kwargs": generation_kwargs or {}, + "chat_template_kwargs": chat_template_kwargs or {}, + "tools": tools, + }, + ) + if response.status_code == 200: + json_response = response.json() + return { + "prompt_ids": json_response["prompt_ids"], + "completion_ids": json_response["completion_ids"], + "logprobs": json_response["logprobs"], + "logprob_token_ids": json_response["logprob_token_ids"], + } + else: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + def init_communicator(self, device: torch.device | str | int = 0): + """ + Initializes the weight update group in a distributed setup for model synchronization. + + Args: + device (`torch.device`, `str`, or `int`, *optional*, defaults to `0`): + Device of trainer main process. It's the device that will be used for the weights synchronization. Can + be a `torch.device` object, a string like `'cuda:0'`, or an integer device index. + """ + # Get the world size from the server + url = f"{self.base_url}/get_world_size/" + response = requests.get(url) + if response.status_code == 200: + vllm_world_size = response.json()["world_size"] + else: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + world_size = vllm_world_size + 1 # add the client to the world + self.rank = vllm_world_size # the client's rank is the last process + + # Initialize weight update group + url = f"{self.base_url}/init_communicator/" + # Will simplify it after torch xpu 2.9 support get uuid. + if is_torch_xpu_available(): + if hasattr(torch.xpu.get_device_properties(device), "uuid"): + client_device_uuid = str(torch.xpu.get_device_properties(device).uuid) + else: + client_device_uuid = "42" + else: + client_device_uuid = str(torch.cuda.get_device_properties(device).uuid) + + # Set the weight update group's host to "0.0.0.0" so that + # clients from different IPs can send updated weights + response = self.session.post( + url, + json={ + "host": "0.0.0.0", + "port": self.group_port, + "world_size": world_size, + "client_device_uuid": client_device_uuid, + }, + ) + if response.status_code != 200: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + # Brief delay to allow server initialization. While not strictly required (client socket will retry on + # connection failure), this prevents log warnings like: + # [W416 23:24:57.460001114 socket.cpp:204] [c10d] The hostname of the client socket cannot be retrieved. err=-3 + time.sleep(0.1) + + # Set up the communication group for weight broadcasting + if is_torch_xpu_available(): + store = torch.distributed.TCPStore( + host_name=self.host, port=self.group_port, world_size=world_size, is_master=(self.rank == 0) + ) + prefixed_store = c10d.PrefixStore("client2server", store) + xccl_options = c10d.ProcessGroupXCCL.Options() + pg = c10d.ProcessGroupXCCL( + store=prefixed_store, + rank=self.rank, + size=world_size, + options=xccl_options, + ) + self.communicator = pg + else: + pg = StatelessProcessGroup.create( + host=self.host, port=self.group_port, rank=self.rank, world_size=world_size + ) + self.communicator = PyNcclCommunicator(pg, device=device) + + # When the client object is deleted, close the weight update group + atexit.register(self.close_communicator) + + def update_named_param(self, name: str, weights: torch.Tensor): + """ + Updates a specific named parameter in the model and broadcasts it to other processes. + + Args: + name (`str`): + Name of the layer whose weights are being updated. + weights (`torch.Tensor`): + Tensor containing the updated weights. + """ + dtype, shape = str(weights.dtype), tuple(weights.shape) + url = f"{self.base_url}/update_named_param/" + response = self.session.post(url, json={"name": name, "dtype": dtype, "shape": shape}) + if response.status_code != 200: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + if is_torch_xpu_available(): + # Use XCCL to broadcast the updated weights from the client (src) to all workers. + self.communicator.broadcast(weights, root=self.rank) + self.communicator.barrier() + else: + # Use NCCL to broadcast the updated weights from the client (src) to all workers. + self.communicator.broadcast(weights, src=self.rank) + self.communicator.group.barrier() + + def update_model_params(self, model: nn.Module): + """ + Updates all parameters of the given model by calling `update_named_param` for each parameter in the model. + + Args: + model (`nn.Module`): + Model whose parameters (weights/biases) are to be updated. + """ + for name, param in model.named_parameters(): + # Update each parameter individually + self.update_named_param(name, param.data) + + def get_sequence_logprobs( + self, + sequences: list[list[int]], + prompt_lengths: list[int], + top_logprobs: int = 100, + temperature: float = 1.0, + use_binary: bool = True, + chunk_size: int = 0, + max_concurrent_requests: int = 4, + ) -> dict[str, list]: + """ + Computes teacher logprobs for existing token sequences without generating new tokens. + + Sends full sequences (prompt + completion) to the vLLM server and retrieves per-token top-k logprobs for the + completion region only. This is used for knowledge distillation where the teacher model evaluates existing + sequences rather than generating new ones. + + When `chunk_size > 0`, splits the batch into chunks and dispatches them concurrently via a thread pool, keeping + the server's data-parallel workers busy. + + When `use_binary=True`, uses base64-encoded numpy arrays for fast serialization instead of nested JSON lists. + + Args: + sequences (`list[list[int]]`): + List of full token ID sequences (prompt + completion). + prompt_lengths (`list[int]`): + Number of prompt tokens in each sequence. Logprobs are returned starting from this position. + top_logprobs (`int`, *optional*, defaults to `100`): + Number of top logprobs to return per token position. + temperature (`float`, *optional*, defaults to `1.0`): + Temperature used when scoring the teacher distribution. + use_binary (`bool`, *optional*, defaults to `True`): + Use binary (base64 numpy) response format for faster serialization. + chunk_size (`int`, *optional*, defaults to `0`): + If > 0, split batch into chunks of this size and dispatch concurrently. If 0, send the entire batch in + a single request. + max_concurrent_requests (`int`, *optional*, defaults to `4`): + Maximum number of concurrent requests when using chunked dispatch. + + Returns: + `dict` with keys: + - `logprobs` (`list[list[list[float]]]`): + Per-token logprobs of shape (batch, completion_len, top_logprobs), sorted by descending + probability. + - `logprob_token_ids` (`list[list[list[int]]]`): + Token IDs corresponding to each logprob, same shape as `logprobs`. + """ + from concurrent.futures import ThreadPoolExecutor, as_completed + + if temperature <= 0: + raise ValueError(f"temperature must be positive, got {temperature}") + + url = f"{self.base_url}/get_sequence_logprobs/" + response_format = "binary" if use_binary else "json" + + if chunk_size > 0 and len(sequences) > chunk_size: + # Chunked concurrent dispatch + n = len(sequences) + chunks = [] + for i in range(0, n, chunk_size): + chunks.append((sequences[i : i + chunk_size], prompt_lengths[i : i + chunk_size])) + + responses = [None] * len(chunks) + + def _send_chunk(idx, seqs, plens): + resp = self.session.post( + url, + json={ + "sequences": seqs, + "prompt_lengths": plens, + "top_logprobs": top_logprobs, + "temperature": temperature, + "response_format": response_format, + }, + ) + if resp.status_code != 200: + raise Exception(f"Request failed: {resp.status_code}, {resp.text}") + return idx, resp.json() + + with ThreadPoolExecutor(max_workers=min(max_concurrent_requests, len(chunks))) as executor: + futures = { + executor.submit(_send_chunk, idx, seqs, plens): idx for idx, (seqs, plens) in enumerate(chunks) + } + for future in as_completed(futures): + idx, result = future.result() + responses[idx] = result + + # Merge results + if use_binary: + return self._merge_binary_responses(responses, top_logprobs) + else: + all_logprobs = [] + all_token_ids = [] + for resp in responses: + all_logprobs.extend(resp["logprobs"]) + all_token_ids.extend(resp["logprob_token_ids"]) + return {"logprobs": all_logprobs, "logprob_token_ids": all_token_ids} + else: + # Single request + response = self.session.post( + url, + json={ + "sequences": sequences, + "prompt_lengths": prompt_lengths, + "top_logprobs": top_logprobs, + "temperature": temperature, + "response_format": response_format, + }, + ) + if response.status_code != 200: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + json_response = response.json() + if use_binary: + return self._decode_binary_logprobs(json_response) + else: + return { + "logprobs": json_response["logprobs"], + "logprob_token_ids": json_response["logprob_token_ids"], + } + + @staticmethod + def _decode_binary_logprobs(response: dict) -> dict[str, list]: + """Decode base64-encoded numpy arrays back to nested lists. + + Returns a dict with: + ``logprobs`` / ``logprob_token_ids`` — teacher's sorted top-k logprobs and + token IDs (shape per sequence: ``(comp_len, top_k)``). Used for the forward KL term. + ``actual_logprobs`` / ``actual_token_ids`` — teacher logprob for the actual + token at each position (shape per sequence: ``(comp_len, 1)``). Used for the reverse KL term. + """ + import numpy as np + + shape = response["shape"] # [batch, max_comp_len, top_k] + comp_lengths = response["completion_lengths"] + + logprobs_arr = np.frombuffer(base64.b64decode(response["logprobs_b64"]), dtype=np.float32).reshape(shape) + token_ids_arr = np.frombuffer(base64.b64decode(response["token_ids_b64"]), dtype=np.int32).reshape(shape) + + # Convert back to nested lists, trimming padding + all_logprobs = [] + all_token_ids = [] + for i, comp_len in enumerate(comp_lengths): + all_logprobs.append(logprobs_arr[i, :comp_len, :].tolist()) + all_token_ids.append(token_ids_arr[i, :comp_len, :].tolist()) + + result = {"logprobs": all_logprobs, "logprob_token_ids": all_token_ids} + + # Decode actual-token logprobs (for reverse KL) + if "actual_logprobs_b64" in response: + actual_shape = [shape[0], shape[1], 1] + actual_lp = np.frombuffer(base64.b64decode(response["actual_logprobs_b64"]), dtype=np.float32).reshape( + actual_shape + ) + actual_ids = np.frombuffer(base64.b64decode(response["actual_token_ids_b64"]), dtype=np.int32).reshape( + actual_shape + ) + all_actual_lps = [] + all_actual_ids = [] + for i, comp_len in enumerate(comp_lengths): + all_actual_lps.append(actual_lp[i, :comp_len, :].tolist()) + all_actual_ids.append(actual_ids[i, :comp_len, :].tolist()) + result["actual_logprobs"] = all_actual_lps + result["actual_token_ids"] = all_actual_ids + + return result + + @staticmethod + def _merge_binary_responses(responses: list[dict], top_logprobs: int) -> dict[str, list]: + """Merge binary responses from multiple chunks into a single result.""" + + all_logprobs = [] + all_token_ids = [] + all_actual_lps = [] + all_actual_ids = [] + for resp in responses: + decoded = VLLMClient._decode_binary_logprobs(resp) + all_logprobs.extend(decoded["logprobs"]) + all_token_ids.extend(decoded["logprob_token_ids"]) + if "actual_logprobs" in decoded: + all_actual_lps.extend(decoded["actual_logprobs"]) + all_actual_ids.extend(decoded["actual_token_ids"]) + + result = {"logprobs": all_logprobs, "logprob_token_ids": all_token_ids} + if all_actual_lps: + if len(all_actual_lps) != len(all_logprobs): + raise ValueError( + f"Inconsistent chunks: {len(all_actual_lps)} actual_logprobs entries " + f"but {len(all_logprobs)} logprobs entries." + ) + result["actual_logprobs"] = all_actual_lps + result["actual_token_ids"] = all_actual_ids + return result + + def reset_prefix_cache(self): + """ + Resets the prefix cache for the model. + """ + url = f"{self.base_url}/reset_prefix_cache/" + response = self.session.post(url) + if response.status_code != 200: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + def close_communicator(self): + """ + Closes the weight update group and cleans up the communication group. + """ + url = f"{self.base_url}/close_communicator/" + + try: + response = self.session.post(url) + except ConnectionError: + # The server might be already down, so we don't need to close the communicator + pass + else: + if response.status_code != 200: + raise Exception(f"Request failed: {response.status_code}, {response.text}") + + if self.communicator is not None: + self.communicator = None + + +# Example usage +if __name__ == "__main__": + from vllm import SamplingParams + + device = "xpu" if is_torch_xpu_available() else "cuda" + client = VLLMClient() + client.init_communicator(device=device) + + # Generate completions + responses = client.generate(["Hello, AI!", "Tell me a joke"], n=4, max_tokens=32, sampling_params=SamplingParams()) + print("Responses:", responses) # noqa + + # Update model weights + from transformers import AutoModelForCausalLM + + model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B").to(device) + client.update_model_params(model) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/vllm_generation.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/vllm_generation.py new file mode 100644 index 0000000000000000000000000000000000000000..30658fd7980265355b0249179d24acb26d3c84f9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/generation/vllm_generation.py @@ -0,0 +1,712 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""vLLM-based generation backend for TRL trainers.""" + +import logging +import math +import os +from contextlib import nullcontext +from typing import TYPE_CHECKING + +import torch +from accelerate.utils import broadcast_object_list, gather_object, is_peft_model +from torch import nn +from torch.distributed.fsdp import FullyShardedDataParallel as FSDP +from transformers import PreTrainedModel, PreTrainedTokenizerBase, ProcessorMixin, is_bitsandbytes_available +from transformers.utils import is_torch_mlu_available, is_torch_npu_available, is_torch_xpu_available + +from ..extras.profiling import ProfilingContext +from ..import_utils import is_vllm_available +from ..trainer.utils import ensure_master_addr_port +from .vllm_client import VLLMClient + + +if is_vllm_available(): + from vllm import LLM, RequestOutput, SamplingParams + from vllm.sampling_params import StructuredOutputsParams + + +logger = logging.getLogger(__name__) + + +def empty_cache() -> None: + """Empties the cache of the available torch device. + + This function checks for the availability of different torch devices (XPU, MLU, NPU, CUDA) and empties the cache of + the first available device it finds. + + If none of the specific devices are available, it defaults to emptying the CUDA cache. + """ + if is_torch_xpu_available(): + torch.xpu.empty_cache() + elif is_torch_mlu_available(): + torch.mlu.empty_cache() + elif is_torch_npu_available(): + torch.npu.empty_cache() + else: + torch.cuda.empty_cache() + + +def extract_logprobs(all_outputs: list["RequestOutput"]): + """ + Extract logprobs and token IDs from vLLM generation outputs. + + Returns logprobs and token IDs sorted by rank (most probable first). Each returned list has shape (num_sequences, + seq_len, num_logprobs), where num_logprobs is determined by the `logprobs` parameter passed to vLLM (1 when + `logprobs=0`, up to N+1 when `logprobs=N`). NaN logprob values are replaced with `None`. + + Args: + all_outputs (list of `RequestOutput`): + List of vLLM `RequestOutput` objects from generation. + + Returns: + Tuple of (logprobs, logprob_token_ids), each of shape (num_sequences, seq_len, num_logprobs). + """ + all_logprobs = [] + all_token_ids = [] + for outputs in all_outputs: + for output in outputs.outputs: + if output.logprobs is None: + return None, None + seq_logprobs = [] + seq_token_ids = [] + for lp in output.logprobs: + sorted_items = sorted(lp.items(), key=lambda x: x[1].rank) + seq_token_ids.append([token_id for token_id, _ in sorted_items]) + seq_logprobs.append([None if math.isnan(item.logprob) else item.logprob for _, item in sorted_items]) + all_logprobs.append(seq_logprobs) + all_token_ids.append(seq_token_ids) + return all_logprobs, all_token_ids + + +if TYPE_CHECKING: + from accelerate import Accelerator + from peft import PeftModel + + +if is_bitsandbytes_available(): + import bitsandbytes as bnb + + +class VLLMGeneration: + """Handles vLLM-based generation for trainers. + + Extracts all vLLM-specific logic (initialization, generation, weight sync) from trainers into a separate, testable + class. + + Args: + model ([`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to use for generation. + accelerator ([`~accelerate.Accelerator`]): + Accelerator for distributed training. + is_fsdp_enabled (`bool`): + Whether FSDP is enabled. + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`]): + Tokenizer or processor for the model. + + > Parameters for vLLM: + + mode (`str`, *optional*, defaults to `"colocate"`): + vLLM mode. Must be one of `"colocate"` or `"server"`. + + - `"colocate"`: vLLM will run in the same process and share the training GPUs. This avoids the need for a + separate server but may cause resource contention with training. + - `"server"`: The trainer will send generation requests to a separate vLLM server. Make sure a TRL vLLM + server is running (start with `trl vllm-serve`). + + structured_outputs_regex (`str`, *optional*): + Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled. + + > Parameters for "server" vLLM mode: + + server_base_url (`str`, *optional*): + Base URL for the vLLM server (e.g., `"http://localhost:8000"`). If provided, `server_host` and + `server_port` are ignored. + server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the vLLM server to connect to. Ignored if `server_base_url` is provided. + server_port (`int`, *optional*, defaults to `8000`): + Port of the vLLM server to connect to. Ignored if `server_base_url` is provided. + server_timeout (`float`, *optional*, defaults to `240.0`): + Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up after the + timeout, a `ConnectionError` is raised. + group_port (`int`, *optional*, defaults to `51216`): + Port number for the weight update group. This is used to communicate with the vLLM server. Unless the port + is occupied, there is no need to change it. + + > Parameters for "colocate" vLLM mode: + + tensor_parallel_size (`int`, *optional*, defaults to `1`): + The number of GPUs to use for distributed execution with tensor parallelism. This setting only applies when + `mode` is set to `"colocate"`. If you are using `mode="server"`, this parameter must be passed separately + when launching the vLLM server via the `--vllm_tensor_parallel_size` flag. + gpu_memory_utilization (`float`, *optional*, defaults to `0.9`): + Ratio (between 0 and 1) of GPU memory to reserve for the model weights, activations, and KV cache. Higher + values will increase the KV cache size and thus improve the model's throughput. However, if the value is + too high, it may cause out-of- memory (OOM) errors. This setting only applies when `mode` is set to + `"colocate"`. If you are using `mode="server"`, this parameter must be passed separately when launching the + vLLM server via the `--vllm_gpu_memory_utilization` flag. + max_model_length (`int`, *optional*): + Model context length (prompt and completion). Set it to at least the maximum prompt length in the dataset + plus `max_completion_length`; if omitted, it is inferred from the model config. + max_num_seqs (`int`, *optional*): + Maximum number of sequences to process in parallel, effectively capping the batch size. + enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Whether to enable sleep mode for the engine to offload weights/cache during the optimizer step. Keeps GPU + memory usage low, but waking the engine adds host–device transfer latency. + model_impl (`str`, *optional*, defaults to `"auto"`): + Model implementation to use for vLLM. + - "auto" will try to use the vLLM implementation, if it exists, and fall back to the Transformers + implementation if no vLLM implementation is available. + - "vllm" will use the vLLM model implementation. + - "transformers" will use the Transformers model implementation. + - "terratorch" will use the TerraTorch model implementation. + + > Parameters for generation: + + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Parameter for repetition penalty. It penalizes new tokens based on whether they appear in the prompt and + the generated text so far. Values > 1 encourage the model to use new tokens, while values < 1 encourage the + model to repeat tokens. Default `1.0` means no penalty. + temperature(`float`, *optional*, defaults to `1.0`): + Sampling temperature. It controls the randomness of the sampling. Lower values make the model more + deterministic, while higher values make the model more random and increase diversity. + top_p: (`float`, *optional*, defaults to `1.0`): + Top-p sampling parameter. It controls the cumulative probability of the top tokens to consider. Defaults to + `1.0` to consider all tokens. + top_k (`int`, *optional*, defaults to `0`): + Top-k sampling parameter. It controls the number of top tokens to consider. Defaults to `0` to consider all + tokens. + min_p (`float`, *optional*, defaults to `0.0`): + Min-p sampling parameter. It represents the minimum probability for a token to be considered, relative to + the probability of the most likely token. Default `0.0` means min-p is disabled. + max_completion_length (`int`, *optional*, defaults to `16`): + Maximum number of tokens to generate for each prompt. + logprobs (`int` or `None`, *optional*, defaults to `0`): + Number of top logprobs to return per token. When 0 (default), only the sampled token's logprob is returned + (inner dimension = 1). When N>0, returns up to N+1 logprobs sorted by descending probability, because vLLM + always includes the sampled token's logprob alongside the top-N (the sampled token may or may not already + be in the top-N). + generation_kwargs (`dict`, *optional*): + Additional generation parameters to pass to the vLLM `SamplingParams`. This can include parameters like + `seed`, `frequency_penalty`, etc. If it contains keys that conflict with the other parameters, they will + override them. + + > Parameters for chat/tools: + + chat_template (`str`, *optional*): + Template to use for structuring the chat. If not provided, the model's default chat template will be used. + chat_template_kwargs (`dict`, *optional*): + Additional keyword arguments to customize the chat template used by the model. + tools (`list`, *optional*): + Tools available for tool calling during chat generation. + """ + + def __init__( + self, + model: "PreTrainedModel | PeftModel", + accelerator: "Accelerator", + is_fsdp_enabled: bool, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + # vLLM configuration + mode: str = "colocate", + structured_outputs_regex: str | None = None, + # Server mode configuration + server_base_url: str | None = None, + server_host: str = "0.0.0.0", + server_port: int = 8000, + server_timeout: float = 240.0, + group_port: int = 51216, + # Colocate mode configuration + tensor_parallel_size: int = 1, + gpu_memory_utilization: float = 0.9, + max_model_length: int | None = None, + max_num_seqs: int | None = None, + enable_sleep_mode: bool = False, + model_impl: str = "auto", + # Generation configuration + repetition_penalty: float = 1.0, + temperature: float = 1.0, + top_p: float = 1.0, + top_k: int = 0, + min_p: float = 0.0, + max_completion_length: int = 16, + logprobs: int | None = 0, + generation_kwargs: dict | None = None, + ): + self.model = model + self.accelerator = accelerator + self.is_fsdp_enabled = is_fsdp_enabled + self.processing_class = processing_class + + # vLLM configuration + self.mode = mode + self.structured_outputs_regex = structured_outputs_regex + + # Server mode configuration + self.server_base_url = server_base_url + self.server_host = server_host + self.server_port = server_port + self.group_port = group_port + self.server_timeout = server_timeout + + # Colocate mode configuration + self.tensor_parallel_size = tensor_parallel_size + self.gpu_memory_utilization = gpu_memory_utilization + self.max_model_length = max_model_length + self.max_num_seqs = max_num_seqs + self.enable_sleep_mode = enable_sleep_mode + self.model_impl = model_impl + + # Generation configuration + self.repetition_penalty = repetition_penalty + self.temperature = temperature + self.top_p = top_p + self.top_k = top_k + self.min_p = min_p + self.max_completion_length = max_completion_length + self.logprobs = logprobs + self.generation_kwargs = generation_kwargs or {} + + self._init_vllm() + + def _init_vllm(self): + """Initialize vLLM in server or colocate mode.""" + model = self.model + accelerator = self.accelerator + + if not is_vllm_available(): + raise ImportError( + "vLLM is not available and `use_vllm` is set to True. Please install vLLM with " + "`pip install trl[vllm]` to use it." + ) + + if self.mode == "server": + if accelerator.is_main_process: + if self.server_base_url is not None: + base_url = self.server_base_url + else: + base_url = f"http://{self.server_host}:{self.server_port}" + self.vllm_client = VLLMClient( + base_url=base_url, group_port=self.group_port, connection_timeout=self.server_timeout + ) + self.vllm_client.init_communicator(device=torch.cuda.current_device()) + + elif self.mode == "colocate": + # Make sure tensor_parallel_size group size evenly divides the world size - each group should have + # the same number of ranks + if not accelerator.num_processes % self.tensor_parallel_size == 0: + raise ValueError( + f"tensor_parallel_size ({self.tensor_parallel_size}) must divide world size " + f"({accelerator.num_processes}) evenly." + ) + + if self.tensor_parallel_size > 1: + # Create subgroups of ranks for TP, each group with `tensor_parallel_size` ranks. + # For example, if world_size=8 and tensor_parallel_size=2 → groups: [0,1], [2,3], [4,5], [6,7] + self.tp_group, _ = torch.distributed.new_subgroups_by_enumeration( + [ + list(range(i * self.tensor_parallel_size, (i + 1) * self.tensor_parallel_size)) + for i in range(accelerator.num_processes // self.tensor_parallel_size) + ] + ) + + # vLLM requires the environment variables to be set for distributed training. + os.environ["RANK"] = str(accelerator.process_index) + os.environ["LOCAL_RANK"] = str(accelerator.local_process_index) + os.environ["WORLD_SIZE"] = str(accelerator.num_processes) + # Ensure distributed rendezvous variables are set without colliding across concurrent runs + ensure_master_addr_port() + + quantization = None + if is_bitsandbytes_available(): + for _, module in model.named_modules(): + if isinstance(module, bnb.nn.Linear4bit): + quantization = "bitsandbytes" + break + elif isinstance(module, bnb.nn.Linear8bitLt): + raise ValueError("vLLM does not support in-flight 8-bit quantization.") + + # Build LLM initialization kwargs + self.llm = LLM( + model=model.name_or_path, + tensor_parallel_size=self.tensor_parallel_size, + gpu_memory_utilization=self.gpu_memory_utilization, + max_model_len=self.max_model_length, + max_num_seqs=self.max_num_seqs, + enable_sleep_mode=self.enable_sleep_mode, + model_impl=self.model_impl, + distributed_executor_backend="external_launcher", + # Feed identical seed for tp groups to ensure sampling results are the same across workers + seed=accelerator.process_index // self.tensor_parallel_size, + # Latest vLLM v1 memory profiler is misled by the high default value (i.e., 32768) - thinking there's not enough memory + max_num_batched_tokens=4096, + # Important so temperature scaling/logit tweaking affects the TIS log probs + logprobs_mode="processed_logprobs", + quantization=quantization, + ) + if self.enable_sleep_mode: + self.llm.sleep(level=2) + else: + raise ValueError(f"vllm_mode must be either 'server' or 'colocate', got '{self.mode}'.") + + # When using vLLM, the main process is responsible for loading the model weights. This can cause process + # desynchronization and seems to lead to DeepSpeed hanging during initialization. To prevent this, we + # synchronize all processes after vLLM has been fully initialized. + accelerator.wait_for_everyone() + + def _fix_param_name_to_vllm(self, name: str, extra_prefixes: list[str] | None = None) -> str: + """Fix parameter name for vLLM compatibility.""" + extra_prefixes = extra_prefixes or [] + prefixes = ["_checkpoint_wrapped_module."] + extra_prefixes + for prefix in prefixes: + name = name.replace(prefix, "") + return name + + def _sync_fsdp1_params_to_vllm(self, module: nn.Module, prefix: str = "", visited: set[str] | None = None): + """Memory-efficient post-order traversal of FSDP modules to extract full parameters and sync with vLLM.""" + # For FSDP1, we need to recurse into children and also use summon_full_params + accelerator = self.accelerator + + if visited is None: + visited = set() + for child_name, child_module in module.named_children(): + child_prefix = f"{prefix}.{child_name}" if prefix else child_name + self._sync_fsdp1_params_to_vllm( + child_module, prefix=child_prefix, visited=visited + ) # recurse into the child + + if isinstance(module, FSDP): + with FSDP.summon_full_params(module, recurse=False, writeback=False): + for param_name, param in module.named_parameters(): + full_name = f"{prefix}.{param_name}" if prefix else param_name + full_name = self._fix_param_name_to_vllm(full_name, extra_prefixes=["_fsdp_wrapped_module."]) + + if full_name in visited: + continue # skip FSDP subtrees already traversed + visited.add(full_name) + + if self.mode == "server" and accelerator.is_main_process: + self.vllm_client.update_named_param(full_name, param.data) + elif self.mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(full_name, param.data)]) + + def _sync_fsdp2_params_to_vllm(self, module: nn.Module): + """FSDP2-specific parameter synchronization.""" + accelerator = self.accelerator + + # For FSDP2, module.state_dict() already covers all parameters, so no need for recursion + for name, param in module.state_dict().items(): + # When using PEFT, we need to recover the original parameter name + name = name.removeprefix("base_model.model.").replace(".base_layer", "") + # Skip PEFT layers: they don't exist in vLLM, and they are merged already. + if is_peft_model(module) and module.prefix in name: + continue + # When module to save, remove its prefix and discard the original module + if "original_module" in name: + continue + name = self._fix_param_name_to_vllm(name, extra_prefixes=["modules_to_save.default."]) + + if param.is_cpu: + param = param.to(torch.device("cuda")) + param = param.full_tensor() + + if self.mode == "server" and accelerator.is_main_process: + self.vllm_client.update_named_param(name, param) + elif self.mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(name, param)]) + + def sync_weights(self): + """Synchronize model weights to vLLM. + + Handles FSDP, DeepSpeed, PEFT weight synchronization. + """ + # Wake up vLLM weights before loading to ensure device memory is mapped. Without this, load_weights() writes to + # freed/unmapped memory when sleep mode is active, which crashes on backends with strict physical memory + # management (e.g., Ascend NPU). See https://github.com/huggingface/trl/issues/5142 + if self.mode == "colocate" and self.enable_sleep_mode: + empty_cache() # required to avoid OOM in some cases + self.llm.wake_up(tags=["weights"]) + + model = self.model + accelerator = self.accelerator + is_fsdp_enabled = self.is_fsdp_enabled + + # For DeepSpeed ZeRO-3 and FSDP, we need to gather all parameters before operations + deepspeed_plugin = accelerator.state.deepspeed_plugin + zero_stage_3 = deepspeed_plugin is not None and deepspeed_plugin.zero_stage == 3 + if zero_stage_3: + import deepspeed + + gather_if_zero3 = deepspeed.zero.GatheredParameters + else: + gather_if_zero3 = nullcontext + + if is_peft_model(model): + # With PEFT and FSDP/DeepSpeed ZeRO Stage 3, we must gather the full model at once before merging, as + # merging adapters in a sharded manner is not supported. + # TODO: does this work with FSDP? + with gather_if_zero3(list(model.parameters())): + model.merge_adapter() + + # Update vLLM weights while parameters are gathered + if is_fsdp_enabled: # note if using FSDP, gather_if_zero3 is nullcontext + # Update vLLM weights while parameters are gathered + # For PEFT with FSDP we need to use the memory efficient post-order traversal + fsdp_plugin = getattr(accelerator.state, "fsdp_plugin", None) + fsdp_version = getattr(fsdp_plugin, "fsdp_version", 1) if fsdp_plugin else 1 + if fsdp_version == 1: + self._sync_fsdp1_params_to_vllm(model) # use memory-efficient post-order traversal for FSDP + elif fsdp_version == 2: + self._sync_fsdp2_params_to_vllm(model) + else: + # DeepSpeed ZeRO-3 with PEFT + for name, param in model.named_parameters(): + # When using PEFT, we need to recover the original parameter name + name = name.removeprefix("base_model.model.").replace(".base_layer", "") + # Skip PEFT layers: they don't exist in vLLM, and they are merged already. + if model.prefix in name: + continue + # When module to save, remove its prefix and discard the original module + if "original_module" in name: + continue + name = self._fix_param_name_to_vllm(name, extra_prefixes=["modules_to_save.default."]) + + if self.mode == "server" and accelerator.is_main_process: + self.vllm_client.update_named_param(name, param.data) + elif self.mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(name, param.data)]) + # Unmerge adapters while parameters are still gathered + model.unmerge_adapter() + # Parameters will automatically be repartitioned when exiting the context + else: + # For non-PEFT models, simply gather (if needed) and update each parameter individually. + if is_fsdp_enabled: + fsdp_plugin = getattr(accelerator.state, "fsdp_plugin", None) + fsdp_version = getattr(fsdp_plugin, "fsdp_version", 1) if fsdp_plugin else 1 + if fsdp_version == 1: + self._sync_fsdp1_params_to_vllm(model) # use memory-efficient post-order traversal for FSDP + elif fsdp_version == 2: + self._sync_fsdp2_params_to_vllm(model) + else: + for name, param in model.named_parameters(): + name = self._fix_param_name_to_vllm(name) + with gather_if_zero3([param]): + if self.mode == "server" and accelerator.is_main_process: + self.vllm_client.update_named_param(name, param.data) + elif self.mode == "colocate": + llm_model = self.llm.llm_engine.model_executor.driver_worker.model_runner.model + llm_model.load_weights([(name, param.data)]) + + # Reset cache on vLLM + if self.mode == "server" and accelerator.is_main_process: + self.vllm_client.reset_prefix_cache() + elif self.mode == "colocate": + self.llm.reset_prefix_cache() + + def generate( + self, + prompts: list[list[int]], + images: list[list | None] | None, + num_generations: int, + profiler: ProfilingContext | None = None, + ) -> tuple: + """Generate completions using vLLM. + + Args: + prompts: List of token ID lists, one per prompt (already tokenized). + images: Optional list of image lists for VLM support. Each element is a list of PIL images for the + corresponding prompt, or `None` if no images for that prompt. `None` if no images at all. + num_generations: Number of generations per prompt. + profiler: Optional profiler for performance tracking. + + Returns: + Tuple of (prompt_ids, completion_ids, logprobs, logprob_token_ids). + + - `prompt_ids`: `list[list[int]]` of shape `(batch_size, prompt_len)`. + - `completion_ids`: `list[list[int]]` of shape `(batch_size, completion_len)`. + - `logprobs`: `list[list[list[float | None]]]` of shape `(batch_size, completion_len, num_logprobs)`. + - `logprob_token_ids`: `list[list[list[int]]]` of shape `(batch_size, completion_len, num_logprobs)`. + + `num_logprobs` is 1 when `logprobs=0`, or up to N+1 when `logprobs=N` (the sampled token is always included + and may fall outside the top-N). + """ + profiler = profiler or nullcontext() + accelerator = self.accelerator + temperature = self.temperature + top_p = self.top_p + top_k = self.top_k + min_p = self.min_p + repetition_penalty = self.repetition_penalty + max_completion_length = self.max_completion_length + + # Wake up colocated vLLM weights if needed (idempotent if already awake from sync_weights) + if self.mode == "colocate" and self.enable_sleep_mode: + empty_cache() # required to avoid OOM in some cases + self.llm.wake_up(tags=["weights"]) + # Work around for https://github.com/vllm-project/vllm/issues/29341 + try: + self.llm.collective_rpc("reload_weights") + except NotImplementedError: + # Non-CUDA vLLM backends (e.g., vllm-ascend's NPUWorkerV1), don't implement reload_weights + pass + + # Generate completions using vLLM: gather all prompts and use them in a single call in the main process + if self.mode == "server": + all_prompts = gather_object(prompts) + # Always gather images (even when None) to avoid deadlock: images may be None on some ranks + # and non-None on others in mixed datasets, and gather_object is a collective operation. + all_images = gather_object(images if images is not None else [None] * len(prompts)) + if all(img is None for img in all_images): + all_images = None + + if accelerator.is_main_process: + # Since 'prompts' contains 'num_generations' duplicates, we first take unique prompts, and + # generate num_generations outputs for each one. This is faster than generating outputs for each + # duplicate prompt individually. + ordered_set_of_prompt_ids = all_prompts[::num_generations] + ordered_set_of_images = all_images[::num_generations] if all_images is not None else None + + sampling_params = { + "n": num_generations, + "repetition_penalty": repetition_penalty, + "temperature": temperature, + "top_p": top_p, + "top_k": top_k, + "min_p": 0.0 if min_p is None else min_p, + "max_tokens": max_completion_length, + "logprobs": self.logprobs, + "structured_outputs_regex": self.structured_outputs_regex, + "generation_kwargs": self.generation_kwargs, + } + with profiler: + output = self.vllm_client.generate( + prompts=ordered_set_of_prompt_ids, + images=ordered_set_of_images, + **sampling_params, + ) + payload = ( + output["prompt_ids"], + output["completion_ids"], + output["logprobs"], + output.get("logprob_token_ids"), + ) + else: + payload = None + + # Broadcast the completions from the main process to all processes, ensuring each process receives its corresponding slice. + obj_list = [payload] + broadcast_object_list(obj_list, from_process=0) + all_prompt_ids, all_completion_ids, all_logprobs, all_logprob_token_ids = obj_list[0] + + # vllm_client.generate(n=num_generations) returns num_generations completions per prompt. + # Duplicate prompt_ids to align with per-completion entries. + all_prompt_ids = [ids for ids in all_prompt_ids for _ in range(num_generations)] + + process_slice = slice( + accelerator.process_index * len(prompts), + (accelerator.process_index + 1) * len(prompts), + ) + prompt_ids = all_prompt_ids[process_slice] + completion_ids = all_completion_ids[process_slice] + logprobs = all_logprobs[process_slice] if all_logprobs is not None else None + logprob_token_ids = all_logprob_token_ids[process_slice] if all_logprob_token_ids is not None else None + + # Generate completions using colocated vLLM instances: each device holds vLLM copy and work on their own batch of prompts + elif self.mode == "colocate": + generation_kwargs = { + "n": 1, # vLLM on each GPU generates only 1 in colocate mode + "repetition_penalty": repetition_penalty, + "temperature": temperature, + "top_p": top_p, + "top_k": top_k, + "min_p": 0.0 if min_p is None else min_p, + "max_tokens": max_completion_length, + "logprobs": self.logprobs, + } + generation_kwargs.update(self.generation_kwargs) + + if self.structured_outputs_regex is not None: + if generation_kwargs.get("structured_outputs") is not None: + logger.warning( + "Both `structured_outputs_regex` and `generation_kwargs['structured_outputs']` are set; " + "`structured_outputs_regex` takes precedence." + ) + generation_kwargs["structured_outputs"] = StructuredOutputsParams(regex=self.structured_outputs_regex) + elif isinstance(structured_outputs_kwargs := generation_kwargs.get("structured_outputs"), dict): + generation_kwargs["structured_outputs"] = StructuredOutputsParams(**structured_outputs_kwargs) + sampling_params = SamplingParams(**generation_kwargs) + + if self.tensor_parallel_size > 1: + # Gather prompts from all ranks in the TP group and flatten. + # Each rank starts with its own prompts; after gathering, all ranks see the full group set. + orig_size = len(prompts) + gathered_prompts = [None for _ in range(self.tensor_parallel_size)] + torch.distributed.all_gather_object(gathered_prompts, prompts, group=self.tp_group) + all_prompts = [p for sublist in gathered_prompts for p in sublist] + # Always gather images (even when None) to avoid deadlock: images may be None on some + # ranks and non-None on others in mixed datasets, and all_gather_object is collective. + local_images = images if images is not None else [None] * len(prompts) + gathered_images = [None for _ in range(self.tensor_parallel_size)] + torch.distributed.all_gather_object(gathered_images, local_images, group=self.tp_group) + all_images = [img for sublist in gathered_images for img in sublist] + if all(img is None for img in all_images): + all_images = None + else: + all_prompts = prompts + all_images = images + + if self.enable_sleep_mode: + self.llm.wake_up(tags=["kv_cache"]) + + # Build vLLM-compatible prompt inputs with token IDs and optional multi-modal data + vllm_prompts = [] + if all_images is not None: + for ids, img_list in zip(all_prompts, all_images, strict=True): + row = {"prompt_token_ids": ids} + if img_list is not None: + row["multi_modal_data"] = {"image": img_list if len(img_list) > 1 else img_list[0]} + vllm_prompts.append(row) + else: + vllm_prompts = [{"prompt_token_ids": ids} for ids in all_prompts] + + with profiler: + all_outputs = self.llm.generate(vllm_prompts, sampling_params=sampling_params, use_tqdm=False) + + all_prompt_ids = [output.prompt_token_ids for output in all_outputs] + all_completion_ids = [output.token_ids for outputs in all_outputs for output in outputs.outputs] + all_logprobs, all_logprob_token_ids = extract_logprobs(all_outputs) + + if self.tensor_parallel_size > 1: + # Slice completions for this rank within its TP group. + # Each rank generates all outputs — we keep only our share. + local_rank_in_group = torch.distributed.get_rank(group=self.tp_group) + tp_slice = slice(local_rank_in_group * orig_size, (local_rank_in_group + 1) * orig_size) + prompt_ids = all_prompt_ids[tp_slice] + completion_ids = all_completion_ids[tp_slice] + logprobs = all_logprobs[tp_slice] if all_logprobs is not None else None + logprob_token_ids = all_logprob_token_ids[tp_slice] if all_logprob_token_ids is not None else None + else: + prompt_ids = all_prompt_ids + completion_ids = all_completion_ids + logprobs = all_logprobs + logprob_token_ids = all_logprob_token_ids + + if self.enable_sleep_mode: + self.llm.sleep(level=2) + + return prompt_ids, completion_ids, logprobs, logprob_token_ids diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/import_utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/import_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..a8adca36f34c9452c1233c003949d8534d605e78 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/import_utils.py @@ -0,0 +1,141 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import importlib +import importlib.metadata +import importlib.util +import warnings +from contextlib import contextmanager + +from packaging.version import Version + + +LIGER_KERNEL_MIN_VERSION = "0.7.0" +PACKAGE_DISTRIBUTION_MAPPING = importlib.metadata.packages_distributions() + + +# From transformers: https://github.com/huggingface/transformers/blob/556312cd45a5e619c41b0f8adf680eab0d334324/src/transformers/utils/import_utils.py#L48-L77 +def _is_package_available(pkg_name: str, return_version: bool = False) -> tuple[bool, str] | bool: + """Check if `pkg_name` exist, and optionally try to get its version""" + spec = importlib.util.find_spec(pkg_name) + package_exists = spec is not None + package_version = "N/A" + if package_exists and return_version: + try: + # importlib.metadata works with the distribution package, which may be different from the import + # name (e.g. `PIL` is the import name, but `pillow` is the distribution name) + distributions = PACKAGE_DISTRIBUTION_MAPPING[pkg_name] + # Per PEP 503, underscores and hyphens are equivalent in package names. + # Prefer the distribution that matches the (normalized) package name. + normalized_pkg_name = pkg_name.replace("_", "-") + if normalized_pkg_name in distributions: + distribution_name = normalized_pkg_name + elif pkg_name in distributions: + distribution_name = pkg_name + else: + distribution_name = distributions[0] + package_version = importlib.metadata.version(distribution_name) + except (importlib.metadata.PackageNotFoundError, KeyError): + # If we cannot find the metadata (because of editable install for example), try to import directly. + # Note that this branch will almost never be run, so we do not import packages for nothing here + package = importlib.import_module(pkg_name) + package_version = getattr(package, "__version__", "N/A") + if return_version: + return package_exists, package_version + else: + return package_exists + + +def is_deepspeed_available() -> bool: + return _is_package_available("deepspeed") + + +def is_fastapi_available() -> bool: + return _is_package_available("fastapi") + + +def is_jmespath_available() -> bool: + return _is_package_available("jmespath") + + +def is_joblib_available() -> bool: + return _is_package_available("joblib") + + +def is_liger_kernel_available(min_version: str = LIGER_KERNEL_MIN_VERSION) -> bool: + _liger_kernel_available, _liger_kernel_version = _is_package_available("liger_kernel", return_version=True) + return _liger_kernel_available and Version(_liger_kernel_version) >= Version(min_version) + + +def is_math_verify_available() -> bool: + return _is_package_available("math_verify") + + +def is_mergekit_available() -> bool: + return _is_package_available("mergekit") + + +def is_pydantic_available() -> bool: + return _is_package_available("pydantic") + + +def is_requests_available() -> bool: + return _is_package_available("requests") + + +def is_unsloth_available() -> bool: + return _is_package_available("unsloth") + + +def is_uvicorn_available() -> bool: + return _is_package_available("uvicorn") + + +def is_vllm_available(min_version: str | None = None) -> bool: + _vllm_available, _vllm_version = _is_package_available("vllm", return_version=True) + if _vllm_available: + if not (Version("0.12.0") <= Version(_vllm_version) <= Version("0.18.0")): + warnings.warn( + f"TRL currently supports vLLM versions from 0.12.0 to 0.18.0. You have version {_vllm_version} " + "installed. We recommend installing a supported version to avoid compatibility issues.", + stacklevel=2, + ) + if min_version is not None and Version(_vllm_version) < Version(min_version): + return False + return _vllm_available + + +def is_vllm_ascend_available() -> bool: + return _is_package_available("vllm_ascend") + + +def is_weave_available() -> bool: + return _is_package_available("weave") + + +class TRLExperimentalWarning(UserWarning): + """Warning for using the 'trl.experimental' submodule.""" + + pass + + +@contextmanager +def suppress_warning(category): + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=category) + yield + + +def suppress_experimental_warning(): + return suppress_warning(TRLExperimentalWarning) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/models/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f84d989c2825020b0b69c4b31f0285fdcdf54b41 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/models/__init__.py @@ -0,0 +1,32 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import TYPE_CHECKING + +from .._lazy_module import _LazyModule + + +_import_structure = { + "activation_offloading": ["get_act_offloading_ctx_manager"], + "utils": ["create_reference_model", "prepare_deepspeed", "prepare_fsdp", "unwrap_model_for_generation"], +} + + +if TYPE_CHECKING: + from .activation_offloading import get_act_offloading_ctx_manager + from .utils import create_reference_model, prepare_deepspeed, prepare_fsdp, unwrap_model_for_generation +else: + import sys + + sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/models/activation_offloading.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/models/activation_offloading.py new file mode 100644 index 0000000000000000000000000000000000000000..df2fa50d2a0f004d01f62259870d4b07be1e63ae --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/models/activation_offloading.py @@ -0,0 +1,700 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of https://github.com/pytorch/torchtune. + + +import psutil +import torch +from accelerate import logging +from accelerate.utils.versions import is_torch_version +from torch import nn +from torch.autograd.graph import saved_tensors_hooks +from transformers import is_torch_npu_available + + +if is_torch_npu_available(): + import torch_npu # noqa: F401 + +# Import DTensor for FSDP v2 support with version-aware import path +DTensor = None +if torch.distributed.is_available(): + try: + if is_torch_version(">=", "2.5.0"): + from torch.distributed.tensor import DTensor + else: + # from torch 2.0.0 (oldest supported accelerate torch version), DTensor is in torch.distributed._tensor + from torch.distributed._tensor import DTensor + except (ImportError, AttributeError): + DTensor = None + +logger = logging.get_logger(__name__) + + +def _get_unique_tensor_key(tensor: torch.Tensor) -> tuple: + """ + Get a unique key for a tensor based on its storage pointer and dtype. This allows deduplication of tensors that + share the same underlying storage. From: + https://github.com/volcengine/verl/blob/main/verl/utils/activation_offload.py + + Args: + tensor: The tensor to get the key for + + Returns: + A tuple of (storage_pointer, dtype) that uniquely identifies the tensor's storage + """ + # Handle special tensor types - primarily for FSDP v2 DTensor + actual_tensor = tensor + + # For DTensor (FSDP v2), extract the local tensor + if DTensor is not None and isinstance(tensor, DTensor) and hasattr(tensor, "_local_tensor"): + actual_tensor = tensor._local_tensor + + # Try to get storage pointer, but fall back to tensor id if not accessible + try: + storage_ptr = actual_tensor.untyped_storage().data_ptr() + actual_tensor.storage_offset() + except (RuntimeError, AttributeError): + # For tensors with invalid storage, use tensor id + # This won't enable deduplication for these tensors, but allows offloading to work + storage_ptr = id(actual_tensor) + + return (storage_ptr, actual_tensor.dtype) + + +class OffloadActivations(saved_tensors_hooks): + """ + Context manager under which activation tensors created in the forward pass will be offloaded. + + Enable the memory efficiency technique of activation offloading, where activations bigger than `min_offload_size` + bytes will be offloaded to CPU in the forward and brought back in the backward. This is in contrast to maintaining + the activation on GPU VRAM throughout the program. + + This manager contains the option of using one additional CUDA stream to handle the communication between CUDA and + CPU, which is intended to overlap with the default computation stream to improve runtime. We designed + synchronization with a few heuristics for optimizing the tradeoff between runtime vs memory usage. + + Args: + use_pin_memory (`bool`, *optional*, defaults to `True`): + Whether to offloaded Tensor will be placed in pinned memory on the CPU. Pinned memory allows the Tensor to + be moved back onto GPU more quickly but is a limited resource. + use_streams (`bool`, *optional*, defaults to `True`): + Whether to use streams for performance optimization where the communications get overlapped with the + computation. Requires a torch build after torch-2.5.0. + min_offload_size (`int`, *optional*, defaults to `1024`): + Minimum number of bytes a Tensor must be in order to qualify for offloading. If the tensor is too small, we + do not want to waste bandwidth and resources moving it to CPU and back. + max_fwd_stash_size (`int`, *optional*, defaults to `5`): + Maximum size of the forward stash, or the maximum number of consecutive activations to keep alive during + the forward pass. This number must be at least 1. Keeping alive more activations will potentially allow + more overlap between the communication and compute streams at the cost of increasing memory usage. Keeping + alive fewer activations will conserve memory, but may cause poor overlap between the streams, increasing + runtime. + + Raises: + ValueError: if `max_fwd_stash_size` is not at least `1`. + + Example: + ```python + >>> with OffloadActivations(): + ... outputs = model(inputs, labels=labels) + >>> loss = outputs.loss + >>> loss.backward() + ``` + """ + + def __init__( + self, + use_pin_memory: bool = True, + use_streams: bool = True, + min_offload_size: int = 1024, + max_fwd_stash_size: int = 5, + ) -> None: + self.use_streams = use_streams + + self.min_tensor_size_bytes = min_offload_size # we don't want to bother with small tensors + self.tracker = {} # tensor_id => (new_tensor, if_modified) ---> track what saved/offloaded tensors are where + self.tensor_id = 0 + self.is_first_forward_call = True + self.is_first_backward_call = True + self.is_first_forward_pass = True + + # Storage deduplication: maps storage key to tensor_id to avoid offloading same storage multiple times + self.storage_to_tensor_id = {} + + # Parameter filtering: track parameter storage pointers to skip them during offloading + self.param_storages = set() + + # Managing cpu memory + self.use_pin_memory = use_pin_memory + self.virtual_memory_safe_pct = 60 # we should not exceed this percentage of memory + + self.accelerator_type = ( + torch.accelerator.current_accelerator().type if hasattr(torch, "accelerator") else "cuda" + ) + # NOTE: xpu doesn't have `default_stream` API, use `current_stream` instead + if self.accelerator_type == "xpu": # comp stream + self.s0 = torch.xpu.current_stream() + elif is_torch_npu_available() and self.accelerator_type == "npu": + self.s0 = torch.npu.current_stream() + else: + self.s0 = torch.cuda.default_stream() + + # For streaming + if self.use_streams: + if self.accelerator_type == "xpu": # comms stream + self.s1 = torch.xpu.Stream() + elif self.accelerator_type == "npu": + self.s1 = torch.npu.Stream() + else: + self.s1 = torch.cuda.Stream() + self.fwd_stash = {} # tensor_id => (activation, ev1) + if max_fwd_stash_size < 1: + raise ValueError(f"max_fwd_stash_size should be at least 1 but is {max_fwd_stash_size}") + self.max_fwd_stash_size = max_fwd_stash_size + self.bwd_tensor_stash = {} # tensor_id => activation + self.bwd_ev_stash = {} # tensor_id => ev0 + self.curr_graph_id = None + self.curr_autograd_node = None + + # -------- platform util functions -------- # + def verify_sufficient_virtual_memory(): + curr_pct = get_cpu_ram_pct() + if curr_pct > self.virtual_memory_safe_pct: + logger.warning(f"{curr_pct=}% > {self.virtual_memory_safe_pct=}% of virtual memory used") + + def get_cpu_ram_pct() -> float: + # get the percentage of memory used by the system + return psutil.virtual_memory().percent + + def get_tensor_id() -> int: + # create a unique id for each tensor we are managing + self.tensor_id += 1 + return self.tensor_id + + def get_num_bytes_tensor(x: torch.Tensor) -> int: + # get the number of bytes in a tensor, for memory management purposes + return x.element_size() * x.nelement() # x.element_size() * x._base_storage().nbytes() + + # -------- core pack / unpack work -------- # + def pack_tensor(activation: torch.Tensor) -> int: + # activations are passed in during forward pass - from here we take over and return a unique id + if self.is_first_forward_call: + if len(self.tracker) != 0: + raise ValueError("Backward pass should have cleared tracker of all tensors") + + # set training phase trackers + self.is_first_forward_call = False + self.is_first_backward_call = True + # Reset deduplication map for new forward pass + self.storage_to_tensor_id = {} + + # query for basic tensor info + num_bytes = get_num_bytes_tensor(activation) + tensor_id = get_tensor_id() + + # Check for tensor deduplication using storage pointer + # If this storage is already being tracked, we still create a new tensor_id + # but don't offload again (just keep the tensor in GPU) + storage_key = _get_unique_tensor_key(activation) + if storage_key in self.storage_to_tensor_id: + # Storage already offloaded - don't offload again, just track the reference + self.tracker[tensor_id] = (activation, False, None, None, None) # Keep on GPU, don't offload + return tensor_id + + # Check if tensor is on CPU (skip offloading) + if activation.device.type not in ["cuda", "xpu", "npu"]: + self.tracker[tensor_id] = (activation, False, None, None, None) + return tensor_id + + # Check if tensor is too small + if num_bytes < self.min_tensor_size_bytes: + self.tracker[tensor_id] = (activation, False, None, None, None) + return tensor_id + + # Check if tensor is a parameter or buffer + if isinstance(activation, torch.nn.Parameter) or ( + hasattr(torch.nn, "Buffer") and isinstance(activation, torch.nn.Buffer) + ): + self.tracker[tensor_id] = (activation, False, None, None, None) + return tensor_id + + # Check if tensor is an FP8 tensor (TorchAO) - skip offloading as they're already compressed + tensor_class_name = type(activation).__name__ + if tensor_class_name in ["Float8TrainingTensor", "ScaledMMConfig", "LinearMMConfig"]: + self.tracker[tensor_id] = (activation, False, None, None, None) + return tensor_id + + # Check if tensor storage is a model parameter (for FSDP compatibility) + try: + # Extract actual tensor for DTensor + check_tensor = activation + if DTensor is not None and isinstance(activation, DTensor) and hasattr(activation, "_local_tensor"): + check_tensor = activation._local_tensor + + if check_tensor.untyped_storage().data_ptr() in self.param_storages: + self.tracker[tensor_id] = (activation, False, None, None, None) + return tensor_id + except (RuntimeError, AttributeError): + # If we can't get data_ptr, skip this check + pass + + # Tensor qualifies for offloading + if self.use_streams: + # First, sync back and dereference previously offloaded tensors + # as the offloading should be done sufficiently long ago. + for id in list(self.fwd_stash.keys()): + if id <= tensor_id - self.max_fwd_stash_size: + _, ev = self.fwd_stash[id] + self.s0.wait_event(ev) + del self.fwd_stash[id] + else: + break + + # Sync in, offload, and add an event to sync back later + self.s1.wait_stream(self.s0) + + stream = self.s1 if self.use_streams else self.s0 + if self.accelerator_type == "xpu": + stream_ctx = torch.xpu.stream(stream) + elif self.accelerator_type == "npu": + stream_ctx = torch.npu.stream(stream) + else: + stream_ctx = torch.cuda.stream(stream) + with stream_ctx: + # Save original stride and shape information + original_stride = activation.stride() + original_storage_offset = activation.storage_offset() + original_shape = activation.size() + + # Check if tensor has broadcast dimensions (stride == 0) + # If so, copy the underlying storage directly instead of materializing the broadcast + has_broadcast = 0 in original_stride + + if has_broadcast: + # Copy only the actual underlying storage, not the materialized broadcast + # Create CPU tensor with same storage size as original + storage_size = activation.untyped_storage().size() + cpu_storage = torch.empty( + storage_size // activation.element_size(), + dtype=activation.dtype, + pin_memory=self.use_pin_memory, + device="cpu", + ) + # Copy the raw storage + cpu_storage_view = torch.as_strided( + activation, size=(storage_size // activation.element_size(),), stride=(1,), storage_offset=0 + ) + cpu_storage.copy_(cpu_storage_view, non_blocking=True) + cpu_tensor = cpu_storage + else: + # No broadcast - use normal contiguous copy + cpu_tensor = torch.empty_like(activation, pin_memory=self.use_pin_memory, device="cpu") + cpu_tensor.copy_(activation, non_blocking=True) + + # Store CPU tensor along with stride information + self.tracker[tensor_id] = ( + cpu_tensor, + True, # True = (in future) modified + original_stride, # Save original GPU stride + original_storage_offset, # Save original storage offset + original_shape, # Save original shape for broadcast restoration + ) + + if self.use_streams: + event = self.s1.record_event() + + # Stash to keep activation alive til s1 is done + self.fwd_stash[tensor_id] = (activation, event) + + # Track this storage for deduplication + self.storage_to_tensor_id[storage_key] = tensor_id + + return tensor_id + + def unpack_tensor_single_stream(unpack_tensor_id: int) -> torch.Tensor: + # backward pass - we are called with the tensor_id, which + # we will use to retrieve the saved/offloaded tensor + if self.is_first_backward_call: + if self.is_first_forward_pass: + self.is_first_forward_pass = False + if self.use_pin_memory: + verify_sufficient_virtual_memory() + + self.is_first_backward_call = False + + if unpack_tensor_id not in self.tracker: + raise ValueError(f"Untracked tensor with id {unpack_tensor_id}") + + ( + maybe_accelerator_tensor, + modified, + original_stride, + original_storage_offset, + original_shape, + ) = self.tracker[unpack_tensor_id] + + if modified: + # Restore tensor to GPU + accelerator_tensor = maybe_accelerator_tensor.to(self.accelerator_type, non_blocking=True) + # Restore original stride if we saved it (handles both broadcast and non-broadcast cases) + if original_stride is not None: + accelerator_tensor = torch.as_strided( + accelerator_tensor, + size=original_shape, + stride=original_stride, + storage_offset=original_storage_offset, + ) + maybe_accelerator_tensor = accelerator_tensor + + # clear tensor from tracking + del self.tracker[unpack_tensor_id] + # Only set is_first_forward_call to True when all tensors have been unpacked + if len(self.tracker) == 0: + self.is_first_forward_call = True + return maybe_accelerator_tensor + + def unpack_tensor_with_streams(unpack_tensor_id: int) -> torch.Tensor: + # backward pass - we are called with the tensor_id, which + # we will use to retrieve the saved/offloaded tensor + if self.is_first_backward_call: + self.curr_graph_id = torch._C._current_graph_task_id() + + def wait_and_del_remaining_references() -> None: + for id in list(self.bwd_tensor_stash.keys()): + if id in self.bwd_ev_stash: + event = self.bwd_ev_stash[id] + self.s1.wait_event(event) + del self.bwd_tensor_stash[id] + + # Register a callback to the end of autograd to clean everything up + torch.autograd.variable.Variable._execution_engine.queue_callback(wait_and_del_remaining_references) + + if self.is_first_forward_pass: + self.is_first_forward_pass = False + if self.use_pin_memory: + verify_sufficient_virtual_memory() + + self.is_first_backward_call = False + + if unpack_tensor_id not in self.tracker: + raise ValueError(f"untracked tensor with id {unpack_tensor_id}") + + ( + maybe_accelerator_tensor, + modified, + original_stride, + original_storage_offset, + original_shape, + ) = self.tracker[unpack_tensor_id] + + if modified: + # Get data on the current autograd node + graph_id = torch._C._current_graph_task_id() + node = torch._C._current_autograd_node() + prev_node_ids = [] + + # If we're on a new node, mark prev node's tensors to be freed later + if graph_id == self.curr_graph_id and self.curr_autograd_node != node: + self.curr_autograd_node = node + prev_node_ids = list(self.bwd_tensor_stash.keys()) + + brought_back_from_cpu = True + if unpack_tensor_id in self.fwd_stash: + maybe_accelerator_tensor = self.fwd_stash[unpack_tensor_id][0] + brought_back_from_cpu = False + else: + # Kick off the process to bring tensors back + if self.accelerator_type == "xpu": + stream_ctx = torch.xpu.stream(self.s1) + elif self.accelerator_type == "npu": + stream_ctx = torch.npu.stream(self.s1) + else: + stream_ctx = torch.cuda.stream(self.s1) + with stream_ctx: + # Restore tensor to GPU + accelerator_tensor = maybe_accelerator_tensor.to(self.accelerator_type, non_blocking=True) + # Restore original stride if we saved it (handles both broadcast and non-broadcast cases) + if original_stride is not None: + accelerator_tensor = torch.as_strided( + accelerator_tensor, + size=original_shape, + stride=original_stride, + storage_offset=original_storage_offset, + ) + maybe_accelerator_tensor = accelerator_tensor + + # Tell comp stream to wait for the info to be loaded before executing + self.s0.wait_stream(self.s1) + + # Stash the tensor to keep memory alive until compute stream is complete + self.bwd_tensor_stash[unpack_tensor_id] = maybe_accelerator_tensor + + # Note: [Track views of the unpacked] + # Why do we get the use count of the unpacked tensor here? We want an + # initial count to compare to later, during the post-hook of the + # backward node, when we need to decide whether we're allowed to free + # the tensor yet. In what obscure cases must we delay freeing the + # tensor (and thus call record_stream)? + # 1. Any of the outputs of the backward node is a view of the unpacked + # tensor. + # 2. In the case that this unpacked tensor will be used in a + # checkpointed region, if one of the recomputed saved tensors ends + # up as a view of the unpacked tensor. + # 3. The user abuses the system somehow and manually relies on the + # unpacked tensor to exist after the backward node has executed. + if self.accelerator_type == "npu": + storage_refcount = torch_npu._C._storage_Use_Count( + maybe_accelerator_tensor.untyped_storage()._cdata + ) + else: + storage_refcount = torch._C._storage_Use_Count( + maybe_accelerator_tensor.untyped_storage()._cdata + ) + + def hook(outputs, inputs): + # create events for the current node inputs/outputs if they were streamed in + if brought_back_from_cpu: + # See Note: [Track views of the unpacked] + # IF any of the outputs is a view of the tensor, OR if a view of + # the tensor has been saved as a part of checkpoint's recompute + # process, OR the user has abusedly incurred a reference on the + # unpacked tensor, THEN the tensor might be used later and we + # cannot presume to delete it after only the current node is + # done! So we use our frenemy, record_stream, to ensure the + # Tensor stays unmessed with until it's done getting used in the + # compute stream (s0 here). Note that the con here is we introduce + # non-deterministic (thus higher) memory usage, but this case + # should not happen often. + # Check if tensor still exists (might have been cleaned up by a previous node) + if unpack_tensor_id in self.bwd_tensor_stash: + unpacked_tensor = self.bwd_tensor_stash[unpack_tensor_id] + if self.accelerator_type == "npu": + storage_count = torch_npu._C._storage_Use_Count( + unpacked_tensor.untyped_storage()._cdata + ) + else: + storage_count = torch._C._storage_Use_Count(unpacked_tensor.untyped_storage()._cdata) + if storage_count > storage_refcount: + unpacked_tensor.record_stream(self.s0) + del self.bwd_tensor_stash[unpack_tensor_id] + else: + event = self.s0.record_event() + self.bwd_ev_stash[unpack_tensor_id] = event + + # if there are still things in the fwd_stash, get rid of them as we're in bwd now + for id in list(self.fwd_stash.keys()): + _, ev = self.fwd_stash[id] + self.s0.wait_event(ev) + del self.fwd_stash[id] + + # wait on prev node's events and del those + for id in prev_node_ids: + # Only wait on events that exist (some tensors may have used record_stream instead) + if id in self.bwd_ev_stash: + event = self.bwd_ev_stash[id] + self.s1.wait_event(event) + del self.bwd_ev_stash[id] + if id in self.bwd_tensor_stash: + del self.bwd_tensor_stash[id] + + return outputs + + node.register_hook(hook) + + # clear tensor from tracking + del self.tracker[unpack_tensor_id] + # Only set is_first_forward_call to True when all tensors have been unpacked + if len(self.tracker) == 0: + self.is_first_forward_call = True + return maybe_accelerator_tensor + + unpack_tensor = unpack_tensor_with_streams if self.use_streams else unpack_tensor_single_stream + super().__init__(pack_tensor, unpack_tensor) + + def update_model_params(self, model: nn.Module): + """ + Update the set of parameter storage pointers from the model. This allows filtering out model parameters during + offloading, which is especially important for FSDP models where parameters may not be detected by isinstance + checks. + + For FSDP v2, this method handles DTensor parameters which may be sharded across ranks and not have valid local + storage on all ranks. We extract the local tensor from DTensors using _local_tensor when available. + + Args: + model: The model whose parameters should be tracked + """ + param_storages = set() + + for p in model.parameters(): + # For FSDP v2: extract local tensor from DTensor + actual_tensor = p + if DTensor is not None and isinstance(p, DTensor) and hasattr(p, "_local_tensor"): + actual_tensor = p._local_tensor + + # Try to get storage pointer + try: + storage_ptr = actual_tensor.untyped_storage().data_ptr() + if storage_ptr != 0: + param_storages.add(storage_ptr) + except RuntimeError: + # Parameter doesn't have accessible storage (e.g., FSDP v2 sharded without local shard, FP8 parameters) + # These will be caught by other checks (isinstance for Parameter, class name for FP8) + continue + + self.param_storages = param_storages + + +class NoOpManager(saved_tensors_hooks): + """ + A `saved_tensors_hook` manager used to disable any other `saved_tensors_hook` manager applied before. This relies + on the behavior that only the most recently registered `saved_tensors_hook` will run. + + One example usage is to opt a local region of code out of activations offloading, which is usually applied globally + to best track state. + """ + + def __init__(self) -> None: + def noop(tensor): + return tensor + + super().__init__(noop, noop) + + +def get_act_offloading_ctx_manager( + model: nn.Module, + use_pin_memory: bool = True, + use_streams: bool = True, + min_offload_size: int = 1024, + max_fwd_stash_size: int = 5, + warn_if_no_head: bool = True, +) -> OffloadActivations: + """ + Returns the activation offloading context manager for the model. All but the last output Linear in every step will + be offloaded. + + If activation offloading is enabled, we return the OffloadActivations context manager. If activation offloading is + disabled, we return a NoOpManager context manager. + + Args: + model (`nn.Module`): + Model to wrap with the activation offloading context manager. + use_pin_memory (`bool`, *optional*, defaults to `True`): + Whether to offloaded Tensor will be placed in pinned memory on the CPU. Pinned memory allows the Tensor to + be moved back onto GPU more quickly but is a limited resource. + use_streams (`bool`, *optional*, defaults to `True`): + Whether to use streams for performance optimization where the communications get overlapped with the + computation. Requires a torch build after torch-2.5.0. + min_offload_size (`int`, *optional*, defaults to `1024`): + Minimum number of bytes a Tensor must be in order to qualify for offloading. If the tensor is too small, we + do not want to waste bandwidth and resources moving it to CPU and back. + max_fwd_stash_size (`int`, *optional*, defaults to `5`): + Maximum size of the forward stash, or the maximum number of consecutive activations to keep alive during + the forward pass. This number must be at least 1. Keeping alive more activations will potentially allow + more overlap between the communication and compute streams at the cost of increasing memory usage. Keeping + alive fewer activations will conserve memory, but may cause poor overlap between the streams, increasing + runtime. + warn_if_no_head (`bool`, *optional*, defaults to `True`): + Whether to warn if no output head is detected. If set to `False`, no warning will be raised if no output + head is detected. + + Returns: + `contextlib.ContextDecorator`: + Activation offloading context manager for the model. + """ + activations_handling_ctx = OffloadActivations( + use_pin_memory=use_pin_memory, + use_streams=use_streams, + min_offload_size=min_offload_size, + max_fwd_stash_size=max_fwd_stash_size, + ) + + # Update parameter storages to filter them during offloading (important for FSDP) + activations_handling_ctx.update_model_params(model) + + # Below is our hack to disable offloading the last output Linear in every + # step, as the cost for offloading the activation and then soon after bringing + # it back is expensive. + output_head_detected = False + noop_ctx = NoOpManager() + + # Try to get the actual model if it's wrapped + unwrapped_model = model + if hasattr(unwrapped_model, "module"): + unwrapped_model = unwrapped_model.module + # check for PEFT models + if hasattr(unwrapped_model, "base_model") and hasattr(unwrapped_model, "peft_config"): + unwrapped_model = unwrapped_model.base_model + + # Check for different types of output heads + if hasattr(unwrapped_model, "output"): + if isinstance(unwrapped_model.output, nn.Module): + unwrapped_model.output.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + unwrapped_model.output.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + elif hasattr(unwrapped_model.output, "linear") and isinstance(unwrapped_model.output.linear, nn.Module): + unwrapped_model.output.linear.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + unwrapped_model.output.linear.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + + # Check for HuggingFace model output heads + elif hasattr(unwrapped_model, "lm_head"): + unwrapped_model.lm_head.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + unwrapped_model.lm_head.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + + # Check for decoder-based models + elif hasattr(unwrapped_model, "decoder"): + decoder = unwrapped_model.decoder + if hasattr(decoder, "output"): + decoder.output.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + decoder.output.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + # Some models have lm_head in the decoder + elif hasattr(decoder, "lm_head"): + decoder.lm_head.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + decoder.lm_head.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + + # Check for transformer models with final layer norm + elif hasattr(unwrapped_model, "final_layer_norm") or hasattr(unwrapped_model, "ln_f"): + final_norm = getattr(unwrapped_model, "final_layer_norm", None) or unwrapped_model.ln_f + final_norm.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + final_norm.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + + # Check for models with head module + elif hasattr(unwrapped_model, "head") and isinstance(unwrapped_model.head, nn.Module): + unwrapped_model.head.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + unwrapped_model.head.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + output_head_detected = True + + if not output_head_detected and warn_if_no_head: + logger.warning( + "During activation offloading, no output head was detected. If your model has an output head, it will be " + "offloaded. This usually greatly slows training, given the large vocabulary size. To change this " + "behavior, set your output head as model.output and make it an nn.Module. You can disable this warning by " + "passing `warn_if_no_head=False`." + ) + + # Disable offloading for any Liger modules + for name, module in unwrapped_model.named_modules(): + if "liger" in name.lower(): + module.register_forward_pre_hook(lambda *args: noop_ctx.__enter__()) + module.register_forward_hook(lambda *args: noop_ctx.__exit__(), always_call=True) + + return activations_handling_ctx diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/models/utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/models/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..1e9151258b528b45174726f15def7c53c75e38cf --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/models/utils.py @@ -0,0 +1,395 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import itertools +import warnings +from collections.abc import Callable +from contextlib import contextmanager +from copy import deepcopy +from typing import TYPE_CHECKING, Any + +import accelerate +import torch.nn as nn +import transformers +from accelerate import Accelerator +from packaging.version import Version +from torch.distributed.fsdp import FSDPModule +from torch.distributed.fsdp.fully_sharded_data_parallel import FullyShardedDataParallel as FSDP +from transformers import GenerationConfig, PreTrainedModel + +from ..import_utils import suppress_experimental_warning + + +with suppress_experimental_warning(): + from ..experimental.utils import create_reference_model as _create_reference_model + + +if Version(accelerate.__version__) >= Version("1.11.0"): + from accelerate.utils.fsdp_utils import get_parameters_from_modules + +if TYPE_CHECKING: + from deepspeed.runtime.engine import DeepSpeedEngine + from torch.nn import Module + from torch.nn.parallel.distributed import DistributedDataParallel + + +def remove_hooks(model: "DeepSpeedEngine") -> None: + """Removes the optimizer hooks from a DeepSpeed ZeRO-3 model.""" + if not hasattr(model, "optimizer"): # before the first training step, the model has no optimizer + return + if model.optimizer is not None and hasattr(model.optimizer, "parameter_offload"): + optimizer_offload = model.optimizer.parameter_offload + elif model.optimizer is not None: + optimizer_offload = model.optimizer + else: + raise RuntimeError("The model optimizer is None, which is not yet supported.") + + for param in iter_params(optimizer_offload.module, recurse=True): + param.ds_active_sub_modules.clear() + + for hook in optimizer_offload.forward_hooks: + hook.remove() + for hook in optimizer_offload.backward_hooks: + hook.remove() + + optimizer_offload.forward_hooks = [] + optimizer_offload.backward_hooks = [] + + +def get_all_parameters(sub_module, recurse=False): + return itertools.chain(sub_module.named_parameters(recurse=recurse), sub_module.ds_external_parameters()) + + +def iter_params(module, recurse=False): + return [param for _, param in get_all_parameters(module, recurse)] + + +def add_hooks(model: "DeepSpeedEngine") -> None: + """Adds the optimizer hooks from a DeepSpeed ZeRO-3 model.""" + import deepspeed + + if not hasattr(model, "optimizer"): # before the first training step, the model has no optimizer + return + if model.optimizer is not None and hasattr(model.optimizer, "parameter_offload"): + optimizer_offload = model.optimizer.parameter_offload + elif model.optimizer is not None: + optimizer_offload = model.optimizer + else: + raise RuntimeError("The model optimizer is None, which is not yet supported.") + if Version(deepspeed.__version__) >= Version("0.16.4"): + # Account for renaming in https://github.com/deepspeedai/DeepSpeed/pull/6847 + optimizer_offload._register_deepspeed_module(optimizer_offload.module) + else: + optimizer_offload._register_hooks_recursively(optimizer_offload.module) + + +@contextmanager +def _unwrap_model_for_generation( + model: "DistributedDataParallel | DeepSpeedEngine", + accelerator: "Accelerator", + gather_deepspeed3_params: bool = True, +): + """ + Context manager to unwrap distributed or accelerated models for generation tasks. + + Args: + model (`DistributedDataParallel | DeepSpeedEngine`): + Model to be unwrapped. + accelerator ([`~accelerate.Accelerator`]): + Accelerator instance managing the model. + gather_deepspeed3_params (`bool`, *optional*, defaults to `True`): + Whether to gather weights for DeepSpeed ZeRO Stage 3 models. If `False`, skips parameter gathering, which + can be more memory-efficient but may lead to slower generation times. + + Yields: + Unwrapped model. + + Example: + ```python + with _unwrap_model_for_generation(model, accelerator) as unwrapped_model: + generated_outputs = unwrapped_model.generate(input_ids) + ``` + """ + unwrapped_model = accelerator.unwrap_model(model) + is_gradient_checkpointing = unwrapped_model.is_gradient_checkpointing + if is_gradient_checkpointing: + unwrapped_model.gradient_checkpointing_disable() + if accelerator.state.deepspeed_plugin is not None and accelerator.state.deepspeed_plugin.zero_stage == 3: + if not gather_deepspeed3_params: + yield accelerator.unwrap_model(model) + else: + import deepspeed + + with deepspeed.zero.GatheredParameters(model.parameters()): + remove_hooks(model) + yield accelerator.unwrap_model(model) + add_hooks(model) + else: + yield unwrapped_model + if is_gradient_checkpointing: + unwrapped_model.gradient_checkpointing_enable() + + +@contextmanager +def _override_model_generation_config(model, generation_kwargs=None): + """ + Context manager to temporarily override a model's generation_config with training config. + + This works around transformers' config merging logic that would otherwise overwrite values matching global defaults + with model-specific values (see upstream issue transformers#42762; fixed in transformers v5 by PR + `transformers#42702`). + + By temporarily setting the model's generation_config to match the passed generation_config, we avoid the conflict. + + The model's original generation_config is preserved outside this context, ensuring that saved/pushed models retain + their intended inference behavior. + + Args: + model: The model (typically unwrapped_model) whose generation_config to temporarily override. + generation_kwargs (dict): Generation kwargs to be used to override model's generation config. + """ + if ( + # Issue fixed in transformers v5 by PR transformers#42702 + Version(transformers.__version__) >= Version("5.0.0") + or generation_kwargs is None + or not hasattr(model, "generation_config") + ): + yield model + return + # If it is a PEFT model, override the underlying base model + if hasattr(model, "get_base_model"): + model = model.get_base_model() + # Keep original model generation_config + original_config = model.generation_config + # Create training-specific generation config from the model's original generation config + # Then overwrite it with the training-specific generation kwargs + generation_config = GenerationConfig.from_dict(model.generation_config.to_dict()) + generation_config.update(**generation_kwargs) + model.generation_config = generation_config + try: + yield + finally: + model.generation_config = original_config + + +@contextmanager +def unwrap_model_for_generation( + model: "DistributedDataParallel | DeepSpeedEngine", + accelerator: "Accelerator", + gather_deepspeed3_params: bool = True, + generation_kwargs: dict | None = None, +): + """ + Context manager to unwrap distributed or accelerated models for generation tasks. + + This function unwraps distributed models (FSDP, DeepSpeed) and optionally overrides the model's generation_config + temporarily during generation. This is useful for applying training-specific generation parameters without + permanently modifying the model's original generation_config. + + Args: + model (`DistributedDataParallel | DeepSpeedEngine`): + Model to be unwrapped. + accelerator ([`~accelerate.Accelerator`]): + Accelerator instance managing the model. + gather_deepspeed3_params (`bool`, *optional*, defaults to `True`): + Whether to gather weights for DeepSpeed ZeRO Stage 3 models. If `False`, skips parameter gathering, which + can be more memory-efficient but may lead to slower generation times. + generation_kwargs (dict, *optional*): + If provided, temporarily overrides the model's generation_config during generation. The original config is + automatically restored when exiting the context. This is useful for using different generation parameters + during training vs. inference. + + Yields: + Unwrapped model with optionally overridden generation_config. + """ + with ( + _unwrap_model_for_generation( + model, accelerator, gather_deepspeed3_params=gather_deepspeed3_params + ) as unwrapped_model, + _override_model_generation_config(unwrapped_model, generation_kwargs=generation_kwargs), + ): + yield unwrapped_model + + +def prepare_deepspeed(model: "Module", accelerator: "Accelerator"): + """Prepares the model for DeepSpeed inference or evaluation by initializing it with the appropriate configuration. + + Adapted from accelerate: + https://github.com/huggingface/accelerate/blob/739b135f8367becb67ffaada12fe76e3aa60fefd/src/accelerate/accelerator.py#L1473 + """ + import deepspeed # local import (instead of top-level) to avoid DS init interfering with other backends (like vllm): https://github.com/deepspeedai/DeepSpeed/issues/7252 + + deepspeed_plugin = accelerator.state.deepspeed_plugin + config_kwargs = deepcopy(deepspeed_plugin.deepspeed_config) + stage = config_kwargs["zero_optimization"]["stage"] + + if model is not None: + hidden_size = ( + max(model.config.hidden_sizes) + if getattr(model.config, "hidden_sizes", None) + else getattr(model.config, "hidden_size", None) + ) + if hidden_size is not None and stage == 3: + # Note that `stage3_prefetch_bucket_size` can produce DeepSpeed messages like: `Invalidate trace cache + # @ step 0: expected module 1, but got module 0` + # This is expected and is not an error, see: https://github.com/microsoft/DeepSpeed/discussions/4081 + config_kwargs.update( + { + "zero_optimization.reduce_bucket_size": hidden_size * hidden_size, + "zero_optimization.stage3_param_persistence_threshold": 10 * hidden_size, + "zero_optimization.stage3_prefetch_bucket_size": 0.9 * hidden_size * hidden_size, + } + ) + + # If ZeRO-3 is used, we shard both the active and reference model. + # Otherwise, we assume the reference model fits in memory and is initialized on each device with ZeRO + # disabled (stage 0) + if stage != 3: + config_kwargs["zero_optimization"]["stage"] = 0 + model, *_ = deepspeed.initialize(model=model, config=config_kwargs) + model.eval() + return model + + +def prepare_fsdp(model, accelerator: Accelerator) -> FSDP | FSDPModule: + # Check if the model is already a FSDP model due to `Manual Wrapping` and if so, don't wrap it again + if not isinstance(model, (FSDP, FSDPModule)): + fsdp_plugin = accelerator.state.fsdp_plugin + if fsdp_plugin.fsdp_version == 1: + accelerator.state.fsdp_plugin.set_auto_wrap_policy(model) + kwargs = { + "sharding_strategy": fsdp_plugin.sharding_strategy or fsdp_plugin.reshard_after_forward, + "cpu_offload": fsdp_plugin.cpu_offload, + "auto_wrap_policy": fsdp_plugin.auto_wrap_policy, + "mixed_precision": fsdp_plugin.mixed_precision_policy, + "sync_module_states": fsdp_plugin.sync_module_states, + "backward_prefetch": fsdp_plugin.backward_prefetch, + "forward_prefetch": fsdp_plugin.forward_prefetch, + "use_orig_params": fsdp_plugin.use_orig_params, + "param_init_fn": fsdp_plugin.param_init_fn, + "ignored_modules": fsdp_plugin.ignored_modules, + "limit_all_gathers": fsdp_plugin.limit_all_gathers, + "device_id": accelerator.device, + } + model = FSDP(model, **kwargs) + elif fsdp_plugin.fsdp_version == 2: + from torch.distributed.fsdp import MixedPrecisionPolicy, fully_shard + + mesh = getattr(accelerator, "torch_device_mesh", None) + if Version(accelerate.__version__) >= Version("1.11.0"): + ignored_params = get_parameters_from_modules(fsdp_plugin.ignored_modules, model, accelerator.device) + else: + warnings.warn( + "FSDP version 2 is being used with accelerate version < 1.11.0, which may lead to incorrect " + "handling of ignored modules. Please upgrade accelerate to v1.11.0 or later for proper support." + ) + ignored_params = None + fully_shard( + model, + reshard_after_forward=fsdp_plugin.reshard_after_forward, + offload_policy=fsdp_plugin.cpu_offload, + # `fully_shard` doesn't accept `None` in case of `MixedPrecisionPolicy` + mp_policy=fsdp_plugin.mixed_precision_policy or MixedPrecisionPolicy(), + mesh=mesh[tuple(accelerator.parallelism_config.fsdp_dim_names)] if mesh is not None else None, + ignored_params=ignored_params, + ) + else: + raise ValueError(f"FSDP version {fsdp_plugin.fsdp_version} is not supported.") + model.eval() + return model + + +class _ForwardRedirection: + """Implements the `forward-redirection`. + + Taken from Pytorch-lightning: + https://github.com/Lightning-AI/pytorch-lightning/blob/02311d03fb982560246eead7c08104481fac9579/src/lightning/pytorch/strategies/strategy.py#L602 + + A method call to a wrapped module gets rerouted through the wrapper's `forward` method instead. + + """ + + def __call__( + self, wrapper_module: nn.Module, original_module: nn.Module, method: Callable, *args: Any, **kwargs: Any + ): + """Reroutes a method call through the `wrapper_module`'s `forward` method. + + Args: + wrapper_module: The module that has `original_module` wrapped. + original_module: The module that was wrapped inside `wrapper_module`. + method: The method that should be called on the `original_module` after inputs get + redirected through the `wrapper_module`'s `forward` method. + *args: The positional arguments to the `method`. They will get passed to a patched + `forward` method instead. + **kwargs: The keyword arguments to the `method`. They will get passed to a patched + `forward` method instead. + + """ + original_forward = original_module.forward + + def wrapped_forward(*_args: Any, **_kwargs: Any) -> Any: + # Unpatch ourselves immediately before calling the method `method_name` + # because itself may want to call the real `forward` + original_module.forward = original_forward # type: ignore[method-assign] + # Call the actual method e.g. `.training_step(...)` + out = method(*_args, **_kwargs) + self.on_after_inner_forward(wrapper_module, original_module) + return out + + # Patch the original_module's forward so we can redirect the arguments back to the real method + original_module.forward = wrapped_forward # type: ignore[method-assign] + + wrapper_output = wrapper_module(*args, **kwargs) + self.on_after_outer_forward(wrapper_module, original_module) + return wrapper_output + + def on_after_inner_forward(self, wrapper_module: nn.Module, original_module: nn.Module) -> None: + pass + + def on_after_outer_forward(self, wrapper_module: nn.Module, original_module: nn.Module) -> None: + pass + + +@contextmanager +def disable_gradient_checkpointing(model: PreTrainedModel, gradient_checkpointing_kwargs: dict | None = None): + """ + Temporarily disable gradient checkpointing, restoring the previous state afterward. + + Args: + model (`PreTrainedModel`): + Model for which to temporarily disable gradient checkpointing. + gradient_checkpointing_kwargs (`dict` or `None`, *optional*): + Additional kwargs for gradient checkpointing enabling. + """ + was_enabled = model.is_gradient_checkpointing + if was_enabled: + model.gradient_checkpointing_disable() + try: + yield + finally: + if was_enabled: + model.gradient_checkpointing_enable(gradient_checkpointing_kwargs) + + +def create_reference_model( + model: nn.Module, num_shared_layers: int | None = None, pattern: str | None = None +) -> nn.Module: + warnings.warn( + "The `create_reference_model` function is now located in `trl.experimental.utils`. Please update your " + "imports to `from trl.experimental.utils import create_reference_model`. This import path will be removed in " + "TRL 1.0.0.", + FutureWarning, + stacklevel=2, + ) + return _create_reference_model(model, num_shared_layers=num_shared_layers, pattern=pattern) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/py.typed b/tasks/tasksmith-1c108f674e97/tests/source/trl/py.typed new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..aeec677314023b0a2221d98872304a4f631530cf --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/__init__.py @@ -0,0 +1,35 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from typing import TYPE_CHECKING + +from .._lazy_module import _LazyModule + + +_import_structure = { + "accuracy_rewards": ["accuracy_reward", "reasoning_accuracy_reward"], + "format_rewards": ["think_format_reward"], + "other_rewards": ["get_soft_overlong_punishment"], +} + + +if TYPE_CHECKING: + from .accuracy_rewards import accuracy_reward, reasoning_accuracy_reward + from .format_rewards import think_format_reward + from .other_rewards import get_soft_overlong_punishment + + +else: + sys.modules[__name__] = _LazyModule(__name__, __file__, _import_structure, module_spec=__spec__) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/accuracy_rewards.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/accuracy_rewards.py new file mode 100644 index 0000000000000000000000000000000000000000..f2fedf913f89ebda59743405d3d3a3156cc3fa99 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/accuracy_rewards.py @@ -0,0 +1,244 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import threading +from collections.abc import Callable + +from ..import_utils import is_math_verify_available + + +if is_math_verify_available(): + from latex2sympy2_extended import NormalizationConfig + from math_verify import LatexExtractionConfig, parse, verify + + +def accuracy_reward( + completions: list[list[dict[str, str]]], + solution: list[str], + log_extra: Callable[[str, list], None] | None = None, + **kwargs, +) -> list[float | None]: + r""" + Reward function that checks if the completion matches the ground truth. + - If both gold and prediction are parseable → use math verification. + - If gold is not parseable → return `None` to skip the example. + + Args: + completions (`list[list[dict[str, str]]]`): + List of completions to be evaluated. Each completion must be a list of one message, i.e. a dictionary + containing the key `"content"` with the value being the text of the completion. + solution: (`list[str]`): + List of the raw-text solutions to the questions/problems/prompts. + log_extra (`callable`, *optional*): + Callable to log extra columns to the completions table, provided automatically by the trainer. Defaults to + `None` to allow calling the function directly outside of a trainer (e.g., for testing). + **kwargs: + Additional keyword arguments. This function does not use them, but they are required in the function + signature to ensure compatibility with trainers like [`GRPOTrainer`]. + Example: + ```python + >>> from trl.rewards import accuracy_reward + + >>> solutions = [r"\frac{1}{3}", r"\frac{1}{3}"] + >>> completions = [ + ... [{"role": "assistant", "content": r"My answer is \boxed{\frac{1}{3}}"}], + ... [{"role": "assistant", "content": r"My answer is \boxed{\frac{1}{2}}"}], + ... ] + >>> accuracy_reward(completions, solutions) + [1.0, 0.0] + ``` + """ + if not is_math_verify_available(): + raise ImportError("Please install the `math_verify` package to use accuracy_reward") + + contents = [completion[0]["content"] for completion in completions] + rewards = [] + gold_parsed_strs = [] + answer_parsed_strs = [] + + # math_verify uses signal.alarm() for timeouts, which only works in the main thread. + # Disable timeouts when running in a non-main thread to avoid ValueError. + is_main_thread = threading.current_thread() is threading.main_thread() + parsing_timeout = None if not is_main_thread else 10 + verify_timeout = None if not is_main_thread else 5 + + # Suppress the "Timeout is disabled" warnings from math_verify when we intentionally disable timeouts + if not is_main_thread: + logging.getLogger("math_verify.parser").setLevel(logging.ERROR) + logging.getLogger("math_verify.grader").setLevel(logging.ERROR) + + for content, sol in zip(contents, solution, strict=True): + gold_parsed = parse(sol, parsing_timeout=parsing_timeout) + if len(gold_parsed) != 0: + # We require the answer to be provided in correct latex (no malformed operators) + answer_parsed = parse( + content, + extraction_config=[ + LatexExtractionConfig( + normalization_config=NormalizationConfig(units=True), + # Ensures that boxed is tried first + boxed_match_priority=0, + try_extract_without_anchor=False, + ) + ], + extraction_mode="first_match", + parsing_timeout=parsing_timeout, + ) + reward = float(verify(gold_parsed, answer_parsed, timeout_seconds=verify_timeout)) + gold_parsed_strs.append(str(gold_parsed)) + answer_parsed_strs.append(str(answer_parsed) if answer_parsed else "[unparseable]") + else: + # If the gold solution cannot be parsed, we assign `None` to skip this example + reward = None + gold_parsed_strs.append("[unparseable]") + answer_parsed_strs.append("[skipped]") + rewards.append(reward) + + if log_extra is not None: + log_extra("solution", list(solution)) + log_extra("gold_parsed", gold_parsed_strs) + log_extra("answer_parsed", answer_parsed_strs) + + return rewards + + +def reasoning_accuracy_reward( + completions: list[list[dict[str, str]]], + solution: list[str], + reasoning_delimiters: list[str] | None = None, + log_extra: Callable[[str, list], None] | None = None, + **kwargs, +) -> list[float | None]: + r""" + Reward function that removes the reasoning content and checks if the final answer matches the ground truth. + - If both gold and prediction are parseable → use math verification. + - If gold is not parseable → return `None` to skip the example. + + Args: + completions (`list[list[dict[str, str]]]`): + List of completions to be evaluated. Each completion must be a list of one message, i.e. a dictionary + containing the key `"content"` with the value being the text of the completion. + solution: (`list[str]`): + List of the raw-text solutions to the questions/problems/prompts. + reasoning_delimiters (`list[str]]`, *optional*): + List of strings indicating where the reasoning content ends. The final answer is assumed to be after the + last occurrence of any of these delimiters. If `None`, defaults to `[""]`. + log_extra (`callable`, *optional*): + Callable to log extra columns to the completions table, provided automatically by the trainer. Defaults to + `None` to allow calling the function directly outside of a trainer (e.g., for testing). + **kwargs: + Additional keyword arguments. This function does not use them, but they are required in the function + signature to ensure compatibility with trainers like [`GRPOTrainer`]. + Example: + ```python + >>> from trl.rewards import reasoning_accuracy_reward + + >>> reasoning_delimiters = [""] + >>> solutions = [r"\frac{1}{3}", r"\frac{1}{3}", r"\frac{1}{3}"] + >>> completions = [ + ... [ + ... { + ... "role": "assistant", + ... "content": r" Reasoning content The final answer is \boxed{\frac{1}{3}}", + ... } + ... ], + ... [ + ... { + ... "role": "assistant", + ... "content": r" Reasoning content The final answer is \boxed{\frac{1}{2}}", + ... } + ... ], + ... [ + ... { + ... "role": "assistant", + ... "content": r" Reasoning content with partial answers \boxed{\frac{1}{3}} but no final answer", + ... } + ... ], + ... ] + >>> reasoning_accuracy_reward(completions, solutions, reasoning_delimiters=reasoning_delimiters) + [1.0, 0.0, 0.0] + ``` + """ + if not is_math_verify_available(): + raise ImportError("Please install the `math_verify` package to use reasoning_accuracy_reward") + + if reasoning_delimiters is None: + # Use sensible defaults for majority of reasoning models + reasoning_delimiters = [""] + + rewards = [] + contents = [completion[0]["content"] for completion in completions] + gold_parsed_strs = [] + answer_parsed_strs = [] + + # math_verify uses signal.alarm() for timeouts, which only works in the main thread. + # Disable timeouts when running in a non-main thread to avoid ValueError. + is_main_thread = threading.current_thread() is threading.main_thread() + parsing_timeout = None if not is_main_thread else 10 + verify_timeout = None if not is_main_thread else 5 + + # Suppress the "Timeout is disabled" warnings from math_verify when we intentionally disable timeouts + if not is_main_thread: + logging.getLogger("math_verify.parser").setLevel(logging.ERROR) + logging.getLogger("math_verify.grader").setLevel(logging.ERROR) + + for content, sol in zip(contents, solution, strict=True): + # Split final answer from reasoning content + is_reasoning_complete = False + for delim in reasoning_delimiters: + if delim in content: + content = content.split(delim)[-1] + is_reasoning_complete = True + break + if not is_reasoning_complete: + # We assign zero reward instead of `None` to penalize incomplete reasoning + rewards.append(0.0) + gold_parsed_strs.append("[incomplete reasoning]") + answer_parsed_strs.append("[incomplete reasoning]") + continue + + gold_parsed = parse(sol, parsing_timeout=parsing_timeout) + if len(gold_parsed) != 0: + # We require the answer to be provided in correct latex (no malformed operators) + answer_parsed = parse( + content, + extraction_config=[ + LatexExtractionConfig( + boxed_match_priority=0, + normalization_config=NormalizationConfig( + units=True, + ), + try_extract_without_anchor=False, + ) + ], + extraction_mode="first_match", + parsing_timeout=parsing_timeout, + ) + reward = float(verify(gold_parsed, answer_parsed, timeout_seconds=verify_timeout)) + gold_parsed_strs.append(str(gold_parsed)) + answer_parsed_strs.append(str(answer_parsed) if answer_parsed else "[unparseable]") + else: + # If the gold solution cannot be parsed, we assign `None` to skip this example + reward = None + gold_parsed_strs.append("[unparseable]") + answer_parsed_strs.append("[skipped]") + rewards.append(reward) + + if log_extra is not None: + log_extra("solution", list(solution)) + log_extra("gold_parsed", gold_parsed_strs) + log_extra("answer_parsed", answer_parsed_strs) + + return rewards diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/format_rewards.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/format_rewards.py new file mode 100644 index 0000000000000000000000000000000000000000..c737d0036b165ebf4a15e2c2558f82187e87038d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/format_rewards.py @@ -0,0 +1,50 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re + + +def think_format_reward(completions: list[list[dict[str, str]]], **kwargs) -> list[float]: + r""" + Reward function that checks if the reasoning process is enclosed within `""` and `""` tags. The + function returns a reward of 1.0 if the format is correct, otherwise 0.0. + + Args: + completions (`list[list[dict[str, str]]]`): + List of completions to be evaluated. Each completion must be a list of one message, i.e. a dictionary + containing the key `"content"` with the value being the text of the completion. + **kwargs: + Additional keyword arguments. This function does not use them, but they are required in the function + signature to ensure compatibility with trainers like [`GRPOTrainer`]. + + Returns: + `list[float]`: + A list of rewards, where each reward is 1.0 if the completion matches the expected format, otherwise 0.0. + + Example: + ```python + >>> from trl.rewards import think_format_reward + + >>> completions = [ + ... [{"content": "\nThis is my reasoning.\n\nThis is my answer."}], + ... [{"content": "\nThis is my reasoning.\nThis is my answer."}], + ... ] + >>> think_format_reward(completions) + [1.0, 0.0] + ``` + """ + pattern = r"^(?!.*)(.*?).*$" + completion_contents = [completion[0]["content"] for completion in completions] + matches = [re.match(pattern, content, re.DOTALL | re.MULTILINE) for content in completion_contents] + return [1.0 if match else 0.0 for match in matches] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/other_rewards.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/other_rewards.py new file mode 100644 index 0000000000000000000000000000000000000000..4d26ec2d52045e88fbfe4250636eb0de32d9afe3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/rewards/other_rewards.py @@ -0,0 +1,62 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections.abc import Callable + + +def get_soft_overlong_punishment(max_completion_len: int, soft_punish_cache: int) -> Callable: + # docstyle-ignore + r""" + Reward function that penalizes overlong completions. It is used to penalize overlong completions, but not to reward + shorter completions. Reference: Eq. (13) from the DAPO paper (https://huggingface.co/papers/2503.14476) + + $$ + R_{\text{length}}(y) = \begin{cases} + 0, & |y| \le L_{\max} - L_{\text{cache}} \\ + \dfrac{(L_{\max} - L_{\text{cache}}) - |y|}{L_{\text{cache}}}, & L_{\max} - L_{\text{cache}} < |y| \le L_{\max} \\ + -1, & L_{\max} < |y| + \end{cases} + $$ + + Args: + max_completion_len (`int`): + Maximum length of the completion, \( L_{\max} \). + soft_punish_cache (`int`): + Minimum length of the completion, \( L_{\text{cache}} \). If set to `0`, no minimum length is applied. + + Example: + ```python + from trl.rewards import get_soft_overlong_punishment + + soft_overlong_punishment = get_soft_overlong_punishment(max_completion_len=100, soft_punish_cache=20) + completion_ids = [[1] * 90] # simulating a completion with 90 tokens. 90 is between 80 and 100. + rewards = soft_overlong_punishment(completion_ids) + print(rewards) # [-0.5] + ``` + """ + + def soft_overlong_punishment_reward(completion_ids: list[list[int]], **kwargs) -> list[float]: + """Reward function that penalizes overlong completions.""" + rewards = [] + for ids in completion_ids: + completion_length = len(ids) + if completion_length <= max_completion_len - soft_punish_cache: + rewards.append(0.0) + elif max_completion_len - soft_punish_cache < completion_length <= max_completion_len: + rewards.append((max_completion_len - soft_punish_cache - completion_length) / soft_punish_cache) + else: + rewards.append(-1.0) + return rewards + + return soft_overlong_punishment_reward diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..cb15e6cdfe5446affd20a72cd22a8c74c6f15e1e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/__init__.py @@ -0,0 +1,29 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import TYPE_CHECKING + +from .._lazy_module import _LazyModule + + +_import_structure = { + "utils": ["DatasetMixtureConfig", "ScriptArguments", "TrlParser", "get_dataset", "init_zero_verbose"], +} + +if TYPE_CHECKING: + from .utils import DatasetMixtureConfig, ScriptArguments, TrlParser, get_dataset, init_zero_verbose +else: + import sys + + sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/_hf_argparser.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/_hf_argparser.py new file mode 100644 index 0000000000000000000000000000000000000000..a64efd6f3dbc623df188018c7db6ca1d598ea024 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/_hf_argparser.py @@ -0,0 +1,432 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Copied from: https://github.com/huggingface/transformers/blob/3a275d3581c0ecf962f7412aa764c2047331fd6b/src/transformers/hf_argparser.py +# This avoids an upstream latency issue: https://github.com/huggingface/transformers/issues/44273 +# - Moved yaml import inside function + + +import dataclasses +import json +import os +import sys +import types +from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError +from collections.abc import Callable, Iterable +from copy import copy +from enum import Enum +from inspect import isclass +from pathlib import Path +from typing import Any, Literal, NewType, Union, get_type_hints + + +DataClass = NewType("DataClass", Any) +DataClassType = NewType("DataClassType", Any) + + +# From https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse +def string_to_bool(v): + if isinstance(v, bool): + return v + if v.lower() in ("yes", "true", "t", "y", "1"): + return True + elif v.lower() in ("no", "false", "f", "n", "0"): + return False + else: + raise ArgumentTypeError( + f"Truthy value expected: got {v} but expected one of yes/no, true/false, t/f, y/n, 1/0 (case insensitive)." + ) + + +def make_choice_type_function(choices: list) -> Callable[[str], Any]: + """ + Creates a mapping function from each choices string representation to the actual value. Used to support multiple + value types for a single argument. + + Args: + choices (list): List of choices. + + Returns: + Callable[[str], Any]: Mapping function from string representation to actual value for each choice. + """ + str_to_choice = {str(choice): choice for choice in choices} + return lambda arg: str_to_choice.get(arg, arg) + + +def HfArg( + *, + aliases: str | list[str] | None = None, + help: str | None = None, + default: Any = dataclasses.MISSING, + default_factory: Callable[[], Any] = dataclasses.MISSING, + metadata: dict | None = None, + **kwargs, +) -> dataclasses.Field: + """Argument helper enabling a concise syntax to create dataclass fields for parsing with `HfArgumentParser`. + + Example comparing the use of `HfArg` and `dataclasses.field`: + ``` + @dataclass + class Args: + regular_arg: str = dataclasses.field(default="Huggingface", metadata={"aliases": ["--example", "-e"], "help": "This syntax could be better!"}) + hf_arg: str = HfArg(default="Huggingface", aliases=["--example", "-e"], help="What a nice syntax!") + ``` + + Args: + aliases (Union[str, list[str]], optional): + Single string or list of strings of aliases to pass on to argparse, e.g. `aliases=["--example", "-e"]`. + Defaults to None. + help (str, optional): Help string to pass on to argparse that can be displayed with --help. Defaults to None. + default (Any, optional): + Default value for the argument. If not default or default_factory is specified, the argument is required. + Defaults to dataclasses.MISSING. + default_factory (Callable[[], Any], optional): + The default_factory is a 0-argument function called to initialize a field's value. It is useful to provide + default values for mutable types, e.g. lists: `default_factory=list`. Mutually exclusive with `default=`. + Defaults to dataclasses.MISSING. + metadata (dict, optional): Further metadata to pass on to `dataclasses.field`. Defaults to None. + + Returns: + Field: A `dataclasses.Field` with the desired properties. + """ + if metadata is None: + # Important, don't use as default param in function signature because dict is mutable and shared across function calls + metadata = {} + if aliases is not None: + metadata["aliases"] = aliases + if help is not None: + metadata["help"] = help + + return dataclasses.field(metadata=metadata, default=default, default_factory=default_factory, **kwargs) + + +class HfArgumentParser(ArgumentParser): + """ + This subclass of `argparse.ArgumentParser` uses type hints on dataclasses to generate arguments. + + The class is designed to play well with the native argparse. In particular, you can add more (non-dataclass backed) + arguments to the parser after initialization and you'll get the output back after parsing as an additional + namespace. Optional: To create sub argument groups use the `_argument_group_name` attribute in the dataclass. + + Args: + dataclass_types (`DataClassType` or `Iterable[DataClassType]`, *optional*): + Dataclass type, or list of dataclass types for which we will "fill" instances with the parsed args. + kwargs (`dict[str, Any]`, *optional*): + Passed to `argparse.ArgumentParser()` in the regular way. + """ + + dataclass_types: Iterable[DataClassType] + + def __init__(self, dataclass_types: DataClassType | Iterable[DataClassType] | None = None, **kwargs): + # Make sure dataclass_types is an iterable + if dataclass_types is None: + dataclass_types = [] + elif not isinstance(dataclass_types, Iterable): + dataclass_types = [dataclass_types] + + # To make the default appear when using --help + if "formatter_class" not in kwargs: + kwargs["formatter_class"] = ArgumentDefaultsHelpFormatter + super().__init__(**kwargs) + if dataclasses.is_dataclass(dataclass_types): + dataclass_types = [dataclass_types] + self.dataclass_types = list(dataclass_types) + for dtype in self.dataclass_types: + self._add_dataclass_arguments(dtype) + + @staticmethod + def _parse_dataclass_field(parser: ArgumentParser, field: dataclasses.Field): + # Long-option strings are conventionlly separated by hyphens rather + # than underscores, e.g., "--long-format" rather than "--long_format". + # Argparse converts hyphens to underscores so that the destination + # string is a valid attribute name. Hf_argparser should do the same. + long_options = [f"--{field.name}"] + if "_" in field.name: + long_options.append(f"--{field.name.replace('_', '-')}") + + kwargs = field.metadata.copy() + # field.metadata is not used at all by Data Classes, + # it is provided as a third-party extension mechanism. + if isinstance(field.type, str): + raise RuntimeError( + "Unresolved type detected, which should have been done with the help of " + "`typing.get_type_hints` method by default" + ) + + aliases = kwargs.pop("aliases", []) + if isinstance(aliases, str): + aliases = [aliases] + + origin_type = getattr(field.type, "__origin__", field.type) + if origin_type is Union or (hasattr(types, "UnionType") and isinstance(origin_type, types.UnionType)): + if str not in field.type.__args__ and ( + len(field.type.__args__) != 2 or type(None) not in field.type.__args__ + ): + raise ValueError( + "Only `Union[X, NoneType]` (i.e., `Optional[X]`) is allowed for `Union` because" + " the argument parser only supports one type per argument." + f" Problem encountered in field '{field.name}'." + ) + if type(None) not in field.type.__args__: + # filter `str` in Union + field.type = field.type.__args__[0] if field.type.__args__[1] is str else field.type.__args__[1] + origin_type = getattr(field.type, "__origin__", field.type) + elif bool not in field.type.__args__: + # filter `NoneType` in Union (except for `Union[bool, NoneType]`) + field.type = ( + field.type.__args__[0] if isinstance(None, field.type.__args__[1]) else field.type.__args__[1] + ) + origin_type = getattr(field.type, "__origin__", field.type) + + # A variable to store kwargs for a boolean field, if needed + # so that we can init a `no_*` complement argument (see below) + bool_kwargs = {} + if origin_type is Literal or (isinstance(field.type, type) and issubclass(field.type, Enum)): + if origin_type is Literal: + kwargs["choices"] = field.type.__args__ + else: + kwargs["choices"] = [x.value for x in field.type] + + kwargs["type"] = make_choice_type_function(kwargs["choices"]) + + if field.default is not dataclasses.MISSING: + kwargs["default"] = field.default + else: + kwargs["required"] = True + elif field.type is bool or field.type == bool | None: + # Copy the correct kwargs to use to instantiate a `no_*` complement argument below. + # We do not initialize it here because the `no_*` alternative must be instantiated after the real argument + bool_kwargs = copy(kwargs) + + # Hack because type=bool in argparse does not behave as we want. + kwargs["type"] = string_to_bool + if field.type is bool or (field.default is not None and field.default is not dataclasses.MISSING): + # Default value is False if we have no default when of type bool. + default = False if field.default is dataclasses.MISSING else field.default + # This is the value that will get picked if we don't include --{field.name} in any way + kwargs["default"] = default + # This tells argparse we accept 0 or 1 value after --{field.name} + kwargs["nargs"] = "?" + # This is the value that will get picked if we do --{field.name} (without value) + kwargs["const"] = True + elif isclass(origin_type) and issubclass(origin_type, list): + kwargs["type"] = field.type.__args__[0] + kwargs["nargs"] = "+" + if field.default_factory is not dataclasses.MISSING: + kwargs["default"] = field.default_factory() + elif field.default is dataclasses.MISSING: + kwargs["required"] = True + else: + kwargs["type"] = field.type + if field.default is not dataclasses.MISSING: + kwargs["default"] = field.default + elif field.default_factory is not dataclasses.MISSING: + kwargs["default"] = field.default_factory() + else: + kwargs["required"] = True + parser.add_argument(*long_options, *aliases, **kwargs) + + # Add a complement `no_*` argument for a boolean field AFTER the initial field has already been added. + # Order is important for arguments with the same destination! + # We use a copy of earlier kwargs because the original kwargs have changed a lot before reaching down + # here and we do not need those changes/additional keys. + if field.default is True and (field.type is bool or field.type == bool | None): + bool_kwargs["default"] = False + parser.add_argument( + f"--no_{field.name}", + f"--no-{field.name.replace('_', '-')}", + action="store_false", + dest=field.name, + **bool_kwargs, + ) + + def _add_dataclass_arguments(self, dtype: DataClassType): + if hasattr(dtype, "_argument_group_name"): + parser = self.add_argument_group(dtype._argument_group_name) + else: + parser = self + + try: + type_hints: dict[str, type] = get_type_hints(dtype) + except NameError: + raise RuntimeError( + f"Type resolution failed for {dtype}. Try declaring the class in global scope or " + "removing line of `from __future__ import annotations` which opts in Postponed " + "Evaluation of Annotations (PEP 563)" + ) from None + + for field in dataclasses.fields(dtype): + if not field.init: + continue + field.type = type_hints[field.name] + self._parse_dataclass_field(parser, field) + + def parse_args_into_dataclasses( + self, + args=None, + return_remaining_strings=False, + look_for_args_file=True, + args_filename=None, + args_file_flag=None, + ) -> tuple[DataClass, ...]: + """ + Parse command-line args into instances of the specified dataclass types. + + This relies on argparse's `ArgumentParser.parse_known_args`. See the doc at: + docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_args + + Args: + args: + List of strings to parse. The default is taken from sys.argv. (same as argparse.ArgumentParser) + return_remaining_strings: + If true, also return a list of remaining argument strings. + look_for_args_file: + If true, will look for a ".args" file with the same base name as the entry point script for this + process, and will append its potential content to the command line args. + args_filename: + If not None, will uses this file instead of the ".args" file specified in the previous argument. + args_file_flag: + If not None, will look for a file in the command-line args specified with this flag. The flag can be + specified multiple times and precedence is determined by the order (last one wins). + + Returns: + Tuple consisting of: + + - the dataclass instances in the same order as they were passed to the initializer.abspath + - if applicable, an additional namespace for more (non-dataclass backed) arguments added to the parser + after initialization. + - The potential list of remaining argument strings. (same as argparse.ArgumentParser.parse_known_args) + """ + + if args_file_flag or args_filename or (look_for_args_file and len(sys.argv)): + args_files = [] + + if args_filename: + args_files.append(Path(args_filename)) + elif look_for_args_file and len(sys.argv): + args_files.append(Path(sys.argv[0]).with_suffix(".args")) + + # args files specified via command line flag should overwrite default args files so we add them last + if args_file_flag: + # Create special parser just to extract the args_file_flag values + args_file_parser = ArgumentParser() + args_file_parser.add_argument(args_file_flag, type=str, action="append") + + # Use only remaining args for further parsing (remove the args_file_flag) + cfg, args = args_file_parser.parse_known_args(args=args) + cmd_args_file_paths = vars(cfg).get(args_file_flag.lstrip("-"), None) + + if cmd_args_file_paths: + args_files.extend([Path(p) for p in cmd_args_file_paths]) + + file_args = [] + for args_file in args_files: + if args_file.exists(): + file_args += args_file.read_text().split() + + # in case of duplicate arguments the last one has precedence + # args specified via the command line should overwrite args from files, so we add them last + args = file_args + args if args is not None else file_args + sys.argv[1:] + namespace, remaining_args = self.parse_known_args(args=args) + outputs = [] + for dtype in self.dataclass_types: + keys = {f.name for f in dataclasses.fields(dtype) if f.init} + inputs = {k: v for k, v in vars(namespace).items() if k in keys} + for k in keys: + delattr(namespace, k) + obj = dtype(**inputs) + outputs.append(obj) + if len(namespace.__dict__) > 0: + # additional namespace. + outputs.append(namespace) + if return_remaining_strings: + return (*outputs, remaining_args) + else: + if remaining_args: + raise ValueError(f"Some specified arguments are not used by the HfArgumentParser: {remaining_args}") + + return (*outputs,) + + def parse_dict(self, args: dict[str, Any], allow_extra_keys: bool = False) -> tuple[DataClass, ...]: + """ + Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass + types. + + Args: + args (`dict`): + dict containing config values + allow_extra_keys (`bool`, *optional*, defaults to `False`): + Defaults to False. If False, will raise an exception if the dict contains keys that are not parsed. + + Returns: + Tuple consisting of: + + - the dataclass instances in the same order as they were passed to the initializer. + """ + unused_keys = set(args.keys()) + outputs = [] + for dtype in self.dataclass_types: + keys = {f.name for f in dataclasses.fields(dtype) if f.init} + inputs = {k: v for k, v in args.items() if k in keys} + unused_keys.difference_update(inputs.keys()) + obj = dtype(**inputs) + outputs.append(obj) + if not allow_extra_keys and unused_keys: + raise ValueError(f"Some keys are not used by the HfArgumentParser: {sorted(unused_keys)}") + return tuple(outputs) + + def parse_json_file(self, json_file: str | os.PathLike, allow_extra_keys: bool = False) -> tuple[DataClass, ...]: + """ + Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the + dataclass types. + + Args: + json_file (`str` or `os.PathLike`): + File name of the json file to parse + allow_extra_keys (`bool`, *optional*, defaults to `False`): + Defaults to False. If False, will raise an exception if the json file contains keys that are not + parsed. + + Returns: + Tuple consisting of: + + - the dataclass instances in the same order as they were passed to the initializer. + """ + with open(Path(json_file), encoding="utf-8") as open_json_file: + data = json.loads(open_json_file.read()) + outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys) + return tuple(outputs) + + def parse_yaml_file(self, yaml_file: str | os.PathLike, allow_extra_keys: bool = False) -> tuple[DataClass, ...]: + """ + Alternative helper method that does not use `argparse` at all, instead loading a yaml file and populating the + dataclass types. + + Args: + yaml_file (`str` or `os.PathLike`): + File name of the yaml file to parse + allow_extra_keys (`bool`, *optional*, defaults to `False`): + Defaults to False. If False, will raise an exception if the json file contains keys that are not + parsed. + + Returns: + Tuple consisting of: + + - the dataclass instances in the same order as they were passed to the initializer. + """ + import yaml + + outputs = self.parse_dict(yaml.safe_load(Path(yaml_file).read_text()), allow_extra_keys=allow_extra_keys) + return tuple(outputs) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/dpo.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/dpo.py new file mode 100644 index 0000000000000000000000000000000000000000..a32eba070862d64bd60f3fd4f0ce11fd23a83ec3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/dpo.py @@ -0,0 +1,158 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +""" +# Full training +```bash +python trl/scripts/dpo.py \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --learning_rate 5.0e-7 \ + --num_train_epochs 1 \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --gradient_accumulation_steps 8 \ + --eval_strategy steps \ + --eval_steps 50 \ + --output_dir Qwen2-0.5B-DPO \ + --no_remove_unused_columns +``` + +# LoRA: +```bash +python trl/scripts/dpo.py \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --learning_rate 5.0e-6 \ + --num_train_epochs 1 \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --gradient_accumulation_steps 8 \ + --eval_strategy steps \ + --eval_steps 50 \ + --output_dir Qwen2-0.5B-DPO \ + --no_remove_unused_columns \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 +``` +""" + +import argparse + + +def main(script_args, training_args, model_args, dataset_args): + import torch + from accelerate import logging + from datasets import load_dataset + from transformers import AutoModelForCausalLM + + from trl import DPOTrainer, get_dataset, get_kbit_device_map, get_peft_config, get_quantization_config + + logger = logging.get_logger(__name__) + + ################ + # Model + ################### + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code, **model_kwargs + ) + peft_config = get_peft_config(model_args) + if script_args.ignore_bias_buffers: + # torch distributed hack + model._ddp_params_and_buffers_to_ignore = [ + name for name, buffer in model.named_buffers() if buffer.dtype == torch.bool + ] + + # Load the dataset + if dataset_args.datasets and script_args.dataset_name: + logger.warning( + "Both `datasets` and `dataset_name` are provided. The `datasets` argument will be used to load the " + "dataset and `dataset_name` will be ignored." + ) + dataset = get_dataset(dataset_args) + elif dataset_args.datasets and not script_args.dataset_name: + dataset = get_dataset(dataset_args) + elif not dataset_args.datasets and script_args.dataset_name: + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, streaming=script_args.dataset_streaming + ) + else: + raise ValueError("Either `datasets` or `dataset_name` must be provided.") + + # Initialize the DPO trainer + trainer = DPOTrainer( + model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=peft_config, + ) + + # Train the model + trainer.train() + + # Log training complete + trainer.accelerator.print("✅ Training completed.") + + if training_args.eval_strategy != "no": + metrics = trainer.evaluate() + trainer.log_metrics("eval", metrics) + trainer.save_metrics("eval", metrics) + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + trainer.accelerator.print(f"💾 Model saved to {training_args.output_dir}.") + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + trainer.accelerator.print(f"🤗 Model pushed to the Hub in https://huggingface.co/{trainer.hub_model_id}.") + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import DatasetMixtureConfig, DPOConfig, ModelConfig, ScriptArguments, TrlParser + + dataclass_types = (ScriptArguments, DPOConfig, ModelConfig, DatasetMixtureConfig) + if subparsers is not None: + parser = subparsers.add_parser("dpo", help="Run the DPO training script", dataclass_types=dataclass_types) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args, dataset_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args, dataset_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/env.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/env.py new file mode 100644 index 0000000000000000000000000000000000000000..830bbee0a9ab39e1426f011bcdf06df3a9b85f9e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/env.py @@ -0,0 +1,81 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# ] +# /// + +import os +import platform +from importlib.metadata import version + + +def print_env(): + import torch + from accelerate.commands.config import default_config_file, load_config_from_file + from transformers import is_bitsandbytes_available + from transformers.utils import is_peft_available + + from trl import __version__ + from trl.import_utils import is_deepspeed_available, is_liger_kernel_available, is_vllm_available + from trl.scripts.utils import get_git_commit_hash + + devices = None + if torch.cuda.is_available(): + devices = [torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())] + elif torch.backends.mps.is_available(): + devices = ["MPS"] + elif torch.xpu.is_available(): + devices = [torch.xpu.get_device_name(i) for i in range(torch.xpu.device_count())] + + accelerate_config = accelerate_config_str = "not found" + + # Get the default from the config file. + if os.path.isfile(default_config_file): + accelerate_config = load_config_from_file(default_config_file).to_dict() + + accelerate_config_str = ( + "\n" + "\n".join([f" - {prop}: {val}" for prop, val in accelerate_config.items()]) + if isinstance(accelerate_config, dict) + else accelerate_config + ) + + commit_hash = get_git_commit_hash("trl") + + info = { + "Platform": platform.platform(), + "Python version": platform.python_version(), + "TRL version": f"{__version__}+{commit_hash[:7]}" if commit_hash else __version__, + "PyTorch version": version("torch"), + "accelerator(s)": ", ".join(devices) if devices is not None else "cpu", + "Transformers version": version("transformers"), + "Accelerate version": version("accelerate"), + "Accelerate config": accelerate_config_str, + "Datasets version": version("datasets"), + "HF Hub version": version("huggingface_hub"), + "bitsandbytes version": version("bitsandbytes") if is_bitsandbytes_available() else "not installed", + "DeepSpeed version": version("deepspeed") if is_deepspeed_available() else "not installed", + "Liger-Kernel version": version("liger_kernel") if is_liger_kernel_available() else "not installed", + "PEFT version": version("peft") if is_peft_available() else "not installed", + "vLLM version": version("vllm") if is_vllm_available() else "not installed", + } + + info_str = "\n".join([f"- {prop}: {val}" for prop, val in info.items()]) + print(f"\nCopy-paste the following information when reporting an issue:\n\n{info_str}\n") # noqa + + +if __name__ == "__main__": + print_env() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/grpo.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/grpo.py new file mode 100644 index 0000000000000000000000000000000000000000..04ed41148dcc68752556c6f7f6c231af2f2ec205 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/grpo.py @@ -0,0 +1,181 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +import argparse +import importlib +import os +import sys +from dataclasses import dataclass, field + +from trl import ScriptArguments + + +@dataclass +class GRPOScriptArguments(ScriptArguments): + """ + Script arguments for the GRPO training script. + + Args: + reward_model_name_or_path (`str`, *optional*): + Reward model id of a pretrained model hosted inside a model repo on huggingface.co or local path to a + directory containing model weights saved using [`~transformers.PreTrainedModel.save_pretrained`]. + reward_funcs (`list[str]`, *optional*): + Reward functions to use. Supported values are: + - `"accuracy_reward"` + - `"reasoning_accuracy_reward"` + - `"think_format_reward"` + - `"get_soft_overlong_punishment"` (used value are `max_completion_len=1280`, `soft_punish_cache=256`) + - any dotted import path " (e.g., `'my_lib.rewards.custom_reward'`). + """ + + reward_model_name_or_path: str | None = field( + default=None, + metadata={ + "help": "Reward model id of a pretrained model hosted inside a model repo on huggingface.co or " + "local path to a directory containing model weights saved using `PreTrainedModel.save_pretrained`." + }, + ) + reward_funcs: list[str] | None = field( + default=None, + metadata={ + "help": "Reward functions to use. Supported values are: `accuracy_reward`, `reasoning_accuracy_reward`, `think_format_reward`, " + "`get_soft_overlong_punishment` (used values are `max_completion_len=1280`, `soft_punish_cache=256`), or " + "any dotted import path (e.g., `'my_lib.rewards.custom_reward'`)." + }, + ) + + +def main(script_args, training_args, model_args, dataset_args): + import torch + from accelerate import logging + from datasets import load_dataset + + from trl import GRPOTrainer, get_dataset, get_kbit_device_map, get_peft_config, get_quantization_config + from trl.rewards import ( + accuracy_reward, + get_soft_overlong_punishment, + reasoning_accuracy_reward, + think_format_reward, + ) + + logger = logging.get_logger(__name__) + + reward_funcs_registry = { + "accuracy_reward": accuracy_reward, + "reasoning_accuracy_reward": reasoning_accuracy_reward, + "think_format_reward": think_format_reward, + "get_soft_overlong_punishment": get_soft_overlong_punishment(max_completion_len=1280, soft_punish_cache=256), + } + + # Get the reward models and functions + reward_funcs = [] + if script_args.reward_model_name_or_path: + reward_funcs.append(script_args.reward_model_name_or_path) + + if script_args.reward_funcs: + for func_name in script_args.reward_funcs: + if func_name in reward_funcs_registry: + reward_funcs.append(reward_funcs_registry[func_name]) + elif "." in func_name: + module_path, func_name = func_name.rsplit(".", 1) + sys.path.insert(0, os.getcwd()) + module = importlib.import_module(module_path) + reward_func = getattr(module, func_name) + reward_funcs.append(reward_func) + else: + raise ValueError( + f"Could not load reward function '{func_name}'. Expected one of " + f"{list(reward_funcs_registry.keys())} or a valid import path." + ) + dtype = model_args.dtype if model_args.dtype in ["auto", None] else getattr(torch, model_args.dtype) + + model_kwargs = dict( + revision=model_args.model_revision, + attn_implementation=model_args.attn_implementation, + dtype=dtype, + ) + quantization_config = get_quantization_config(model_args) + + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + training_args.model_init_kwargs = model_kwargs + + # Load the dataset + if dataset_args.datasets and script_args.dataset_name: + logger.warning( + "Both `datasets` and `dataset_name` are provided. The `datasets` argument will be used to load the " + "dataset and `dataset_name` will be ignored." + ) + dataset = get_dataset(dataset_args) + elif dataset_args.datasets and not script_args.dataset_name: + dataset = get_dataset(dataset_args) + elif not dataset_args.datasets and script_args.dataset_name: + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, streaming=script_args.dataset_streaming + ) + else: + raise ValueError("Either `datasets` or `dataset_name` must be provided.") + + # Initialize the GRPO trainer + trainer = GRPOTrainer( + model=model_args.model_name_or_path, + reward_funcs=reward_funcs, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + # Train the model + trainer.train() + + # Log training complete + trainer.accelerator.print("✅ Training completed.") + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + trainer.accelerator.print(f"💾 Model saved to {training_args.output_dir}.") + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + trainer.accelerator.print(f"🤗 Model pushed to the Hub in https://huggingface.co/{trainer.hub_model_id}.") + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import DatasetMixtureConfig, GRPOConfig, ModelConfig, TrlParser + + dataclass_types = (GRPOScriptArguments, GRPOConfig, ModelConfig, DatasetMixtureConfig) + if subparsers is not None: + parser = subparsers.add_parser("grpo", help="Run the GRPO training script", dataclass_types=dataclass_types) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args, dataset_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args, dataset_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/kto.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/kto.py new file mode 100644 index 0000000000000000000000000000000000000000..ad0bb3e9c6059bfc6f78a706994932c8409900b4 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/kto.py @@ -0,0 +1,151 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +""" +Run the KTO training script with the commands below. In general, the optimal configuration for KTO will be similar to +that of DPO. + +# Full training: +```bash +python trl/scripts/kto.py \ + --dataset_name trl-lib/kto-mix-14k \ + --model_name_or_path=trl-lib/qwen1.5-1.8b-sft \ + --per_device_train_batch_size 16 \ + --num_train_epochs 1 \ + --learning_rate 5e-7 \ + --lr_scheduler_type=cosine \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir=kto-aligned-model \ + --warmup_steps 0.1 \ + --logging_first_step +``` + +# QLoRA: +```bash +# QLoRA: +python trl/scripts/kto.py \ + --dataset_name trl-lib/kto-mix-14k \ + --model_name_or_path=trl-lib/qwen1.5-1.8b-sft \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 5e-7 \ + --lr_scheduler_type=cosine \ + --gradient_accumulation_steps 1 \ + --eval_steps 500 \ + --output_dir=kto-aligned-model-lora \ + --warmup_steps 0.1 \ + --logging_first_step \ + --use_peft \ + --load_in_4bit \ + --lora_target_modules=all-linear \ + --lora_r=16 \ + --lora_alpha=16 +``` +""" + +import argparse + + +def main(script_args, training_args, model_args, dataset_args): + from accelerate import logging + from datasets import load_dataset + from transformers import AutoModelForCausalLM, AutoTokenizer + + from trl import get_dataset, get_peft_config + from trl.experimental.kto import KTOTrainer + + logger = logging.get_logger(__name__) + + # Load a pretrained model + model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + ref_model = AutoModelForCausalLM.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + + tokenizer = AutoTokenizer.from_pretrained( + model_args.model_name_or_path, trust_remote_code=model_args.trust_remote_code + ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + + # Load the dataset + if dataset_args.datasets and script_args.dataset_name: + logger.warning( + "Both `datasets` and `dataset_name` are provided. The `datasets` argument will be used to load the " + "dataset and `dataset_name` will be ignored." + ) + dataset = get_dataset(dataset_args) + elif dataset_args.datasets and not script_args.dataset_name: + dataset = get_dataset(dataset_args) + elif not dataset_args.datasets and script_args.dataset_name: + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, streaming=script_args.dataset_streaming + ) + else: + raise ValueError("Either `datasets` or `dataset_name` must be provided.") + + # Initialize the KTO trainer + trainer = KTOTrainer( + model, + ref_model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + processing_class=tokenizer, + peft_config=get_peft_config(model_args), + ) + + # Train the model + trainer.train() + + # Log training complete + trainer.accelerator.print("✅ Training completed.") + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + trainer.accelerator.print(f"💾 Model saved to {training_args.output_dir}.") + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + trainer.accelerator.print(f"🤗 Model pushed to the Hub in https://huggingface.co/{trainer.hub_model_id}.") + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import DatasetMixtureConfig, ModelConfig, ScriptArguments, TrlParser + from trl.experimental.kto import KTOConfig + + dataclass_types = (ScriptArguments, KTOConfig, ModelConfig, DatasetMixtureConfig) + if subparsers is not None: + parser = subparsers.add_parser("kto", help="Run the KTO training script", dataclass_types=dataclass_types) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args, dataset_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args, dataset_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/reward.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/reward.py new file mode 100644 index 0000000000000000000000000000000000000000..5242f71f851d8bbb156a1ed05925ecc83c227f6e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/reward.py @@ -0,0 +1,91 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +import argparse + + +def main(script_args, training_args, model_args, dataset_args): + from accelerate import logging + from datasets import load_dataset + + from trl import RewardTrainer, get_dataset, get_peft_config + + logger = logging.get_logger(__name__) + + # Load the dataset + if dataset_args.datasets and script_args.dataset_name: + logger.warning( + "Both `datasets` and `dataset_name` are provided. The `datasets` argument will be used to load the " + "dataset and `dataset_name` will be ignored." + ) + dataset = get_dataset(dataset_args) + elif dataset_args.datasets and not script_args.dataset_name: + dataset = get_dataset(dataset_args) + elif not dataset_args.datasets and script_args.dataset_name: + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, streaming=script_args.dataset_streaming + ) + else: + raise ValueError("Either `datasets` or `dataset_name` must be provided.") + + # Initialize the RewardTrainer + trainer = RewardTrainer( + model=model_args.model_name_or_path, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + # Train the model + trainer.train() + + # Log training complete + trainer.accelerator.print("✅ Training completed.") + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + trainer.accelerator.print(f"💾 Model saved to {training_args.output_dir}.") + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + trainer.accelerator.print(f"🤗 Model pushed to the Hub in https://huggingface.co/{trainer.hub_model_id}.") + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import DatasetMixtureConfig, ModelConfig, RewardConfig, ScriptArguments, TrlParser + + dataclass_types = (ScriptArguments, RewardConfig, ModelConfig, DatasetMixtureConfig) + if subparsers is not None: + parser = subparsers.add_parser( + "reward", help="Run the reward training script", dataclass_types=dataclass_types + ) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args, dataset_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args, dataset_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/rloo.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/rloo.py new file mode 100644 index 0000000000000000000000000000000000000000..c8485871e242b66f53b4e545e125147e374f1661 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/rloo.py @@ -0,0 +1,165 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +import argparse +import importlib +import os +import sys +from dataclasses import dataclass, field + +from trl import ScriptArguments + + +@dataclass +class RLOOScriptArguments(ScriptArguments): + """ + Script arguments for the RLOO training script. + + Args: + reward_model_name_or_path (`str`, *optional*): + Reward model id of a pretrained model hosted inside a model repo on huggingface.co or local path to a + directory containing model weights saved using [`~transformers.PreTrainedModel.save_pretrained`]. + reward_funcs (`list[str]`, *optional*): + Reward functions to use. Supported values are: + - `"accuracy_reward"` + - `"reasoning_accuracy_reward"` + - `"think_format_reward"` + - `"get_soft_overlong_punishment"` (used value are `max_completion_len=1280`, `soft_punish_cache=256`) + - any dotted import path " (e.g., `'my_lib.rewards.custom_reward'`). + """ + + reward_model_name_or_path: str | None = field( + default=None, + metadata={ + "help": "Reward model id of a pretrained model hosted inside a model repo on huggingface.co or " + "local path to a directory containing model weights saved using `PreTrainedModel.save_pretrained`." + }, + ) + reward_funcs: list[str] | None = field( + default=None, + metadata={ + "help": "Reward functions to use. Supported values are: `accuracy_reward`, `reasoning_accuracy_reward`, `think_format_reward`, " + "`get_soft_overlong_punishment` (used values are `max_completion_len=1280`, `soft_punish_cache=256`), or " + "any dotted import path (e.g., `'my_lib.rewards.custom_reward'`)." + }, + ) + + +def main(script_args, training_args, model_args, dataset_args): + from accelerate import logging + from datasets import load_dataset + + from trl import RLOOTrainer, get_dataset, get_peft_config + from trl.rewards import ( + accuracy_reward, + get_soft_overlong_punishment, + reasoning_accuracy_reward, + think_format_reward, + ) + + logger = logging.get_logger(__name__) + + reward_funcs_registry = { + "accuracy_reward": accuracy_reward, + "reasoning_accuracy_reward": reasoning_accuracy_reward, + "think_format_reward": think_format_reward, + "get_soft_overlong_punishment": get_soft_overlong_punishment(max_completion_len=1280, soft_punish_cache=256), + } + + # Get the reward models and functions + reward_funcs = [] + if script_args.reward_model_name_or_path: + reward_funcs.append(script_args.reward_model_name_or_path) + + if script_args.reward_funcs: + for func_name in script_args.reward_funcs: + if func_name in reward_funcs_registry: + reward_funcs.append(reward_funcs_registry[func_name]) + elif "." in func_name: + module_path, func_name = func_name.rsplit(".", 1) + sys.path.insert(0, os.getcwd()) + module = importlib.import_module(module_path) + reward_func = getattr(module, func_name) + reward_funcs.append(reward_func) + else: + raise ValueError( + f"Could not load reward function '{func_name}'. Expected one of " + f"{list(reward_funcs_registry.keys())} or a valid import path." + ) + + # Load the dataset + if dataset_args.datasets and script_args.dataset_name: + logger.warning( + "Both `datasets` and `dataset_name` are provided. The `datasets` argument will be used to load the " + "dataset and `dataset_name` will be ignored." + ) + dataset = get_dataset(dataset_args) + elif dataset_args.datasets and not script_args.dataset_name: + dataset = get_dataset(dataset_args) + elif not dataset_args.datasets and script_args.dataset_name: + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, streaming=script_args.dataset_streaming + ) + else: + raise ValueError("Either `datasets` or `dataset_name` must be provided.") + + # Initialize the RLOO trainer + trainer = RLOOTrainer( + model=model_args.model_name_or_path, + reward_funcs=reward_funcs, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + # Train the model + trainer.train() + + # Log training complete + trainer.accelerator.print("✅ Training completed.") + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + trainer.accelerator.print(f"💾 Model saved to {training_args.output_dir}.") + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + trainer.accelerator.print(f"🤗 Model pushed to the Hub in https://huggingface.co/{trainer.hub_model_id}.") + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import DatasetMixtureConfig, ModelConfig, RLOOConfig, TrlParser + + dataclass_types = (RLOOScriptArguments, RLOOConfig, ModelConfig, DatasetMixtureConfig) + if subparsers is not None: + parser = subparsers.add_parser("rloo", help="Run the RLOO training script", dataclass_types=dataclass_types) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args, dataset_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args, dataset_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/sft.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/sft.py new file mode 100644 index 0000000000000000000000000000000000000000..1fb07acb10dda9583af0ba818cee99770e1a1065 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/sft.py @@ -0,0 +1,156 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# /// script +# dependencies = [ +# "trl", +# "peft", +# "trackio", +# "kernels", +# ] +# /// + +""" +# Full training +``` +python trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --learning_rate 2.0e-5 \ + --num_train_epochs 1 \ + --packing \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 8 \ + --eos_token '<|im_end|>' \ + --eval_strategy steps \ + --eval_steps 100 \ + --output_dir Qwen2-0.5B-SFT \ + --push_to_hub +``` + +# LoRA +``` +python trl/scripts/sft.py \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --learning_rate 2.0e-4 \ + --num_train_epochs 1 \ + --packing \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 8 \ + --eos_token '<|im_end|>' \ + --eval_strategy steps \ + --eval_steps 100 \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --output_dir Qwen2-0.5B-SFT \ + --push_to_hub +``` +""" + +import argparse + + +def main(script_args, training_args, model_args, dataset_args): + from accelerate import logging + from datasets import load_dataset + from transformers import AutoConfig, AutoModelForCausalLM + from transformers.models.auto.modeling_auto import MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES + + from trl import SFTTrainer, get_dataset, get_kbit_device_map, get_peft_config, get_quantization_config + + logger = logging.get_logger(__name__) + + ################ + # Model init kwargs + ################ + model_kwargs = dict( + revision=model_args.model_revision, + trust_remote_code=model_args.trust_remote_code, + attn_implementation=model_args.attn_implementation, + dtype=model_args.dtype, + ) + quantization_config = get_quantization_config(model_args) + if quantization_config is not None: + # Passing None would not be treated the same as omitting the argument, so we include it only when valid. + model_kwargs["device_map"] = get_kbit_device_map() + model_kwargs["quantization_config"] = quantization_config + + # Create model + config = AutoConfig.from_pretrained(model_args.model_name_or_path) + valid_image_text_architectures = MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES.values() + + if config.architectures and any(arch in valid_image_text_architectures for arch in config.architectures): + from transformers import AutoModelForImageTextToText + + model = AutoModelForImageTextToText.from_pretrained(model_args.model_name_or_path, **model_kwargs) + else: + model = AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path, **model_kwargs) + + # Load the dataset + if dataset_args.datasets and script_args.dataset_name: + logger.warning( + "Both `datasets` and `dataset_name` are provided. The `datasets` argument will be used to load the " + "dataset and `dataset_name` will be ignored." + ) + dataset = get_dataset(dataset_args) + elif dataset_args.datasets and not script_args.dataset_name: + dataset = get_dataset(dataset_args) + elif not dataset_args.datasets and script_args.dataset_name: + dataset = load_dataset( + script_args.dataset_name, name=script_args.dataset_config, streaming=script_args.dataset_streaming + ) + else: + raise ValueError("Either `datasets` or `dataset_name` must be provided.") + + # Initialize the SFT trainer + trainer = SFTTrainer( + model=model, + args=training_args, + train_dataset=dataset[script_args.dataset_train_split], + eval_dataset=dataset[script_args.dataset_test_split] if training_args.eval_strategy != "no" else None, + peft_config=get_peft_config(model_args), + ) + + # Train the model + trainer.train() + + # Log training complete + trainer.accelerator.print("✅ Training completed.") + + # Save and push to Hub + trainer.save_model(training_args.output_dir) + trainer.accelerator.print(f"💾 Model saved to {training_args.output_dir}.") + + if training_args.push_to_hub: + trainer.push_to_hub(dataset_name=script_args.dataset_name) + trainer.accelerator.print(f"🤗 Model pushed to the Hub in https://huggingface.co/{trainer.hub_model_id}.") + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import DatasetMixtureConfig, ModelConfig, ScriptArguments, SFTConfig, TrlParser + + dataclass_types = (ScriptArguments, SFTConfig, ModelConfig, DatasetMixtureConfig) + if subparsers is not None: + parser = subparsers.add_parser("sft", help="Run the SFT training script", dataclass_types=dataclass_types) + else: + parser = TrlParser(dataclass_types, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + script_args, training_args, model_args, dataset_args = parser.parse_args_and_config(fail_with_unknown_args=False) + main(script_args, training_args, model_args, dataset_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..165fec49fc32ed3c00cb3001f64f35ab5d690a6f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/utils.py @@ -0,0 +1,466 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import importlib +import inspect +import logging +import os +import subprocess +import sys +from collections.abc import Iterable +from dataclasses import dataclass, field +from typing import TYPE_CHECKING + +# Temporarily import from the local module instead of transformers to avoid an upstream latency issue +# See: https://github.com/huggingface/transformers/issues/44273 +# This workaround can be reverted once the fix is included in the minimum required transformers version +from trl.scripts._hf_argparser import DataClass, DataClassType, HfArgumentParser + + +if TYPE_CHECKING: + from datasets import DatasetDict + + +logger = logging.getLogger(__name__) + + +@dataclass +class DatasetConfig: + """ + Configuration for a dataset. + + This class matches the signature of [`~datasets.load_dataset`] and the arguments are used directly in the + [`~datasets.load_dataset`] function. You can refer to the [`~datasets.load_dataset`] documentation for more + details. + + Parameters: + path (`str`): + Path or name of the dataset. + name (`str`, *optional*): + Defining the name of the dataset configuration. + data_dir (`str`, *optional*): + Defining the `data_dir` of the dataset configuration. If specified for the generic builders(csv, text etc.) + or the Hub datasets and `data_files` is `None`, the behavior is equal to passing `os.path.join(data_dir, + **)` as `data_files` to reference all the files in a directory. + data_files (`str` or `Sequence` or `Mapping`, *optional*): + Path(s) to source data file(s). + split (`str`, *optional*, defaults to `"train"`): + Which split of the data to load. + columns (`list[str]`, *optional*): + List of column names to select from the dataset. If `None`, all columns are selected. + """ + + path: str + name: str | None = None + data_dir: str | None = None + data_files: str | list[str] | dict[str, str] | None = None + split: str = "train" + columns: list[str] | None = None + + +@dataclass +class DatasetMixtureConfig: + """ + Configuration class for a mixture of datasets. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + datasets (`list[DatasetConfig]`): + List of dataset configurations to include in the mixture. + streaming (`bool`, *optional*, defaults to `False`): + Whether to stream the datasets. If `True`, the datasets will be loaded in streaming mode. + test_split_size (`float`, *optional*): + Size of the test split. Refer to the `test_size` parameter in the [`~datasets.train_test_split`] function + for more details. If `None`, the dataset will not be split into train and test sets. + + Usage: + When using the CLI, you can add the following section to your YAML config file: + + ```yaml + datasets: + - path: ... + name: ... + data_dir: ... + data_files: ... + split: ... + columns: ... + - path: ... + name: ... + data_dir: ... + data_files: ... + split: ... + columns: ... + streaming: ... + test_split_size: ... + ``` + """ + + datasets: list[DatasetConfig] = field( + default_factory=list, + metadata={"help": "List of dataset configurations to include in the mixture."}, + ) + streaming: bool = field( + default=False, + metadata={"help": "Whether to stream the datasets. If True, the datasets will be loaded in streaming mode."}, + ) + test_split_size: float | None = field( + default=None, + metadata={ + "help": "Size of the test split. Refer to the `test_size` parameter in the `datasets.train_test_split` " + "function for more details. If None, the dataset will not be split into train and test sets." + }, + ) + + def __post_init__(self): + # Convert any dataset dicts (from CLI/config parsing) into DatasetConfig objects + for idx, dataset in enumerate(self.datasets): + if isinstance(dataset, dict): + # If it's a dict, convert it to DatasetConfig + self.datasets[idx] = DatasetConfig(**dataset) + + +@dataclass +class ScriptArguments: + """ + Arguments common to all scripts. + + Args: + dataset_name (`str`,, *optional*): + Path or name of the dataset to load. If `datasets` is provided, this will be ignored. + dataset_config (`str`, *optional*): + Dataset configuration name. Corresponds to the `name` argument of the [`~datasets.load_dataset`] function. + If `datasets` is provided, this will be ignored. + dataset_train_split (`str`, *optional*, defaults to `"train"`): + Dataset split to use for training. If `datasets` is provided, this will be ignored. + dataset_test_split (`str`, *optional*, defaults to `"test"`): + Dataset split to use for evaluation. If `datasets` is provided, this will be ignored. + dataset_streaming (`bool`, *optional*, defaults to `False`): + Whether to stream the dataset. If True, the dataset will be loaded in streaming mode. If `datasets` is + provided, this will be ignored. + ignore_bias_buffers (`bool`, *optional*, defaults to `False`): + Debug argument for distributed training. Fix for DDP issues with LM bias/mask buffers - invalid scalar + type, inplace operation. See + https://github.com/huggingface/transformers/issues/22482#issuecomment-1595790992. + """ + + dataset_name: str | None = field( + default=None, + metadata={"help": "Path or name of the dataset to load. If `datasets` is provided, this will be ignored."}, + ) + dataset_config: str | None = field( + default=None, + metadata={ + "help": "Dataset configuration name. Corresponds to the `name` argument of the `datasets.load_dataset` " + "function. If `datasets` is provided, this will be ignored." + }, + ) + dataset_train_split: str = field( + default="train", + metadata={"help": "Dataset split to use for training. If `datasets` is provided, this will be ignored."}, + ) + dataset_test_split: str = field( + default="test", + metadata={"help": "Dataset split to use for evaluation. If `datasets` is provided, this will be ignored."}, + ) + dataset_streaming: bool = field( + default=False, + metadata={ + "help": "Whether to stream the dataset. If True, the dataset will be loaded in streaming mode. If " + "`datasets` is provided, this will be ignored." + }, + ) + ignore_bias_buffers: bool = field( + default=False, + metadata={ + "help": "Debug argument for distributed training. Fix for DDP issues with LM bias/mask buffers - invalid " + "scalar type, inplace operation. See " + "https://github.com/huggingface/transformers/issues/22482#issuecomment-1595790992." + }, + ) + + +def init_zero_verbose(): + """ + Perform zero verbose init - use this method on top of the CLI modules to make logging and warning output cleaner. + Uses Rich if available, falls back otherwise. + """ + import logging + import warnings + + from transformers.utils import is_rich_available + + FORMAT = "%(message)s" + + if is_rich_available(): + from rich.logging import RichHandler + + handler = RichHandler() + else: + handler = logging.StreamHandler() + + logging.basicConfig(format=FORMAT, datefmt="[%X]", handlers=[handler], level=logging.ERROR) + + # Custom warning handler to redirect warnings to the logging system + def warning_handler(message, category, filename, lineno, file=None, line=None): + logging.warning(f"{filename}:{lineno}: {category.__name__}: {message}") + + # Add the custom warning handler - we need to do that before importing anything to make sure the loggers work well + warnings.showwarning = warning_handler + + +class TrlParser(HfArgumentParser): + """ + A subclass of [`transformers.HfArgumentParser`] designed for parsing command-line arguments with dataclass-backed + configurations, while also supporting configuration file loading and environment variable management. + + Args: + dataclass_types (`DataClassType | Iterable[DataClassType]`, *optional*): + Dataclass types to use for argument parsing. + **kwargs: + Additional keyword arguments passed to the [`transformers.HfArgumentParser`] constructor. + + Examples: + + ```yaml + # config.yaml + env: + VAR1: value1 + arg1: 23 + ``` + + ```python + # main.py + import os + from dataclasses import dataclass + from trl import TrlParser + + + @dataclass + class MyArguments: + arg1: int + arg2: str = "alpha" + + + parser = TrlParser(dataclass_types=[MyArguments]) + training_args = parser.parse_args_and_config() + + print(training_args, os.environ.get("VAR1")) + ``` + + ```bash + $ python main.py --config config.yaml + (MyArguments(arg1=23, arg2='alpha'),) value1 + + $ python main.py --arg1 5 --arg2 beta + (MyArguments(arg1=5, arg2='beta'),) None + ``` + """ + + def __init__( + self, + dataclass_types: DataClassType | Iterable[DataClassType] | None = None, + **kwargs, + ): + # Make sure dataclass_types is an iterable + if dataclass_types is None: + dataclass_types = [] + elif not isinstance(dataclass_types, Iterable): + dataclass_types = [dataclass_types] + + # Check that none of the dataclasses have the "config" field + for dataclass_type in dataclass_types: + if "config" in dataclass_type.__dataclass_fields__: + raise ValueError( + f"Dataclass {dataclass_type.__name__} has a field named 'config'. This field is reserved for the " + f"config file path and should not be used in the dataclass." + ) + + super().__init__(dataclass_types=dataclass_types, **kwargs) + + def parse_args_and_config( + self, + args: Iterable[str] | None = None, + return_remaining_strings: bool = False, + fail_with_unknown_args: bool = True, + separate_remaining_strings: bool = False, + ) -> tuple[DataClass, ...]: + """ + Parse command-line args and config file into instances of the specified dataclass types. + + This method wraps [`transformers.HfArgumentParser.parse_args_into_dataclasses`] and also parses the config file + specified with the `--config` flag. The config file (in YAML format) provides argument values that replace the + default values in the dataclasses. Command line arguments can override values set by the config file. The + method also sets any environment variables specified in the `env` field of the config file. + """ + import yaml + + args = list(args) if args is not None else sys.argv[1:] + if "--config" in args: + # Get the config file path from + config_index = args.index("--config") + args.pop(config_index) # remove the --config flag + config_path = args.pop(config_index) # get the path to the config file + with open(config_path) as yaml_file: + config = yaml.safe_load(yaml_file) + + # Set the environment variables specified in the config file + if "env" in config: + env_vars = config.pop("env", {}) + if not isinstance(env_vars, dict): + raise ValueError("`env` field should be a dict in the YAML file.") + for key, value in env_vars.items(): + os.environ[key] = str(value) + + # Set the defaults from the config values + config_remaining_strings = self.set_defaults_with_config(**config) + else: + config_remaining_strings = [] + + # Parse the arguments from the command line + output = self.parse_args_into_dataclasses(args=args, return_remaining_strings=return_remaining_strings) + + # Merge remaining strings from the config file with the remaining strings from the command line + if return_remaining_strings: + args_remaining_strings = output[-1] + if separate_remaining_strings: + return output[:-1] + (config_remaining_strings, args_remaining_strings) + return output[:-1] + (config_remaining_strings + args_remaining_strings,) + elif fail_with_unknown_args and config_remaining_strings: + raise ValueError( + f"Unknown arguments from config file: {config_remaining_strings}. Please remove them, add them to the " + "dataclass, or set `fail_with_unknown_args=False`." + ) + else: + return output + + def set_defaults_with_config(self, **kwargs) -> list[str]: + """ + Overrides the parser's default values with those provided via keyword arguments, including for subparsers. + + Any argument with an updated default will also be marked as not required if it was previously required. + + Returns a list of strings that were not consumed by the parser. + """ + + def apply_defaults(parser, kw): + used_keys = set() + for action in parser._actions: + # Handle subparsers recursively + if isinstance(action, argparse._SubParsersAction): + for subparser in action.choices.values(): + used_keys.update(apply_defaults(subparser, kw)) + elif action.dest in kw: + action.default = kw[action.dest] + action.required = False + used_keys.add(action.dest) + return used_keys + + used_keys = apply_defaults(self, kwargs) + # Remaining args not consumed by the parser + remaining = [ + item for key, value in kwargs.items() if key not in used_keys for item in (f"--{key}", str(value)) + ] + return remaining + + +def get_git_commit_hash(package_name): + try: + # Import the package to locate its path + package = importlib.import_module(package_name) + # Get the path to the package using inspect + package_path = os.path.dirname(inspect.getfile(package)) + + # Navigate up to the Git repository root if the package is inside a subdirectory + git_repo_path = os.path.abspath(os.path.join(package_path, "..")) + git_dir = os.path.join(git_repo_path, ".git") + + if os.path.isdir(git_dir): + # Run the git command to get the current commit hash + commit_hash = ( + subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=git_repo_path).strip().decode("utf-8") + ) + return commit_hash + else: + return None + except Exception as e: + return f"Error: {str(e)}" + + +def get_dataset(mixture_config: DatasetMixtureConfig) -> "DatasetDict": + """ + Load a mixture of datasets based on the configuration. + + Args: + mixture_config ([`DatasetMixtureConfig`]): + Script arguments containing dataset configuration. + + Returns: + [`~datasets.DatasetDict`]: + Combined dataset(s) from the mixture configuration, with optional train/test split if `test_split_size` is + set. + + Example: + ```python + from trl import DatasetMixtureConfig, get_dataset + from trl.scripts.utils import DatasetConfig + + mixture_config = DatasetMixtureConfig(datasets=[DatasetConfig(path="trl-lib/tldr")]) + dataset = get_dataset(mixture_config) + print(dataset) + ``` + + ``` + DatasetDict({ + train: Dataset({ + features: ['prompt', 'completion'], + num_rows: 116722 + }) + }) + ``` + """ + import datasets + + logger.info(f"Creating dataset mixture with {len(mixture_config.datasets)} datasets") + datasets_list = [] + for dataset_config in mixture_config.datasets: + logger.info(f"Loading dataset for mixture: {dataset_config.path} (config name: {dataset_config.name})") + dataset = datasets.load_dataset( + path=dataset_config.path, + name=dataset_config.name, + data_dir=dataset_config.data_dir, + data_files=dataset_config.data_files, + split=dataset_config.split, + streaming=mixture_config.streaming, + ) + if dataset_config.columns is not None: + dataset = dataset.select_columns(dataset_config.columns) + datasets_list.append(dataset) + + if datasets_list: + combined_dataset = datasets.concatenate_datasets(datasets_list) + if isinstance(combined_dataset, datasets.Dataset): # IterableDataset does not have a length + logger.info(f"Created dataset mixture with {len(combined_dataset)} examples") + + if mixture_config.test_split_size is not None: + logger.info(f"Splitting dataset into train and test sets with test size: {mixture_config.test_split_size}") + combined_dataset = combined_dataset.train_test_split(test_size=mixture_config.test_split_size) + return combined_dataset + else: + return datasets.DatasetDict({"train": combined_dataset}) + else: + raise ValueError("No datasets were loaded from the mixture configuration") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/vllm_serve.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/vllm_serve.py new file mode 100644 index 0000000000000000000000000000000000000000..ccf182eeaacfbc498b3fbcd5c455a3e93be16536 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/scripts/vllm_serve.py @@ -0,0 +1,1220 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import base64 +import json +import logging +import math +import os +from collections.abc import Sequence +from contextlib import asynccontextmanager +from dataclasses import dataclass, field +from io import BytesIO +from itertools import chain +from multiprocessing import Pipe, Process +from multiprocessing.connection import Connection + + +# We use CUDA with multiprocessing, so we must use the 'spawn' start method. Otherwise, we will get the following +# error: RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use +# the 'spawn' start method +os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn" + + +class WeightSyncWorkerExtension: + """ + A vLLM worker extension that enables weight synchronization between a client and multiple server workers. + + This worker uses a `StatelessProcessGroup` to establish communication and a `PyNcclCommunicator` or + `ProcessGroupXCCL` to handle efficient GPU-based communication using NCCL. The primary purpose of this class is to + receive updated model weights from a client process and distribute them to all worker processes participating in + model inference. + """ + + # The following attributes are initialized when `init_communicator` method is called. + communicator = None # Communicator for weight updates + client_rank = None # Source rank for broadcasting updated weights + + def init_communicator(self, host: str, port: int, world_size: int, client_device_uuid: str) -> None: + """ + Initializes the weight update communicator using a stateless process group. + + This method creates a `StatelessProcessGroup` that allows external training processes to communicate with vLLM + workers without interfering with the global torch distributed group. + + Args: + host (`str`): + Hostname or IP address of the master node. + port (`int`): + Port number to be used for communication. + world_size (`int`): + Total number of participating processes in the update group. + client_device_uuid (`str`): + UUID of the device of client main process. Used to assert that devices are different from vllm workers + devices. + """ + import torch + import torch.distributed.distributed_c10d as c10d + from transformers import is_torch_xpu_available + from vllm.distributed.device_communicators.pynccl import PyNcclCommunicator + from vllm.distributed.parallel_state import get_world_group + from vllm.distributed.utils import StatelessProcessGroup + + from trl.import_utils import is_vllm_ascend_available + + if is_vllm_ascend_available(): + from vllm_ascend.distributed.device_communicators.pyhccl import PyHcclCommunicator as PyNcclCommunicator + + if self.communicator is not None: + raise RuntimeError("Weight update group already initialized. Call close_communicator first.") + + # TODO: will remove after torch xpu 2.9 support uuid in get_device_properties + if torch.cuda.is_available() or ( + is_torch_xpu_available() and hasattr(torch.xpu.get_device_properties(self.device), "uuid") + ): + accelerator_module = torch.xpu if is_torch_xpu_available() else torch.cuda + if client_device_uuid == str(accelerator_module.get_device_properties(self.device).uuid): + raise RuntimeError( + f"Attempting to use the same CUDA device (UUID: {client_device_uuid}) for multiple distinct " + "roles/ranks within the same communicator. This setup is unsupported and will likely lead to program " + "hangs or incorrect behavior. Ensure that trainer is using different devices than vLLM server." + ) + # Get the rank of the current worker in the global world group. + rank = get_world_group().rank + + if is_torch_xpu_available(): + store = torch.distributed.TCPStore(host_name=host, port=port, world_size=world_size, is_master=(rank == 0)) + prefixed_store = c10d.PrefixStore("client2server", store) + xccl_options = c10d.ProcessGroupXCCL.Options() + pg = c10d.ProcessGroupXCCL( + store=prefixed_store, + rank=rank, + size=world_size, + options=xccl_options, + ) + self.communicator = pg + else: + # Create a stateless process group to manage communication between training processes and vLLM workers. + # Initialize the NCCL-based communicator for weight synchronization. + pg = StatelessProcessGroup.create(host=host, port=port, rank=rank, world_size=world_size) + self.communicator = PyNcclCommunicator(pg, device=self.device) + + # The client process that sends updated weights has the highest rank (world_size - 1). + self.client_rank = world_size - 1 + + def update_named_param(self, name: str, dtype: str, shape: Sequence[int]) -> None: + """ + Receives updated weights from the client process and updates the named parameter in the model. + + Args: + name (`str`): + Name of the weight tensor being updated. + dtype (`str`): + Data type of the weight tensor as a string (e.g., `"torch.float32"`). + shape (`Sequence[int]`): + Shape of the weight tensor. + """ + import torch + from transformers import is_torch_xpu_available + + if self.communicator is None: + raise RuntimeError("Communicator not initialized. Call `init_communicator` first.") + + dtype = getattr(torch, dtype.split(".")[-1]) + # Allocate memory for the incoming weight tensor on the correct device. + weight = torch.empty(shape, dtype=dtype, device=self.device) + + if is_torch_xpu_available(): + # Use XCCL to broadcast the updated weights from the client (src) to all workers. + self.communicator.broadcast(weight, root=self.client_rank) + self.communicator.barrier() + else: + # Use NCCL to broadcast the updated weights from the client (src) to all workers. + self.communicator.broadcast(weight, src=self.client_rank) + self.communicator.group.barrier() + + # Load the received weights into the model. + self.model_runner.model.load_weights(weights=[(name, weight)]) + + def close_communicator(self) -> None: + """ + Closes the communicator when weight synchronization is no longer needed. + + This method deletes the NCCL communicator to release associated resources. + """ + + if self.communicator is not None: + del self.communicator + self.communicator = None # Ensure attribute is reset to None + self.client_rank = None # Ensure attribute is reset to None + + +@dataclass +class ScriptArguments: + r""" + Arguments for the script. + + Args: + model (`str`): + Model name or path to load the model from. + revision (`str`, *optional*): + Revision to use for the model. If not specified, the default branch will be used. + tensor_parallel_size (`int`, *optional*, defaults to `1`): + Number of tensor parallel workers to use. + data_parallel_size (`int`, *optional*, defaults to `1`): + Number of data parallel workers to use. For dense models, keep this at 1. Starting from vLLM `0.14.0`, + setting this above `1` for dense models is no longer supported/useful and will error out (see vLLM PR + #30739). + host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host address to run the server on. + port (`int`, *optional*, defaults to `8000`): + Port to run the server on. + gpu_memory_utilization (`float`, *optional*, defaults to `0.9`): + Ratio (between 0 and 1) of GPU memory to reserve for the model weights, activations, and KV cache on the + device dedicated to generation powered by vLLM. Higher values will increase the KV cache size and thus + improve the model's throughput. However, if the value is too high, it may cause out-of-memory (OOM) errors + during initialization. + dtype (`str`, *optional*, defaults to `"auto"`): + Data type to use for vLLM generation. If set to `"auto"`, the data type will be automatically determined + based on the model configuration. Find the supported values in the vLLM documentation. + max_model_len (`int`, *optional*): + If set, the `max_model_len` to use for vLLM. This can be useful when running with reduced + `vllm_gpu_memory_utilization`, leading to a reduced KV cache size. If not set, vLLM will use the model + context size, which might be much larger than the KV cache, leading to inefficiencies. + enable_prefix_caching (`bool`, *optional*): + Whether to enable prefix caching in vLLM. If set to `True`, ensure that the model and the hardware support + this feature. + enforce_eager (`bool`, *optional*, defaults to `False`): + Whether to enforce eager execution. If set to `True`, we will disable CUDA graph and always execute the + model in eager mode. If `False` (default behavior), we will use CUDA graph and eager execution in hybrid. + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation to use for vLLM. Must be one of `"transformers"` or `"vllm"`. `"transformers"`: Use + the `transformers` backend for model implementation. `"vllm"`: Use the `vllm` library for model + implementation. + kv_cache_dtype (`str`, *optional*, defaults to `"auto"`): + Data type to use for KV cache. If set to `"auto"`, the dtype will default to the model data type. + trust_remote_code (`bool`, *optional*, defaults to `False`): + Whether to trust remote code when loading models. Set to `True` to allow executing code from model + repositories. This is required for some custom models but introduces security risks. + log_level (`str`, *optional*, defaults to `"info"`): + Log level for uvicorn. Possible choices: `"critical"`, `"error"`, `"warning"`, `"info"`, `"debug"`, + `"trace"`. + distributed_executor_backend (`str` or `None`, *optional*): + Distributed executor backend for vLLM. Set to `"ray"` to distribute tensor parallel workers across multiple + nodes via a Ray cluster. Required when `tensor_parallel_size` exceeds the number of local GPUs. If not set, + vLLM defaults to the multiproc backend (single-node only). + speculative_config (`str`, *optional*): + JSON string for vLLM speculative decoding config, forwarded to `LLM(speculative_config=...)`. When unset, + speculative decoding is disabled. Example: `'{"method": "qwen3_next_mtp", "num_speculative_tokens": 5}'`. + """ + + model: str = field( + metadata={"help": "Model name or path to load the model from."}, + ) + revision: str | None = field( + default=None, + metadata={"help": "Revision to use for the model. If not specified, the default branch will be used."}, + ) + tensor_parallel_size: int = field( + default=1, + metadata={"help": "Number of tensor parallel workers to use."}, + ) + data_parallel_size: int = field( + default=1, + metadata={ + "help": "Number of data parallel workers to use. For dense models, keep this at 1. Starting from vLLM " + "`0.14.0`, setting this above `1` for dense models is no longer supported/useful and will error out (see " + "vLLM PR #30739)." + }, + ) + host: str = field( + default="0.0.0.0", + metadata={"help": "Host address to run the server on."}, + ) + port: int = field( + default=8000, + metadata={"help": "Port to run the server on."}, + ) + gpu_memory_utilization: float = field( + default=0.9, + metadata={ + "help": "Ratio (between 0 and 1) of GPU memory to reserve for the model weights, activations, and KV " + "cache on the device dedicated to generation powered by vLLM. Higher values will increase the KV cache " + "size and thus improve the model's throughput. However, if the value is too high, it may cause " + "out-of-memory (OOM) errors during initialization." + }, + ) + dtype: str = field( + default="auto", + metadata={ + "help": "Data type to use for vLLM generation. If set to 'auto', the data type will be automatically " + "determined based on the model configuration. Find the supported values in the vLLM documentation." + }, + ) + max_model_len: int | None = field( + default=None, + metadata={ + "help": "If set, the `max_model_len` to use for vLLM. This can be useful when running with reduced " + "`vllm_gpu_memory_utilization`, leading to a reduced KV cache size. If not set, vLLM will use the model " + "context size, which might be much larger than the KV cache, leading to inefficiencies." + }, + ) + enable_prefix_caching: bool | None = field( + default=None, + metadata={ + "help": "Whether to enable prefix caching in vLLM. If set to `True`, ensure that the model and the " + "hardware support this feature." + }, + ) + enforce_eager: bool | None = field( + default=False, + metadata={ + "help": "Whether to enforce eager execution. If set to `True`, we will disable CUDA graph and always " + "execute the model in eager mode. If `False` (default behavior), we will use CUDA graph and eager " + "execution in hybrid." + }, + ) + kv_cache_dtype: str = field( + default="auto", + metadata={ + "help": "Data type to use for KV cache. If set to 'auto', the dtype will default to the model data type." + }, + ) + trust_remote_code: bool = field( + default=False, + metadata={ + "help": "Whether to trust remote code when loading models. Set to True to allow executing code from model " + "repositories. This is required for some custom models but introduces security risks." + }, + ) + log_level: str = field( + default="info", + metadata={ + "help": "Log level for uvicorn. Possible choices: 'critical', 'error', 'warning', 'info', 'debug', " + "'trace'." + }, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={ + "help": "Model implementation to use for vLLM. Must be one of `transformers` or `vllm`. `transformers`: " + "Use the `transformers` backend for model implementation. `vllm`: Use the `vllm` library for " + "model implementation." + }, + ) + distributed_executor_backend: str | None = field( + default=None, + metadata={ + "help": "Distributed executor backend for vLLM. When set to 'ray', vLLM uses Ray to distribute tensor " + "parallel workers across multiple nodes. Required when tensor_parallel_size exceeds the number of local " + "GPUs. If not set, vLLM defaults to the multiproc backend (single-node only)." + }, + ) + speculative_config: str | None = field( + default=None, + metadata={ + "help": "JSON string for vLLM speculative decoding config. " + 'Example: \'{"method": "qwen3_next_mtp", "num_speculative_tokens": 5}\'' + }, + ) + + +def llm_worker( + script_args: ScriptArguments, data_parallel_rank: int, master_port: int, connection: Connection +) -> None: + from vllm import LLM + + # Set required environment variables for DP to work with vLLM + os.environ["VLLM_DP_RANK"] = str(data_parallel_rank) + os.environ["VLLM_DP_RANK_LOCAL"] = str(data_parallel_rank) + os.environ["VLLM_DP_SIZE"] = str(script_args.data_parallel_size) + os.environ["VLLM_DP_MASTER_PORT"] = str(master_port) + + llm = LLM( + model=script_args.model, + revision=script_args.revision, + tensor_parallel_size=script_args.tensor_parallel_size, + gpu_memory_utilization=script_args.gpu_memory_utilization, + enforce_eager=script_args.enforce_eager, + dtype=script_args.dtype, + # Automatic Prefix Caching caches the KV cache of existing queries, so that a new query can + # directly reuse the KV cache if it shares the same prefix with one of the existing queries. + # This is particularly useful here because we generate completions from the same prompts. + enable_prefix_caching=script_args.enable_prefix_caching, + kv_cache_dtype=script_args.kv_cache_dtype, + max_model_len=script_args.max_model_len, + worker_extension_cls="trl.scripts.vllm_serve.WeightSyncWorkerExtension", + trust_remote_code=script_args.trust_remote_code, + model_impl=script_args.vllm_model_impl, + distributed_executor_backend=script_args.distributed_executor_backend, + # Important so temperature scaling/logit tweaking affects the TIS log probs + logprobs_mode="processed_logprobs", + speculative_config=json.loads(script_args.speculative_config) if script_args.speculative_config else None, + ) + + # Send ready signal to parent process + connection.send({"status": "ready"}) + + while True: + # Wait for commands from the parent process + try: + command = connection.recv() + except KeyboardInterrupt: + llm.collective_rpc(method="close_communicator") + break + + # Handle commands + if command["type"] in ["call", "fire_and_forget"]: + method_name = command["method"] + args, kwargs = command.get("args", ()), command.get("kwargs", {}) + method = getattr(llm, method_name) + result = method(*args, **kwargs) + if command["type"] == "call": + connection.send(result) + elif command["type"] == "shutdown": + break + + +def chunk_list(lst: list, n: int) -> list[list]: + """ + Split list `lst` into `n` evenly distributed sublists. + + Example: + ```python + >>> chunk_list([1, 2, 3, 4, 5, 6], 2) + [[1, 2, 3], [4, 5, 6]] + + >>> chunk_list([1, 2, 3, 4, 5, 6], 4) + [[1, 2], [3, 4], [5], [6]] + + >>> chunk_list([1, 2, 3, 4, 5, 6], 8) + [[1], [2], [3], [4], [5], [6], [], []] + ``` + """ + k, r = divmod(len(lst), n) + return [lst[i * k + min(i, r) : (i + 1) * k + min(i + 1, r)] for i in range(n)] + + +def main(script_args: ScriptArguments): + import asyncio + + from transformers import is_vision_available + + from trl.generation.vllm_generation import extract_logprobs + from trl.import_utils import ( + is_fastapi_available, + is_pydantic_available, + is_uvicorn_available, + is_vllm_available, + ) + + if not is_fastapi_available(): + raise ImportError( + "FastAPI is required to run the vLLM serve script. Please install it using `pip install fastapi`." + ) + + if not is_pydantic_available(): + raise ImportError( + "Pydantic is required to run the vLLM serve script. Please install it using `pip install pydantic`." + ) + + if not is_uvicorn_available(): + raise ImportError( + "Uvicorn is required to run the vLLM serve script. Please install it using `pip install uvicorn`." + ) + + if not is_vllm_available(): + raise ImportError("vLLM is required to run the vLLM serve script. Please install it using `pip install vllm`.") + + import uvicorn + from fastapi import FastAPI + from pydantic import BaseModel + from vllm import SamplingParams + from vllm.sampling_params import StructuredOutputsParams + from vllm.utils.network_utils import get_open_port + + if is_vision_available(): + from PIL import Image + + logger = logging.getLogger(__name__) + + # Spawn dp workers, and setup pipes for communication + master_port = get_open_port() + connections = [] + processes = [] + for data_parallel_rank in range(script_args.data_parallel_size): + parent_connection, child_connection = Pipe() + process = Process(target=llm_worker, args=(script_args, data_parallel_rank, master_port, child_connection)) + process.start() + connections.append(parent_connection) + processes.append(process) + + @asynccontextmanager + async def lifespan(app: FastAPI): + # Wait for all workers to send "ready" + ready_connections = set() + while len(ready_connections) < script_args.data_parallel_size: + for connection in connections: + msg = connection.recv() + if isinstance(msg, dict) and msg.get("status") == "ready": + ready_connections.add(connection) + + # Start the logprob request batcher background task + batcher_task = asyncio.create_task(_logprob_batcher()) + + yield + + batcher_task.cancel() + + # Wait for processes to terminate + for process in processes: + process.join(timeout=10) # Wait for 10 seconds for the process to terminate + if process.is_alive(): + logger.warning(f"Process {process} is still alive after 10 seconds, attempting to terminate...") + process.terminate() + process.join() # ensure process termination after calling terminate() + + app = FastAPI(lifespan=lifespan) + + # Define the endpoints for the model server + @app.get("/health/") + async def health(): + """ + Health check endpoint to verify that the server is running. + """ + return {"status": "ok"} + + @app.get("/get_world_size/") + async def get_world_size(): + """ + Retrieves the world size of the LLM engine, which is `tensor_parallel_size * data_parallel_size`. + + Returns: + `dict`: + A dictionary containing the world size. + + Example response: + ```json + {"world_size": 8} + ``` + """ + return {"world_size": script_args.tensor_parallel_size * script_args.data_parallel_size} + + class GenerateRequest(BaseModel): + prompts: list[str] | list[list[int]] + images: list[list[str] | None] | None = None + n: int = 1 + repetition_penalty: float = 1.0 + temperature: float = 1.0 + top_p: float = 1.0 + top_k: int = -1 + min_p: float = 0.0 + max_tokens: int = 16 + logprobs: int | None = 0 + structured_outputs_regex: str | None = None + generation_kwargs: dict = field(default_factory=dict) + + class GenerateResponse(BaseModel): + prompt_ids: list[list[int]] + completion_ids: list[list[int]] + logprobs: list[list[list[float | None]]] | None + logprob_token_ids: list[list[list[int]]] | None + + @app.post("/generate/", response_model=GenerateResponse) + async def generate(request: GenerateRequest): + """ + Generates completions for the provided prompts. + + Args: + request (`GenerateRequest`): + - `prompts` (list of `str` or list of list of `int`): A list of prompts. It accepts either text strings + or pre-tokenized token ID lists. When text strings are provided, `images` can optionally be included. + - `images` (list of list of `str` or `None`, *optional*): A list of image lists. Each element is a list + of base64-encoded images for the corresponding prompt, or `None` if no images for that prompt. + - `n` (`int`, *optional*, defaults to `1`): Number of completions to generate for each prompt. + - `repetition_penalty` (`float`, *optional*, defaults to `1.0`): Repetition penalty to apply during + generation. + - `temperature` (`float`, *optional*, defaults to `1.0`): Temperature for sampling. Higher values lead + to more random outputs. + - `top_p` (`float`, *optional*, defaults to `1.0`): Top-p (nucleus) sampling parameter. It controls the + diversity of the generated text. + - `top_k` (`int`, *optional*, defaults to `-1`): Top-k sampling parameter. If set to `-1`, it disables + top-k sampling. + - `min_p` (`float`, *optional*, defaults to `0.0`): Minimum probability threshold for sampling. + - `max_tokens` (`int`, *optional*, defaults to `16`): Maximum number of tokens to generate for each + completion. + - `logprobs` (`int`, *optional*, defaults to `0`): Number of top logprobs to return per token. When 0, + only the sampled token's logprob is returned. When N>0, returns up to N+1 logprobs sorted by + descending probability, because vLLM always includes the sampled token's logprob (which may fall + outside the top-N). + - `structured_outputs_regex` (`str`, *optional*): A regex pattern for structured outputs. If provided, + the model will only generate tokens that match this regex pattern. + - `generation_kwargs` (`dict`, *optional*): Additional generation parameters to pass to the vLLM + `SamplingParams`. This can include parameters like `seed`, `frequency_penalty`, etc. If it contains + keys that conflict with the other parameters, they will override them. + + Returns: + `GenerateResponse`: + - `prompt_ids` (list of list of `int`): A list of lists of token IDs for each input prompt. + - `completion_ids` (list of list of `int`): A list of lists of token IDs for each generated completion. + - `logprobs` (list of list of list of `float`): Per-token logprobs of shape (num_sequences, seq_len, + num_logprobs), sorted by descending probability. + - `logprob_token_ids` (list of list of list of `int`): Token IDs corresponding to each logprob, same + shape as `logprobs`. + + Example request (text prompts): + ```json + {"prompts": ["Hello world", "What is AI?"]} + ``` + + Example request (token IDs): + ```json + {"prompts": [[101, 102], [201, 202]]} + ``` + + Example response: + ```json + { + "prompt_ids": [[101, 102], [201, 202]], + "completion_ids": [[103, 104, 105], [203, 204, 205]], + "logprobs": [[[-0.1], [-0.2], [-0.3]], [[-0.4], [-0.5], [-0.6]]], + "logprob_token_ids": [[[103], [104], [105]], [[203], [204], [205]]] + } + ``` + """ + # Build vLLM-compatible prompt inputs + is_token_ids = request.prompts and isinstance(request.prompts[0], list) + request.images = request.images or [None] * len(request.prompts) + + prompts = [] + for prompt, image_list in zip(request.prompts, request.images, strict=True): + row = {"prompt_token_ids": prompt} if is_token_ids else {"prompt": prompt} + if image_list is not None: + row["multi_modal_data"] = {"image": [Image.open(BytesIO(base64.b64decode(img))) for img in image_list]} + prompts.append(row) + + generation_kwargs = { + "n": request.n, + "repetition_penalty": request.repetition_penalty, + "temperature": request.temperature, + "top_p": request.top_p, + "top_k": request.top_k, + "min_p": request.min_p, + "max_tokens": request.max_tokens, + "logprobs": request.logprobs, + } + generation_kwargs.update(request.generation_kwargs) + + # Structured outputs, if enabled + if request.structured_outputs_regex is not None: + if generation_kwargs.get("structured_outputs") is not None: + logger.warning( + "Both `structured_outputs_regex` and `generation_kwargs['structured_outputs']` are set; " + "`structured_outputs_regex` takes precedence." + ) + generation_kwargs["structured_outputs"] = StructuredOutputsParams(regex=request.structured_outputs_regex) + elif isinstance(structured_outputs_kwargs := generation_kwargs.get("structured_outputs"), dict): + generation_kwargs["structured_outputs"] = StructuredOutputsParams(**structured_outputs_kwargs) + sampling_params = SamplingParams(**generation_kwargs) + + # Evenly distribute prompts across DP ranks + chunked_prompts = chunk_list(prompts, script_args.data_parallel_size) + + # Send the prompts to each worker + for connection, prompts in zip(connections, chunked_prompts, strict=True): + # When the number of prompts is less than data_parallel_size, some workers will receive empty prompts. + # However, vLLM requires that we always send at least one prompt. So we send a placeholder prompt to comply + # with vLLM's requirement, and we later ignore the result. + if not prompts: + prompts = [""] + kwargs = {"prompts": prompts, "sampling_params": sampling_params} + connection.send({"type": "call", "method": "generate", "kwargs": kwargs}) + + # Receive results + all_outputs = [connection.recv() for connection in connections] + + # Handle empty prompts (see above) + all_outputs = [output for output, prompts in zip(all_outputs, chunked_prompts, strict=True) if prompts] + + # Flatten and combine all results + all_outputs = list(chain.from_iterable(all_outputs)) # from list of list to single list + prompt_ids = [output.prompt_token_ids for output in all_outputs] + completion_ids = [list(output.token_ids) for outputs in all_outputs for output in outputs.outputs] + logprobs, logprob_token_ids = extract_logprobs(all_outputs) + + return { + "prompt_ids": prompt_ids, + "completion_ids": completion_ids, + "logprobs": logprobs, + "logprob_token_ids": logprob_token_ids, + } + + class SequenceLogprobsRequest(BaseModel): + sequences: list[list[int]] + prompt_lengths: list[int] + top_logprobs: int = 100 + temperature: float = 1.0 + response_format: str = "json" # "json" (legacy) or "binary" (base64 numpy arrays) + + class SequenceLogprobsResponse(BaseModel): + logprobs: list[list[list[float | None]]] | None = None + logprob_token_ids: list[list[list[int]]] | None = None + # Binary format fields (base64-encoded numpy arrays) + logprobs_b64: str | None = None + token_ids_b64: str | None = None + actual_logprobs_b64: str | None = None + actual_token_ids_b64: str | None = None + shape: list[int] | None = None # [batch_size, max_completion_len, top_logprobs] + completion_lengths: list[int] | None = None # actual completion length per sample + + def _run_prompt_logprobs(prompts, sampling_params): + """Send prompts to DP workers and collect outputs.""" + chunked_prompts = chunk_list(prompts, script_args.data_parallel_size) + for connection, chunk in zip(connections, chunked_prompts, strict=True): + if not chunk: + chunk = [{"prompt_token_ids": [0]}] + kwargs = {"prompts": chunk, "sampling_params": sampling_params} + connection.send({"type": "call", "method": "generate", "kwargs": kwargs}) + all_outputs = [connection.recv() for connection in connections] + all_outputs = [output for output, chunk in zip(all_outputs, chunked_prompts, strict=True) if chunk] + return list(chain.from_iterable(all_outputs)) + + # ── Request batching for get_sequence_logprobs ── + # Collects concurrent requests into batches and dispatches them together so that + # all DP workers stay busy. Without this, async endpoint handlers block the event + # loop during pipe I/O, serializing requests and leaving DP workers idle. + _logprob_queue: asyncio.Queue = asyncio.Queue() + + # Maximum time (seconds) to wait for more requests before dispatching a batch. + _BATCH_WAIT_S = 0.005 # 5ms - short enough to not add much latency when lightly loaded + # Maximum number of HTTP requests to collect per batcher cycle + _MAX_BATCH_REQUESTS = max(script_args.data_parallel_size * 4, 16) + # Maximum total tokens per batch. prompt_logprobs materializes full-vocab logits + # during the forward pass, so each worker can safely handle ~1 max-length sequence. + # Budget = max_model_len * dp_size gives ~1 sequence per worker at max length. + _max_model_len = script_args.max_model_len or 8192 + _MAX_BATCH_TOKENS = _max_model_len * script_args.data_parallel_size + + async def _logprob_batcher(): + """Background task that continuously drains the queue, batches requests, and dispatches.""" + loop = asyncio.get_running_loop() + + while True: + batch = [] + try: + # Wait for the first request + batch_tokens = 0 + item = await _logprob_queue.get() + batch.append(item) + # Count tokens in this item's sequences + for prompt in item[0]: + batch_tokens += len(prompt.get("prompt_token_ids", [])) + + # Collect more requests up to batch limit, timeout, or token budget + deadline = loop.time() + _BATCH_WAIT_S + while len(batch) < _MAX_BATCH_REQUESTS and batch_tokens < _MAX_BATCH_TOKENS: + remaining = deadline - loop.time() + if remaining <= 0: + break + try: + item = await asyncio.wait_for(_logprob_queue.get(), timeout=remaining) + # Check if adding this item would exceed the token budget + item_tokens = sum(len(p.get("prompt_token_ids", [])) for p in item[0]) + if batch_tokens + item_tokens > _MAX_BATCH_TOKENS and len(batch) > 0: + # Put it back and dispatch current batch + await _logprob_queue.put(item) + break + batch.append(item) + batch_tokens += item_tokens + except asyncio.TimeoutError: + break + + # batch is a list of (prompts, prompt_lengths, top_logprobs, temperature, response_format, future) + # All items in a batch must share the same (top_logprobs, temperature) pair. + # Group by those execution parameters to handle mixed requests. + groups = {} + for prompts, prompt_lengths, top_logprobs, temperature, response_format, future in batch: + key = (top_logprobs, temperature) + if key not in groups: + groups[key] = [] + groups[key].append((prompts, prompt_lengths, response_format, future)) + + for (top_logprobs, temperature), items in groups.items(): + # Merge all sequences into a single batch + all_prompts = [] + all_prompt_lengths = [] + offsets = [] # (start_idx, count) per original request + for prompts, prompt_lengths, _response_format, _future in items: + start = len(all_prompts) + all_prompts.extend(prompts) + all_prompt_lengths.extend(prompt_lengths) + offsets.append((start, len(prompts))) + + sampling_params = SamplingParams( + max_tokens=1, + temperature=temperature, + prompt_logprobs=top_logprobs, + ) + + # Dispatch to workers in a thread to avoid blocking the event loop + try: + all_outputs = await loop.run_in_executor( + None, _run_prompt_logprobs, all_prompts, sampling_params + ) + + # Split results back to individual requests + for (start, count), (_, prompt_lengths, response_format, future) in zip( + offsets, items, strict=True + ): + outputs_slice = all_outputs[start : start + count] + if not future.done(): + future.set_result((outputs_slice, prompt_lengths, top_logprobs, response_format)) + except Exception as e: + # Signal error to all waiting requests in this execution-parameter group + for *_, future in items: + if not future.done(): + future.set_exception(e) + except Exception as e: + # Prevent killing the batcher task — signal error to all unfulfilled futures + for *_, future in batch: + if not future.done(): + future.set_exception(e) + + def _format_logprob_response(all_outputs, prompt_lengths, top_k, response_format): + """Format vLLM outputs into the response dict (runs in any thread).""" + import numpy as np + + batch_size = len(all_outputs) + use_binary = response_format == "binary" + + if use_binary: + from starlette.responses import Response + + comp_lengths = [] + for output, prompt_length in zip(all_outputs, prompt_lengths, strict=True): + prompt_lps = output.prompt_logprobs + if prompt_lps is None: + raise ValueError("prompt_logprobs is None.") + comp_lengths.append(len(prompt_lps) - prompt_length) + + max_comp_len = max(comp_lengths) if comp_lengths else 0 + + # logprobs_arr / token_ids_arr: teacher's sorted top-k logprobs + token ids (for forward KL). + # actual_logprobs_arr / actual_token_ids_arr: actual token's teacher logprob (for reverse KL). + logprobs_arr = np.full((batch_size, max_comp_len, top_k), float("-inf"), dtype=np.float32) + token_ids_arr = np.zeros((batch_size, max_comp_len, top_k), dtype=np.int32) + actual_logprobs_arr = np.full((batch_size, max_comp_len, 1), float("-inf"), dtype=np.float32) + actual_token_ids_arr = np.zeros((batch_size, max_comp_len, 1), dtype=np.int32) + + for i, (output, prompt_length) in enumerate(zip(all_outputs, prompt_lengths, strict=True)): + prompt_lps = output.prompt_logprobs + seq_tokens = output.prompt_token_ids + if comp_lengths[i] == 0: + continue + + for pos in range(prompt_length, len(prompt_lps)): + lp = prompt_lps[pos] + if lp is None: + continue + t = pos - prompt_length + actual_token = seq_tokens[pos] + + # Actual token's logprob (for reverse KL) + if actual_token in lp: + val = lp[actual_token].logprob + if not math.isnan(val): + actual_logprobs_arr[i, t, 0] = val + actual_token_ids_arr[i, t, 0] = actual_token + + # Teacher's top-k logprobs (for forward KL) + if top_k == 1: + # Fast path: find rank-1 directly instead of sorting + for token_id, logprob_obj in lp.items(): + if logprob_obj.rank == 1: + val = logprob_obj.logprob + if not math.isnan(val): + logprobs_arr[i, t, 0] = val + token_ids_arr[i, t, 0] = token_id + break + else: + sorted_items = sorted(lp.items(), key=lambda x: x[1].rank) + for k_idx, (token_id, logprob_obj) in enumerate(sorted_items[:top_k]): + val = logprob_obj.logprob + if not math.isnan(val): + logprobs_arr[i, t, k_idx] = val + token_ids_arr[i, t, k_idx] = token_id + + payload = { + "logprobs_b64": base64.b64encode(logprobs_arr.tobytes()).decode("ascii"), + "token_ids_b64": base64.b64encode(token_ids_arr.tobytes()).decode("ascii"), + "actual_logprobs_b64": base64.b64encode(actual_logprobs_arr.tobytes()).decode("ascii"), + "actual_token_ids_b64": base64.b64encode(actual_token_ids_arr.tobytes()).decode("ascii"), + "shape": [batch_size, max_comp_len, top_k], + "completion_lengths": comp_lengths, + } + + try: + import orjson + + return Response(content=orjson.dumps(payload), media_type="application/json") + except ImportError: + return payload + else: + all_logprobs = [] + all_token_ids = [] + for output, prompt_length in zip(all_outputs, prompt_lengths, strict=True): + prompt_lps = output.prompt_logprobs + if prompt_lps is None: + raise ValueError("prompt_logprobs is None.") + seq_logprobs = [] + seq_token_ids = [] + for pos in range(prompt_length, len(prompt_lps)): + lp = prompt_lps[pos] + if lp is None: + seq_logprobs.append([]) + seq_token_ids.append([]) + continue + sorted_items = sorted(lp.items(), key=lambda x: x[1].rank) + seq_token_ids.append([token_id for token_id, _ in sorted_items]) + seq_logprobs.append( + [None if math.isnan(item.logprob) else item.logprob for _, item in sorted_items] + ) + all_logprobs.append(seq_logprobs) + all_token_ids.append(seq_token_ids) + return {"logprobs": all_logprobs, "logprob_token_ids": all_token_ids} + + @app.post("/get_sequence_logprobs/", response_model=SequenceLogprobsResponse) + async def get_sequence_logprobs(request: SequenceLogprobsRequest): + """ + Computes teacher logprobs for existing token sequences without generating new tokens. + + Concurrent requests are automatically batched and dispatched together to maximize GPU utilization across DP + workers. This avoids the event-loop-blocking problem where synchronous pipe I/O serializes requests despite + having multiple DP workers. + + Args: + request (`SequenceLogprobsRequest`): + - `sequences` (list of list of `int`): Full token sequences (prompt + completion) per sample. + - `prompt_lengths` (list of `int`): Number of prompt tokens per sequence; completion logprobs start + after each prompt. + - `top_logprobs` (`int`, *optional*, defaults to `100`): Number of top teacher logprobs to return per + completion position (sorted by vLLM rank). + - `temperature` (`float`, *optional*, defaults to `1.0`): Sampling temperature passed to vLLM for + logprob computation. + - `response_format` (`str`, *optional*, defaults to `"json"`): Either `"json"` (nested lists, + backward-compatible) or `"binary"` (base64-encoded numpy arrays for fast serialization). + + Returns: + `SequenceLogprobsResponse` or Starlette `Response`: + When `response_format` is `"json"`, a JSON object with: + - `logprobs` (list of list of list of `float` or `None`): Top-k teacher logprobs per completion token. + - `logprob_token_ids` (list of list of list of `int`): Token IDs aligned with `logprobs`. + When `response_format` is `"binary"`, a JSON response (Starlette `Response` if `orjson` is installed) + whose body is a JSON object with base64-encoded float32/int32 arrays: `logprobs_b64`, `token_ids_b64`, + `actual_logprobs_b64`, `actual_token_ids_b64`, plus `shape` (`list[int]`, `[batch_size, + max_completion_len, top_k]`) and `completion_lengths` (`list[int]`). + """ + if len(request.sequences) != len(request.prompt_lengths): + raise ValueError("sequences and prompt_lengths must have the same length.") + + for i, (seq, pl) in enumerate(zip(request.sequences, request.prompt_lengths, strict=True)): + if pl < 0 or pl > len(seq): + raise ValueError( + f"Sequence {i} has prompt_length={pl} which is out of range [0, {len(seq)}]. " + f"prompt_length must be between 0 and the sequence length inclusive." + ) + + # Validate sequence lengths against max_model_len to prevent worker OOM crashes + if _max_model_len: + for i, seq in enumerate(request.sequences): + if len(seq) > _max_model_len: + raise ValueError( + f"Sequence {i} has length {len(seq)} which exceeds max_model_len={_max_model_len}. " + f"Truncate sequences or increase --max-model-len." + ) + + prompts = [{"prompt_token_ids": seq} for seq in request.sequences] + + # Submit to the batching queue and await result + loop = asyncio.get_running_loop() + future = loop.create_future() + await _logprob_queue.put( + ( + prompts, + list(request.prompt_lengths), + request.top_logprobs, + request.temperature, + request.response_format, + future, + ) + ) + + # Wait for the batcher to process our request + all_outputs, prompt_lengths, top_k, response_format = await future + + return await loop.run_in_executor( + None, _format_logprob_response, all_outputs, prompt_lengths, top_k, response_format + ) + + class ChatRequest(BaseModel): + messages: list[list[dict]] + n: int = 1 + repetition_penalty: float = 1.0 + temperature: float = 1.0 + top_p: float = 1.0 + top_k: int = -1 + min_p: float = 0.0 + max_tokens: int = 16 + logprobs: int | None = 0 + structured_outputs_regex: str | None = None + generation_kwargs: dict = field(default_factory=dict) + chat_template_kwargs: dict = field(default_factory=dict) + tools: list | None = None + + class ChatResponse(BaseModel): + prompt_ids: list[list[int]] + completion_ids: list[list[int]] + logprobs: list[list[list[float | None]]] | None + logprob_token_ids: list[list[list[int]]] | None + + @app.post("/chat/", response_model=ChatResponse) + async def chat(request: ChatRequest): + """ + Generates completions for the provided chat messages. + + Args: + request (`ChatRequest`): + - `messages` (list of `dict`): A list of messages (dicts with "role" and "content" keys) for the model + to generate completions. + - `n` (`int`, *optional*, defaults to `1`): Number of completions to generate for each prompt. + - `repetition_penalty` (`float`, *optional*, defaults to `1.0`): Repetition penalty to apply during + generation. + - `temperature` (`float`, *optional*, defaults to `1.0`): Temperature for sampling. Higher values lead + to more random outputs. + - `top_p` (`float`, *optional*, defaults to `1.0`): Top-p (nucleus) sampling parameter. It controls the + diversity of the generated text. + - `top_k` (`int`, *optional*, defaults to `-1`): Top-k sampling parameter. If set to `-1`, it disables + top-k sampling. + - `min_p` (`float`, *optional*, defaults to `0.0`): Minimum probability threshold for sampling. + - `max_tokens` (`int`, *optional*, defaults to `16`): Maximum number of tokens to generate for each + completion. + - `logprobs` (`int`, *optional*, defaults to `0`): Number of top logprobs to return per token. When 0, + only the sampled token's logprob is returned. When N>0, returns up to N+1 logprobs sorted by + descending probability, because vLLM always includes the sampled token's logprob (which may fall + outside the top-N). + - `structured_outputs_regex` (`str`, *optional*): A regex pattern for structured outputs. If provided, + the model will only generate tokens that match this regex pattern. + - `generation_kwargs` (`dict`, *optional*): Additional generation parameters to pass to the vLLM + `SamplingParams`. This can include parameters like `seed`, `frequency_penalty`, etc. If it contains + keys that conflict with the other parameters, they will override them. + - `chat_template_kwargs` (`dict`, *optional*): Additional keyword arguments to pass to the chat + template. + + Returns: + `ChatResponse`: + - `prompt_ids` (list of list of `int`): A list of lists of token IDs for each input prompt. + - `completion_ids` (list of list of `int`): A list of lists of token IDs for each generated completion. + - `logprobs` (list of list of list of `float`): Per-token logprobs of shape (num_sequences, seq_len, + num_logprobs), sorted by descending probability. + - `logprob_token_ids` (list of list of list of `int`): Token IDs corresponding to each logprob, same + shape as `logprobs`. + + Example request: + ```bash + curl -X POST 'http://0.0.0.0:8000/chat/' \ + -H 'Content-Type: application/json' \ + -d '{"messages": [[{ "role": "user", "content": "Hello!" }]]}' + ``` + + Example response: + ```json + { + "prompt_ids": [[151644, 872, 198, 9707, 0, 151645, 198, 151644, 77091, 198]], + "completion_ids": [[151667, 198, 32313, 11, 279]], + "logprobs": [[[-0.0003], [-3.58e-07], [-0.0902], [-6.39e-05], [-0.0387]]], + "logprob_token_ids": [[[151667], [198], [32313], [11], [279]]] + } + ``` + """ + # Convert PIL images to base64 strings + for message_list in request.messages: + for message in message_list: + if isinstance(message["content"], list): + for part in message["content"]: + if part["type"] == "image_pil": + part["image_pil"] = Image.open(BytesIO(base64.b64decode(part["image_pil"]))) + + generation_kwargs = { + "n": request.n, + "repetition_penalty": request.repetition_penalty, + "temperature": request.temperature, + "top_p": request.top_p, + "top_k": request.top_k, + "min_p": request.min_p, + "max_tokens": request.max_tokens, + "logprobs": request.logprobs, + } + generation_kwargs.update(request.generation_kwargs) + + # Structured outputs, if enabled + if request.structured_outputs_regex is not None: + if generation_kwargs.get("structured_outputs") is not None: + logger.warning( + "Both `structured_outputs_regex` and `generation_kwargs['structured_outputs']` are set; " + "`structured_outputs_regex` takes precedence." + ) + generation_kwargs["structured_outputs"] = StructuredOutputsParams(regex=request.structured_outputs_regex) + elif isinstance(structured_outputs_kwargs := generation_kwargs.get("structured_outputs"), dict): + generation_kwargs["structured_outputs"] = StructuredOutputsParams(**structured_outputs_kwargs) + sampling_params = SamplingParams(**generation_kwargs) + + # Evenly distribute prompts across DP ranks + chunked_messages = chunk_list(request.messages, script_args.data_parallel_size) + + # Send the messages to each worker + for connection, messages in zip(connections, chunked_messages, strict=True): + # When the number of messages is less than data_parallel_size, some workers will receive empty messages. + # However, vLLM requires that we always send at least one prompt. So we send a placeholder prompt to comply + # with vLLM's requirement, and we later ignore the result. + if not messages: + messages = [[{"role": "user", "content": ""}]] + kwargs = { + "messages": messages, + "sampling_params": sampling_params, + "chat_template_kwargs": request.chat_template_kwargs, + "tools": request.tools, + } + connection.send({"type": "call", "method": "chat", "kwargs": kwargs}) + + # Receive results + all_outputs = [connection.recv() for connection in connections] + + # Handle empty prompts (see above) + all_outputs = [output for output, prompts in zip(all_outputs, chunked_messages, strict=True) if prompts] + + # Flatten and combine all results + all_outputs = list(chain.from_iterable(all_outputs)) # from list of list to single list + prompt_ids = [output.prompt_token_ids for output in all_outputs] + completion_ids = [list(output.token_ids) for outputs in all_outputs for output in outputs.outputs] + logprobs, logprob_token_ids = extract_logprobs(all_outputs) + + return { + "prompt_ids": prompt_ids, + "completion_ids": completion_ids, + "logprobs": logprobs, + "logprob_token_ids": logprob_token_ids, + } + + class InitCommunicatorRequest(BaseModel): + host: str + port: int + world_size: int + client_device_uuid: str + + @app.post("/init_communicator/") + async def init_communicator(request: InitCommunicatorRequest): + """ + Initializes the communicator for synchronizing model weights between a client and multiple server workers. + + Args: + request (`InitCommunicatorRequest`): + - `host` (`str`): Hostname or IP address of the master node. + - `port` (`int`): Port number to be used for communication. + - `world_size` (`int`): Total number of participating processes in the group. + - `client_device_uuid` (`str`): UUID of the device of client main process. Used to assert that devices + are different from vLLM workers devices. + """ + world_size = script_args.tensor_parallel_size * script_args.data_parallel_size + 1 + + # The function init_communicator is called this way: init_communicator(host, port, world_size) + # So with collective_rpc we need to call it this way: + # llm.collective_rpc(method="init_communicator", args=(host, port, world_size)) + kwargs = { + "method": "init_communicator", + "args": (request.host, request.port, world_size, request.client_device_uuid), + } + for connection in connections: + connection.send({"type": "fire_and_forget", "method": "collective_rpc", "kwargs": kwargs}) + + return {"message": "Request received, initializing communicator"} + + class UpdateWeightsRequest(BaseModel): + name: str + dtype: str + shape: list[int] + + @app.post("/update_named_param/") + async def update_named_param(request: UpdateWeightsRequest): + """ + Updates the model weights with the provided tensor. + + Once this endpoint is called, the client process should broadcast the updated weights to all server workers. + + Args: + request (`UpdateWeightsRequest`): + - `name` (`str`): Name of the weight tensor being updated. + - `dtype` (`str`): Data type of the weight tensor (e.g., `"torch.float32"`). + - `shape` (list of `int`): Shape of the weight + + """ + # The function update_named_param is called this way: update_named_param("name", "torch.float32", (10, 10)) + # So with collective_rpc we need to call it this way: + # llm.collective_rpc("update_named_param", args=("name", "torch.float32", (10, 10))) + kwargs = {"method": "update_named_param", "args": (request.name, request.dtype, tuple(request.shape))} + for connection in connections: + connection.send({"type": "fire_and_forget", "method": "collective_rpc", "kwargs": kwargs}) + + return {"message": "Request received, updating named parameter"} + + @app.post("/reset_prefix_cache/") + async def reset_prefix_cache(): + """ + Resets the prefix cache for the model. + """ + for connection in connections: + connection.send({"type": "call", "method": "reset_prefix_cache"}) + # Wait for and collect all results + all_outputs = [connection.recv() for connection in connections] + success = all(output for output in all_outputs) + return {"message": "Request received, resetting prefix cache status: " + str(success)} + + @app.post("/close_communicator/") + async def close_communicator(): + """ + Closes the weight update group and cleans up associated resources. + """ + kwargs = {"method": "close_communicator"} + for connection in connections: + connection.send({"type": "fire_and_forget", "method": "collective_rpc", "kwargs": kwargs}) + return {"message": "Request received, closing communicator"} + + # Start the server + uvicorn.run(app, host=script_args.host, port=script_args.port, log_level=script_args.log_level) + + +def make_parser(subparsers: argparse._SubParsersAction | None = None, prog: str | None = None): + from trl import TrlParser + + if subparsers is not None: + parser = subparsers.add_parser("vllm-serve", help="Run the vLLM serve script", dataclass_types=ScriptArguments) + else: + parser = TrlParser(ScriptArguments, prog=prog) + return parser + + +if __name__ == "__main__": + parser = make_parser() + (script_args,) = parser.parse_args_and_config() + main(script_args) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..29603ebfd06c6042f7892ccff7426cf38a2936b7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .skills import ( + install_skill, + list_agent_names, + list_skills, + resolve_target_path, + uninstall_skill, +) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/cli.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/cli.py new file mode 100644 index 0000000000000000000000000000000000000000..6f3de49c23e8c32f5258846390b52382b17dba62 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/cli.py @@ -0,0 +1,199 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +CLI commands for TRL skills installation and management. + +This module provides command-line interface for installing TRL skills to various AI agent directories. +""" + +import argparse + +from .skills import install_skill, list_agent_names, list_skills, resolve_target_path, uninstall_skill + + +def add_skills_subcommands(subparsers: argparse._SubParsersAction) -> None: + """ + Add skills subcommands to the parser. + + This creates nested subcommands under 'trl skills' for managing skill installations. + + Args: + subparsers: Subparsers from 'trl skills' command + """ + # Parent parser for common target options + target_parser = argparse.ArgumentParser(add_help=False) + target_parser.add_argument( + "--target", + required=True, + help=f"Installation target: agent name ({', '.join(list_agent_names())}) or directory path", + ) + target_parser.add_argument( + "--scope", + choices=["project", "global"], + default="project", + help="Scope when using --target with agent name: project (./agent/skills/) or global (user-level like ~/.agent/skills/)", + ) + + # trl skills list (no target required - lists TRL's built-in skills by default) + list_parser = subparsers.add_parser( + "list", + help="List available TRL skills or installed skills in a target", + description="Show TRL skills available for installation, or if --target is specified, show installed skills", + ) + list_parser.add_argument( + "--target", + help="Optional: show installed skills in target (agent name or directory path)", + ) + list_parser.add_argument( + "--scope", + choices=["project", "global"], + default="project", + help="Scope when using --target with agent name: project (./agent/skills/) or global (user-level like ~/.agent/skills/)", + ) + list_parser.set_defaults(func=cmd_list) + + # trl skills install + install_parser = subparsers.add_parser( + "install", + parents=[target_parser], + help="Install skill", + description="Install TRL skill to to target", + ) + install_parser.add_argument("skill", nargs="?", help="Skill name to install (omit to use --all)") + install_parser.add_argument("--all", action="store_true", help="Install all available TRL skills") + install_parser.add_argument("--force", action="store_true", help="Overwrite if skill already exists") + install_parser.set_defaults(func=cmd_install) + + # trl skills uninstall + uninstall_parser = subparsers.add_parser( + "uninstall", + parents=[target_parser], + help="Uninstall skill from target", + description="Remove a TRL skill from an AI agent's skills directory", + ) + uninstall_parser.add_argument("skill", help="Skill name to uninstall") + uninstall_parser.set_defaults(func=cmd_uninstall) + + +def cmd_install(args): + """Handle 'trl skills install' command.""" + # Validate arguments + if not args.skill and not args.all: + print("Error: Either provide a skill name or use --all to install all skills") + print("Usage: trl skills install --target ") + print(" or: trl skills install --all --target ") + return 1 + + if args.skill and args.all: + print("Error: Cannot specify both a skill name and --all") + return 1 + + # Determine skills to install + if args.all: + skills_to_install = list_skills() + if not skills_to_install: + print("No skills available to install") + return 1 + print(f"Installing {len(skills_to_install)} skills to {args.target}") + else: + skills_to_install = [args.skill] + + # Install each skill + success_count = 0 + for skill_name in skills_to_install: + try: + print(f"Installing '{skill_name}'...", end=" ") + install_skill( + skill_name=skill_name, + target=args.target, + scope=args.scope, + force=args.force, + ) + print("✓") + success_count += 1 + + except FileExistsError as e: + print("✗") + print(f" Error: {e}") + if not args.force: + print(" Use --force to overwrite") + except (FileNotFoundError, ValueError) as e: + print("✗") + print(f" Error: {e}") + + # Summary + print(f"\n{success_count}/{len(skills_to_install)} skills installed successfully") + + if success_count > 0: + target_path = resolve_target_path(args.target, args.scope) + print(f"\nSkills are now available at: {target_path}") + print("You may need to restart your AI agent to use the new skills.") + + return 0 if success_count == len(skills_to_install) else 1 + + +def cmd_uninstall(args): + """Handle 'trl skills uninstall' command.""" + try: + print(f"Uninstalling '{args.skill}' from {args.target}...", end=" ") + uninstall_skill(args.skill, target=args.target, scope=args.scope) + print("✓") + print(f"\nSkill '{args.skill}' has been removed") + return 0 + + except (FileNotFoundError, PermissionError, ValueError) as e: + print("✗") + print(f"Error: {e}") + return 1 + + +def cmd_list(args): + """Handle 'trl skills list' command.""" + try: + # List skills - if no target specified, list TRL's built-in skills + if args.target: + skills = list_skills(target=args.target, scope=args.scope) + location = args.target + else: + skills = list_skills() + location = "TRL (available for installation)" + + if not skills: + if args.target: + print(f"No skills installed in {args.target}") + else: + print("No TRL skills available") + return 0 + + print(f"\nSkills in {location}:\n") + + for skill in skills: + print(f" {skill}") + + print(f"\nTotal: {len(skills)} skill(s)") + + if not args.target: + print("\nUse 'trl skills install --target ' to install a skill") + + return 0 + + except ValueError as e: + print(f"Error: {e}") + return 1 + + +__all__ = [ + "add_skills_subcommands", +] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/skills.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/skills.py new file mode 100644 index 0000000000000000000000000000000000000000..aea1a37c3b5d847bc624688801456df2c862cf2c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/skills.py @@ -0,0 +1,357 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Agent Skills. + +This module: +- provides utilities for discovering and accessing TRL skills that can be used by AI agents to learn how to use the TRL + CLI +- handles installation, uninstallation, and management of TRL skills +- defines where different AI agents and coding tools look for skills, enabling easy installation of TRL skills to the + appropriate directories + +Agent Skills are folders of instructions, scripts, and resources that agents can discover and use to perform tasks more +accurately and efficiently. Learn more at https://agentskills.io +""" + +import importlib.resources as resources +import shutil +from pathlib import Path + + +AGENT_PATHS = { + "claude": { + "global": Path("~/.claude/skills"), + "project": Path("./.claude/skills"), + }, + "codex": { + "global": Path("~/.codex/skills"), + "project": Path("./.codex/skills"), + }, + "opencode": { + "global": Path("~/.config/opencode/skills"), + "project": Path(".opencode/skills"), + }, +} + + +def list_agent_names() -> list[str]: + """ + List available predefined agent names. + + Returns: + `list[str]`: Sorted list of agent names (e.g., ['claude', 'codex', 'opencode']). + """ + return sorted(AGENT_PATHS.keys()) + + +def _get_trl_skills_dir() -> Path: + """ + Get the path to the TRL skills directory. + + This is the directory inside the TRL package containing skills that can be installed to AI agent directories. + + Returns: + `Path`: TRL skills directory. + """ + return Path(str(resources.files("trl.skills"))) + + +def resolve_target_path(target: str | Path, scope: str = "project") -> Path: + """ + Resolve target to a concrete directory path. + + Converts semantic agent names (e.g., 'claude') with scope to actual filesystem paths, or normalizes provided paths. + + Args: + target (`str | Path`): Agent name (e.g., 'claude', 'codex') or directory path. + scope (`str`, defaults to `"project"`): + Scope for agent names: 'global' (user-level like ~/.agent/skills/) or 'project' (./agent/skills/). + + Returns: + `Path`: Resolved absolute path. + + Raises: + `ValueError`: If `scope` is invalid for a predefined agent target. + + Example: + ```python + from trl.skills import resolve_target_path + + # Resolve agent name with scope + path = resolve_target_path("claude", "global") + print(path) # /home/user/.claude/skills + + # Resolve custom path + path = resolve_target_path("/custom/skills") + print(path) # /custom/skills + ``` + """ + if isinstance(target, Path): + return target.expanduser().resolve() + + # Check if it's a predefined agent + if target in AGENT_PATHS: + if scope not in AGENT_PATHS[target]: + valid_scopes = ", ".join(sorted(AGENT_PATHS[target])) + raise ValueError(f"Invalid scope '{scope}' for agent '{target}'. Expected one of: {valid_scopes}") + agent_path = AGENT_PATHS[target][scope] + return agent_path.expanduser().resolve() + + # Treat as custom path string + return Path(target).expanduser().resolve() + + +def _list_skills_in_dir(skills_dir: Path) -> list[str]: + """ + List skills in directory. + + A skill is a directory containing a SKILL.md file. + + Args: + skills_dir (`Path`): Skills directory to scan. + + Returns: + `list[str]`: Skill names (directory names containing SKILL.md). + """ + if not skills_dir.exists(): + return [] + skills = [] + for item in skills_dir.iterdir(): + if item.is_dir() and (item / "SKILL.md").exists(): + skills.append(item.name) + return sorted(skills) + + +def list_skills(target: str | Path | None = None, scope: str = "project") -> list[str]: + """ + List skills. + + A skill is a directory containing a SKILL.md file. + + Args: + target (`str | Path`, *optional*): + Agent name (e.g., 'claude'), directory path, or `None` for TRL's built-in skills. + scope (`str`, defaults to `"project"`): + For agent names: 'global' (user-level) or 'project' (current directory). + + Returns: + `list[str]`: Skill names (directory names containing SKILL.md). + + Example: + ```python + from trl.skills import list_skills + + # List TRL's built-in skills + skills = list_skills() + print(skills) # ['trl-training'] + + # List skills installed for Claude globally + installed = list_skills(target="claude", scope="global") + print(installed) # ['trl-training', 'custom-skill'] + + # List skills in custom directory + custom = list_skills(target="/path/to/skills") + print(custom) # [...] + ``` + """ + if target is None: + # List TRL's built-in skills + return _list_skills_in_dir(_get_trl_skills_dir()) + + target_dir = resolve_target_path(target, scope) + return _list_skills_in_dir(target_dir) + + +def _install_skill_to_dir( + skill_name: str, + target_dir: Path, + source_dir: Path, + force: bool = False, +) -> bool: + """ + Install a skill to target directory. + + Args: + skill_name (`str`): Name of skill to install. + target_dir (`Path`): Target installation directory. + source_dir (`Path`): Source directory containing skills. + force (`bool`, defaults to `False`): Whether to overwrite if exists. + + Returns: + `bool`: True if installed successfully. + + Raises: + - `FileNotFoundError`: If skill doesn't exist in source_dir. + - `FileExistsError`: If skill already installed and not force. + - `PermissionError`: If no permission to write to target_dir. + - `ValueError`: If source_dir entry exists but is not a directory. + - `OSError`: If copying the skill fails. + """ + source_skill = source_dir / skill_name + + # Check if source skill exists + if not source_skill.exists(): + available = ", ".join(list_skills(target=source_dir)) + source_msg = f"source directory {source_dir}" + if available: + raise FileNotFoundError(f"Skill '{skill_name}' not found in {source_msg}. Available skills: {available}") + raise FileNotFoundError(f"Skill '{skill_name}' not found in {source_msg}") + + if not source_skill.is_dir(): + raise ValueError(f"Skill '{skill_name}' is not a directory") + + target_skill = target_dir / skill_name + + # Check if already exists + if target_skill.exists() and not force: + raise FileExistsError(f"Skill '{skill_name}' already installed at {target_skill}. Use --force to overwrite.") + + # Create target directory + try: + target_dir.mkdir(parents=True, exist_ok=True) + except PermissionError as e: + raise PermissionError(f"Cannot create directory {target_dir}: {e}") from e + + # Remove existing if force + if target_skill.exists() and force: + if target_skill.is_symlink(): + target_skill.unlink() + else: + shutil.rmtree(target_skill) + + # Install + try: + shutil.copytree(source_skill, target_skill) + except OSError as e: + raise OSError(f"Failed to install skill: {e}") from e + + return True + + +def install_skill( + skill_name: str, + target: str | Path, + scope: str = "project", + source: str | Path | None = None, + force: bool = False, +) -> bool: + """ + Install a skill. + + Args: + skill_name (`str`): Name of skill to install. + target (`str | Path`): Agent name (e.g., 'claude', 'codex') or directory path. + scope (`str`, defaults to `"project"`): + Scope for agent names: 'global' (user-level) or 'project' (current directory). + source (`str | Path`, *optional*): + Source directory containing skills. If `None`, defaults to TRL skills directory. + force (`bool`, defaults to `False`): Whether to overwrite if skill already exists. + + Returns: + `bool`: True if installed successfully. + + Raises: + - `FileNotFoundError`: If skill doesn't exist in source. + - `FileExistsError`: If skill already installed and not force. + - `PermissionError`: If no permission to write to target. + - `ValueError`: + - If `scope` is invalid for a predefined agent target. + - If `source` entry exists but is not a directory. + - `OSError`: If copying the skill fails. + + Example: + ```python + from trl.skills import install_skill + + # Install to Claude's global skills directory + install_skill("trl-training", target="claude", scope="global") + + # Install to custom directory + install_skill("trl-training", target="/path/to/skills") + + # Overwrite existing installation + install_skill("trl-training", target="claude", force=True) + ``` + """ + target_dir = resolve_target_path(target, scope) + source_dir = Path(source).expanduser().resolve() if source else _get_trl_skills_dir() + return _install_skill_to_dir(skill_name, target_dir, source_dir, force) + + +def _uninstall_skill_from_dir(skill_name: str, target_dir: Path) -> bool: + """ + Uninstall a skill from target directory. + + Args: + skill_name (`str`): Name of skill to uninstall. + target_dir (`Path`): Directory skill is installed in. + + Returns: + `bool`: True if uninstalled successfully. + + Raises: + - `FileNotFoundError`: If skill not installed. + - `PermissionError`: If no permission to remove. + - `OSError`: If removing the skill fails for another filesystem reason. + """ + target_skill = target_dir / skill_name + + if not target_skill.exists(): + raise FileNotFoundError(f"Skill '{skill_name}' not installed at {target_dir}") + + # Remove symlink or directory + try: + shutil.rmtree(target_skill) + except PermissionError as e: + raise PermissionError(f"Cannot remove skill: {e}") from e + except OSError as e: + raise OSError(f"Failed to remove skill: {e}") from e + + return True + + +def uninstall_skill(skill_name: str, target: str | Path, scope: str = "project") -> bool: + """ + Uninstall a skill. + + Args: + skill_name (`str`): Name of skill to uninstall. + target (`str | Path`): Agent name (e.g., 'claude', 'codex') or directory path. + scope (`str`, defaults to `"project"`): + Scope for agent names: 'global' (user-level) or 'project' (current directory). + + Returns: + `bool`: True if uninstalled successfully. + + Raises: + - `FileNotFoundError`: If skill not installed. + - `PermissionError`: If no permission to remove. + - `OSError`: If removing the skill fails for another filesystem reason. + - `ValueError`: If `scope` is invalid for a predefined agent target. + + Example: + ```python + from trl.skills import uninstall_skill + + # Uninstall from Claude's global directory + uninstall_skill("trl-training", target="claude", scope="global") + + # Uninstall from custom directory + uninstall_skill("trl-training", target="/path/to/skills") + ``` + """ + target_dir = resolve_target_path(target, scope) + return _uninstall_skill_from_dir(skill_name, target_dir) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/trl-training/SKILL.md b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/trl-training/SKILL.md new file mode 100644 index 0000000000000000000000000000000000000000..1941385812d82abbbe1f466aa1204e0f8d775ea9 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/skills/trl-training/SKILL.md @@ -0,0 +1,333 @@ +--- +name: trl-training +description: Train and fine-tune transformer language models using TRL (Transformers Reinforcement Learning). Supports SFT, DPO, GRPO, KTO, RLOO and Reward Model training via CLI commands. +license: Apache-2.0 +metadata: + version: "1.0.0" + author: huggingface + commands: + - trl sft + - trl dpo + - trl grpo + - trl kto + - trl rloo + - trl reward + categories: + - machine-learning + - llm-training + - reinforcement-learning + tags: + - rlhf + - supervised-fine-tuning + - dpo + - grpo + - huggingface + - transformers + documentation: https://huggingface.co/docs/trl/en/clis +--- + +# TRL Training Skill + +You are an expert at using the TRL (Transformers Reinforcement Learning) library to train and fine-tune large language models. + +## Overview + +TRL provides CLI commands for post-training foundation models using state-of-the-art techniques: + +- **SFT** (Supervised Fine-Tuning): Fine-tune models on instruction-following or conversational datasets +- **DPO** (Direct Preference Optimization): Align models using preference data +- **GRPO** (Group Relative Policy Optimization): Train models by ranking multiple sampled outputs relative to each other and optimizing based on their comparative rewards. +- **RLOO** (Reinforce Leave One Out): Online RL training with generation-based rewards +- **Reward Model Training**: Train reward models for RLHF + +TRL is built on top of Hugging Face Transformers and Accelerate, providing seamless integration with the Hugging Face ecosystem. + +## Core Commands + +### trl sft - Supervised Fine-Tuning + +Fine-tune language models on instruction-following or conversational datasets. + +**Full training:** + +```bash +trl sft \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --learning_rate 2.0e-5 \ + --num_train_epochs 1 \ + --packing \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 8 \ + --eos_token '<|im_end|>' \ + --eval_strategy steps \ + --eval_steps 100 \ + --output_dir Qwen2-0.5B-SFT \ + --push_to_hub +``` + +**Train with LoRA adapters:** + +```bash +trl sft \ + --model_name_or_path Qwen/Qwen2-0.5B \ + --dataset_name trl-lib/Capybara \ + --learning_rate 2.0e-4 \ + --num_train_epochs 1 \ + --packing \ + --per_device_train_batch_size 2 \ + --gradient_accumulation_steps 8 \ + --eos_token '<|im_end|>' \ + --eval_strategy steps \ + --eval_steps 100 \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 \ + --output_dir Qwen2-0.5B-SFT \ + --push_to_hub +``` + +### trl dpo - Direct Preference Optimization + +Align models using preference data (chosen/rejected pairs). + +**Full training:** + +```bash +trl dpo \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --learning_rate 5.0e-7 \ + --num_train_epochs 1 \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --gradient_accumulation_steps 8 \ + --eval_strategy steps \ + --eval_steps 50 \ + --output_dir Qwen2-0.5B-DPO \ + --no_remove_unused_columns +``` + +**Train with LoRA adapters:** + +```bash +trl dpo \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --learning_rate 5.0e-6 \ + --num_train_epochs 1 \ + --per_device_train_batch_size 2 \ + --max_steps 1000 \ + --gradient_accumulation_steps 8 \ + --eval_strategy steps \ + --eval_steps 50 \ + --output_dir Qwen2-0.5B-DPO \ + --no_remove_unused_columns \ + --use_peft \ + --lora_r 32 \ + --lora_alpha 16 +``` + +### trl grpo - Group Relative Policy Optimization + +Train models using reward functions or LLM-as-a-judge for evaluating generations and providing rewards. + +**Basic usage:** + +```bash +trl grpo \ + --model_name_or_path Qwen/Qwen2.5-0.5B \ + --dataset_name trl-lib/gsm8k \ + --reward_funcs accuracy_reward \ + --output_dir Qwen2-0.5B-GRPO \ + --push_to_hub +``` + +### trl rloo - Reinforce Leave One Out + +Online RL training where the model generates text and receives rewards based on custom criteria. + +**Basic usage:** + +```bash +trl rloo \ + --model_name_or_path Qwen/Qwen2.5-0.5B \ + --dataset_name trl-lib/tldr \ + --reward_model_name_or_path sentiment-analysis:nlptown/bert-base-multilingual-uncased-sentiment \ + --output_dir Qwen2-0.5B-RLOO \ + --push_to_hub +``` + +### trl reward - Reward Model Training + +Train a reward model to score text quality for RLHF. + +**Full training:** + +```bash +trl reward \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --output_dir Qwen2-0.5B-Reward \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 1.0e-5 \ + --eval_strategy steps \ + --eval_steps 50 \ + --max_length 2048 +``` + +**Train with LoRA adapters:** + +```bash +trl reward \ + --model_name_or_path Qwen/Qwen2-0.5B-Instruct \ + --dataset_name trl-lib/ultrafeedback_binarized \ + --output_dir Qwen2-0.5B-Reward-LoRA \ + --per_device_train_batch_size 8 \ + --num_train_epochs 1 \ + --learning_rate 1.0e-4 \ + --eval_strategy steps \ + --eval_steps 50 \ + --max_length 2048 \ + --use_peft \ + --lora_task_type SEQ_CLS \ + --lora_r 32 \ + --lora_alpha 16 +``` + +## Configuration Files + +TRL supports YAML configuration files for reproducible training. All CLI arguments can be specified in a config file. + +**Example config (sft_config.yaml):** + +```yaml +model_name_or_path: Qwen/Qwen2.5-0.5B +dataset_name: trl-lib/Capybara +learning_rate: 2.0e-5 +num_train_epochs: 1 +per_device_train_batch_size: 8 +gradient_accumulation_steps: 2 +output_dir: ./sft_output +use_peft: true +lora_r: 16 +lora_alpha: 16 +report_to: trackio +``` + +**Launch with config:** + +```bash +trl sft --config sft_config.yaml +``` + +**Override config values:** + +```bash +trl sft --config sft_config.yaml --learning_rate 1.0e-5 +``` + +## Distributed Training + +TRL integrates with Accelerate for multi-GPU and multi-node training. + +**Multi-GPU training:** + +```bash +trl sft \ + --config sft_config.yaml \ + --num_processes 4 +``` + +**Use predefined Accelerate configs:** + +TRL provides predefined configs: `single_gpu`, `multi_gpu`, `fsdp1`, `fsdp2`, `zero1`, `zero2`, `zero3` + +```bash +trl sft \ + --config sft_config.yaml \ + --accelerate_config zero2 +``` + +**Custom Accelerate config:** + +```bash +# Generate custom config +accelerate config + +# Use custom config +trl sft --config sft_config.yaml --config_file ~/.cache/huggingface/accelerate/default_config.yaml +``` + +**Fully Sharded Data Parallel (FSDP):** + +```bash +trl sft --config sft_config.yaml --accelerate_config fsdp2 +``` + +**DeepSpeed ZeRO:** + +```bash +trl sft --config sft_config.yaml --accelerate_config zero3 +``` + +## Troubleshooting + +### CUDA Out of Memory + +- Reduce `--per_device_train_batch_size` and increase `--gradient_accumulation_steps` +- Enable `--use_peft` for LoRA training +- Use `--gradient_checkpointing` to save memory +- Try smaller model or longer sequence truncation + +### Dataset Loading Issues + +- Verify dataset exists: check Hugging Face Hub or local path +- Check dataset format matches expected columns +- Use `--dataset_config` for multi-config datasets +- Inspect dataset: `from datasets import load_dataset; ds = load_dataset(name)` + +### Model Loading Issues + +- Verify model exists on Hugging Face Hub +- Check if gated model requires authentication: `hf auth login` +- For local models, provide absolute path +- Ensure sufficient disk space and memory + +### Slow Training + +- Enable dataset `--packing` for short sequences +- Use larger `--per_device_train_batch_size` if memory allows +- Enable `--tf32` for faster computation on Ampere GPUs +- Use `--bf16` on supported hardware +- Consider multi-GPU training with `--num_processes` + +### Generation Issues (GRPO/RLOO) + +- Check prompt format in dataset +- Adjust `--temperature` and `--top_p` for generation +- Verify the reward function (for GRPO/RLOO) + +## Additional Resources + +- **Documentation**: https://huggingface.co/docs/trl +- **GitHub**: https://github.com/huggingface/trl +- **Examples**: https://github.com/huggingface/trl/tree/main/examples + +## Best Practices + +1. **Start with SFT**: Always fine-tune base models with SFT before preference alignment +2. **Use LoRA for efficiency**: Enable `--use_peft` for faster training and lower memory +3. **Monitor training**: Use `--report_to trackio` (or `--report_to wandb` or `--report_to tensorboard`) for tracking +4. **Save checkpoints**: TRL automatically saves checkpoints in `--output_dir` +5. **Test on small datasets first**: Verify pipeline works before full training +6. **Use configuration files**: Create YAML configs for reproducibility +7. **Leverage Accelerate**: Use multi-GPU training for faster iteration + +When helping users with TRL: +- Always check which training method is appropriate for their use case +- Verify dataset format matches the expected schema +- Recommend starting with smaller models for testing +- Suggest LoRA for resource-constrained environments +- Point to specific documentation sections for advanced features diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/completions_dataset_card.md b/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/completions_dataset_card.md new file mode 100644 index 0000000000000000000000000000000000000000..6246844db5738c7cc6807c9b221544f6939692c6 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/completions_dataset_card.md @@ -0,0 +1,40 @@ +--- +{{ card_data }} +--- + +# TRL Completion logs + +This dataset contains the completions generated during training using `trl`. + +{% if hub_model_id %} +Find the trained model at https://huggingface.co/{{ hub_model_id }}. + +{% endif %} +The completions are stored in parquet files, and each file contains the completions for a single step of training (depending on the `logging_steps` argument). + +Each file contains the following columns: + +- `step`: the step of training +- `prompt`: the prompt used to generate the completion +- `completion`: the completion generated by the model +- ``: the reward(s) assigned to the completion by the reward function(s) used during training +- `advantage`: the computed advantage for the completion + +Having this data stored as a simple parquet file makes it easy to load and analyze using the Datasets Viewer, Polars, Pandas, etc. + +You can load the dataset using the `datasets` library: + +```python +import datasets + +dataset = datasets.load_dataset("{{ repo_id }}") +``` + +You can also load the dataset using Polars: + +```python +import polars as pl + +# Login using e.g. `hf auth login` to access this dataset if it's private +df = pl.read_parquet(f"hf://datasets/{{ repo_id }}/*.parquet") +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/lm_model_card.md b/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/lm_model_card.md new file mode 100644 index 0000000000000000000000000000000000000000..ae7e33bfb5d5e5864257fd0abf04bd78d1629c5f --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/lm_model_card.md @@ -0,0 +1,55 @@ +--- +{{ card_data }} +--- + +# Model Card for {{ model_name }} + +This model is a fine-tuned version of [{{ base_model }}](https://huggingface.co/{{ base_model }}){% if dataset_name %} on the [{{ dataset_name }}](https://huggingface.co/datasets/{{ dataset_name }}) dataset{% endif %}. +It has been trained using [TRL](https://github.com/huggingface/trl). + +## Quick start + +```python +from transformers import pipeline + +question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?" +generator = pipeline("text-generation", model="{{ hub_model_id }}", device="cuda") +output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0] +print(output["generated_text"]) +``` + +## Training procedure + +{% if wandb_url %}[Visualize in Weights & Biases]({{ wandb_url }}){% endif %} +{% if trackio_url %}[Visualize in Trackio]({{ trackio_url }}){% endif %} +{% if comet_url %}[Visualize in Comet]({{ comet_url }}){% endif %} + +This model was trained with {{ trainer_name }}{% if paper_id %}, a method introduced in [{{ paper_title }}](https://huggingface.co/papers/{{ paper_id }}){% endif %}. + +### Framework versions + +- TRL: {{ trl_version }} +- Transformers: {{ transformers_version }} +- Pytorch: {{ pytorch_version }} +- Datasets: {{ datasets_version }} +- Tokenizers: {{ tokenizers_version }} + +## Citations + +{% if trainer_citation %}Cite {{ trainer_name }} as: + +```bibtex +{{ trainer_citation }} +```{% endif %} + +Cite TRL as: + +```bibtex +{% raw %}@software{vonwerra2020trl, + title = {{TRL: Transformers Reinforcement Learning}}, + author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin}, + license = {Apache-2.0}, + url = {https://github.com/huggingface/trl}, + year = {2020} +}{% endraw %} +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/rm_model_card.md b/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/rm_model_card.md new file mode 100644 index 0000000000000000000000000000000000000000..0e47e9724a6c38f262b63782507d5871bb4272c2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/templates/rm_model_card.md @@ -0,0 +1,55 @@ +--- +{{ card_data }} +--- + +# Model Card for {{ model_name }} + +This model is a fine-tuned version of [{{ base_model }}](https://huggingface.co/{{ base_model }}){% if dataset_name %} on the [{{ dataset_name }}](https://huggingface.co/datasets/{{ dataset_name }}) dataset{% endif %}. +It has been trained using [TRL](https://github.com/huggingface/trl). + +## Quick start + +```python +from transformers import pipeline + +text = "The capital of France is Paris." +rewarder = pipeline(model="{{ hub_model_id }}", device="cuda") +output = rewarder(text)[0] +print(output["score"]) +``` + +## Training procedure + +{% if wandb_url %}[Visualize in Weights & Biases]({{ wandb_url }}){% endif %} +{% if trackio_url %}[Visualize in Trackio]({{ trackio_url }}){% endif %} +{% if comet_url %}[Visualize in Comet]({{ comet_url }}){% endif %} + +This model was trained with {{ trainer_name }}{% if paper_id %}, a method introduced in [{{ paper_title }}](https://huggingface.co/papers/{{ paper_id }}){% endif %}. + +### Framework versions + +- TRL: {{ trl_version }} +- Transformers: {{ transformers_version }} +- Pytorch: {{ pytorch_version }} +- Datasets: {{ datasets_version }} +- Tokenizers: {{ tokenizers_version }} + +## Citations + +{% if trainer_citation %}Cite {{ trainer_name }} as: + +```bibtex +{{ trainer_citation }} +```{% endif %} + +Cite TRL as: + +```bibtex +{% raw %}@software{vonwerra2020trl, + title = {{TRL: Transformers Reinforcement Learning}}, + author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin}, + license = {Apache-2.0}, + url = {https://github.com/huggingface/trl}, + year = {2020} +}{% endraw %} +``` diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/__init__.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1d79d365056136a5940af7d23fb964fb8db0e62c --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/__init__.py @@ -0,0 +1,83 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import TYPE_CHECKING + +from .._lazy_module import _LazyModule + + +_import_structure = { + "callbacks": [ + "BEMACallback", + "LogCompletionsCallback", + "RichProgressCallback", + "SyncRefModelCallback", + "WeaveCallback", + ], + "dpo_config": ["DPOConfig"], + "dpo_trainer": ["DPOTrainer"], + "grpo_config": ["GRPOConfig"], + "grpo_trainer": ["GRPOTrainer"], + "kto_config": ["KTOConfig"], + "kto_trainer": ["KTOTrainer"], + "model_config": ["ModelConfig"], + "reward_config": ["RewardConfig"], + "reward_trainer": ["RewardTrainer"], + "rloo_config": ["RLOOConfig"], + "rloo_trainer": ["RLOOTrainer"], + "sft_config": ["SFTConfig"], + "sft_trainer": ["SFTTrainer"], + "utils": [ + "disable_dropout_in_model", + "ensure_master_addr_port", + "get_kbit_device_map", + "get_peft_config", + "get_quantization_config", + "patch_chunked_lm_head", + ], +} + +if TYPE_CHECKING: + from .callbacks import ( + BEMACallback, + LogCompletionsCallback, + RichProgressCallback, + SyncRefModelCallback, + WeaveCallback, + ) + from .dpo_config import DPOConfig + from .dpo_trainer import DPOTrainer + from .grpo_config import GRPOConfig + from .grpo_trainer import GRPOTrainer + from .kto_config import KTOConfig + from .kto_trainer import KTOTrainer + from .model_config import ModelConfig + from .reward_config import RewardConfig + from .reward_trainer import RewardTrainer + from .rloo_config import RLOOConfig + from .rloo_trainer import RLOOTrainer + from .sft_config import SFTConfig + from .sft_trainer import SFTTrainer + from .utils import ( + disable_dropout_in_model, + ensure_master_addr_port, + get_kbit_device_map, + get_peft_config, + get_quantization_config, + patch_chunked_lm_head, + ) +else: + import sys + + sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/base_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/base_config.py new file mode 100644 index 0000000000000000000000000000000000000000..fd20188c74b342974ace79b863b0566c23673ec3 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/base_config.py @@ -0,0 +1,107 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + +from transformers import TrainingArguments + + +@dataclass +class _BaseConfig(TrainingArguments): + """ + Base configuration class for all TRL trainer configurations. + + Subclasses [`~transformers.TrainingArguments`] and overrides fields that are common across TRL trainers or that + contain unescaped "%" characters which would cause argparse to raise a `TypeError` when rendering `--help` output. + + Parameters: + logging_steps (`int` or `float`, *optional*, defaults to `10`): + Number of update steps between two logs if `logging_strategy="steps"`. Should be an integer or a float in + range `[0,1)`. If smaller than 1, will be interpreted as ratio of total training steps. + gradient_checkpointing (`bool`, *optional*, defaults to `True`): + Whether to enable gradient checkpointing to trade compute for memory. Reduces memory usage by clearing + activations during forward pass and recomputing them during backward pass. Enables training larger models + or batch sizes at the cost of ~20% slower training. + bf16 (`bool`, *optional*): + Whether to use bfloat16 (BF16) mixed precision instead of 32-bit. Generally preferred over FP16 due to + better numerical stability and no loss scaling required. Requires Ampere or higher NVIDIA architecture or + Intel XPU or using CPU (use_cpu) or Ascend NPU. If not set, it defaults to `True` if `fp16` is not set. + lr_scheduler_kwargs (`dict` or `str`, *optional*): + Additional parameters for the lr_scheduler, such as `{'num_cycles': 1}` for cosine with hard restarts. See + the documentation of each scheduler for possible values. + use_liger_kernel (`bool`, *optional*, defaults to `False`): + Enable [Liger Kernel](https://github.com/linkedin/Liger-Kernel) optimizations. Increases multi-GPU + throughput by ~20% and reduces memory usage by ~60%. Works with Flash Attention, FSDP, and DeepSpeed. + Currently, supports Llama, Mistral, Mixtral, and Gemma models. + torch_empty_cache_steps (`int`, *optional*): + Number of steps to wait before calling `torch..empty_cache()`. If left unset or set to None, cache + will not be emptied. This can help avoid CUDA out-of-memory errors by lowering peak VRAM usage at a cost of + about [10% slower performance](https://github.com/huggingface/transformers/issues/31372). + """ + + # Override fields from TrainingArguments to set defaults preferred by all TRL trainers. + logging_steps: float = field( + default=10, + metadata={ + "help": "Log every X updates steps. Should be an integer or a float in range `[0,1)`. If smaller than 1, " + "will be interpreted as ratio of total training steps." + }, + ) + gradient_checkpointing: bool = field( + default=True, + metadata={ + "help": "Enable gradient checkpointing to trade compute for memory. Reduces memory at the cost of ~20%% slower training." + }, + ) + bf16: bool | None = field( + default=None, + metadata={ + "help": "Whether to use bf16 (mixed) precision instead of 32-bit. Requires Ampere or higher NVIDIA " + "architecture or Intel XPU or using CPU (use_cpu) or Ascend NPU. If not set, it defaults to `True` if " + "`fp16` is not set." + }, + ) + # Transformers 4.57.0 introduced a bug that caused the dtype of `lr_scheduler_kwargs` to be unparsable. This issue + # was fixed in https://github.com/huggingface/transformers/pull/41322 and released in 4.57.5. We add a temporary + # workaround here, which can be removed once we drop support for versions older than 4.57.5. + lr_scheduler_kwargs: dict | str | None = field( + default=None, + metadata={ + "help": "Additional parameters for the lr_scheduler, such as {'num_cycles': 1} for cosine with hard " + "restarts. See the documentation of each scheduler for possible values." + }, + ) + + # Override fields from TrainingArguments whose help strings contain unescaped "%" characters. + # argparse interprets "%" as a format specifier, raising TypeError when rendering --help output. + # Fixed upstream in transformers v5.3.0, but overridden here to support older versions. + # - Introduced in v5.2.0; fixed in v5.3.0 + use_liger_kernel: bool = field( + default=False, + metadata={ + "help": "Enable Liger Kernel optimizations. Increases throughput by ~20%% and reduces memory by ~60%%." + }, + ) + # - Introduced in v4.54.1; fixed in v5.3.0 + torch_empty_cache_steps: int | None = field( + default=None, + metadata={ + "help": "Number of steps to wait before calling `torch..empty_cache()`. Helps avoid CUDA OOM at a cost of ~10%% slower performance. If None, cache will not be emptied." + }, + ) + + def __post_init__(self): + self.bf16 = not (self.fp16) if self.bf16 is None else self.bf16 + + super().__post_init__() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/base_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/base_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..d46ba94c87c8eb11d525e327a52d0f8740217c72 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/base_trainer.py @@ -0,0 +1,96 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from transformers import Trainer, is_wandb_available + +from .utils import generate_model_card, get_comet_experiment_url, get_config_model_id, get_trackio_space_url + + +if is_wandb_available(): + import wandb + + +class _BaseTrainer(Trainer): + _tag_names = [] + _name = "Base" + _paper = {} + _template_file = None + + def create_model_card( + self, + model_name: str | None = None, + dataset_name: str | None = None, + tags: str | list[str] | None = None, + ): + """ + Creates a draft of a model card using the information available to the `Trainer`. + + Args: + model_name (`str`, *optional*): + Name of the model. + dataset_name (`str`, *optional*): + Name of the dataset used for training. + tags (`str`, `list[str]`, *optional*): + Tags to be associated with the model card. + """ + if not self.is_world_process_zero(): + return + + model_name_or_path = get_config_model_id(self.model.config) + if model_name_or_path and not os.path.isdir(model_name_or_path): + base_model = model_name_or_path + else: + base_model = None + + # Normalize tags + if tags is None: + tags = set() + elif isinstance(tags, str): + tags = {tags} + else: + tags = set(tags) + if hasattr(self.model.config, "unsloth_version"): + tags.add("unsloth") + if "JOB_ID" in os.environ: + tags.add("hf_jobs") + tags.update(self._tag_names) + + trackio_url = get_trackio_space_url() + # Pop existing Trackio tag and re-add the one with the proper url parameters + if trackio_url is not None: + for tag in list(tags): + if tag.startswith("trackio:"): + tags.remove(tag) + tags.add(f"trackio:{trackio_url}") + + tags = list(tags) + + model_card = generate_model_card( + base_model=base_model, + model_name=model_name, + hub_model_id=self.hub_model_id, + dataset_name=dataset_name, + tags=tags, + wandb_url=wandb.run.url if is_wandb_available() and wandb.run is not None else None, + trackio_url=trackio_url, + comet_url=get_comet_experiment_url(), + trainer_name=self._name, + trainer_citation=self._paper.get("citation"), + template_file=self._template_file, + paper_title=self._paper.get("title"), + paper_id=self._paper.get("id"), + ) + model_card.save(os.path.join(self.args.output_dir, "README.md")) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/callbacks.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/callbacks.py new file mode 100644 index 0000000000000000000000000000000000000000..a530e38b0c4f39f63ca16c7c8a52fa6078316b76 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/callbacks.py @@ -0,0 +1,758 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +import pandas as pd +import torch +from accelerate import Accelerator +from accelerate.state import AcceleratorState +from accelerate.utils import gather_object, is_wandb_available +from transformers import ( + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + Trainer, + TrainerCallback, + TrainerControl, + TrainerState, + TrainingArguments, +) +from transformers.trainer_utils import has_length +from transformers.utils import is_rich_available + +from ..data_utils import maybe_apply_chat_template +from ..import_utils import is_weave_available +from ..models.utils import unwrap_model_for_generation +from .utils import log_table_to_comet_experiment + + +if is_rich_available(): + from rich.columns import Columns + from rich.console import Console, Group + from rich.live import Live + from rich.panel import Panel + from rich.progress import Progress + from rich.table import Table + +if is_wandb_available(): + import wandb + +if is_weave_available(): + import weave + from weave import EvaluationLogger + from weave.trace.context import weave_client_context + + +# Logger for module-level logging +logger = logging.getLogger(__name__) + + +def _generate_completions( + prompts: list[str], + model: PreTrainedModel, + tokenizer: PreTrainedTokenizerBase, + accelerator: Accelerator, + generation_config: GenerationConfig | None, + batch_size: int = 1, +) -> list[str]: + """ + Generates completions for a list of pre-formatted prompts from the given model. + + Args: + prompts (list[str]): A list of input prompts for which completions are to be generated. + model (PreTrainedModel): The pre-trained model to be used for generation. + tokenizer (PreTrainedTokenizerBase): The tokenizer to be used for encoding and decoding. + accelerator (Accelerator): The accelerator to be used for model execution. + generation_config (GenerationConfig): Configuration for text generation. + batch_size (int, optional): The number of prompts to process in each batch. Default is 1. + + Returns: + list[str]: A list of generated text completions corresponding to the input prompts. + """ + completions = [] + # TODO: Override model.generation_config with generation_kwargs + with unwrap_model_for_generation(model, accelerator) as unwrapped_model: + for idx in range(0, len(prompts), batch_size): + batch = prompts[idx : idx + batch_size] + tokenized_batch = tokenizer(batch, return_tensors="pt", padding=True, truncation=True).to(model.device) + generations = unwrapped_model.generate( + **tokenized_batch, + generation_config=generation_config, + ) + for prompt, generation in zip(tokenized_batch.input_ids, generations, strict=True): + # Remove prompt from generation + generation = generation[len(prompt) :] + completion = tokenizer.decode(generation, skip_special_tokens=True) + completions.append(completion) + return completions + + +class SyncRefModelCallback(TrainerCallback): + """ + Callback to synchronize the model with a reference model. + """ + + def __init__( + self, + ref_model: PreTrainedModel | torch.nn.Module, + accelerator: Accelerator | None, + ): + self.accelerator = accelerator + self.ref_model = ref_model + + @staticmethod + def _sync_target_model(model, target_model, alpha): + for target_param, copy_param in zip(target_model.parameters(), model.parameters(), strict=True): + target_param.data.mul_(1.0 - alpha).add_(copy_param.data, alpha=alpha) + + @staticmethod + def sync_target_model(model, target_model, alpha): + deepspeed_plugin = AcceleratorState().deepspeed_plugin + if deepspeed_plugin is not None and deepspeed_plugin.zero_stage == 3: + import deepspeed + + with deepspeed.zero.GatheredParameters( + list(model.parameters()) + list(target_model.parameters()), modifier_rank=0 + ): + if deepspeed.comm.get_rank() == 0: + SyncRefModelCallback._sync_target_model(model, target_model, alpha) + else: + SyncRefModelCallback._sync_target_model(model, target_model, alpha) + + def on_step_end(self, args, state, control, **kwargs): + model: PreTrainedModel = kwargs["model"] + + if self.ref_model is not None and state.global_step % args.ref_model_sync_steps == 0: + if self.accelerator: + model = self.accelerator.unwrap_model(model) + self.sync_target_model(model, self.ref_model, args.ref_model_mixup_alpha) + + +class RichProgressCallback(TrainerCallback): + """ + A [`TrainerCallback`] that displays the progress of training or evaluation using Rich. + """ + + def __init__(self): + if not is_rich_available(): + raise ImportError("RichProgressCallback requires the `rich` extra. To install, run `pip install rich`.") + + self.training_bar = None + self.evaluation_bar = None + self.training_task = None + self.evaluation_task = None + self.rich_group = None + self.rich_console = None + self.training_status = None + self.current_step = None + + def on_train_begin(self, args, state, control, **kwargs): + if not state.is_world_process_zero: + return + + self.training_bar = Progress() + self.evaluation_bar = Progress() + self.rich_console = Console() + self.training_status = self.rich_console.status("Nothing to log yet ...") + self.rich_group = Live(Panel(Group(self.training_bar, self.evaluation_bar, self.training_status))) + self.rich_group.start() + self.training_task = self.training_bar.add_task("[blue]Training ", total=state.max_steps) + self.current_step = 0 + + def on_step_end(self, args, state, control, **kwargs): + if not state.is_world_process_zero: + return + + self.training_bar.update(self.training_task, advance=state.global_step - self.current_step, update=True) + self.current_step = state.global_step + + def on_prediction_step(self, args, state, control, eval_dataloader=None, **kwargs): + if not state.is_world_process_zero: + return + + if has_length(eval_dataloader): + if self.evaluation_task is None: + self.evaluation_task = self.evaluation_bar.add_task("[blue]Evaluation", total=len(eval_dataloader)) + self.evaluation_bar.update(self.evaluation_task, advance=1, update=True) + + def on_evaluate(self, args, state, control, **kwargs): + if not state.is_world_process_zero: + return + + if self.evaluation_task is not None: + self.evaluation_bar.remove_task(self.evaluation_task) + self.evaluation_task = None + + def on_predict(self, args, state, control, **kwargs): + if not state.is_world_process_zero: + return + + if self.evaluation_task is not None: + self.evaluation_bar.remove_task(self.evaluation_task) + self.evaluation_task = None + + def on_log(self, args, state, control, logs=None, **kwargs): + if not (state.is_world_process_zero and self.training_bar): + return + + # Group keys by top-level prefix + grouped_logs = {} + for key, value in logs.items(): + parts = key.split("/") + group = parts[0] if len(parts) > 1 else None + subkey = "/".join(parts[1:]) if len(parts) > 1 else key + grouped_logs.setdefault(group, {})[subkey] = value + + # Create a table per group + tables = [] + for group_name, metrics in grouped_logs.items(): + table = Table( + title=f"[bold blue]{group_name}[/]" if group_name else None, header_style="bold magenta", box=None + ) + table.add_column("Metric", justify="left", no_wrap=True) + table.add_column("Value", justify="right") + + for metric, val in metrics.items(): + formatted = f"{val:.3f}" if isinstance(val, (float, int)) else str(val) + table.add_row(metric, formatted) + + tables.append(Panel(table, border_style="cyan", padding=(0, 1))) + + # Arrange tables in columns using Columns + column_layout = Columns(tables, equal=False, expand=True) + self.training_status.update( + Panel(column_layout, title=f"[bold green]Step {state.global_step}[/bold green]", border_style="green") + ) + + def on_train_end(self, args, state, control, **kwargs): + if not state.is_world_process_zero: + return + + self.rich_group.stop() + self.training_bar = None + self.evaluation_bar = None + self.training_task = None + self.evaluation_task = None + self.rich_group = None + self.rich_console = None + self.training_status = None + self.current_step = None + + +class LogCompletionsCallback(TrainerCallback): + r""" + A [`~transformers.TrainerCallback`] that logs completions to Weights & Biases and/or Comet. + + Usage: + ```python + trainer = DPOTrainer(...) + completions_callback = LogCompletionsCallback(trainer=trainer) + trainer.add_callback(completions_callback) + ``` + + Args: + trainer (`Trainer`): + Trainer to which the callback will be attached. The trainer's evaluation dataset must include a `"prompt"` + column containing the prompts for generating completions. + generation_config ([`~transformers.GenerationConfig`], *optional*): + The generation config to use for generating completions. + num_prompts (`int`, *optional*): + The number of prompts to generate completions for. If not provided, defaults to the number of examples in + the evaluation dataset. + freq (`int`, *optional*): + The frequency at which to log completions. If not provided, defaults to the trainer's `eval_steps`. + """ + + def __init__( + self, + trainer: Trainer, + generation_config: GenerationConfig | None = None, + num_prompts: int | None = None, + freq: int | None = None, + ): + self.trainer = trainer + self.generation_config = generation_config + self.freq = freq + self.table = [] + self._last_logged_step = -1 + + if self.trainer.eval_dataset is None: + raise ValueError("Trainer must have an evaluation dataset to use the LogCompletionsCallback.") + else: + self.eval_dataset = self.trainer.eval_dataset + + if num_prompts is not None: + self.eval_dataset = self.eval_dataset.select(range(num_prompts)) + + def on_step_end(self, args, state, control, **kwargs): + # Only log once per step (this method may be called multiple times) + if state.global_step == self._last_logged_step: + return + + # Only log every `freq` steps (if no `freq` is provided, log every `eval_steps` steps) + freq = self.freq or state.eval_steps + if state.global_step % freq != 0: + return + + tokenizer = kwargs["processing_class"] + tokenizer.padding_side = "left" + accelerator = self.trainer.accelerator + model = self.trainer.model_wrapped + with accelerator.split_between_processes(self.eval_dataset["prompt"]) as prompts: + prompts = [maybe_apply_chat_template({"prompt": prompt}, tokenizer)["prompt"] for prompt in prompts] + completions = _generate_completions( + prompts, + model=model, + tokenizer=tokenizer, + accelerator=accelerator, + generation_config=self.generation_config, + batch_size=args.per_device_eval_batch_size, + ) + completions = gather_object(completions) + prompts = gather_object(prompts) + + # Build the data to log + if self.trainer.accelerator.is_main_process: + global_step = [str(state.global_step)] * len(prompts) + data = list(zip(global_step, prompts, completions, strict=True)) + self.table.extend(data) + table = pd.DataFrame(columns=["step", "prompt", "completion"], data=self.table) + + if "wandb" in args.report_to: + wandb.log({"completions": table}) + + if "comet_ml" in args.report_to: + log_table_to_comet_experiment( + name="completions.csv", + table=table, + ) + + # Save the last logged step, so we don't log the same completions multiple times + self._last_logged_step = state.global_step + + +class WeaveCallback(TrainerCallback): + r""" + A [`~transformers.TrainerCallback`] that logs traces and evaluations to W&B Weave. The callback uses + https://weave-docs.wandb.ai/guides/evaluation/evaluation_logger/ to log traces and evaluations at each evaluation + step. + + Supports two modes based on the `scorers` parameter: + - **Tracing Mode** (when scorers=None): Logs predictions for data exploration and analysis + - **Evaluation Mode** (when scorers provided): Logs predictions with scoring and summary metrics + + Both modes use Weave's EvaluationLogger for structured, consistent data logging. + + The callback logs data during evaluation phases (`on_evaluate`) rather than training steps, making it more + efficient and semantically correct. It gracefully handles missing weave installation by logging warnings and + skipping weave-specific functionality. It also checks for existing weave clients before initializing new ones. + + Usage: + ```python + # Tracing mode (just log predictions) + trainer = DPOTrainer(...) + weave_callback = WeaveTraceCallback(trainer=trainer) # project_name optional + trainer.add_callback(weave_callback) + + # Or specify a project name + weave_callback = WeaveTraceCallback(trainer=trainer, project_name="my-llm-training") + trainer.add_callback(weave_callback) + + + # Evaluation mode (log predictions + scores + summary) + def accuracy_scorer(prompt: str, completion: str) -> float: + # Your scoring logic here (metadata available via eval_attributes) + return score + + + weave_callback = WeaveTraceCallback( + trainer=trainer, + project_name="my-llm-training", # optional and needed only if weave client is not initialized + scorers={"accuracy": accuracy_scorer}, + ) + trainer.add_callback(weave_callback) + ``` + + Args: + trainer (`Trainer`): + Trainer to which the callback will be attached. The trainer's evaluation dataset must include a `"prompt"` + column containing the prompts for generating completions. + project_name (`str`, *optional*): + Name of the Weave project where data will be logged. If not provided, will try to use existing weave client + or fall back to the active wandb run's project name. Raises an error if none of these are available. + scorers (`dict[str, Callable]`, *optional*): + Dictionary mapping scorer names to scorer functions. If `None`, operates in tracing mode (predictions + only). If provided, operates in evaluation mode (predictions + scores + summary). Scorer functions should + have signature: `scorer(prompt: str, completion: str) -> float | int` + generation_config ([`~transformers.GenerationConfig`], *optional*): + Generation config to use for generating completions. + num_prompts (`int` or `None`, *optional*): + Number of prompts to generate completions for. If not provided, defaults to the number of examples in the + evaluation dataset. + dataset_name (`str`, *optional*, defaults to `"eval_dataset"`): + Name for the dataset metadata in Weave. + model_name (`str`, *optional*): + Name for the model metadata in Weave. If not provided, attempts to extract from model config. + """ + + def __init__( + self, + trainer: Trainer, + project_name: str | None = None, + scorers: dict[str, callable] | None = None, + generation_config: GenerationConfig | None = None, + num_prompts: int | None = None, + dataset_name: str = "eval_dataset", + model_name: str | None = None, + ): + self.trainer = trainer + self.project_name = project_name + self.scorers = scorers or {} + self.generation_config = generation_config + self.dataset_name = dataset_name + self.model_name = model_name + self._last_logged_step = -1 + self._weave_initialized = False + self._eval_logger = None + + if self.trainer.eval_dataset is None: + raise ValueError("Trainer must have an evaluation dataset to use the WeaveCallback.") + else: + self.eval_dataset = self.trainer.eval_dataset + + if num_prompts is not None: + self.eval_dataset = self.eval_dataset.select(range(num_prompts)) + + def _initialize_weave(self): + """Initialize Weave and EvaluationLogger if not already initialized.""" + if not self._weave_initialized: + if not is_weave_available(): + logger.warning("Weave is not available. Please install weave to enable logging: `pip install weave`") + return + + if wc := weave_client_context.get_weave_client(): + self._weave_client = wc + else: + if self.project_name is None: + if is_wandb_available(): + if wandb.run is not None: + self.project_name = wandb.run.entity + "/" + wandb.run.project + logger.info(f"Using project name from active wandb run: {self.project_name}") + + if self.project_name is None: + raise ValueError( + "No existing Weave client found and no project_name provided. " + "Please either initialize weave with `weave.init('project-name')`, " + "provide a project_name to the `WeaveTraceCallback`, " + "or ensure an active wandb run exists." + ) + + self._weave_client = weave.init(self.project_name) + logger.info(f"Initialized Weave with project: {self.project_name}") + + if self.model_name is None: + self.model_name = getattr(self.trainer.model_wrapped.config, "_name_or_path", "unknown_model") + + self._EvaluationLogger = EvaluationLogger + + self._weave_initialized = True + + @property + def is_evaluation_mode(self) -> bool: + """True if scorers are provided (evaluation mode), False for tracing mode.""" + return bool(self.scorers) + + def on_train_begin(self, args, state, control, **kwargs): + """Initialize Weave when training begins.""" + self._initialize_weave() + + def on_evaluate(self, args, state, control, **kwargs): + if state.global_step == self._last_logged_step: + return + + self._initialize_weave() + + if not self._weave_initialized: + logger.debug("Weave not initialized, skipping logging") + return + + tokenizer = kwargs["processing_class"] + tokenizer.padding_side = "left" + accelerator = self.trainer.accelerator + model = self.trainer.model_wrapped + + with accelerator.split_between_processes(self.eval_dataset["prompt"]) as prompts: + prompts = [maybe_apply_chat_template({"prompt": prompt}, tokenizer)["prompt"] for prompt in prompts] + + completions = _generate_completions( + prompts=prompts, + model=model, + tokenizer=tokenizer, + accelerator=accelerator, + generation_config=self.generation_config, + batch_size=args.per_device_eval_batch_size, + ) + + all_prompts = gather_object(prompts) + all_completions = gather_object(completions) + + if self.trainer.accelerator.is_main_process: + eval_attributes = { + "training_step": state.global_step, + "model_name": self.model_name, + "generation_config": (self.generation_config.to_dict() if self.generation_config else None), + } + + eval_logger = self._EvaluationLogger( + model=self.model_name, + dataset=self.dataset_name, + eval_attributes=eval_attributes, + ) + + successful_predictions = 0 + total_score_values = {} # For summary statistics + + for prompt, completion in zip(all_prompts, all_completions, strict=True): + try: + pred_logger = eval_logger.log_prediction(inputs={"prompt": prompt}, output=completion) + + if self.is_evaluation_mode: + for scorer_name, scorer_func in self.scorers.items(): + try: + score = scorer_func(prompt, completion) + pred_logger.log_score(scorer=scorer_name, score=score) + + if scorer_name not in total_score_values: + total_score_values[scorer_name] = [] + total_score_values[scorer_name].append(score) + + except Exception as scorer_e: + logger.warning(f"Failed to apply scorer '{scorer_name}': {scorer_e}") + + pred_logger.finish() + successful_predictions += 1 + + except Exception as pred_e: + logger.warning(f"Failed to log prediction for prompt: {pred_e}") + # Continue with other predictions even if one fails + + if self.is_evaluation_mode and total_score_values: + try: + summary_stats = { + "total_predictions": len(all_prompts), + "successful_predictions": successful_predictions, + } + + for scorer_name, scores in total_score_values.items(): + if scores: # Only if we have valid scores + summary_stats[f"avg_{scorer_name}"] = sum(scores) / len(scores) + + eval_logger.log_summary(summary_stats) + + except Exception as summary_e: + logger.warning(f"Failed to log summary: {summary_e}") + else: + try: + eval_logger.finish() + except Exception as finish_e: + logger.warning(f"Failed to finish evaluation logger: {finish_e}") + + self._last_logged_step = state.global_step + + +class BEMACallback(TrainerCallback): + # docstyle-ignore + r""" + A [`~transformers.TrainerCallback`] that implements [BEMA](https://huggingface.co/papers/2508.00180) + (Bias-Corrected Exponential Moving Average) by [Adam Block](https://huggingface.co/abblock) and [Cyril + Zhang](https://huggingface.co/cyrilzhang). Code from https://github.com/abblock/bema under MIT license. + + BEMA computes model weights that scale like: + + $$ + \theta_t' = \alpha_t \cdot (\theta_t - \theta_0) + \text{EMA}_t + $$ + + where \\( \theta_t \\) is the current model weights, \\( \theta_0 \\) is a snapshot of the model weights at the + first `update_after` step, \\( \text{EMA}_t \\) is the exponential moving average of the model weights, and + \\( \alpha_t \\) is a scaling factor that decays with the number of steps \\( t \\) as + + $$ + \alpha_t = (\rho + \gamma \cdot t)^{-\eta}. + $$ + + The EMA is computed as: + + $$ + \text{EMA}_t = (1 - \beta_t) \cdot \text{EMA}_{t-1} + \beta_t \cdot \theta_t + $$ + + where \\( \beta_t \\) is a decay factor that decays with the number of steps \\( t \\) as + + $$ + \beta_t = (\rho + \gamma \cdot t)^{-\kappa}. + $$ + + Args: + update_freq (`int`, *optional*, defaults to `400`): + Update the BEMA weights every X steps. Denoted this as \\( \phi \\) in the paper. + ema_power (`float`, *optional*, defaults to `0.5`): + Power for the EMA decay factor. Denoted \\( \kappa \\) in the paper. To disable EMA, set this to `0.0`. + bias_power (`float`, *optional*, defaults to `0.2`): + Power for the BEMA scaling factor. Denoted \\( \eta \\) in the paper. To disable BEMA, set this to `0.0`. + lag (`int`, *optional*, defaults to `10`): + Initial offset in the weight decay schedule that controls early-stage smoothness by acting as a virtual + starting age for the updates. Denoted as \\( \rho \\) in the paper. + update_after (`int`, *optional*, defaults to `0`): + Burn-in time before starting to update the BEMA weights. Denoted \\( \tau \\) in the paper. + multiplier (`float`, *optional*, defaults to `1.0`): + Initial value for the EMA decay factor. Denoted as \\( \gamma \\) in the paper. + min_ema_multiplier (`float`, *optional*, defaults to `0.0`): + Minimum value for the EMA decay factor. + device (`str`, *optional*, defaults to `"cpu"`): + Device to use for the BEMA buffers, e.g. `"cpu"` or `"cuda"`. Note that in most cases, this device SHOULD + BE DIFFERENT from the device used for training in order to avoid OOM. + + Example: + + ```python + from trl import BEMACallback + + trainer = Trainer(..., callbacks=[BEMACallback()]) + ``` + """ + + def __init__( + self, + update_freq: int = 400, + ema_power: float = 0.5, + bias_power: float = 0.2, + lag: int = 10, + update_after: int = 0, + multiplier: float = 1.0, + min_ema_multiplier: float = 0.0, + device: str = "cpu", + ): + # User-provided hyperparams + self.update_freq = update_freq + self.ema_power = ema_power + self.bias_power = bias_power + self.lag = lag + self.update_after = update_after + self.multiplier = multiplier + self.min_ema_multiplier = min_ema_multiplier + self.device = device + + # Internal state + self.param_names = [] # references to training model param names + self.thetat_params = [] # references to training model params + self.theta0_params = [] # θ₀ buffers (on self.device) + self.ema_params = [] # EMA buffers (on self.device) + self.running_model = None # a copy of the model to run BEMA on + + @staticmethod + def _unwrap_model(model): + """ + Helper function to unwrap model from various wrappers including DataParallel, DistributedDataParallel, + DeepSpeed, and FSDP. + """ + # Handle DeepSpeed + if hasattr(model, "module") and hasattr(model, "engine"): + # DeepSpeed engine + return model.module + + # Handle FSDP + if hasattr(model, "_fsdp_wrapped_module"): + # FSDP wrapped model + return model._fsdp_wrapped_module + + # Handle DataParallel/DistributedDataParallel + if hasattr(model, "module"): + return model.module + + return model + + @torch.no_grad() + def on_train_begin( + self, args: TrainingArguments, state: TrainerState, control: TrainerControl, model: PreTrainedModel, **kwargs + ): + model = self._unwrap_model(model) + + # Create a new instance and load state_dict + self.running_model = type(model)(model.config).to(self.device) + self.running_model.load_state_dict(model.state_dict()) + + # Cache trainable parameters once in a fixed order + for name, param in model.named_parameters(): + if not param.requires_grad: + continue + self.param_names.append(name) + self.thetat_params.append(param) + + # Clone θ₀ and EMA on the same device as model + theta0 = param.detach().clone().to(self.device) + self.theta0_params.append(theta0) + self.ema_params.append(theta0.clone()) # initialize EMA with θ₀ + + def _ema_beta(self, step: int) -> float: + """Compute the EMA decay factor βₜ = (ρ + γ·t)⁻ᵏᵃᵖᵖᵃ.""" + beta = (self.lag + self.multiplier * step) ** (-self.ema_power) + return max(beta, self.min_ema_multiplier) + + def _bema_alpha(self, step: int) -> float: + """Compute the BEMA scaling factor αₜ = (ρ + γ·t)⁻ᵉᵗᵃ.""" + return (self.lag + self.multiplier * step) ** (-self.bias_power) + + def _update_bema_weights(self, step: int): + beta = self._ema_beta(step) + alpha = self._bema_alpha(step) + + # Compute EMA + BEMA in-place and write directly to running_model + for thetat, theta0, ema, run_param in zip( + self.thetat_params, self.theta0_params, self.ema_params, self.running_model.parameters(), strict=True + ): + thetat = thetat.detach().to(self.device) + ema.mul_(1 - beta).add_(thetat, alpha=beta) # EMA update: ema = (1 - beta) * ema + beta * θₜ + run_param.copy_(ema + alpha * (thetat - theta0)) # BEMA update: run_param = ema + alpha * (θₜ - θ₀) + + @torch.no_grad() + def on_step_end( + self, args: TrainingArguments, state: TrainerState, control: TrainerControl, model: PreTrainedModel, **kwargs + ): + step = state.global_step + + # If we haven't reached the update_after step, skip the BEMA update + if step < self.update_after: + return + + # Snapshot θ₀ and EMA at first update + if step == self.update_after: + for thetat_param, theta0_param, ema_param in zip( + self.thetat_params, self.theta0_params, self.ema_params, strict=True + ): + theta0_param.copy_(thetat_param) + ema_param.copy_(thetat_param) + + # Update BEMA weights every `update_freq` steps + elif (step - self.update_after) % self.update_freq == 0: + self._update_bema_weights(step) + logger.info(f"Updated BEMA weights at step {step}") + + @torch.no_grad() + def on_train_end(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs): + if state.is_world_process_zero: + save_directory = f"{args.output_dir}/bema" + self.running_model.save_pretrained(save_directory) + logger.info(f"Saved BEMA model to {save_directory}") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/dpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/dpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..979747dd07458da2eeb6ce5394946a30ea6b90f0 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/dpo_config.py @@ -0,0 +1,343 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from .base_config import _BaseConfig + + +@dataclass +class DPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`DPOTrainer`]. + + This class includes only the parameters that are specific to DPO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`DPOTrainer`] is provided as a string. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model and reference model. + + > Parameters that control the data preprocessing + + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from the left or + right depending on the `truncation_mode`. If `None`, no truncation is applied. + truncation_mode (`str`, *optional*, defaults to `"keep_start"`): + Truncation mode to use when the sequence exceeds `max_length`. The only supported value is + `"keep_start"`. The `"keep_end"` value is deprecated and will be removed in v2.0.0. + padding_free (`bool`, *optional*, defaults to `False`): + Whether to perform forward passes without padding by flattening all sequences in the batch into a single + continuous sequence. This reduces memory usage by eliminating padding overhead. Currently, this is only + supported with the FlashAttention 2 or 3, which can efficiently handle the flattened batch structure. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + precompute_ref_log_probs (`bool`, *optional*, defaults to `False`): + Whether to precompute the reference model log probabilities for the entire training dataset before + training. This allows to save memory during training, as the reference model does not need to be kept in + memory. + precompute_ref_batch_size (`int`, *optional*): + Batch size to use when precomputing reference model log probabilities. This can be set higher than the + training batch size to speed up preprocessing. If `None`, defaults to `per_device_train_batch_size` for + training and `per_device_eval_batch_size` for evaluation. + + > Parameters that control the training + + loss_type (`list[str]`, *optional*, defaults to `["sigmoid"]`): + Type of loss to use. Possible values are: `'sigmoid'`, `'hinge'`, `'ipo'`, `'exo_pair'`, `'nca_pair'`, + `'robust'`, `'bco_pair'`, `'sppo_hard'`, `'aot'`, `'aot_unpaired'`, `'apo_zero'`, `'apo_down'`, + `'discopop'`, `'sft'`. If multiple loss types are provided, they will be combined using the weights + specified in `loss_weights`. + loss_weights (`list[float]`, *optional*): + List of loss weights for multi-loss combinations. Used when combining multiple loss types. Example: `[0.8, + 0.2, 1.0]` for MPO. If not provided, defaults to equal weights (`1.0`) for all loss types. + ld_alpha (`float`, *optional*): + α parameter from the LD-DPO paper, which controls the weighting of the verbose token log-probabilities in + responses. If `None`, no weighting is applied to the verbose part, and the loss is equivalent to the + standard DPO loss. Must be in [0.0, 1.0]: `ld_alpha=1.0` applies no weighting, and `ld_alpha=0.0` masks + tokens beyond shared lengths. + f_divergence_type (`str`, *optional*, defaults to `"reverse_kl"`): + f-divergence regularizer between policy and reference (f-DPO paper). Possible values are: `reverse_kl` + (default), `forward_kl`, `js_divergence`, `alpha_divergence`. + f_alpha_divergence_coef (`float`, *optional*, defaults to `0.5`): + α coefficient for the α-divergence u^-α regularizer, used only when `f_divergence_type='alpha_divergence'`. + label_smoothing (`float`, *optional*, defaults to `0.0`): + Label smoothing parameter used in Robust DPO and EXO. In Robust DPO, it is interpreted as the probability + that a preference label is flipped and must lie in [0.0, 0.5); a typical value recommended by the Robust + DPO paper is 0.1. In EXO, it corresponds to the ε label smoothing parameter, for which the paper recommends + a typical value of 1e-3. + beta (`float`, *optional*, defaults to `0.1`): + Parameter controlling the deviation from the reference model. Higher β means less deviation from the + reference model. For the IPO loss (`loss_type='ipo'`), this value is the regularization parameter denoted + by τ in the [paper](https://huggingface.co/papers/2310.12036). + use_weighting (`bool`, *optional*, defaults to `False`): + Whether to apply WPO-style weighting (https://huggingface.co/papers/2406.11827) to preference pairs using + the policy's length-normalized sequence probabilities. + discopop_tau (`float`, *optional*, defaults to `0.05`): + τ/temperature parameter from the DiscoPOP paper, which controls the shape of the log-ratio modulated loss + when using `loss_type='discopop'`. The paper recommends the default value `discopop_tau=0.05`. + activation_offloading (`bool`, *optional*, defaults to `False`): + Whether to offload the activations to the CPU. + sync_ref_model (`bool`, *optional*, defaults to `False`): + Whether to synchronize the reference model with the active model every `ref_model_sync_steps` steps, using + the `ref_model_mixup_alpha` parameter. This synchronization originates from the + [TR-DPO](https://huggingface.co/papers/2404.09656) paper. `sync_ref_model=True` is not yet compatible with + PEFT or `precompute_ref_log_probs=True`. + ref_model_mixup_alpha (`float`, *optional*, defaults to `0.6`): + α parameter from the TR-DPO paper, which controls the mix between the current policy and the previous + reference policy during updates. The reference policy is updated according to the equation: `π_ref = α * + π_θ + (1 - α) * π_ref_prev`. To use this parameter, you must set `sync_ref_model=True`. + ref_model_sync_steps (`int`, *optional*, defaults to `512`): + τ parameter from the TR-DPO paper, which determines how frequently the current policy is synchronized with + the reference policy. To use this parameter, you must set `sync_ref_model=True`. + + > Deprecated parameters + + pad_token: + + + + Parameter `pad_token` is deprecated and will be removed in version v2.0.0. Set `tokenizer.pad_token` + directly and pass it as `processing_class` to the trainer instead. + + + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument of " + "the `DPOTrainer` is provided as a string." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model and reference model."}, + ) + + # Parameters that control the data preprocessing + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + max_length: int | None = field( + default=1024, + metadata={ + "help": "Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from " + "the left or right depending on the `truncation_mode`. If `None`, no truncation is applied." + }, + ) + truncation_mode: str = field( + default="keep_start", + metadata={ + "help": "Truncation mode to use when the sequence exceeds `max_length`. The only supported value is " + "`'keep_start'`. The `'keep_end'` value is deprecated and will be removed in v2.0.0.", + "choices": ["keep_end", "keep_start"], + }, + ) + padding_free: bool = field( + default=False, + metadata={ + "help": "Whether to perform forward passes without padding by flattening all sequences in the batch into " + "a single continuous sequence. This reduces memory usage by eliminating padding overhead. Currently, this " + "is only supported with the FlashAttention 2 or 3, which can efficiently handle the flattened batch " + "structure." + }, + ) + pad_to_multiple_of: int | None = field( + default=None, + metadata={"help": "If set, the sequences will be padded to a multiple of this value."}, + ) + precompute_ref_log_probs: bool = field( + default=False, + metadata={ + "help": "Whether to precompute the reference model log probabilities for the entire training dataset " + "before training. This allows to save memory during training, as the reference model does not need to be " + "kept in memory." + }, + ) + precompute_ref_batch_size: int | None = field( + default=None, + metadata={ + "help": "Batch size to use when precomputing reference model log probabilities. This can be set higher " + "than the training batch size to speed up preprocessing. If `None`, defaults to " + "`per_device_train_batch_size` for training and `per_device_eval_batch_size` for evaluation." + }, + ) + + # Parameters that control the training + loss_type: list[str] = field( + default_factory=lambda: ["sigmoid"], + metadata={ + "help": "Type of loss to use. Possible values are: `'sigmoid'`, `'hinge'`, `'ipo'`, `'exo_pair'`, " + "`'nca_pair'`, `'robust'`, `'bco_pair'`, `'sppo_hard'`, `'aot'`, `'aot_unpaired'`, `'apo_zero'`, " + "`'apo_down'`, `'discopop'`, `'sft'`. If multiple loss types are provided, they will be combined using " + "the weights specified in `loss_weights`.", + }, + ) + loss_weights: list[float] | None = field( + default=None, + metadata={ + "help": "List of loss weights for multi-loss combinations. Used when combining multiple loss types. " + "Example: `[0.8, 0.2, 1.0]` for MPO. If not provided, defaults to equal weights (`1.0`) for all loss " + "types." + }, + ) + ld_alpha: float | None = field( + default=None, + metadata={ + "help": "α parameter from the LD-DPO paper, which controls the weighting of the verbose token " + "log-probabilities in responses. If `None`, no weighting is applied to the verbose part, and the loss is " + "equivalent to the standard DPO loss. Must be in [0.0, 1.0]: `ld_alpha=1.0` applies no weighting, and " + "`ld_alpha=0.0` masks tokens beyond shared lengths.", + }, + ) + f_divergence_type: str = field( + default="reverse_kl", + metadata={ + "help": "f-divergence regularizer between policy and reference (f-DPO paper). Possible values are: " + "`reverse_kl` (default), `forward_kl`, `js_divergence`, `alpha_divergence`.", + }, + ) + f_alpha_divergence_coef: float = field( + default=0.5, + metadata={ + "help": "α coefficient for the α-divergence u^-α regularizer, used only when " + "`f_divergence_type='alpha_divergence'`." + }, + ) + label_smoothing: float = field( + default=0.0, + metadata={ + "help": "Label smoothing parameter used in Robust DPO and EXO. In Robust DPO, it is interpreted as the " + "probability that a preference label is flipped and must lie in [0.0, 0.5); a typical value recommended " + "by the Robust DPO paper is 0.1. In EXO, it corresponds to the ε label smoothing parameter, for which the " + "paper recommends a typical value of 1e-3." + }, + ) + beta: float = field( + default=0.1, + metadata={ + "help": "Parameter controlling the deviation from the reference model. Higher β means less deviation from " + "the reference model. For the IPO loss (`loss_type='ipo'`), this value is the regularization parameter " + "denoted by τ in the [paper](https://huggingface.co/papers/2310.12036)." + }, + ) + use_weighting: bool = field( + default=False, + metadata={ + "help": "Whether to apply WPO-style weighting (https://huggingface.co/papers/2406.11827) to preference " + "pairs using the policy's length-normalized sequence probabilities." + }, + ) + discopop_tau: float = field( + default=0.05, + metadata={ + "help": "τ/temperature parameter from the DiscoPOP paper, which controls the shape of the log-ratio " + "modulated loss when using `loss_type='discopop'`. The paper recommends the default value " + "`discopop_tau=0.05`." + }, + ) + activation_offloading: bool = field( + default=False, + metadata={"help": "Whether to offload the activations to the CPU."}, + ) + sync_ref_model: bool = field( + default=False, + metadata={ + "help": "Whether to synchronize the reference model with the active model every `ref_model_sync_steps` " + "steps, using the `ref_model_mixup_alpha` parameter. This synchronization originates from the " + "[TR-DPO](https://huggingface.co/papers/2404.09656) paper. `sync_ref_model=True` is not yet compatible " + "with PEFT or `precompute_ref_log_probs=True`." + }, + ) + ref_model_mixup_alpha: float = field( + default=0.6, + metadata={ + "help": "α parameter from the TR-DPO paper, which controls the mix between the current policy and the " + "previous reference policy during updates. The reference policy is updated according to the equation: " + "`π_ref = α * π_θ + (1 - α) * π_ref_prev`. To use this parameter, you must set `sync_ref_model=True`." + }, + ) + ref_model_sync_steps: int = field( + default=512, + metadata={ + "help": "τ parameter from the TR-DPO paper, which determines how frequently the current policy is " + "synchronized with the reference policy. To use this parameter, you must set `sync_ref_model=True`." + }, + ) + + # Deprecated parameters + pad_token: str | None = field( + default=None, + metadata={ + "help": "Deprecated. Set `tokenizer.pad_token` directly and pass it as `processing_class` to the trainer instead." + }, + ) + + def __post_init__(self): + if isinstance(self.loss_type, str): + self.loss_type = [self.loss_type] + if self.loss_weights is not None and len(self.loss_weights) != len(self.loss_type): + raise ValueError( + "`loss_weights` must have the same length as `loss_type` when combining multiple losses. " + f"Got {len(self.loss_weights)} weights for {len(self.loss_type)} loss types." + ) + if self.pad_token is not None: + warnings.warn( + "`pad_token` is deprecated and will be removed in v2.0.0. " + "Set `tokenizer.pad_token` directly and pass it as `processing_class` to the trainer instead.", + FutureWarning, + stacklevel=3, + ) + if self.truncation_mode == "keep_end": + warnings.warn( + "The `'keep_end'` truncation mode is deprecated and will be removed in v2.0.0. " + "Use `truncation_mode='keep_start'` (the default) instead.", + FutureWarning, + stacklevel=3, + ) + + super().__post_init__() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/dpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/dpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..11c265aefd769a8465f7982bf90d0835d407b8ca --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/dpo_trainer.py @@ -0,0 +1,1498 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import contextlib +import json +import os +import textwrap +from collections import defaultdict +from collections.abc import Callable +from dataclasses import dataclass +from pathlib import Path +from typing import Any + +import numpy as np +import torch +import torch.nn.functional as F +import transformers +from accelerate import PartialState +from accelerate.logging import get_logger +from accelerate.utils import is_peft_model, tqdm +from datasets import Dataset, IterableDataset, IterableDatasetDict +from datasets.fingerprint import Hasher +from packaging.version import Version +from torch.utils.data import DataLoader +from transformers import ( + AutoProcessor, + DataCollator, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, +) +from transformers.data.data_collator import DataCollatorMixin +from transformers.trainer_callback import TrainerCallback +from transformers.trainer_utils import EvalPrediction +from transformers.utils import is_liger_kernel_available, is_peft_available + +from ..data_utils import apply_chat_template, extract_prompt, is_conversational, prepare_multimodal_messages +from ..models import get_act_offloading_ctx_manager, prepare_deepspeed, prepare_fsdp +from ..models.utils import disable_gradient_checkpointing +from .base_trainer import _BaseTrainer +from .callbacks import SyncRefModelCallback +from .dpo_config import DPOConfig +from .utils import ( + create_model_from_path, + disable_dropout_in_model, + entropy_from_logits, + flush_left, + get_config_model_id, + hash_module, + pad, + selective_log_softmax, + use_adapter, +) + + +if is_peft_available(): + from peft import PeftConfig, PeftModel, get_peft_model + + +if is_liger_kernel_available(): + from liger_kernel.chunked_loss import LigerFusedLinearDPOLoss + + +logger = get_logger(__name__) + + +FLASH_ATTENTION_VARIANTS = { + "flash_attention_2", + "flash_attention_3", + "kernels-community/flash-attn2", + "kernels-community/flash-attn3", + "kernels-community/vllm-flash-attn3", +} + + +def get_dataset_column_names(dataset: Dataset | IterableDataset) -> list[str]: + return list(next(iter(dataset)).keys()) if dataset.column_names is None else dataset.column_names + + +@dataclass +class DataCollatorForPreference(DataCollatorMixin): + """ + Data collator used for preference data. Inputs are dynamically padded to the maximum length of a batch. + + This collator expects each example in the input list to be a dictionary containing the keys `"prompt_ids"`, + `"chosen_ids"` and `"rejected_ids"`. The collator returns a dictionary containing the following keys: + - `"input_ids"`: Tensor of input IDs, padded to the maximum length of the batch. The first half of the batch + corresponds to the `"chosen_ids"` and the second half to the `"rejected_ids"`. + - `"attention_mask"`: Tensor of attention mask, padded to the maximum length of the batch. + - `"completion_mask"`: Tensor indicating the positions of the completion tokens, padded to the maximum length of + the batch. + + Optionally, the examples can contain a `"ref_chosen_logps"` and `"ref_rejected_logps"` keys, in which case the + returned dictionary will also contain these keys with the corresponding tensors. + + Args: + pad_token_id (`int`): + Token ID to use for padding. + max_length (`int`, *optional*): + Maximum length of the sequences after concatenation. Sequences longer than `max_length` are truncated + before padding, which avoids allocating oversized tensors for batches containing very long sequences. + truncation_mode (`str`, *optional*, defaults to `"keep_start"`): + Truncation mode when a concatenated sequence exceeds `max_length`. Possible values are `"keep_end"` and + `"keep_start"`. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + return_tensors (`str`, *optional*, defaults to `"pt"`): + Type of Tensor to return. Only `"pt"` is currently supported. + + Examples: + ```python + >>> from trl.trainer.dpo_trainer import DataCollatorForPreference + + >>> collator = DataCollatorForPreference(pad_token_id=0) + >>> examples = [ + ... {"prompt_ids": [1, 2, 3], "chosen_ids": [4, 5], "rejected_ids": [6]}, + ... {"prompt_ids": [7, 8], "chosen_ids": [9], "rejected_ids": [10, 11]}, + ... ] + >>> collator(examples) + {'input_ids': tensor([[ 1, 2, 3, 4, 5], + [ 7, 8, 9, 0, 0], + [ 1, 2, 3, 6, 0], + [ 7, 8, 10, 11, 0]]), + 'attention_mask': tensor([[1, 1, 1, 1, 1], + [1, 1, 1, 0, 0], + [1, 1, 1, 1, 0], + [1, 1, 1, 1, 0]]), + 'completion_mask': tensor([[0, 0, 0, 1, 1], + [0, 0, 1, 0, 0], + [0, 0, 0, 1, 0], + [0, 0, 1, 1, 0]])} + ``` + """ + + pad_token_id: int + max_length: int | None = None + truncation_mode: str = "keep_start" + pad_to_multiple_of: int | None = None + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + prompt_chosen_ids = [example["prompt_ids"] + example["chosen_ids"] for example in examples] + prompt_rejected_ids = [example["prompt_ids"] + example["rejected_ids"] for example in examples] + chosen_mask = [[0] * len(example["prompt_ids"]) + [1] * len(example["chosen_ids"]) for example in examples] + rejected_mask = [[0] * len(example["prompt_ids"]) + [1] * len(example["rejected_ids"]) for example in examples] + + if self.max_length is not None: + if self.truncation_mode == "keep_start": + sl = slice(None, self.max_length) + elif self.truncation_mode == "keep_end": + sl = slice(-self.max_length, None) + else: + raise ValueError( + f"Unsupported truncation mode: {self.truncation_mode}, expected 'keep_start' or 'keep_end'" + ) + prompt_chosen_ids = [ids[sl] for ids in prompt_chosen_ids] + prompt_rejected_ids = [ids[sl] for ids in prompt_rejected_ids] + chosen_mask = [m[sl] for m in chosen_mask] + rejected_mask = [m[sl] for m in rejected_mask] + + chosen_attention_mask = [[1] * len(ids) for ids in prompt_chosen_ids] + rejected_attention_mask = [[1] * len(ids) for ids in prompt_rejected_ids] + input_ids = prompt_chosen_ids + prompt_rejected_ids + attention_mask = chosen_attention_mask + rejected_attention_mask + completion_mask = chosen_mask + rejected_mask + + # Convert to tensor + input_ids = [torch.tensor(ids) for ids in input_ids] + attention_mask = [torch.tensor(m, dtype=torch.long) for m in attention_mask] + completion_mask = [torch.tensor(m, dtype=torch.long) for m in completion_mask] + if "ref_chosen_logps" in examples[0]: + ref_chosen_logps = torch.tensor([example["ref_chosen_logps"] for example in examples]) + if "ref_rejected_logps" in examples[0]: + ref_rejected_logps = torch.tensor([example["ref_rejected_logps"] for example in examples]) + + # Pad + output = {} + output["input_ids"] = pad( + input_ids, + padding_value=self.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + output["attention_mask"] = pad( + attention_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + output["completion_mask"] = pad( + completion_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + if "ref_chosen_logps" in examples[0]: + output["ref_chosen_logps"] = ref_chosen_logps + if "ref_rejected_logps" in examples[0]: + output["ref_rejected_logps"] = ref_rejected_logps + return output + + +@dataclass +class DataCollatorForVisionPreference(DataCollatorMixin): + """ + Data collator for vision-preference tasks. + + Unlike text-only datasets, where the collator typically receives pre-tokenized inputs ready for batching, + vision-language data processing involves converting images into pixel values. This conversion is disk-intensive, + making upfront preprocessing of the entire dataset impractical. Therefore, this collator performs tokenization and + image processing on-the-fly to efficiently prepare batches. + + Each input example should be a dictionary containing at least: + - An `"images"` key holding a list of images, or an `"image"` key holding a single image. + - Keys `"prompt"` `"chosen"` and `"rejected"` for the prompt and preference responses. + + The collator outputs a dictionary including: + - `"input_ids"`: Tensor of token IDs. + - `"attention_mask"`: Tensor indicating attention mask. + - `"completion_mask"`: Tensor indicating which tokens correspond to completions. + - `"pixel_values"`: Tensor representing image pixel values. + + Additional keys may be present depending on the processor, such as `"image_grid_thw"` or `"image_position_ids"`. + + Args: + processor ([`~transformers.ProcessorMixin`]): + The processor used to tokenize text and process images. It must be a subclass of + [`~transformers.ProcessorMixin`] and include a `tokenizer` with a defined `pad_token_id`. + max_length (`int`, *optional*): + Maximum sequence length. Sequences longer than `max_length` are truncated before padding, which avoids + allocating oversized tensors for batches containing very long sequences. Only `"keep_start"` truncation + applies to vision datasets; `"keep_end"` is rejected upstream. + pad_to_multiple_of (`int` or `None`, optional, defaults to `None`): + If set, the sequences will be padded to a multiple of this value. + return_tensors (`str`, optional, defaults to `"pt"`): + The tensor type to return. Currently, only `"pt"` (PyTorch tensors) is supported. + + Example: + ```python + >>> from trl.trainer.dpo_trainer import DataCollatorForVisionPreference + >>> from transformers import AutoProcessor + + >>> processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct") + >>> collator = DataCollatorForVisionPreference(processor) + >>> examples = [ + ... { + ... "images": [Image.open("image_0.png")], + ... "prompt": [{"role": "user", "content": "What is this?"}], + ... "chosen": [{"role": "assistant", "content": "This is a cat."}], + ... "rejected": [{"role": "assistant", "content": "This is a dog."}], + ... }, + ... { + ... "images": [Image.open("image_1.png")], + ... "prompt": [{"role": "user", "content": "Describe this image."}], + ... "chosen": [{"role": "assistant", "content": "A beautiful landscape."}], + ... "rejected": [{"role": "assistant", "content": "An urban cityscape."}], + ... }, + ... ] + >>> collator(examples) + {'input_ids': tensor([[151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 3838, 374, 419, 30, 151645, 198, 151644, 77091, 198, 1986, 374, 264, 8251, 13, 151645, 198], + [151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 74785, 419, 2168, 13, 151645, 198, 151644, 77091, 198, 32, 6233, 18414, 13, 151645, 198, 151643], + [151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 3838, 374, 419, 30, 151645, 198, 151644, 77091, 198, 1986, 374, 264, 5562, 13, 151645, 198], + [151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 74785, 419, 2168, 13, 151645, 198, 151644, 77091, 198, 2082, 15662, 3283, 57518, 13, 151645, 198]]), + 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]), + 'pixel_values': tensor([[-1.3251, 0.1347, -0.4784, ..., 0.4537, -0.0156, 1.2358], + [ 0.5727, 0.4997, -0.9164, ..., -0.5701, 0.7950, -0.7123], + [-0.0550, -0.8288, 1.0690, ..., -0.1293, -0.1151, 1.6055], + ..., + [ 0.2953, 0.5581, 0.1785, ..., -0.7123, -0.7977, 0.1693], + [-0.7558, 1.0398, 1.3464, ..., -0.5417, -0.5417, 0.4395], + [ 0.8063, 0.6895, 0.4267, ..., -0.4422, 1.3354, 0.1266]]), + 'image_grid_thw': tensor([[1, 4, 4], + [1, 4, 4], + [1, 4, 4], + [1, 4, 4]]), + 'completion_mask': tensor([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]])} + ``` + """ + + processor: ProcessorMixin + max_length: int | None = None + pad_to_multiple_of: int | None = None + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + if self.pad_to_multiple_of is not None: + raise NotImplementedError( + "Padding to a multiple of a value is not yet implemented for vision-language modeling and " + "prompt-completion data." + ) + if "image" in examples[0]: + for example in examples: + example["images"] = [example.pop("image")] + images = [example["images"] for example in examples] * 2 # repeat for chosen and rejected + # Transformers requires at least one image in the batch, otherwise it throws an error + if all(img_list == [] for img_list in images): + images = None + if is_conversational(examples[0]): # conversational case + for example in examples: + example["prompt"] = prepare_multimodal_messages(example["prompt"], images=example["images"]) + example["chosen"] = prepare_multimodal_messages(example["chosen"]) + example["rejected"] = prepare_multimodal_messages(example["rejected"]) + examples = [apply_chat_template(example, self.processor) for example in examples] + + prompts = [example["prompt"] for example in examples] * 2 # repeat for chosen and rejected + chosens = [example["chosen"] for example in examples] + rejecteds = [example["rejected"] for example in examples] + + processed_prompts = self.processor( + images=images, + text=prompts, + padding=True, + padding_side="left", + return_tensors=self.return_tensors, + add_special_tokens=False, # to avoid adding the BOS, twice see https://huggingface.co/blog/qgallouedec/gotchas-in-tokenizer-behavior#7-chat-template-and-tokenization-dont-compose-due-to-special-tokens + ) + processed_chosens = self.processor( + text=chosens, + padding=True, + padding_side="right", + return_tensors=self.return_tensors, + add_special_tokens=False, # to avoid adding the BOS, twice see https://huggingface.co/blog/qgallouedec/gotchas-in-tokenizer-behavior#7-chat-template-and-tokenization-dont-compose-due-to-special-tokens + ) + processed_rejecteds = self.processor( + text=rejecteds, + padding=True, + padding_side="right", + return_tensors=self.return_tensors, + add_special_tokens=False, # to avoid adding the BOS, twice see https://huggingface.co/blog/qgallouedec/gotchas-in-tokenizer-behavior#7-chat-template-and-tokenization-dont-compose-due-to-special-tokens + ) + + # Concatenate prompts and completions + prompt_ids, prompt_mask = processed_prompts["input_ids"], processed_prompts["attention_mask"] + chosen_ids, chosen_mask = processed_chosens["input_ids"], processed_chosens["attention_mask"] + rejected_ids, rejected_mask = processed_rejecteds["input_ids"], processed_rejecteds["attention_mask"] + pad_token_id = self.processor.tokenizer.pad_token_id or self.processor.tokenizer.eos_token_id + completion_ids = torch.cat(tuple(pad([chosen_ids, rejected_ids], padding_value=pad_token_id))) + completion_mask = torch.cat(tuple(pad([chosen_mask, rejected_mask], padding_value=0))) + input_ids = torch.cat((prompt_ids, completion_ids), dim=1) + attention_mask = torch.cat((prompt_mask, completion_mask), dim=1) + completion_mask = torch.cat((torch.zeros_like(prompt_mask), completion_mask), dim=1) + if "token_type_ids" in processed_prompts: # special case for Gemma + prompt_token_type_ids = processed_prompts["token_type_ids"] + chosen_type_ids = processed_chosens["token_type_ids"] + rejected_type_ids = processed_rejecteds["token_type_ids"] + completion_token_type_ids = torch.cat(tuple(pad([chosen_type_ids, rejected_type_ids], padding_value=0))) + token_type_ids = torch.cat((prompt_token_type_ids, completion_token_type_ids), dim=1) + if "mm_token_type_ids" in processed_prompts: # special case for Qwen2.5-VL + prompt_mm_token_type_ids = processed_prompts["mm_token_type_ids"] + mm_token_type_ids = torch.cat((prompt_mm_token_type_ids, torch.zeros_like(completion_ids)), dim=1) + + # Flush left to reduce padding + if "token_type_ids" in processed_prompts and "mm_token_type_ids" in processed_prompts: + attention_mask, input_ids, completion_mask, token_type_ids, mm_token_type_ids = flush_left( + attention_mask, input_ids, completion_mask, token_type_ids, mm_token_type_ids + ) + elif "token_type_ids" in processed_prompts: + attention_mask, input_ids, completion_mask, token_type_ids = flush_left( + attention_mask, input_ids, completion_mask, token_type_ids + ) + elif "mm_token_type_ids" in processed_prompts: + attention_mask, input_ids, completion_mask, mm_token_type_ids = flush_left( + attention_mask, input_ids, completion_mask, mm_token_type_ids + ) + else: + attention_mask, input_ids, completion_mask = flush_left(attention_mask, input_ids, completion_mask) + + if self.max_length is not None: + input_ids = input_ids[:, : self.max_length] + attention_mask = attention_mask[:, : self.max_length] + completion_mask = completion_mask[:, : self.max_length] + if "token_type_ids" in processed_prompts: + token_type_ids = token_type_ids[:, : self.max_length] + if "mm_token_type_ids" in processed_prompts: + mm_token_type_ids = mm_token_type_ids[:, : self.max_length] + + # Build the output dictionary + output = processed_prompts # we take processed_prompts because it contains the images + output["input_ids"] = input_ids + output["attention_mask"] = attention_mask + output["completion_mask"] = completion_mask + if "token_type_ids" in processed_prompts: + output["token_type_ids"] = token_type_ids + if "mm_token_type_ids" in processed_prompts: + output["mm_token_type_ids"] = mm_token_type_ids + return output + + +class DPOTrainer(_BaseTrainer): + """ + Trainer for Direct Preference Optimization (DPO) method. This algorithm was initially proposed in the paper [Direct + Preference Optimization: Your Language Model is Secretly a Reward Model](https://huggingface.co/papers/2305.18290). + This class is a wrapper around the [`~transformers.Trainer`] class and inherits all of its attributes and methods. + + Example: + + ```python + from trl import DPOTrainer + from datasets import load_dataset + + dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train") + + trainer = DPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + ref_model ([`~transformers.PreTrainedModel`], *optional*): + Reference model used to compute the reference log probabilities. + + - If provided, this model is used directly as the reference policy. + - If `None`, the trainer will automatically use the initial policy corresponding to `model`, i.e. the model + state before DPO training starts. + args ([`DPOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + data_collator ([`~transformers.DataCollator`], *optional*): + Function to use to form a batch from a list of elements of the processed `train_dataset` or `eval_dataset`. + Will default to [`~trainer.dpo_trainer.DataCollatorForPreference`] if the model is a language model and + [`~trainer.dpo_trainer.DataCollatorForVisionPreference`] if the model is a vision-language model. Custom + collators must truncate sequences before padding; the trainer does not apply post-collation truncation. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. This trainer supports both [language modeling](#language-modeling) type and + [prompt-completion](#prompt-completion) type. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. The padding side must be set to "left". If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoProcessor.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function that will be used to compute metrics at evaluation. Must take a + [`~transformers.EvalPrediction`] and return a dictionary string to metric values. When passing + [`SFTConfig`] with `batch_eval_metrics` set to `True`, your `compute_metrics` function must take a boolean + `compute_result` argument. This will be triggered after the last eval batch to signal that the function + needs to calculate and return the global summary statistics rather than accumulating the batch-level + statistics. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + """ + + _tag_names = ["trl", "dpo"] + _name = "DPO" + _paper = { + "title": "Direct Preference Optimization: Your Language Model is Secretly a Reward Model", + "id": "2305.18290", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{rafailov2023direct, + title = {{Direct Preference Optimization: Your Language Model is Secretly a Reward Model}}, + author = {Rafael Rafailov and Archit Sharma and Eric Mitchell and Christopher D. Manning and Stefano Ermon and Chelsea Finn}, + year = 2023, + booktitle = {Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023}, + url = {http://papers.nips.cc/paper_files/paper/2023/hash/a85b405ed65c6477a4fe8302b5e06ce7-Abstract-Conference.html}, + editor = {Alice Oh and Tristan Naumann and Amir Globerson and Kate Saenko and Moritz Hardt and Sergey Levine}, + }"""), + } + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + ref_model: PreTrainedModel | None = None, + args: DPOConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: "PeftConfig | None" = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = DPOConfig(f"{model_name}-DPO") + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif isinstance(train_dataset, IterableDataset): + # IterableDataset requires dispatch_batches=False because Accelerate's dispatch mode may try to concatenate + # batches from multiple processes, leading to mismatch errors. + if args.accelerator_config.dispatch_batches is True: + logger.warning( + "You are using an `IterableDataset` for training with `dispatch_batches=True`. `dispatch_batches` " + "is forced to `False` when using an `IterableDataset`. To remove this warning, unset " + "`dispatch_batches` in `DPOConfig` or set it to `False`." + ) + args.accelerator_config.dispatch_batches = False + + # Model + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the `DPOConfig`, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + if ref_model is model: + raise ValueError( + "`model` and `ref_model` cannot be the same object. In most cases you should omit `ref_model` and " + "we'll initialize it to a copy of `model` for you." + ) + + # Processing class + if processing_class is None: + processing_class = AutoProcessor.from_pretrained(get_config_model_id(model.config)) + + # Handle pad token for processors or tokenizers + if isinstance(processing_class, ProcessorMixin): + self._tokenizer = processing_class.tokenizer + self._is_vlm = True + elif isinstance(processing_class, PreTrainedTokenizerBase): + self._tokenizer = processing_class + self._is_vlm = False + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if self._tokenizer.pad_token is None: + self._tokenizer.pad_token = self._tokenizer.eos_token + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + if is_peft_available() and is_peft_model(model) and ref_model is None: + # If the model is a PEFT model with a pretrained adapter, we need to create a "ref" adapter that is a copy + # of the "default" adapter, so that we can use it as the reference model during DPO training. + model.add_adapter("ref", model.peft_config["default"]) + for name, param in model.named_parameters(): + if ".default." in name: + ref_name = name.replace(".default.", ".ref.") + ref_param = model.get_parameter(ref_name) + ref_param.data.copy_(param.data) + + # Create PEFT model + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # When using gradient checkpointing with PEFT, we need to enable input gradients. transformers.Trainer normally + # handles this, but a bug currently prevents it; see https://github.com/huggingface/transformers/issues/42489 + if is_peft_available() and isinstance(model, PeftModel) and args.gradient_checkpointing: + model.enable_input_require_grads() + + # When using QLoRA, the PEFT adapter weights are converted to bf16 to follow the recommendations from the + # original paper (see https://huggingface.co/papers/2305.14314, paragraph 3). Normally, this can be done by + # passing `autocast_adapter_dtype=False` to `get_peft_model`, but this option is not yet supported for + # quantized models. See: https://github.com/huggingface/peft/issues/2889 + # Non-quantized models do not have the `is_loaded_in_{8,4}bit` attributes, whereas quantized models do + if getattr(model, "is_loaded_in_4bit", False) or getattr(model, "is_loaded_in_8bit", False): + for param in model.parameters(): + if param.requires_grad: + param.data = param.data.to(torch.bfloat16) + + # Data collator + self.padding_free = args.padding_free + if self.padding_free: + logger.warning( + "`padding_free=True` is temporarily unavailable after a refactor and is currently disabled. Falling " + "back to standard padding (`padding_free=False`). This feature is planned to return in a future " + "update; for now, please set `padding_free=False` explicitly." + ) + self.padding_free = False + dataset_sample = next(iter(train_dataset)) + self._is_vision_dataset = "image" in dataset_sample or "images" in dataset_sample + if self._is_vision_dataset and not self._is_vlm: + raise ValueError( + "The dataset appears to be vision-related (contains 'image' or 'images' keys), but the provided " + "model does not seem to be a vision-language model. Please check your model and dataset." + ) + if self._is_vision_dataset and args.max_length is not None and args.truncation_mode == "keep_end": + raise ValueError( + "truncation_mode='keep_end' is not supported for vision-language models. Image tokens reside " + "inside the prompt portion of the sequence; depending on the example, keep_end may silently " + "drop them, causing pixel_values to be forwarded to the model with no corresponding visual " + "tokens in input_ids. Use truncation_mode='keep_start' (the default) or set max_length=None." + ) + if data_collator is None and not self._is_vision_dataset: + # Get the pad token: if not provided, use the one from the processing class or the eos token + # if the processing class does not have a pad token. + pad_token = args.pad_token or self._tokenizer.pad_token or self._tokenizer.eos_token + if pad_token not in self._tokenizer.get_vocab(): + raise ValueError( + f"The specified `pad_token` ('{pad_token}') is not found in the vocabulary of the given " + f"`processing_class` ({processing_class.__class__.__name__}). Ensure that the `pad_token` exists " + "in the vocabulary before using it as a padding token." + ) + self._tokenizer.pad_token = pad_token + data_collator = DataCollatorForPreference( + pad_token_id=self._tokenizer.pad_token_id, + max_length=args.max_length, + truncation_mode=args.truncation_mode, + pad_to_multiple_of=args.pad_to_multiple_of, + ) + elif data_collator is None and self._is_vision_dataset: + data_collator = DataCollatorForVisionPreference( + processor=processing_class, + max_length=args.max_length, + pad_to_multiple_of=args.pad_to_multiple_of, + ) + + # Training arguments + self.beta = args.beta + self.precompute_ref_logps = args.precompute_ref_log_probs + self.loss_types = args.loss_type # args.loss_type is already a list + self.loss_weights = args.loss_weights or [1.0] * len(self.loss_types) + self.ld_alpha = args.ld_alpha + self.f_divergence_type = args.f_divergence_type + self.f_alpha_divergence_coef = args.f_alpha_divergence_coef + self.label_smoothing = args.label_smoothing + self.use_weighting = args.use_weighting + if self.use_weighting and any(loss_type in {"aot", "aot_unpaired"} for loss_type in self.loss_types): + raise NotImplementedError( + "WPO-style weighting is not implemented for 'aot' or 'aot_unpaired' because those losses sort " + "samples, which would misalign per-pair weights." + ) + if "robust" in self.loss_types and not (0.0 <= self.label_smoothing < 0.5): + logger.warning( + "The `label_smoothing` parameter should lie in [0.0, 0.5) for the 'robust' loss. You provided " + f"{self.label_smoothing}." + ) + if "exo_pair" in self.loss_types and self.label_smoothing == 0.0: + raise ValueError( + "Label smoothing must be greater than 0.0 when using 'exo_pair' loss. The EXO paper recommends a " + "value of 1e-3." + ) + self.use_liger_kernel = args.use_liger_kernel + if args.use_liger_kernel: + if not is_liger_kernel_available(): + raise ImportError( + "You set `use_liger_kernel=True` but the liger kernel is not available. " + "Please install liger-kernel first: `pip install liger-kernel`" + ) + if len(self.loss_types) != 1: + raise NotImplementedError( + "Multiple loss types are not yet supported when using Liger kernel. If you need this feature, " + "please open a feature request at https://github.com/huggingface/trl/issues." + ) + self.liger_loss_fn = LigerFusedLinearDPOLoss(beta=args.beta, loss_type=self.loss_types[0]) + if compute_metrics is not None: + raise ValueError( + "compute_metrics is not supported with the Liger kernel. compute_metrics requires to be able to " + "recover the logits from the forward pass, but Liger kernel does not materialize logits." + ) + if self.precompute_ref_logps: + raise ValueError( + "Liger DPO loss does not support precomputing reference log probabilities. Either disable " + "`precompute_ref_log_probs` or set `use_liger_kernel` to False." + ) + + # Dataset + # Skip dataset preparation if it's a VLM, where preprocessing (e.g., image-to-pixel conversion) is too costly + # and done on the fly instead. + skip_prepare_dataset = self._is_vision_dataset + if not skip_prepare_dataset: + train_dataset = self._prepare_dataset(train_dataset, processing_class, args, "train") + if eval_dataset is not None: + if isinstance(eval_dataset, dict): + eval_dataset = { + key: self._prepare_dataset(dataset, processing_class, args, key) + for key, dataset in eval_dataset.items() + } + else: + eval_dataset = self._prepare_dataset(eval_dataset, processing_class, args, "eval") + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + ) + + # Initialize activation offloading context + if self.args.activation_offloading: + self.maybe_activation_offload_context = get_act_offloading_ctx_manager(model=self.model) + else: + self.maybe_activation_offload_context = contextlib.nullcontext() + + # Reference model + if ref_model is None: + if is_peft_model(self.model) or args.precompute_ref_log_probs: + # If PEFT is used, the reference model is not needed since the adapter can be disabled to revert to the + # initial model. If precompute_ref_log_probs is True, the reference model does not need to be kept in + # memory during training. + self.ref_model = None + else: + ref_model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if self.args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + ref_model_init_kwargs["device_map"] = None + ref_model_path = get_config_model_id(self.model.config) + self.ref_model = create_model_from_path(ref_model_path, **ref_model_init_kwargs) + else: + self.ref_model = ref_model + + # Disable dropout in the models + if args.disable_dropout: + disable_dropout_in_model(model) + if self.ref_model is not None: + disable_dropout_in_model(self.ref_model) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + if self.ref_model is not None: + if self.is_deepspeed_enabled: + self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) + elif self.is_fsdp_enabled: + self.ref_model = prepare_fsdp(self.ref_model, self.accelerator) + else: + self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) + + if args.sync_ref_model: + if is_peft_model(self.model): + raise NotImplementedError( + "You passed `sync_ref_model=True` while using a PEFT model, which is currently not supported. " + "With PEFT, DPOTrainer does not keep a separate reference model in memory; instead, it recovers " + "reference behavior by temporarily disabling the adapter. As a result, there is no standalone " + "`ref_model` instance to synchronize. Use `sync_ref_model=False`, or opt for full fine-tuning if " + "you need a synced reference model. If you need `sync_ref_model` to work with PEFT, please open a " + "feature request at https://github.com/huggingface/trl/issues." + ) + if args.precompute_ref_log_probs: + raise ValueError( + "You cannot use `sync_ref_model=True` together with `precompute_ref_log_probs=True`. " + "`precompute_ref_log_probs=True` assumes a fixed reference model, but with `sync_ref_model=True` " + "the reference model is periodically updated during training, making any precomputed reference " + "log-probs stale. Set `precompute_ref_log_probs=False` or disable `sync_ref_model`." + ) + self.add_callback(SyncRefModelCallback(ref_model=self.ref_model, accelerator=self.accelerator)) + + if args.precompute_ref_log_probs: + if isinstance(self.train_dataset, IterableDataset) or isinstance( + self.eval_dataset, (IterableDataset, IterableDatasetDict) + ): + raise ValueError( + "`precompute_ref_log_probs=True` is not supported with IterableDataset. Please use a map-style " + "Dataset or set `precompute_ref_log_probs=False`." + ) + + self.train_dataset = self._precompute_ref_logps( + self.train_dataset, + "train", + self.args.precompute_ref_batch_size or self.args.per_device_train_batch_size, + ) + if self.eval_dataset is not None: + if isinstance(self.eval_dataset, dict): + self.eval_dataset = { + name: self._precompute_ref_logps( + dataset, name, self.args.precompute_ref_batch_size or self.args.per_device_eval_batch_size + ) + for name, dataset in self.eval_dataset.items() + } + else: + self.eval_dataset = self._precompute_ref_logps( + self.eval_dataset, + "eval", + self.args.precompute_ref_batch_size or self.args.per_device_eval_batch_size, + ) + + def _tokenize( + self, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + input: str | list, + **kwargs, + ) -> dict[str, list]: + """Tokenize a single example for dataset preprocessing. + + Dispatches to `apply_chat_template` for conversational input (list of message dicts) and to `__call__` for + non-conversational input (str). For VLMs, normalizes the batch dimension that processors emit even for single + examples. + + Args: + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`]): + The tokenizer or processor to use. + input (`str` or `list`): + A string for non-conversational input, or a list of message dicts for conversational input. + **kwargs: + Forwarded to `apply_chat_template` (e.g. `add_generation_prompt`, `return_assistant_tokens_mask`). + + Returns: + `dict` with at least an `"input_ids"` key mapping to a flat `list[int]`. + """ + if isinstance(input, list): # conversational: list of message dicts + if self._is_vlm: + input = prepare_multimodal_messages(input) + result = processing_class.apply_chat_template(input, tokenize=True, return_dict=True, **kwargs) + else: # non-conversational: plain text string + result = processing_class(text=input) + # VLMs emit a batch dimension even for single examples; unwrap it + if self._is_vlm: + return {k: v[0] for k, v in result.items()} + return result + + def _prepare_dataset( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + args: DPOConfig, + dataset_name: str, + ) -> Dataset | IterableDataset: + # Build the kwargs for the `map` function + map_kwargs = {} + if isinstance(dataset, Dataset): # IterableDataset does not support num_proc + map_kwargs["num_proc"] = args.dataset_num_proc + + with PartialState().main_process_first(): + # Extract the prompt if needed + first_example = next(iter(dataset)) + if "prompt" not in first_example: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Extracting prompt from {dataset_name} dataset" + dataset = dataset.map(extract_prompt, **map_kwargs) + + # Add EOS token if needed: non-conversational only + first_example = next(iter(dataset)) + if not is_conversational(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Adding EOS to {dataset_name} dataset" + + def add_eos(example, eos_token): + if not example["chosen"].endswith(eos_token): + example["chosen"] = example["chosen"] + eos_token + if not example["rejected"].endswith(eos_token): + example["rejected"] = example["rejected"] + eos_token + return example + + dataset = dataset.map(add_eos, fn_kwargs={"eos_token": self._tokenizer.eos_token}, **map_kwargs) + + # Tokenize the dataset + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Tokenizing {dataset_name} dataset" + + def tokenize_fn(example, processing_class): + tools = example.get("tools") + tools = json.loads(tools) if isinstance(tools, str) else tools + output = {} + if is_conversational(example): + prompt_ids = self._tokenize( + processing_class, + example["prompt"], + tools=tools, + add_generation_prompt=True, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + prompt_chosen_ids = self._tokenize( + processing_class, + example["prompt"] + example["chosen"], + tools=tools, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + prompt_rejected_ids = self._tokenize( + processing_class, + example["prompt"] + example["rejected"], + tools=tools, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + else: + prompt_ids = self._tokenize(processing_class, example["prompt"])["input_ids"] + prompt_chosen_ids = self._tokenize(processing_class, example["prompt"] + example["chosen"])[ + "input_ids" + ] + prompt_rejected_ids = self._tokenize(processing_class, example["prompt"] + example["rejected"])[ + "input_ids" + ] + + # Check if the tokenized prompt starts with the tokenized prompt+completion + if not prompt_chosen_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+chosen. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + if not prompt_rejected_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+rejected. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + + output["prompt_ids"] = prompt_ids + output["chosen_ids"] = prompt_chosen_ids[len(prompt_ids) :] + output["rejected_ids"] = prompt_rejected_ids[len(prompt_ids) :] + return output + + dataset = dataset.map(tokenize_fn, fn_kwargs={"processing_class": processing_class}, **map_kwargs) + + return dataset + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). + if self._signature_columns is None: + if self._is_vision_dataset: + self._signature_columns = [ + "prompt", + "chosen", + "rejected", + "image", + "images", + "tools", + "chat_template_kwargs", + ] + else: + self._signature_columns = [ + "prompt_ids", + "chosen_ids", + "rejected_ids", + "ref_chosen_logps", + "ref_rejected_logps", + ] + + def _precompute_ref_logps(self, dataset: Dataset, name: str, batch_size: int) -> Dataset: + model_hash = hash_module(self.ref_model or self.model) + fingerprint = Hasher.hash((dataset._fingerprint, model_hash)) + cache_file = dataset._get_cache_file_path(fingerprint).removesuffix(".arrow") + ".npz" + if os.path.exists(cache_file): + loaded = np.load(cache_file) + ref_chosen_logps = loaded["ref_chosen_logps"] + ref_rejected_logps = loaded["ref_rejected_logps"] + else: + dataloader = DataLoader( + dataset, + batch_size=batch_size, + collate_fn=self.data_collator, + num_workers=self.args.dataloader_num_workers, + pin_memory=self.args.dataloader_pin_memory, + shuffle=False, + ) + data_loader = self.accelerator.prepare(dataloader) + ref_chosen_logps = [] + ref_rejected_logps = [] + for padded_batch in tqdm(iterable=data_loader, desc=f"Computing reference log probs for {name} dataset"): + ref_chosen_logp, ref_rejected_logp = self.compute_ref_log_probs(padded_batch) + ref_chosen_logp, ref_rejected_logp = self.accelerator.gather_for_metrics( + (ref_chosen_logp, ref_rejected_logp) + ) + ref_chosen_logps.append(ref_chosen_logp.cpu()) + ref_rejected_logps.append(ref_rejected_logp.cpu()) + + # Save the reference log probabilities to cache. We need .float() because bf16 is not supported by numpy + ref_chosen_logps = torch.cat(ref_chosen_logps).float().numpy() + ref_rejected_logps = torch.cat(ref_rejected_logps).float().numpy() + if self.accelerator.is_main_process: + np.savez_compressed( + cache_file, ref_chosen_logps=ref_chosen_logps, ref_rejected_logps=ref_rejected_logps + ) + self.accelerator.wait_for_everyone() + + dataset = dataset.add_column(name="ref_chosen_logps", column=ref_chosen_logps) + dataset = dataset.add_column(name="ref_rejected_logps", column=ref_rejected_logps, new_fingerprint=fingerprint) + + return dataset + + def compute_ref_log_probs(self, inputs): + """Computes reference log probabilities for a single padded batch.""" + device = self.accelerator.device + + _non_model_keys = {"completion_mask", "ref_chosen_logps", "ref_rejected_logps"} + model_kwargs = {k: v for k, v in inputs.items() if k not in _non_model_keys} + model_kwargs["use_cache"] = False + + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + if self.ref_model is None: + if is_peft_model(self.model): + model = self.accelerator.unwrap_model(self.model) + with use_adapter(model, adapter_name="ref" if "ref" in model.peft_config else None): + ref_outputs = self.model(**model_kwargs) + else: + ref_outputs = self.model(**model_kwargs) + else: + ref_outputs = self.ref_model(**model_kwargs) + + input_ids = inputs["input_ids"] + completion_mask = inputs["completion_mask"] + shift_labels = input_ids[..., 1:].contiguous() + shift_completion_mask = completion_mask[..., 1:].contiguous() + ref_shift_logits = ref_outputs.logits[..., :-1, :].contiguous() + ref_per_token_logps = selective_log_softmax(ref_shift_logits, shift_labels) + ref_per_token_logps[shift_completion_mask == 0] = 0.0 + + if self.ld_alpha is None: + ref_logps = ref_per_token_logps.sum(dim=1) + else: + comp_pos = shift_completion_mask.cumsum(dim=1) + comp_lens = shift_completion_mask.sum(dim=1).long() + chosen_lens, rejected_lens = comp_lens.chunk(2, dim=0) + shared_lens = torch.minimum(chosen_lens, rejected_lens) + shared_lens = torch.cat([shared_lens, shared_lens], dim=0).to(device) + shared_mask = (comp_pos > 0) & (comp_pos <= shared_lens.unsqueeze(1)) + tail_mask = comp_pos > shared_lens.unsqueeze(1) + shared_logps = (ref_per_token_logps * shared_mask).sum(dim=1) + tail_logps = (ref_per_token_logps * tail_mask).sum(dim=1) + ref_logps = shared_logps + self.ld_alpha * tail_logps + + ref_chosen_logps, ref_rejected_logps = ref_logps.chunk(2, dim=0) + return ref_chosen_logps, ref_rejected_logps + + def _compute_loss_liger(self, model, inputs, return_outputs): + if return_outputs: + raise RuntimeError( + "return_outputs=True is not supported with the Liger DPO loss. The Liger loss computes the loss " + "without materializing logits, so outputs cannot be returned." + ) + + mode = "train" if self.model.training else "eval" + + input_ids = inputs["input_ids"] + attention_mask = inputs["attention_mask"] + completion_mask = inputs["completion_mask"] + + decoder = model.get_decoder() + outputs = decoder(input_ids, attention_mask=attention_mask, use_cache=False) + hidden_states = outputs.last_hidden_state[:, :-1].contiguous() + lm_head = model.get_output_embeddings() + weight = lm_head.weight + bias = lm_head.bias + + if is_peft_model(model): + raise NotImplementedError("Liger DPO loss is not implemented for PEFT models.") + else: + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + ref_decoder = self.ref_model.get_decoder() + ref_outputs = ref_decoder(input_ids, attention_mask=attention_mask, use_cache=False) + ref_lm_head = self.ref_model.get_output_embeddings() + ref_hidden_states = ref_outputs.last_hidden_state[:, :-1].contiguous() + ref_weight = ref_lm_head.weight + ref_bias = ref_lm_head.bias + + shift_completion_mask = completion_mask[:, 1:].contiguous() + labels = input_ids[:, 1:].clone() + labels[shift_completion_mask == 0] = -100 + + loss, metrics = self.liger_loss_fn( + weight, hidden_states, labels, bias, ref_hidden_states, ref_weight, ref_bias + ) + + ( + chosen_logps, + rejected_logps, + chosen_logits_mean, + rejected_logits_mean, + nll_loss, + chosen_rewards, + rejected_rewards, + ) = metrics + + if mode == "train": + num_tokens_in_batch = self.accelerator.gather_for_metrics(inputs["attention_mask"].sum()).sum().item() + self._total_train_tokens += num_tokens_in_batch + self._metrics[mode]["num_tokens"] = [self._total_train_tokens] + + avg_chosen_logits = self.accelerator.gather_for_metrics(chosen_logits_mean).mean().item() + avg_rejected_logits = self.accelerator.gather_for_metrics(rejected_logits_mean).mean().item() + self._metrics[mode]["logits/chosen"].append(avg_chosen_logits) + self._metrics[mode]["logits/rejected"].append(avg_rejected_logits) + + agg_chosen_rewards = self.accelerator.gather(chosen_rewards) + agg_rejected_rewards = self.accelerator.gather(rejected_rewards) + self._metrics[mode]["rewards/chosen"].append(agg_chosen_rewards.mean().item()) + self._metrics[mode]["rewards/rejected"].append(agg_rejected_rewards.mean().item()) + + reward_accuracies = (chosen_rewards > rejected_rewards).float() + agg_reward_accuracies = self.accelerator.gather(reward_accuracies) + self._metrics[mode]["rewards/accuracies"].append(agg_reward_accuracies.mean().item()) + + margins = chosen_rewards - rejected_rewards + agg_margins = self.accelerator.gather(margins) + self._metrics[mode]["rewards/margins"].append(agg_margins.mean().item()) + + self._metrics[mode]["logps/chosen"].append(self.accelerator.gather(chosen_logps).mean().item()) + self._metrics[mode]["logps/rejected"].append(self.accelerator.gather(rejected_logps).mean().item()) + + return loss + + def _compute_loss(self, model, inputs, return_outputs): + mode = "train" if self.model.training else "eval" + device = self.accelerator.device + + _non_model_keys = {"completion_mask", "ref_chosen_logps", "ref_rejected_logps"} + model_kwargs = {k: v for k, v in inputs.items() if k not in _non_model_keys} + model_kwargs["use_cache"] = False + outputs = model(**model_kwargs) + + input_ids = inputs["input_ids"] + completion_mask = inputs["completion_mask"] + shift_logits = outputs.logits[..., :-1, :].contiguous() + shift_labels = input_ids[..., 1:].contiguous() + shift_completion_mask = completion_mask[..., 1:].contiguous() + per_token_logps = selective_log_softmax(shift_logits, shift_labels) + per_token_logps[shift_completion_mask == 0] = 0.0 # mask out non-completion tokens + if self.ld_alpha is None: + logps = per_token_logps.sum(dim=1) # sum over sequence length + else: + comp_pos = shift_completion_mask.cumsum(dim=1) + comp_lens = shift_completion_mask.sum(dim=1).long() + chosen_lens, rejected_lens = comp_lens.chunk(2, dim=0) + shared_lens = torch.minimum(chosen_lens, rejected_lens) + shared_lens = torch.cat([shared_lens, shared_lens], dim=0).to(device) + shared_mask = (comp_pos > 0) & (comp_pos <= shared_lens.unsqueeze(1)) # shared: 1 <= pos <= shared_len + tail_mask = comp_pos > shared_lens.unsqueeze(1) # tail: pos > shared_len + shared_logps = (per_token_logps * shared_mask).sum(dim=1) + tail_logps = (per_token_logps * tail_mask).sum(dim=1) + logps = shared_logps + self.ld_alpha * tail_logps + chosen_logps, rejected_logps = logps.chunk(2, dim=0) # batch is [chosen, rejected] + + if self.precompute_ref_logps: + ref_chosen_logps, ref_rejected_logps = inputs["ref_chosen_logps"], inputs["ref_rejected_logps"] + else: + # When gradient checkpointing is enabled with use_reentrant=True (default), calling the model inside a + # torch.no_grad() block triggers a harmless PyTorch warning ("None of the inputs have requires_grad=True"). + # Temporarily disable checkpointing to avoid this warning during inference. + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + if is_peft_model(model) and self.ref_model is None: + # When training a PEFT adapter, how we obtain the reference depends on the setup: + # - New adapter: disabling adapters yields the base model. + # - Re-training an existing adapter: an initial copy is loaded under the name "ref". + model = self.accelerator.unwrap_model(model) + with use_adapter(model, adapter_name="ref" if "ref" in model.peft_config else None): + ref_outputs = self.model(**model_kwargs) + else: + ref_outputs = self.ref_model(**model_kwargs) + + ref_shift_logits = ref_outputs.logits[..., :-1, :].contiguous() + ref_per_token_logps = selective_log_softmax(ref_shift_logits, shift_labels) + ref_per_token_logps[shift_completion_mask == 0] = 0.0 # mask out non-completion tokens + if self.ld_alpha is None: + ref_logps = ref_per_token_logps.sum(dim=1) # sum over sequence length + else: + # reuse comp_pos/shared_mask/tail_mask computed above (they depend only on completion_mask) + ref_shared_logps = (ref_per_token_logps * shared_mask).sum(dim=1) + ref_tail_logps = (ref_per_token_logps * tail_mask).sum(dim=1) + ref_logps = ref_shared_logps + self.ld_alpha * ref_tail_logps + ref_chosen_logps, ref_rejected_logps = ref_logps.chunk(2, dim=0) # batch is [chosen, rejected] + + # Get the log ratios for the chosen and rejected responses + chosen_logratios = chosen_logps - ref_chosen_logps + rejected_logratios = rejected_logps - ref_rejected_logps + + if self.f_divergence_type == "reverse_kl": # standard DPO + chosen_scores = chosen_logratios + rejected_scores = rejected_logratios + elif self.f_divergence_type == "forward_kl": + # f'(t) = 1 - 1/t -> drop constant -> -exp(-logratio) + chosen_scores = -torch.exp(-chosen_logratios) + rejected_scores = -torch.exp(-rejected_logratios) + elif self.f_divergence_type == "js_divergence": + # f'(t) = log(2t/(t+1)) -> drop log 2 + chosen_scores = F.logsigmoid(chosen_logratios) + rejected_scores = F.logsigmoid(rejected_logratios) + elif self.f_divergence_type == "alpha_divergence": + # alpha-divergence: f'(t) = (t^(α-1) - 1)/(α-1) + if abs(self.f_alpha_divergence_coef - 1.0) < 1e-6: # limit case f'(t) -> log(t), fall back to reverse_kl + chosen_scores = chosen_logratios + rejected_scores = rejected_logratios + else: + coef = 1.0 / (self.f_alpha_divergence_coef - 1.0) + t_chosen = (self.f_alpha_divergence_coef - 1.0) * chosen_logratios + t_rejected = (self.f_alpha_divergence_coef - 1.0) * rejected_logratios + dtype = t_chosen.dtype + # Clamp max so exp(.) stays representable after casting back + clamp_max = {torch.float16: 11.0, torch.bfloat16: 80.0, torch.float32: 80.0}[dtype] + t_chosen_float = torch.clamp(t_chosen.float(), max=clamp_max) + t_rejected_float = torch.clamp(t_rejected.float(), max=clamp_max) + chosen_scores = torch.exp(t_chosen_float).to(dtype) * coef + rejected_scores = torch.exp(t_rejected_float).to(dtype) * coef + else: + raise ValueError(f"Unknown f_divergence_type: {self.f_divergence_type}") + + delta_score = chosen_scores - rejected_scores + + loss = 0.0 + for loss_type, loss_weight in zip(self.loss_types, self.loss_weights, strict=True): + if loss_type == "sigmoid": + per_sequence_loss = -F.logsigmoid(self.beta * delta_score) + + elif loss_type == "hinge": + per_sequence_loss = torch.relu(1 - self.beta * delta_score) + + elif loss_type == "ipo": + # IPO uses sequence-level log-prob differences; in code these are token-summed over the completion, + # which makes the squared loss scale with completion length. We therefore normalize by the number of + # completion tokens (average per token) to make β/loss comparable across variable lengths. This length + # normalization is not explicitly discussed in the IPO paper; we confirmed this choice with the IPO + # authors, and the results reported in the paper correspond to this normalized form. + chosen_mask, rejected_mask = completion_mask.chunk(2, dim=0) + chosen_avg_score = chosen_scores / chosen_mask.sum(dim=1).clamp(min=1.0) + rejected_avg_score = rejected_scores / rejected_mask.sum(dim=1).clamp(min=1.0) + ipo_delta = chosen_avg_score - rejected_avg_score + # (Eq. 17) of the paper where beta is the regularization parameter for the IPO loss, denoted by τ. + per_sequence_loss = (ipo_delta - 1 / (2 * self.beta)) ** 2 + + elif loss_type == "exo_pair": + # Implements EXO-pref from the paper https://huggingface.co/papers/2402.00856, (Eq. 16) + # Minimize KL(p_fθ || p_rh) for K=2; p_fθ = softmax(βπ * (log πθ − log π_ref)) over {chosen, rejected} + # p_rh = [(1−ε), ε]; expanded KL gives the weighted logsigmoid form below + epsilon = torch.tensor(self.label_smoothing, device=device) + qw = torch.sigmoid(self.beta * delta_score) + log_qw = F.logsigmoid(self.beta * delta_score) + log_pw = torch.log1p(-epsilon) + ql = torch.sigmoid(-self.beta * delta_score) + log_ql = F.logsigmoid(-self.beta * delta_score) + log_pl = torch.log(epsilon) + per_sequence_loss = qw * (log_qw - log_pw) + ql * (log_ql - log_pl) + + elif loss_type == "nca_pair": + chosen_rewards = self.beta * chosen_scores + rejected_rewards = self.beta * rejected_scores + per_sequence_loss = ( + -F.logsigmoid(chosen_rewards) + - 0.5 * F.logsigmoid(-chosen_rewards) + - 0.5 * F.logsigmoid(-rejected_rewards) + ) + + elif loss_type == "robust": + clean_loss_term = -(1 - self.label_smoothing) * F.logsigmoid(self.beta * delta_score) + flipped_loss_term = -self.label_smoothing * F.logsigmoid(-self.beta * delta_score) + per_sequence_loss = (clean_loss_term - flipped_loss_term) / (1 - 2 * self.label_smoothing) + + elif loss_type == "bco_pair": + chosen_rewards = self.beta * chosen_scores + rejected_rewards = self.beta * rejected_scores + per_sequence_loss = -F.logsigmoid(chosen_rewards) - F.logsigmoid(-rejected_rewards) + + elif loss_type == "sppo_hard": + # In the paper (https://huggingface.co/papers/2405.00675), SPPO employs a soft probability approach, + # estimated using the PairRM score. The probability calculation is conducted outside of the trainer + # class. The version described here is the hard probability version, where P in Equation (4.7) of + # Algorithm 1 is set to 1 for the winner and 0 for the loser. + winner_margin_error = (chosen_scores - 0.5 / self.beta) ** 2 + loser_margin_error = (rejected_scores + 0.5 / self.beta) ** 2 + per_sequence_loss = winner_margin_error + loser_margin_error + + elif loss_type == "aot": + logratios = chosen_logps - rejected_logps + ref_logratios = ref_chosen_logps - ref_rejected_logps + logratios_sorted, _ = torch.sort(logratios, dim=0) + ref_logratios_sorted, _ = torch.sort(ref_logratios, dim=0) + delta = logratios_sorted - ref_logratios_sorted + per_sequence_loss = ( + -F.logsigmoid(self.beta * delta) * (1 - self.label_smoothing) + - F.logsigmoid(-self.beta * delta) * self.label_smoothing + ) + + elif loss_type == "aot_unpaired": + chosen_logratios_sorted, _ = torch.sort(chosen_logratios, dim=0) + rejected_logratios_sorted, _ = torch.sort(rejected_logratios, dim=0) + delta = chosen_logratios_sorted - rejected_logratios_sorted + per_sequence_loss = ( + -F.logsigmoid(self.beta * delta) * (1 - self.label_smoothing) + - F.logsigmoid(-self.beta * delta) * self.label_smoothing + ) + + elif loss_type == "apo_zero": + # Eqn (7) of the APO paper (https://huggingface.co/papers/2408.06266) + # Use this loss when you believe the chosen outputs are better than your model's default output + # Increase chosen likelihood and decrease rejected likelihood + losses_chosen = 1 - torch.sigmoid(self.beta * chosen_logratios) + losses_rejected = torch.sigmoid(self.beta * rejected_logratios) + per_sequence_loss = losses_chosen + losses_rejected + + elif loss_type == "apo_down": + # Eqn (8) of the APO paper (https://huggingface.co/papers/2408.06266) + # Use this loss when you believe the chosen outputs are worse than your model's default output. + # Decrease chosen likelihood and decrease rejected likelihood more + losses_chosen = torch.sigmoid(self.beta * chosen_logratios) + losses_rejected = 1 - torch.sigmoid(self.beta * delta_score) + per_sequence_loss = losses_chosen + losses_rejected + + elif loss_type == "discopop": + # Eqn (5) of the DiscoPOP paper (https://huggingface.co/papers/2406.08414) + logits = delta_score * self.beta + # Modulate the mixing coefficient based on the log ratio magnitudes + log_ratio_modulation = torch.sigmoid(logits / self.args.discopop_tau) + logistic_component = -F.logsigmoid(logits) + exp_component = torch.exp(-logits) + # Blend between logistic and exponential component based on log ratio modulation + per_sequence_loss = ( + logistic_component * (1 - log_ratio_modulation) + exp_component * log_ratio_modulation + ) + + elif loss_type == "sft": + chosen_logits, _ = shift_logits.chunk(2, dim=0) + chosen_labels, _ = shift_labels.chunk(2, dim=0) + chosen_mask, _ = shift_completion_mask.chunk(2, dim=0) + batch_loss = F.cross_entropy(chosen_logits[chosen_mask.bool()], chosen_labels[chosen_mask.bool()]) + # Implementation convenience: expand the scalar SFT loss to a per-sequence tensor so it matches the + # shape of other losses; only the mean is used, so this is a no-op numerically. + per_sequence_loss = batch_loss.expand(chosen_logits.size(0)) + + else: + raise ValueError( + f"Unknown loss type: {loss_type}. Should be one of ['sigmoid', 'hinge', 'ipo', 'exo_pair', " + "'nca_pair', 'robust', 'bco_pair', 'sppo_hard', 'aot', 'aot_unpaired', 'apo_zero', 'apo_down', " + "'discopop', 'sft']" + ) + + if self.use_weighting: + # Eq (2) of the WPO paper: https://huggingface.co/papers/2406.11827 + completion_lengths = shift_completion_mask.sum(dim=1).clamp_min(1) + with torch.no_grad(): + lse1 = torch.logsumexp(shift_logits, dim=-1) + lse2 = torch.logsumexp(2.0 * shift_logits, dim=-1) + log_denom = lse2 - 2.0 * lse1 + aligned_logps = (per_token_logps - log_denom) * shift_completion_mask + mean_logps = aligned_logps.sum(dim=1) / completion_lengths + weights = torch.exp(mean_logps) + chosen_weights, rejected_weights = weights.chunk(2, dim=0) + per_sequence_loss *= chosen_weights * rejected_weights + + loss += per_sequence_loss.mean() * loss_weight + + # Log the metrics + # Entropy + per_token_entropy = entropy_from_logits(shift_logits.detach()) + mask = shift_completion_mask + entropy_sum = (per_token_entropy * mask).sum() + total_tokens = mask.sum() + + # Gather counts across ranks and weight-average + entropy_sum = self.accelerator.gather_for_metrics(entropy_sum).sum() + total_tokens = self.accelerator.gather_for_metrics(total_tokens).sum() + entropy = (entropy_sum / total_tokens).item() if total_tokens > 0 else 0.0 + self._metrics[mode]["entropy"].append(entropy) + + # Number of tokens + if mode == "train": + num_tokens_in_batch = self.accelerator.gather_for_metrics(inputs["attention_mask"].sum()).sum().item() + self._total_train_tokens += num_tokens_in_batch + self._metrics[mode]["num_tokens"] = [self._total_train_tokens] + + # Average logits for chosen and rejected completions + chosen_logits, rejected_logits = shift_logits.detach().chunk(2, dim=0) + chosen_mask, rejected_mask = shift_completion_mask.chunk(2, dim=0) + total_chosen_logits = chosen_logits[chosen_mask.bool()].mean(-1).sum() + total_chosen_tokens = chosen_mask.sum() + total_rejected_logits = rejected_logits[rejected_mask.bool()].mean(-1).sum() + total_rejected_tokens = rejected_mask.sum() + total_chosen_logits = self.accelerator.gather_for_metrics(total_chosen_logits).sum().item() + total_chosen_tokens = self.accelerator.gather_for_metrics(total_chosen_tokens).sum().item() + total_rejected_logits = self.accelerator.gather_for_metrics(total_rejected_logits).sum().item() + total_rejected_tokens = self.accelerator.gather_for_metrics(total_rejected_tokens).sum().item() + avg_chosen_logits = total_chosen_logits / total_chosen_tokens if total_chosen_tokens > 0 else 0.0 + avg_rejected_logits = total_rejected_logits / total_rejected_tokens if total_rejected_tokens > 0 else 0.0 + self._metrics[mode]["logits/chosen"].append(avg_chosen_logits) + self._metrics[mode]["logits/rejected"].append(avg_rejected_logits) + + # Token accuracy for the chosen completions + predictions = chosen_logits.argmax(dim=-1) + chosen_mask = shift_completion_mask[: len(shift_completion_mask) // 2].bool() + chosen_labels = shift_labels[: len(shift_labels) // 2] + correct_predictions = (predictions == chosen_labels) & chosen_mask + total_tokens = chosen_mask.sum() + correct_tokens = correct_predictions.sum() + correct_tokens = self.accelerator.gather_for_metrics(correct_tokens) + total_tokens = self.accelerator.gather_for_metrics(total_tokens) + total_sum = total_tokens.sum() + accuracy = (correct_tokens.sum() / total_sum).item() if total_sum > 0 else 0.0 + self._metrics[mode]["mean_token_accuracy"].append(accuracy) + + # Rewards for chosen and rejected completions + chosen_rewards = self.beta * chosen_logratios.detach() + rejected_rewards = self.beta * rejected_logratios.detach() + agg_chosen_rewards = self.accelerator.gather(chosen_rewards) + agg_rejected_rewards = self.accelerator.gather(rejected_rewards) + self._metrics[mode]["rewards/chosen"].append(agg_chosen_rewards.mean().item()) + self._metrics[mode]["rewards/rejected"].append(agg_rejected_rewards.mean().item()) + + # Reward accuracy + reward_accuracies = (chosen_rewards > rejected_rewards).float() + agg_reward_accuracies = self.accelerator.gather(reward_accuracies) + self._metrics[mode]["rewards/accuracies"].append(agg_reward_accuracies.mean().item()) + + # Reward margins + margins = chosen_rewards - rejected_rewards + agg_margins = self.accelerator.gather(margins) + self._metrics[mode]["rewards/margins"].append(agg_margins.mean().item()) + + # Average log probabilities for chosen and rejected completions + self._metrics[mode]["logps/chosen"].append(self.accelerator.gather(chosen_logps).mean().item()) + self._metrics[mode]["logps/rejected"].append(self.accelerator.gather(rejected_logps).mean().item()) + + return (loss, outputs) if return_outputs else loss + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if self.use_liger_kernel: + return self._compute_loss_liger(model, inputs, return_outputs) + else: + return self._compute_loss(model, inputs, return_outputs) + + # Override training step to add activation offloading context. + def training_step(self, *args, **kwargs): + with self.maybe_activation_offload_context: + return super().training_step(*args, **kwargs) + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + metrics = {key: sum(val) / len(val) for key, val in self._metrics[mode].items()} # average the metrics + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + # During eval, Trainer calls prediction_step. If no labels are present in the inputs, it only runs forward and + # returns logits. We override prediction_step to force compute_loss, because this trainer doesn't involve labels. + def prediction_step(self, model, inputs, prediction_loss_only, ignore_keys: list[str] | None = None): + inputs = self._prepare_inputs(inputs) + with torch.no_grad(), self.compute_loss_context_manager(): + if prediction_loss_only: + loss = self.compute_loss(model, inputs, return_outputs=False) # logits aren't materialized with liger + logits, labels = None, None + else: + loss, outputs = self.compute_loss(model, inputs, return_outputs=True) + logits, labels = outputs.logits, inputs["input_ids"] + return loss, logits, labels + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/grpo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/grpo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..e5f373c19f0b0c59a27ccc3f2d7d46f6158b27c5 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/grpo_config.py @@ -0,0 +1,945 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from .base_config import _BaseConfig + + +@dataclass +class GRPOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`GRPOTrainer`]. + + This class includes only the parameters that are specific to GRPO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model and reference model + + model_init_kwargs (`str`, `dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`GRPOTrainer`] is provided as a string. + disable_dropout (`bool`, *optional*, defaults to `False`): + Whether to disable dropout in the model. This is useful for training with a reference model, as it prevents + the model from generating different logprobs for the same input. + cast_lm_head_to_fp32 (`bool`, *optional*, defaults to `False`): + Whether to cast the language modeling head of the policy and reference models to float32. As recommended by + the [ScaleRL](https://huggingface.co/papers/2510.13786) recipe. This flag is only supported when the model + has untied word embedding and language modeling head layers i.e. `tie_word_embeddings` in the model config + is False. + + > Parameters that control the data preprocessing + + remove_unused_columns (`bool`, *optional*, defaults to `False`): + Whether to only keep the column `"prompt"` in the dataset. If you use a custom reward function that + requires any column other than `"prompts"` and `"completions"`, you should keep this to `False`. + num_generations (`int`, *optional*, defaults to `8`): + Number of generations per prompt to sample. The effective batch size (num_processes * per_device_batch_size + * gradient_accumulation_steps) must be evenly divisible by this value. + num_generations_eval (`int` or `None`, *optional*): + Number of generations to sample during evaluation. This allows using fewer generations during evaluation to + save computation. If `None`, uses the value of `num_generations`. + max_completion_length (`int` or `None`, *optional*, defaults to `256`): + Maximum length of the generated completion. + ds3_gather_for_generation (`bool`, *optional*, defaults to `True`): + This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for generation, + improving generation speed. However, disabling this option allows training models that exceed the VRAM + capacity of a single GPU, albeit at the cost of slower generation. Disabling this option is not compatible + with vLLM generation. + shuffle_dataset (`bool`, *optional*, defaults to `True`): + Whether to shuffle the training dataset. + pad_to_multiple_of (`int`, *optional*): + If set, the prompts ids and completions ids will be padded to a multiple of this value. + + > Parameters that control generation + + generation_batch_size: (`int`, *optional*): + Batch size to use for generation. If `None`, it defaults to the effective training batch size: + `per_device_train_batch_size * num_processes * steps_per_generation`. In other words, there is one + generation batch processed per optimization step. Mutually exclusive with `steps_per_generation`. + steps_per_generation: (`int`, *optional*): + Number of steps per generation. If `None`, it defaults to `gradient_accumulation_steps`. Mutually exclusive + with `generation_batch_size`. + temperature (`float`, defaults to `1.0`): + Temperature for sampling. The higher the temperature, the more random the completions. + top_p (`float`, *optional*, defaults to `1.0`): + Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. Set to + `1.0` to consider all tokens. + top_k (`int`, *optional*, defaults to `0`): + Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, top-k-filtering is + disabled and all tokens are considered. + min_p (`float`, *optional*): + Minimum token probability, which will be scaled by the probability of the most likely token. It must be a + value between `0.0` and `1.0`. Typical values are in the `0.01-0.2` range. + generation_kwargs (`dict[str, Any]`, *optional*): + Additional keyword arguments to pass to [`~transformers.GenerationConfig`] (if using transformers) or + `SamplingParams` (if using vLLM) when sampling completions. This can be used to further customize the + generation behavior, such as setting `suppress_tokens`, `num_beams`, etc. If it contains keys that conflict + with the other generation parameters (like `min_p`, `top_p`, etc.), they will override them. + chat_template_kwargs (`dict[str, Any]`, *optional*): + Additional keyword arguments to pass to the `apply_chat_template` function when generating completions. + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. + Values > `1.0` encourage the model to use new tokens, while values < `1.0` encourage the model to repeat + tokens. + cache_implementation (`str`, *optional*): + Implementation of the cache method for faster generation when `use_vllm` is set to `False`. + + > Parameters that control generation acceleration powered by vLLM + + use_vllm (`bool`, *optional*, defaults to `False`): + Whether to use vLLM for generating completions. If set to `True`, the trainer will use vLLM for generation + instead of the default model.generate(). Requires `vllm` to be installed. + vllm_mode (`str`, *optional*, defaults to `"colocate"`): + Mode to use for vLLM integration when `use_vllm` is set to `True`. Must be one of `"server"` or + `"colocate"`. + + - `"server"`: The trainer will send generation requests to a separate vLLM server. Make sure a TRL vLLM + server is running (start with `trl vllm-serve`). + - `"colocate"`: vLLM will run in the same process and share the training GPUs. This avoids the need for a + separate server but may cause resource contention with training. + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation to use for vLLM. Must be one of `"transformers"` or `"vllm"`. `"transformers"`: Use + the `transformers` backend for model implementation. `"vllm"`: Use the `vllm` library for model + implementation. + vllm_structured_outputs_regex (`str`, *optional*): + Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled. + + > Parameters that control the vLLM server (only used when `vllm_mode` is `"server"`) + + vllm_server_base_url (`str`, *optional*): + Base URL for the vLLM server (e.g., `"http://localhost:8000"`). If provided, `vllm_server_host` and + `vllm_server_port` are ignored. + vllm_server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the vLLM server to connect to. Ignored if `vllm_server_base_url` is provided. + vllm_server_port (`int`, *optional*, defaults to `8000`): + Port of the vLLM server to connect to. Ignored if `vllm_server_base_url` is provided. + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up after the + timeout, a `ConnectionError` is raised. + vllm_group_port (`int`, *optional*, defaults to `51216`): + Port number for the weight update group. This is used to communicate with the vLLM server. Unless the port + is occupied, there is no need to change it. + + > Parameters that control colocated vLLM execution (only used when `vllm_mode` is `"colocate"`) + + vllm_gpu_memory_utilization (`float`, *optional*, defaults to `0.3`): + Control the GPU memory utilization for vLLM. This setting only applies when `vllm_mode` is set to + `"colocate"`. If you are using `vllm_mode="server"`, this parameter must be passed separately when + launching the vLLM server via the `--vllm_gpu_memory_utilization` flag. + vllm_max_model_length (`int`, *optional*): + Context window for vLLM. Set it to at least the maximum prompt length in the dataset plus + `max_completion_length`; if omitted, it is inferred from the model config. + vllm_tensor_parallel_size (`int`, *optional*, defaults to `1`): + Control the tensor parallel size for vLLM. This setting only applies when `vllm_mode` is set to + `"colocate"`. If you are using `vllm_mode="server"`, this parameter must be passed separately when + launching the vLLM server via the `--vllm_tensor_parallel_size` flag. + vllm_enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Enable vLLM sleep mode to offload weights/cache during the optimizer step. Keeps GPU memory usage low, but + waking the engine adds host–device transfer latency. + + > Parameters that control the training + + beta (`float`, *optional*, defaults to `0.0`): + KL coefficient. If `0.0` (default), the reference model is not loaded, reducing memory usage and improving + training speed. [DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement + learning](https://huggingface.co/papers/2501.12948) use a value of `0.001`. + num_iterations (`int`, *optional*, defaults to `1`): + Number of iterations per batch (denoted as μ in the algorithm). + epsilon (`float`, *optional*, defaults to `0.2`): + Epsilon value for clipping. + delta (`float`, *optional*): + Enables the upper clipping bound in two-sided GRPO loss when set to a float. If `None` (default), standard + GRPO clipping is used. Recommended to be greater than `1 + ε` when enabled. This method is introduced in + the [INTELLECT-2 tech report](https://huggingface.co/papers/2505.07291). + epsilon_high (`float`, *optional*): + Upper-bound epsilon value for clipping. If not specified, it defaults to the same value as the lower-bound + specified in argument `epsilon`. Paper [DAPO](https://huggingface.co/papers/2503.14476) recommends `0.28`. + When used with `loss_type='cispo'`, this corresponds to the ε_max param specified in the [ScaleRL + paper](https://huggingface.co/papers/2510.13786) and the recommended value is `5.0`. + sapo_temperature_neg (`float`, *optional*, defaults to `1.05`): + Temperature for tokens with non-positive advantage scores used in the `sapo` loss function. This parameter + is introduced in the [Soft Adaptive Policy Optimization paper](https://huggingface.co/papers/2511.20347). + sapo_temperature_pos (`float`, *optional*, defaults to `1.0`): + Temperature for tokens with positive advantage scores used in the `sapo` loss function. This parameter is + introduced in the [Soft Adaptive Policy Optimization paper](https://huggingface.co/papers/2511.20347). + vespo_k_pos (`float`, *optional*, defaults to `2.0`): + k parameter for positive advantages, it is the power exponent in the VESPO loss. Controls how aggressively + we down-weight samples with low importance weights (when the importance sampling ratio < 1). + vespo_lambda_pos (`float`, *optional*, defaults to `3.0`): + lambda parameter for positive advantages, it is the decay factor in the VESPO loss. Controls how + aggressively we down-weight samples with high importance weights (when the importance sampling ratio > 1). + vespo_k_neg (`float`, *optional*, defaults to `3.0`): + k parameter for negative advantages, it is the power exponent in the VESPO loss. Controls how aggressively + we down-weight samples with low importance weights (when the importance sampling ratio < 1). + vespo_lambda_neg (`float`, *optional*, defaults to `2.0`): + lambda parameter for negative advantages, it is the exponential decay factor in the VESPO loss. Controls + how aggressively we down-weight samples with high importance weights (when the importance sampling ratio > + 1). + importance_sampling_level (`str`, *optional*, defaults to `"token"`): + Controls whether importance sampling ratios are computed at the `"token"` or `"sequence"` level. `"token"` + keeps the raw per-token log-probability ratios (one weight per token). `"sequence"` averages the + log-probability ratios across valid tokens to produce a single ratio per sequence. The [GSPO + paper](https://huggingface.co/papers/2507.18071) shows that sequence-level sampling often yields more + stable training and better alignment with sequence-level rewards. + reward_weights (`list[float]`, *optional*): + Weights for each reward function. Must match the number of reward functions. If `None`, all rewards are + weighted equally with weight `1.0`. + multi_objective_aggregation (`str`, *optional*, defaults to `"sum_then_normalize"`): + Method to aggregate multiple reward functions. Supported values are: + + - `"sum_then_normalize"` (default): First sums the weighted rewards from each reward function, then applies + reward scaling/normalization as specified by `scale_rewards` (see `scale_rewards` for details). + - `"normalize_then_sum"`: First normalizes/scales each reward function across generations (within each + group), then sums the normalized rewards using the specified weights. The aggregated reward is then + normalized at the batch level when forming advantages. This is the suggested approach from the paper + [GDPO: Group reward-Decoupled Normalization Policy Optimization for Multi-reward RL + Optimization](https://huggingface.co/papers/2601.05242). + scale_rewards (`str` or `bool`, *optional*, defaults to `"group"`): + Specifies the scaling strategy for rewards. Supported values are: + + - `True` or `"group"` (default): rewards are scaled by the standard deviation within each group, ensuring + unit variance within a group. + - `"batch"`: rewards are scaled by the standard deviation across the entire batch, as recommended in the + [PPO Lite paper](https://huggingface.co/papers/2508.08221). + - `False` or `"none"`: no scaling is applied. The [Dr. GRPO + paper](https://huggingface.co/papers/2503.20783) recommends not scaling rewards, as scaling by the + standard deviation introduces a question-level difficulty bias. + loss_type (`str`, *optional*, defaults to `"dapo"`): + Specifies the loss formulation to use. Supported values are: + + - `"grpo"`: Aggregates token-level losses by normalizing over sequence length. Not recommended due to + length bias—this approach tends to prefer shorter completions with positive advantages and longer ones + with negative advantages. + - `"dr_grpo"`: Aggregates token-level losses by normalizing with a global constant. This method was + introduced in the [Dr. GRPO paper](https://huggingface.co/papers/2503.20783) to eliminate length bias. + The value of the constant corresponds to `max_completion_length`. + - `"dapo"` (default): Aggregates token-level losses by normalizing with the number of active token in the + global accumulated batch. This method was introduced in the [DAPO + paper](https://huggingface.co/papers/2503.14476) to eliminate length bias. + - `"bnpo"`: Aggregates token-level losses by normalizing with the number of active token in the local + batch. Note that normalization is performed over the local batch only, so results may slightly vary + depending on the local batch size, despite a constant effective batch size. When using + `per_device_train_batch_size==1`, the loss is equivalent to the GRPO loss. + - `"cispo"`: Clips the importance sampling weights instead of the advantage scaled importance weights. The + clipped weights are then multiplied with the advantages and policy model's log probs. Individual token + losses are aggregated by normalizing with the number of active tokens in the global accumulated batch. + This method was introduced in the [MiniMax-M1 paper](https://huggingface.co/papers/2506.13585). + - `"sapo"`: Soft Adaptive Policy Optimization loss, as introduced in the [Soft Adaptive Policy Optimization + paper](https://huggingface.co/papers/2511.20347). Replaces hard clipping with a smooth, + temperature-controlled gate that adaptively attenuates off-policy updates while preserving useful + learning signals. + - `"luspo"`: Length-Unbiased Sequence Policy Optimization loss. A sequence-level loss that scales each + sequence's loss by its length. This is a modification of GSPO and requires + `importance_sampling_level="sequence"`. Introduced in the [LUSPO + paper](https://huggingface.co/papers/2602.05261). + - `"vespo"`: Variational Sequence-Level Soft Policy Optimization. Replaces hard clipping with a smooth, + asymmetric Gamma weighting function applied directly to sequence-level importance weights. Introduced in + the [VESPO paper](https://huggingface.co/papers/2602.10693). + mask_truncated_completions (`bool`, *optional*, defaults to `False`): + When enabled, truncated completions are excluded from the loss calculation, preventing them from being + incorrectly penalized and introducing noise during training. According to the + [DAPO](https://huggingface.co/papers/2503.14476) paper, this is a good practice for training stability. + sync_ref_model (`bool`, *optional*, defaults to `False`): + Whether to synchronize the reference model with the active model every `ref_model_sync_steps` steps, using + the `ref_model_mixup_alpha` parameter. This synchronization originates from the + [TR-DPO](https://huggingface.co/papers/2404.09656) paper. + ref_model_mixup_alpha (`float`, *optional*, defaults to `0.6`): + α parameter from the [TR-DPO](https://huggingface.co/papers/2404.09656) paper, which controls the mix + between the current policy and the previous reference policy during updates. The reference policy is + updated according to the equation: `π_ref = α * π_θ + (1 - α) * π_ref_prev`. To use this parameter, you + must set `sync_ref_model=True`. + ref_model_sync_steps (`int`, *optional*, defaults to `512`): + τ parameter from the [TR-DPO](https://huggingface.co/papers/2404.09656) paper, which determines how + frequently the current policy is synchronized with the reference policy. To use this parameter, you must + set `sync_ref_model=True`. + top_entropy_quantile (`float`, *optional*, defaults to `1.0`): + ρ parameter from [Beyond the 80/20 Rule](https://huggingface.co/papers/2506.01939). Keeps in the policy + loss term only the top-ρ quantile of tokens by entropy of the probability distribution at each sequence + position, improving results. Range: `[0.0-1.0]`. A value of `0.0` masks all but the highest entropy token; + `1.0` keeps all tokens. The paper recommends a value of `0.2`. If used with + `mask_truncated_completions=True`, only tokens from non-truncated completions are considered. + max_tool_calling_iterations (`int`, *optional*): + Maximum number of tool-calling turns when training an agent. If `None`, there is no limit and generation + stops when the model generates a response turn with no tool calls or when the total response length reaches + `max_model_length`. + vllm_importance_sampling_correction (`bool`, *optional*, defaults to `True`): + Whether to apply Importance Sampling (IS) to correct for the mismatch between vLLM completion logprobs and + recomputed training logprobs. If set to `False`, no IS is applied regardless of + `vllm_importance_sampling_mode`. When `True`, the selected mode determines how the IS ratios are computed + and constrained. + vllm_importance_sampling_mode (`str`, *optional*, defaults to `"sequence_mask"`): + Specifies how Importance Sampling is performed when `vllm_importance_sampling_correction=True`. Possible + values are: + + - `"token_truncate"`: Token-level truncated IS (default). Per-token ratios are clipped from above at C. + - `"token_mask"`: Token-level masked IS. Per-token ratios above C are set to zero. + - `"sequence_truncate"`: Sequence-level truncated IS. A single sequence ratio is clipped from above at + C and applied to all tokens in the sequence. + - `"sequence_mask"`: Sequence-level masked IS. Sequences with ratios above C are masked out. + vllm_importance_sampling_cap (`float`, *optional*, defaults to `3.0`): + Importance sampling cap C used by `vllm_importance_sampling_mode`. For `*_truncate` modes, importance + ratios are clipped from above at C. For `*_mask` modes, ratios larger than C are set to zero. + off_policy_mask_threshold (`float`, *optional*): + Threshold for off-policy sequence masking. If `None`, off-policy sequence masking is disabled. When set, + sequences with negative advantages and high KL divergence are masked out to stabilize training. This + parameter corresponds to the `delta` threshold in Equation 9 of the [DeepSeek-V3.2 + paper](https://huggingface.co/papers/2512.02556). It expects a positive value (e.g., 0.5). + use_bias_correction_kl (`bool`, *optional*, defaults to `False`): + Whether to use the unbiased KL divergence estimator with importance sampling correction. This corrects the + KL divergence estimate by multiplying it with the importance sampling ratio. This is described in the + [DeepSeek-V3.2 paper](https://huggingface.co/papers/2512.02556). + + > Parameters that control the logging + + log_completions (`bool`, *optional*, defaults to `False`): + Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. If `rich` is installed, + it prints the sample. If `wandb` and/or `trackio` logging is enabled, it logs it to `wandb` and/or + `trackio`. + num_completions_to_print (`int`, *optional*): + Number of completions to print with `rich`. If `None`, all completions are logged. + log_unique_prompts (`bool`, *optional*, defaults to `False`): + Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are + logged. + log_completions_hub_repo (`str`, *optional*): + Hugging Face Hub repository to save the completions. Should be a complete repository name like + `'username/reponame'` or `'orgname/reponame'`, or just `'reponame'` in which case the repository will be + created in the currently-logged-in Hugging Face user's namespace. Note that this repository will be public + unless you set `hub_private_repo=True` or your organization's default is to create private repositories." + + > Deprecated parameters + + use_transformers_paged: + + + + Parameter `use_transformers_paged` is deprecated and will be removed in version v2.0.0. It will be + replaced by `transformers` continuous batching support in an upcoming release. + + + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model and reference model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `transformers.AutoModelForCausalLM.from_pretrained`, used when the `model` " + "argument of the `GRPOTrainer` is provided as a string." + }, + ) + disable_dropout: bool = field( + default=False, + metadata={ + "help": "Whether to disable dropout in the model. This is useful for training with a reference model, as " + "it prevents the model from generating different logprobs for the same input." + }, + ) + cast_lm_head_to_fp32: bool = field( + default=False, + metadata={ + "help": "Whether to cast the language modeling head of the policy and reference, models to float32." + "As recommended by the [ScaleRL](https://huggingface.co/papers/2510.13786) recipe. This flag is only " + "supported when the model has untied word embedding and language modeling head layers i.e. " + "`tie_word_embeddings` in the model config is False." + }, + ) + + # Parameters that control the data preprocessing + # The default value remove_unused_columns is overwritten from the parent class, because in GRPO we usually rely on + # additional columns to compute the reward + remove_unused_columns: bool | None = field( + default=False, + metadata={ + "help": "Whether to only keep the column 'prompt' in the dataset. If you use a custom reward function " + "that requires any column other than 'prompts' and 'completions', you should keep this to `False`." + }, + ) + num_generations: int | None = field( + default=8, + metadata={ + "help": "Number of generations to sample. The effective batch size (num_processes * per_device_batch_size " + "* gradient_accumulation_steps) must be evenly divisible by this value." + }, + ) + num_generations_eval: int | None = field( + default=None, + metadata={ + "help": "Number of generations to sample during evaluation. This allows using fewer generations during " + "evaluation to save computation. If `None`, uses the value of `num_generations`." + }, + ) + max_completion_length: int | None = field( + default=256, + metadata={"help": "Maximum length of the generated completion."}, + ) + ds3_gather_for_generation: bool = field( + default=True, + metadata={ + "help": "This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for " + "generation, improving generation speed. However, disabling this option allows training models that " + "exceed the VRAM capacity of a single GPU, albeit at the cost of slower generation. Disabling this option " + "is not compatible with vLLM generation." + }, + ) + shuffle_dataset: bool | None = field( + default=True, + metadata={"help": "Whether to shuffle the training dataset."}, + ) + pad_to_multiple_of: int | None = field( + default=None, + metadata={"help": "If set, the prompts ids and completions ids will be padded to a multiple of this value."}, + ) + + # Parameters that control generation + generation_batch_size: int | None = field( + default=None, + metadata={ + "help": "Batch size to use for generation. If `None`, it defaults to the effective training batch size: " + "`per_device_train_batch_size * num_processes * steps_per_generation`." + }, + ) + steps_per_generation: int | None = field( + default=None, + metadata={"help": "Number of steps per generation. If `None`, it defaults to `gradient_accumulation_steps`."}, + ) + temperature: float = field( + default=1.0, + metadata={"help": "Temperature for sampling. The higher the temperature, the more random the completions."}, + ) + top_p: float = field( + default=1.0, + metadata={ + "help": "Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. " + "Set to 1.0 to consider all tokens." + }, + ) + top_k: int = field( + default=0, + metadata={ + "help": "Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, " + "top-k-filtering is disabled and all tokens are considered." + }, + ) + min_p: float | None = field( + default=None, + metadata={ + "help": "Minimum token probability, which will be scaled by the probability of the most likely token. It " + "must be a value between 0.0 and 1.0. Typical values are in the 0.01-0.2 range." + }, + ) + generation_kwargs: dict | None = field( + default=None, + metadata={ + "help": "Additional keyword arguments to pass to `GenerationConfig` (if using transformers) or " + "`SamplingParams` (if using vLLM) when sampling completions. This can be used to further customize the " + "generation behavior, such as setting `suppress_tokens`, `num_beams`, etc. If it contains keys that " + "conflict with the other generation parameters (like `min_p`, `top_p`, etc.), they will override them." + }, + ) + chat_template_kwargs: dict | None = field( + default=None, + metadata={ + "help": "Additional keyword arguments to pass to the `apply_chat_template` function when generating " + "completions." + }, + ) + repetition_penalty: float = field( + default=1.0, + metadata={ + "help": "Float that penalizes new tokens based on whether they appear in the prompt and the generated " + "text so far. Values > 1.0 encourage the model to use new tokens, while values < 1.0 encourage the model " + "to repeat tokens." + }, + ) + cache_implementation: str | None = field( + default=None, + metadata={"help": "Implementation of the cache method for faster generation when use_vllm is set to False."}, + ) + + # Parameters that control generation acceleration powered by vLLM + use_vllm: bool = field( + default=False, + metadata={ + "help": "Whether to use vLLM for generating completions. If set to `True`, the trainer will use vLLM for " + "generation instead of the default model.generate(). Requires `vllm` to be installed." + }, + ) + vllm_mode: str = field( + default="colocate", + metadata={ + "help": "Mode to use for vLLM integration when `use_vllm` is set to `True`. Must be one of `'server'` or " + "`'colocate'`. `'server'`: The trainer will send generation requests to a separate vLLM server. Make sure " + "a TRL vLLM server is running (start with `trl vllm-serve`). `'colocate'`: vLLM will run in the same " + "process and share the training GPUs. This avoids the need for a separate server but may cause resource " + "contention with training." + }, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={ + "help": "Model implementation to use for vLLM. Must be one of `transformers` or `vllm`. `transformers`: " + "Use the `transformers` backend for model implementation. `vllm`: Use the `vllm` library for " + "model implementation." + }, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={ + "help": "Enable vLLM sleep mode to offload weights/cache during the optimizer step. Keeps GPU memory " + "usage low, but waking the engine adds host–device transfer latency." + }, + ) + vllm_structured_outputs_regex: str | None = field( + default=None, + metadata={"help": "Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled."}, + ) + + # Parameters that control the vLLM server (only used when `vllm_mode` is `"server"`) + vllm_server_base_url: str | None = field( + default=None, + metadata={ + "help": "Base URL for the vLLM server (e.g., 'http://localhost:8000'). If provided, `vllm_server_host` " + "and `vllm_server_port` are ignored." + }, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": "Host of the vLLM server to connect to. Ignored if vllm_server_base_url is provided."}, + ) + vllm_server_port: int = field( + default=8000, + metadata={"help": "Port of the vLLM server to connect to. Ignored if vllm_server_base_url is provided."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={ + "help": "Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up " + "after the timeout, a `ConnectionError` is raised." + }, + ) + vllm_group_port: int = field( + default=51216, + metadata={ + "help": "Port number for the weight update group. This is used to communicate with the vLLM server. " + "Unless the port is occupied, there is no need to change it.", + }, + ) + + # Parameters that control colocated vLLM execution (only used when `vllm_mode` is `"colocate"`) + vllm_gpu_memory_utilization: float = field( + default=0.3, + metadata={ + "help": "Control the GPU memory utilization for vLLM. This setting only applies when `vllm_mode` is set " + "to `'colocate'`. If you are using `vllm_mode='server'`, this parameter must be passed separately when " + "launching the vLLM server via the `--vllm_gpu_memory_utilization` flag." + }, + ) + vllm_max_model_length: int | None = field( + default=None, + metadata={ + "help": "Context window for vLLM. Set it to at least the maximum prompt length in the dataset plus " + "`max_completion_length`; if omitted, it is inferred from the model config." + }, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={ + "help": "Control the tensor parallel size for vLLM. This setting only applies when `vllm_mode` is set " + "to `'colocate'`. If you are using `vllm_mode='server'`, this parameter must be passed separately when " + "launching the vLLM server via the `--vllm_tensor_parallel_size` flag." + }, + ) + + # Parameters that control the training + beta: float = field( + default=0.0, + metadata={ + "help": "KL coefficient. If `0.0` (default), the reference model is not loaded, reducing memory usage and " + "improving training speed. [DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement " + "learning](https://huggingface.co/papers/2501.12948) use a value of `0.001`." + }, + ) + num_iterations: int = field( + default=1, + metadata={"help": "Number of iterations per batch (denoted as μ in the algorithm)."}, + ) + epsilon: float = field( + default=0.2, + metadata={"help": "Epsilon value for clipping."}, + ) + delta: float | None = field( + default=None, + metadata={ + "help": "Enables the upper clipping bound in two-sided GRPO loss when set to a float. If `None` " + "(default), standard GRPO clipping is used. Recommended to be greater than `1 + ε` when enabled. This " + "method is introduced in the [INTELLECT-2 tech report](https://huggingface.co/papers/2505.07291)." + }, + ) + epsilon_high: float | None = field( + default=None, + metadata={ + "help": "Upper-bound epsilon value for clipping. If not specified, it defaults to the same value as the " + "lower-bound specified in argument `epsilon`. Paper DAPO recommends `0.28`. " + "When used with `loss_type='cispo'`, this corresponds to the ε_max param specified in the" + "[ScaleRL paper]https://huggingface.co/papers/2510.13786) and the recommended value is `5.0`." + }, + ) + sapo_temperature_neg: float = field( + default=1.05, + metadata={ + "help": "Temperature for tokens with non-positive advantage scores used in the `sapo` loss function. " + "This parameter is introduced in the [Soft Adaptive Policy Optimization " + "paper](https://huggingface.co/papers/2511.20347)." + }, + ) + sapo_temperature_pos: float = field( + default=1.0, + metadata={ + "help": "Temperature for tokens with positive advantage scores used in the `sapo` loss function. " + "This parameter is introduced in the [Soft Adaptive Policy Optimization " + "paper](https://huggingface.co/papers/2511.20347)." + }, + ) + vespo_k_pos: float = field( + default=2.0, + metadata={ + "help": "k parameter for positive advantages, it is the power exponent in the VESPO loss. Controls how " + "aggressively we down-weight samples with low importance weights (when the importance sampling ratio < 1)." + }, + ) + vespo_lambda_pos: float = field( + default=3.0, + metadata={ + "help": "lambda parameter for positive advantages, it is the decay factor in the VESPO loss. Controls " + "how aggressively we down-weight samples with high importance weights (when the importance sampling ratio " + "> 1)." + }, + ) + vespo_k_neg: float = field( + default=3.0, + metadata={ + "help": "k parameter for negative advantages, it is the power exponent in the VESPO loss. Controls how " + "aggressively we down-weight samples with low importance weights (when the importance sampling ratio < 1)." + }, + ) + vespo_lambda_neg: float = field( + default=2.0, + metadata={ + "help": "lambda parameter for negative advantages, it is the exponential decay factor in the VESPO loss. " + "Controls how aggressively we down-weight samples with high importance weights (when the importance " + "sampling ratio > 1)." + }, + ) + importance_sampling_level: str = field( + default="token", + metadata={ + "help": "Controls whether importance sampling ratios are computed at the `'token'` or `'sequence'` level. " + "`'token'` keeps the raw per-token log-probability ratios (one weight per token). `'sequence'` averages " + "the log-probability ratios across valid tokens to produce a single ratio per sequence. The GSPO paper " + "shows that sequence-level sampling often yields more stable training and better alignment with " + "sequence-level rewards." + }, + ) + reward_weights: list[float] | None = field( + default=None, + metadata={ + "help": "Weights for each reward function. Must match the number of reward functions. If `None`, all " + "rewards are weighted equally with weight `1.0`." + }, + ) + multi_objective_aggregation: str = field( + default="sum_then_normalize", + metadata={ + "help": "Method to aggregate multiple reward functions. Supported values are: " + "`'sum_then_normalize'` (default): First sums the weighted rewards from each reward function, then " + "applies reward scaling/normalization as specified by `scale_rewards` (see `scale_rewards` for details). " + "`'normalize_then_sum'`: First normalizes/scales each reward function across generations (within each " + "group), then sums the normalized rewards using the specified weights. The aggregated reward is then " + "normalized at the batch level when forming advantages. This is the suggested approach from the paper " + "GDPO: Group reward-Decoupled Normalization Policy Optimization for Multi-reward RL Optimization." + }, + ) + scale_rewards: str = field( + default="group", + metadata={ + "help": "Specifies the scaling strategy for rewards. Supported values are: " + "`True` or `group'` (default): rewards are scaled by the standard deviation within each group, ensuring " + "unit variance within a group. " + "`'batch'`: rewards are scaled by the standard deviation across the entire batch, as recommended in the " + "PPO Lite paper. " + "`False` or `'none'`: no scaling is applied. The Dr. GRPO paper recommends not scaling rewards, as " + "scaling by the standard deviation introduces a question-level difficulty bias." + }, + ) + loss_type: str = field( + default="dapo", + metadata={ + "help": "Specifies the loss formulation to use. Supported values are 'grpo', 'dapo', 'bnpo', and " + "'dr_grpo'. " + "'grpo': Aggregates token-level losses by normalizing over sequence length. Not recommended due to length " + "bias—this approach tends to prefer shorter completions with positive advantages and longer ones with " + "negative advantages. " + "'dapo' (default): Aggregates token-level losses by normalizing with the number of active token in the " + "global accumulated batch. This method was introduced in the DAPO paper to eliminate length bias. " + "'dr_grpo': Aggregates token-level losses by normalizing with a global constant. This method was " + "introduced in the Dr. GRPO paper to eliminate length bias. The value of the constant corresponds to " + "`max_completion_length`. " + "'bnpo': Aggregates token-level losses by normalizing with the number of active token in the local batch. " + "Note that normalization is performed over the local batch only, so results may slightly vary depending " + "on the local batch size, despite a constant effective batch size. When using " + "`per_device_train_batch_size==1`, the loss is equivalent to the GRPO loss." + "'cispo': Clips the importance sampling weights instead of the advantage scaled importance weights. " + "The clipped weights are then multiplied with the advantages and policy model's log probs. " + "Individual token losses are aggregated by normalizing with the number of active tokens in " + "the global accumulated batch. This method was introduced in the " + "[MiniMax-M1 paper](https://huggingface.co/papers/2506.13585). " + "'sapo': Soft Adaptive Policy Optimization loss, as introduced in the " + "[Soft Adaptive Policy Optimization paper](https://huggingface.co/papers/2511.20347). " + "Replaces hard clipping with a smooth, temperature-controlled gate that adaptively attenuates " + "off-policy updates while preserving useful learning signals." + "'luspo': Length-Unbiased Sequence Policy Optimization loss. A sequence-level loss that scales each " + "sequence's loss by its length. This is a modification of GSPO and requires " + "`importance_sampling_level='sequence'`. Introduced in the [LUSPO " + "paper](https://huggingface.co/papers/2602.05261)." + "'vespo': Variational Sequence-Level Soft Policy Optimization. Replaces hard clipping with a smooth, " + "asymmetric Gamma weighting function applied directly to sequence-level importance weights. Introduced in " + "the [VESPO paper](https://huggingface.co/papers/2602.10693)." + }, + ) + mask_truncated_completions: bool = field( + default=False, + metadata={ + "help": "When enabled, truncated completions are excluded from the loss calculation, preventing them from " + "being incorrectly penalized and introducing noise during training. According to the DAPO paper, this is " + "a good practice for training stability." + }, + ) + sync_ref_model: bool = field( + default=False, + metadata={ + "help": "Whether to synchronize the reference model with the active model every `ref_model_sync_steps` " + "steps, using the `ref_model_mixup_alpha` parameter." + }, + ) + ref_model_mixup_alpha: float = field( + default=0.6, + metadata={ + "help": "α parameter from the TR-DPO paper, which controls the mix between the current policy and the " + "previous reference policy during updates. The reference policy is updated according to the equation: " + "`π_ref = α * π_θ + (1 - α) * π_ref_prev`. To use this parameter, you must set `sync_ref_model=True`." + }, + ) + ref_model_sync_steps: int = field( + default=512, + metadata={ + "help": "τ parameter from the TR-DPO paper, which determines how frequently the current policy is " + "synchronized with the reference policy. To use this parameter, you must set `sync_ref_model=True`." + }, + ) + top_entropy_quantile: float = field( + default=1.0, + metadata={ + "help": "ρ parameter from Beyond the 80/20 Rule. Keeps in the policy loss term only the top-ρ quantile of " + "tokens by entropy of the probability distribution at each sequence position, improving results. Range: " + "[0.0-1.0]. A value of `0.0` masks all but the highest entropy token; `1.0` keeps all tokens. The paper " + "recommends a value of `0.2`. If used with `mask_truncated_completions=True`, only tokens from " + "non-truncated completions are considered." + }, + ) + max_tool_calling_iterations: int | None = field( + default=None, + metadata={ + "help": "Maximum number of tool-calling turns when training an agent. If `None`, there is no limit and " + "generation stops when the model generates a response turn with no tool calls or when the total " + "response length reaches `max_model_length`." + }, + ) + vllm_importance_sampling_correction: bool = field( + default=True, + metadata={ + "help": "Whether to apply Importance Sampling (IS) to correct for the mismatch between vLLM " + "completion logprobs and recomputed training logprobs. If set to `False`, no IS is applied " + "regardless of `vllm_importance_sampling_mode`. When `True`, the selected mode determines how " + "IS ratios are computed and constrained." + }, + ) + vllm_importance_sampling_mode: str = field( + default="sequence_mask", + metadata={ + "help": "Specifies how Importance Sampling (IS) is performed when " + "vllm_importance_sampling_correction=True. Modes are defined along two orthogonal " + "dimensions: (1) constraint, which determines how to handle ratios above " + "vllm_importance_sampling_cap (C)—either truncation (clip from above, ρ ← min(ρ, C)) or " + "masking (set ratios above C to zero); and (2) granularity, which determines whether " + "ratios are computed per token or as a single sequence-level ratio applied to all tokens. " + "Supported options are: 'token_truncate', 'token_mask', 'sequence_truncate', and " + "'sequence_mask'." + }, + ) + vllm_importance_sampling_cap: float = field( + default=3.0, + metadata={ + "help": "Importance sampling cap C used by `vllm_importance_sampling_mode`. For '*_truncate' modes, " + "ratios are clipped from above at C. For '*_mask' modes, ratios larger than C are set to zero." + }, + ) + off_policy_mask_threshold: float | None = field( + default=None, + metadata={ + "help": "Threshold for off-policy sequence masking. If `None`, off-policy sequence masking is disabled. " + "When set, sequences with negative advantages and high KL divergence are masked out to stabilize " + "training. This parameter corresponds to the `delta` threshold in Equation 9 of the [DeepSeek-V3.2 " + "paper](https://huggingface.co/papers/2512.02556). It expects a positive value (e.g., 0.5)." + }, + ) + use_bias_correction_kl: bool = field( + default=False, + metadata={ + "help": "Whether to use the unbiased KL divergence estimator with importance sampling correction. This " + "corrects the KL divergence estimate by multiplying it with the importance sampling ratio. " + "This is described in the [DeepSeek-V3.2 paper](https://huggingface.co/papers/2512.02556)." + }, + ) + + # Parameters that control the logging + log_completions: bool = field( + default=False, + metadata={ + "help": "Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. If `rich` is " + "installed, it prints the sample. If `wandb` logging is enabled, it logs it to `wandb`." + }, + ) + num_completions_to_print: int | None = field( + default=None, + metadata={"help": "Number of completions to print with `rich`. If `None`, all completions are logged."}, + ) + log_unique_prompts: bool = field( + default=False, + metadata={ + "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all " + "prompts are logged." + }, + ) + log_completions_hub_repo: str | None = field( + default=None, + metadata={ + "help": "Hugging Face Hub repository to save the completions. Should be a complete repository name like " + "`'username/reponame'` or `'orgname/reponame'`, or just `'reponame'` in which case the repository will " + "be created in the currently-logged-in Hugging Face user's namespace. Note that this repository will be " + "public unless you set `hub_private_repo=True` or your organization's default is to create private " + "repositories." + }, + ) + + # Deprecated parameters + use_transformers_paged: bool = field( + default=False, + metadata={ + "help": "Deprecated. It will be replaced by `transformers` continuous batching support in an upcoming " + "release." + }, + ) + + def __post_init__(self): + super().__post_init__() + + if self.use_transformers_paged: + warnings.warn( + "`use_transformers_paged` is deprecated and will be removed in v2.0.0. It will be replaced by " + "`transformers` continuous batching support in an upcoming release.", + FutureWarning, + stacklevel=3, + ) + + self.scale_rewards = {True: "group", False: "none"}.get(self.scale_rewards, self.scale_rewards) + + if self.log_completions_hub_repo is not None and not self.log_completions: + raise ValueError( + "log_completions_hub_repo is set, but log_completions is False. Enable log_completions to upload " + "completions to the Hub, or unset log_completions_hub_repo." + ) + + num_processes = self.world_size + # The current default effective batch size + if self.generation_batch_size is None and self.steps_per_generation is None: + self.steps_per_generation = self.gradient_accumulation_steps + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + elif self.generation_batch_size is not None and self.steps_per_generation is None: + # Just ensure the value is divisible by the global batch size + if self.generation_batch_size % (self.per_device_train_batch_size * num_processes) != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by the global batch size " + f"({self.per_device_train_batch_size * num_processes})." + ) + self.steps_per_generation = self.generation_batch_size // ( + self.per_device_train_batch_size * num_processes + ) + elif self.generation_batch_size is None and self.steps_per_generation is not None: + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + else: + raise ValueError( + "'generation_batch_size' and 'steps_per_generation' can not be both configured at the same time" + ) + + if self.do_eval and self.eval_strategy != "no": + # Determine the number of generations to use for evaluation + num_generations = self.num_generations_eval or self.num_generations + + # Just ensure the value is divisible by the global batch size + if (self.per_device_eval_batch_size * num_processes) % num_generations != 0: + raise ValueError( + f"The global eval batch size ({self.per_device_eval_batch_size} * {num_processes}) must be " + f"divisible by the number of generations used for evaluation ({num_generations})." + ) + + # The generation batch must contain full prompt groups (no partials), so it must be divisible by + # num_generations. + if self.generation_batch_size % self.num_generations != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by num_generations " + f"({self.num_generations})." + ) + + if self.num_generations < 2: + raise ValueError( + "GRPO requires at least 2 generations per prompt to calculate the advantages. You provided " + f"{self.num_generations}, which is less than the minimum required." + ) + + if self.delta is not None and self.use_liger_kernel: + raise ValueError("Liger kernel does not support two-sided GRPO loss yet.") diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/grpo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/grpo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..0f400e14fcd0a58019bbea2601478f830940bfd7 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/grpo_trainer.py @@ -0,0 +1,2713 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +import atexit +import copy +import importlib.resources as pkg_resources +import inspect +import math +import os +import sys +import textwrap +import time +import warnings +from collections import defaultdict, deque +from collections.abc import Callable +from contextlib import nullcontext +from pathlib import Path +from typing import Any, Protocol + +import numpy as np +import pandas as pd +import torch +import torch.utils.data +import transformers +from accelerate.logging import get_logger +from accelerate.utils import gather, gather_object, is_peft_model, set_seed +from datasets import Dataset, IterableDataset +from huggingface_hub import CommitScheduler, DatasetCard, DatasetCardData, create_repo +from packaging.version import Version +from torch import nn +from torch.distributed.fsdp import FullyShardedDataParallel as FSDP +from torch.utils.data import Sampler +from transformers import ( + AutoModelForSequenceClassification, + AutoProcessor, + AutoTokenizer, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + is_trackio_available, + is_wandb_available, +) +from transformers.utils import is_peft_available, is_rich_available + +from ..chat_template_utils import ( + add_response_schema, + get_training_chat_template, + is_chat_template_prefix_preserving, + parse_response, + supports_tool_calling, +) +from ..data_utils import apply_chat_template, is_conversational, prepare_multimodal_messages +from ..extras.profiling import profiling_context, profiling_decorator +from ..generation.vllm_generation import VLLMGeneration +from ..import_utils import is_jmespath_available, is_liger_kernel_available +from ..models import prepare_deepspeed, prepare_fsdp, unwrap_model_for_generation +from ..models.utils import _ForwardRedirection, disable_gradient_checkpointing +from .base_trainer import _BaseTrainer +from .callbacks import SyncRefModelCallback +from .grpo_config import GRPOConfig +from .utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + entropy_from_logits, + get_config_model_id, + identity, + nanmax, + nanmin, + nanstd, + pad, + print_prompt_completions_sample, + selective_log_softmax, + shuffle_sequence_dict, + shutdown_event_loop_in_daemon, + split_pixel_values_by_grid, + split_tensor_dict, + start_event_loop_in_daemon, + unsplit_pixel_values_by_grid, + use_adapter, +) + + +if is_peft_available(): + from peft import PeftConfig, PeftModel, get_peft_model + +if is_liger_kernel_available(): + from liger_kernel.chunked_loss import LigerFusedLinearGRPOLoss + + +if is_wandb_available(): + import wandb + +if is_trackio_available(): + import trackio + + +logger = get_logger(__name__) + +# A reward function can be a string, interpreted as a model ID and loaded as a pretrained model, a pretrained model, or +# a callable that returns a list of floats (the rewards). The callable receives prompts, completions, and additional +# arguments from the trainer (refer to the trainer's source for details). To ensure forward compatibility, it should +# accept **kwargs. +RewardFunc = str | PreTrainedModel | Callable[..., list[float | None]] + +# What we call a rollout function is a callable that takes prompts (list) and the trainer instance as parameters and +# returns a dict of generation results. Those results must include "prompt_ids", "completion_ids", and "logprobs" +# fields. Any extra fields (per-completion) are forwarded to the reward functions. +RolloutFunc = Callable[[list[str], "GRPOTrainer"], dict[str, Any]] + + +class _SupportsReset(Protocol): + def reset(self, **kwargs) -> str | None: ... + + +EnvironmentFactory = Callable[[], _SupportsReset] + + +class GRPOTrainer(_BaseTrainer): + """ + Trainer for the Group Relative Policy Optimization (GRPO) method. This algorithm was initially proposed in the + paper [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language + Models](https://huggingface.co/papers/2402.03300). + + Example: + + ```python + from trl import GRPOTrainer + from trl.rewards import accuracy_reward + from datasets import load_dataset + + dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + + trainer = GRPOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + reward_funcs=accuracy_reward, + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + reward_funcs (`RewardFunc | list[RewardFunc]`): + Reward functions to be used for computing the rewards. To compute the rewards, we call all the reward + functions with the prompts and completions and sum the rewards. Can be either: + + - A single reward function, such as: + - A string: The *model ID* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForSequenceClassification.from_pretrained`] with `num_labels=1` and the + keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object: Only sequence classification models are supported. + - A custom reward function: The function is provided with the prompts and the generated completions, + plus any additional columns in the dataset. It should return a list of rewards. Custom reward + functions can be either synchronous or asynchronous and can also return `None` when the reward is + not applicable to those samples. This is useful for multi-task training where different reward + functions apply to different types of samples. When a reward function returns `None` for a sample, + that reward function is excluded from the reward calculation for that sample. For more details, see + [Using a custom reward + function](#using-a-custom-reward-function). + + The trainer's state is also passed to the reward function. The trainer's state is an instance of + [`~transformers.TrainerState`] and can be accessed by accessing the `trainer_state` argument to the + reward function's signature. + - A list of reward functions, where each item can independently be any of the above types. Mixing different + types within the list (e.g., a string model ID and a custom reward function) is allowed. + args ([`GRPOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. It must include a column `"prompt"`. Any additional columns in the dataset is + ignored. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. The padding side must be set to "left". If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoProcessor.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + reward_processing_classes ([`~transformers.PreTrainedTokenizerBase`] or `list[PreTrainedTokenizerBase]`, *optional*): + Processing classes corresponding to the reward functions specified in `reward_funcs`. Can be either: + + - A single processing class: Used when `reward_funcs` contains only one reward function. + - A list of processing classes: Must match the order and length of the reward functions in `reward_funcs`. + If set to `None`, or if an element of the list corresponding to a [`~transformers.PreTrainedModel`] is + `None`, the tokenizer for the model is automatically loaded using + [`~transformers.AutoTokenizer.from_pretrained`]. For elements in `reward_funcs` that are custom reward + functions (not [`~transformers.PreTrainedModel`]), the corresponding entries in `reward_processing_classes` + are ignored. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + tools (list of `Callable`, *optional*): + A list of callable tool functions (sync or async) that the model can invoke during generation. Each tool + should be a standard Python function with properly type-hinted arguments and return values, and a + Google-style docstring describing its purpose, arguments, and return value. For more details, see: + https://huggingface.co/docs/transformers/en/chat_extras#passing-tools. The model uses the function's name, + type hints, and docstring to determine how to call it. Ensure that the model's chat template supports tool + use and that it has been fine-tuned for tool calling. + rollout_func (`RolloutFunc`, *optional*): + Function to use for generating completions. It receives the list of prompts allocated to the current + process and the trainer instance. It must return a dict with `"prompt_ids"`, `"completion_ids"`, and + `"logprobs"` fields, and can optionally return `"logprob_token_ids"` (same shape as `"logprobs"`). Any + other fields are forwarded to the reward functions. The function receives the raw per-process prompt slice + with no duplication; it is responsible for returning the correct number of completions per prompt (see + `num_generations` / `num_generations_eval` on the trainer). This feature is experimental and may change or + be removed at any time without prior notice. + environment_factory (`EnvironmentFactory`, *optional*): + A callable that creates and returns an environment instance. The environment class should define methods + that can be invoked as tools during generation. Each method should comply with the same requirements as the + `tools` described above. If `environment_factory` is provided, an instance of the environment is created + for each generation in the batch, allowing for parallel and independent interactions. The environment must + also implement a callable `reset` method that can be used to reset state between generations. The `reset` + method should return either `None` or a string: when it returns a string, that string is appended to the + last user message before generation. This feature is experimental and may change or be removed at any time + without prior notice. + """ + + _tag_names = ["trl", "grpo"] + _name = "GRPO" + _paper = { + "title": "DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models", + "id": "2402.03300", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @article{shao2024deepseekmath, + title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}}, + author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo}, + year = 2024, + eprint = {arXiv:2402.03300}, + }"""), + } + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + reward_funcs: RewardFunc | list[RewardFunc], + args: GRPOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: "PeftConfig | None" = None, + tools: list[Callable] | None = None, + rollout_func: RolloutFunc | None = None, + environment_factory: EnvironmentFactory | None = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = GRPOConfig(f"{model_name}-GRPO") + + # Model + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the `GRPOConfig`, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + + # Some models (SmolVLM/Idefics3) don't support `logits_to_keep` argument and error out if we pass it + # Inspect the forward method before we wrap the model with PEFT + self.model_kwarg_keys = ( + inspect.signature(model.forward).parameters.keys() + if not hasattr(model, "get_base_model") + else inspect.signature(model.get_base_model().forward).parameters.keys() + ) + + # Processing class + if processing_class is None: + processing_class = AutoProcessor.from_pretrained( + get_config_model_id(model.config), truncation_side="left", padding_side="left" + ) + + # Handle pad token for processors or tokenizers + if isinstance(processing_class, ProcessorMixin): + self._tokenizer = processing_class.tokenizer + self._is_vlm = True + elif isinstance(processing_class, PreTrainedTokenizerBase): + self._tokenizer = processing_class + self._is_vlm = False + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if self._tokenizer.pad_token is None: + self._tokenizer.pad_token = self._tokenizer.eos_token + + # Resolve vision placeholder token IDs once. Used by the forward pass to rebuild mm_token_type_ids + # when tool responses inject images into the completion (see _generate forward_kwargs block). + self._image_pad_token_id = None + self._video_pad_token_id = None + if self._is_vlm: + for candidate in ("<|image_pad|>", "<|image|>"): + tid = self._tokenizer.convert_tokens_to_ids(candidate) + if tid != self._tokenizer.unk_token_id: + self._image_pad_token_id = tid + break + tid = self._tokenizer.convert_tokens_to_ids("<|video_pad|>") + if tid != self._tokenizer.unk_token_id: + self._video_pad_token_id = tid + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + if is_peft_available() and is_peft_model(model) and args.beta != 0.0: + # If the model is a PEFT model with a pretrained adapter, we need to create a "ref" adapter that is a copy + # of the "default" adapter, so that we can use it as the reference model during GRPO training. + model.add_adapter("ref", model.peft_config["default"]) + for name, param in model.named_parameters(): + if ".default." in name: + ref_name = name.replace(".default.", ".ref.") + ref_param = model.get_parameter(ref_name) + ref_param.data.copy_(param.data) + + # Create PEFT model + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # When using gradient checkpointing with PEFT, we need to enable input gradients. transformers.Trainer normally + # handles this, but a bug currently prevents it; see https://github.com/huggingface/transformers/issues/42489 + if is_peft_available() and is_peft_model(model) and args.gradient_checkpointing: + model.enable_input_require_grads() + + # When using QLoRA, the PEFT adapter weights are converted to bf16 to follow the recommendations from the + # original paper (see https://huggingface.co/papers/2305.14314, paragraph 3). Normally, this can be done by + # passing `autocast_adapter_dtype=False` to `get_peft_model`, but this option is not yet supported for + # quantized models. See: https://github.com/huggingface/peft/issues/2889 + # Non-quantized models do not have the `is_loaded_in_{8,4}bit` attributes, whereas quantized models do + if getattr(model, "is_loaded_in_4bit", False) or getattr(model, "is_loaded_in_8bit", False): + for param in model.parameters(): + if param.requires_grad: + param.data = param.data.to(torch.bfloat16) + + # Reward functions + if not isinstance(reward_funcs, list): + reward_funcs = [reward_funcs] + self.reward_func_names = [] + for i, reward_func in enumerate(reward_funcs): + if isinstance(reward_func, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + reward_funcs[i] = AutoModelForSequenceClassification.from_pretrained( + reward_func, num_labels=1, **model_init_kwargs + ) + if isinstance(reward_funcs[i], nn.Module): # Use Module over PretrainedModel for compat w/ compiled models + self.reward_func_names.append(get_config_model_id(reward_funcs[i].config).split("/")[-1]) + else: + self.reward_func_names.append(reward_funcs[i].__name__) + self.reward_funcs = reward_funcs + + # Reward weights + if args.reward_weights is not None: + if len(args.reward_weights) != len(reward_funcs): + raise ValueError( + f"Number of reward weights ({len(args.reward_weights)}) must match number of reward " + f"functions ({len(reward_funcs)})" + ) + self.reward_weights = torch.tensor(args.reward_weights, dtype=torch.float32) + else: + self.reward_weights = torch.ones(len(reward_funcs), dtype=torch.float32) + + # Reward processing class + if reward_processing_classes is None: + reward_processing_classes = [None] * len(reward_funcs) + elif not isinstance(reward_processing_classes, list): + reward_processing_classes = [reward_processing_classes] + if len(reward_processing_classes) != len(reward_funcs): + raise ValueError( + f"The number of reward processing classes ({len(reward_processing_classes)}) must match the number of " + f"reward functions ({len(reward_funcs)})." + ) + + for i, (reward_processing_class, reward_func) in enumerate( + zip(reward_processing_classes, reward_funcs, strict=True) + ): + if isinstance(reward_func, PreTrainedModel): + if reward_processing_class is None: + reward_processing_class = AutoTokenizer.from_pretrained(get_config_model_id(reward_func.config)) + if reward_processing_class.pad_token_id is None: + reward_processing_class.pad_token = reward_processing_class.eos_token + # The reward model computes the reward for the latest non-padded token in the input sequence. + # So it's important to set the pad token ID to the padding token ID of the processing class. + reward_func.config.pad_token_id = reward_processing_class.pad_token_id + reward_processing_classes[i] = reward_processing_class + + self.reward_processing_classes = reward_processing_classes + + # Rollout function + if rollout_func is not None and os.environ.get("TRL_EXPERIMENTAL_SILENCE", "0") != "1": + warnings.warn( + "You are using 'rollout_func', which is an experimental feature. This API may change or be removed at " + "any time without prior notice. Silence this warning by setting environment variable " + "TRL_EXPERIMENTAL_SILENCE=1.", + UserWarning, + stacklevel=2, + ) + self.rollout_func = rollout_func + if environment_factory is not None and os.environ.get("TRL_EXPERIMENTAL_SILENCE", "0") != "1": + warnings.warn( + "You are using 'environment_factory', which is an experimental feature. This API may change or be " + "removed at any time without prior notice. Silence this warning by setting environment variable " + "TRL_EXPERIMENTAL_SILENCE=1.", + UserWarning, + stacklevel=2, + ) + + # Tools + if tools: + if not Version(transformers.__version__) >= Version("5.0.0"): + raise ImportError( + "Using tools with GRPOTrainer requires transformers version 5.0.0 or higher. Please upgrade " + "transformers with `pip install --upgrade transformers` to use this feature." + ) + if environment_factory: + if not Version(transformers.__version__) >= Version("5.2.0"): + raise ImportError( + "Using `environment_factory` with GRPOTrainer requires transformers version 5.2.0 or higher. " + "Please install transformers from the main branch with `pip install " + "git+https://github.com/huggingface/transformers.git@main` to use this feature." + ) + if tools or environment_factory: + if not is_jmespath_available(): + raise ImportError( + "Using tools with GRPOTrainer requires the jmespath library for response parsing. Please install " + "it with `pip install jmespath` to use this feature." + ) + if not supports_tool_calling(processing_class): + raise ValueError( + "The provided chat template does not support tool calling. The template must be able to render a " + "full tool-calling conversation (user -> assistant with tool_calls -> tool)." + ) + + # Create the environments and extract their methods to be used as tools. We create one environment per rollout + generation_batch_size = args.per_device_train_batch_size * args.steps_per_generation + if environment_factory is not None: + self.environments = [environment_factory() for _ in range(generation_batch_size)] + environment_methods = [[] for _ in range(generation_batch_size)] + for i, environment in enumerate(self.environments): + has_reset = False + for name, member in inspect.getmembers(environment, predicate=inspect.ismethod): + if name == "reset": + has_reset = True + elif not name.startswith("_"): + environment_methods[i].append(member) + if not has_reset: + raise ValueError( + "Each environment instance returned by `environment_factory` must define a callable `reset` " + ) + else: + self.environments = None + + tools = tools or [] + self._sync_tool_dicts = [{} for _ in range(generation_batch_size)] + self._async_tool_dicts = [{} for _ in range(generation_batch_size)] + for i in range(generation_batch_size): + for tool in tools + (environment_methods[i] if self.environments is not None else []): + if inspect.iscoroutinefunction(tool): + self._async_tool_dicts[i][tool.__name__] = tool + else: + self._sync_tool_dicts[i][tool.__name__] = tool + + self.tools = tools + (environment_methods[0] if self.environments is not None else []) + + # Check for async functions to start an event loop on a daemon thread + self._has_async_funcs = any(inspect.iscoroutinefunction(func) for func in self.reward_funcs + self.tools) + + if self._has_async_funcs: + self.async_loop_thread, self.async_loop, self.async_loop_ready_event = start_event_loop_in_daemon( + name="GRPOTrainer-AsyncLoop" + ) + # wait until the event loop is running in the daemon thread + self.async_loop_ready_event.wait() + atexit.register(shutdown_event_loop_in_daemon, self.async_loop_thread, self.async_loop) + + # At the time of initial implementation, most tokenizers do not have built-in support for response schemas. + # While waiting for broader adoption, we provide this utility function to manually set the response schema for + # known chat templates. `response_schema` lives on the (inner) tokenizer, since `parse_response` is a tokenizer + # method that reads `self.response_schema`. + if self.tools and getattr(self._tokenizer, "response_schema", None) is None: + processing_class = add_response_schema(processing_class) + # In multi-turn training, the chat template *must* be prefix-preserving. If the tokenizer's original template + # isn't, we replace it at initialization with a training-safe, prefix-preserving template. + if self.tools and not is_chat_template_prefix_preserving(processing_class): + self.chat_template = get_training_chat_template(processing_class) + else: + self.chat_template = None + + # Training arguments + self.max_completion_length = args.max_completion_length # = |o_i| in the GRPO paper + self.num_generations = args.num_generations # = G in the GRPO paper + self.max_tool_calling_iterations = args.max_tool_calling_iterations or sys.maxsize + self.num_generations_eval = args.num_generations_eval or self.num_generations + self.chat_template_kwargs = args.chat_template_kwargs or {} + self.temperature = args.temperature + self.top_p = args.top_p + self.top_k = args.top_k + self.min_p = args.min_p + self.repetition_penalty = args.repetition_penalty + self.use_transformers_paged = args.use_transformers_paged + self.pad_to_multiple_of = args.pad_to_multiple_of + self.use_vllm = args.use_vllm + self.vllm_mode = args.vllm_mode + self.vllm_gpu_memory_utilization = args.vllm_gpu_memory_utilization # only applies to colocation mode + self.vllm_tensor_parallel_size = args.vllm_tensor_parallel_size # only applies to colocation mode + self.vllm_importance_sampling_correction = args.vllm_importance_sampling_correction + self.vllm_importance_sampling_mode = args.vllm_importance_sampling_mode + self.vllm_importance_sampling_cap = args.vllm_importance_sampling_cap + self.use_liger_kernel = args.use_liger_kernel + self.loss_type = args.loss_type + self.multi_objective_aggregation = args.multi_objective_aggregation + self.scale_rewards = args.scale_rewards + self.importance_sampling_level = args.importance_sampling_level + self.off_policy_mask_threshold = args.off_policy_mask_threshold + if self.use_liger_kernel and self.off_policy_mask_threshold is not None: + raise ValueError("Liger kernel does not support off-policy sequence masking yet.") + self.mask_truncated_completions = args.mask_truncated_completions + self.top_entropy_quantile = args.top_entropy_quantile + if self.use_liger_kernel and self.top_entropy_quantile < 1.0: + raise NotImplementedError( + "Liger Kernels don't currently support masking token positions based on entropy." + ) + if self.use_liger_kernel and self.importance_sampling_level not in ("token", "sequence"): + raise ValueError( + f"Unknown importance sampling level: {self.importance_sampling_level}. " + "Possible values are 'token' and 'sequence'." + ) + + # Datasets + self.shuffle_dataset = args.shuffle_dataset + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif ( + isinstance(train_dataset, IterableDataset) + or isinstance(eval_dataset, IterableDataset) + or ( + isinstance(eval_dataset, dict) and any(isinstance(ds, IterableDataset) for ds in eval_dataset.values()) + ) + ): + # See https://github.com/huggingface/trl/issues/3213 + raise NotImplementedError( + "Iterable datasets are not yet supported in GRPOTrainer. Please use a standard dataset instead." + ) + + if args.loss_type == "luspo" and args.importance_sampling_level != "sequence": + logger.warning( + "When using `'luspo'` loss, `importance_sampling_level` should be set to `'sequence'` to mirror the " + "paper's setup." + ) + + if args.loss_type == "vespo" and args.importance_sampling_level != "token": + logger.warning( + "VESPO computes sequence-level importance weights internally. `importance_sampling_level` should be " + "set to `'token'` (the default)." + ) + + if self.loss_type == "vespo" and self.use_vllm and self.vllm_importance_sampling_correction: + if self.vllm_importance_sampling_mode not in ["token_truncate", "token_mask"]: + raise ValueError( + f"VESPO loss requires `vllm_importance_sampling_mode` to be either 'token_truncate' or " + f"'token_mask'. Got: {self.vllm_importance_sampling_mode}." + ) + + # Multi-step + self.num_iterations = args.num_iterations # = 𝜇 in the GRPO paper + self.epsilon_low = args.epsilon + self.epsilon_high = args.epsilon_high if args.epsilon_high is not None else args.epsilon + # Tracks the number of iterations (forward + backward passes), including those within a grad accum cycle + self._step = 0 + # Buffer the batch to reuse generated outputs across multiple updates. For more details, see + # `_get_train_sampler` and `_prepare_inputs`. + self._buffered_inputs = None + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=identity, # No data collation is needed in GRPO + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + callbacks=callbacks, + optimizers=optimizers, + # In Trainer, `training_step` scales the loss by `gradient_accumulation_steps` only if `compute_loss_func` + # is None. For DAPO, loss scaling instead depends on the total number of completions tokens across the + # global accumulated batch. To control scaling ourselves, we must disable Trainer’s built-in scaling. The + # simplest (though a bit hacky) way is to set `compute_loss_func` to any non-None value, which bypasses + # that behavior without rewriting `training_step`. + compute_loss_func="non-None value to disable scaling", + ) + + # Reference model + self.beta = args.beta + if self.beta == 0.0: + # If beta is 0.0, the reference model is not needed + self.ref_model = None + elif is_peft_model(model): + # If PEFT is used, the reference model is not needed since the adapter can be disabled + # to revert to the initial model. + self.ref_model = None + else: + # For deepspeed, fsdp or non-distributed models, create a reference model from scratch + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if self.args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + self.ref_model = create_model_from_path(get_config_model_id(self.model.config), **model_init_kwargs) + + # Disable dropout in the models + if args.disable_dropout: + disable_dropout_in_model(model) + if self.ref_model is not None: + disable_dropout_in_model(self.ref_model) + + # Cast LM Head To FP32 + if args.cast_lm_head_to_fp32: + + def _cast_lm_head_to_fp32(target_model: PreTrainedModel): + """Cast lm_head to fp32 while preserving embedding output dtype if tied.""" + + def cast_inputs_to_fp32(module, inputs): + # Preserve other positional args and kwargs untouched + if not inputs: + return inputs + return (inputs[0].to(torch.float32),) + inputs[1:] + + original_dtype_local = target_model.lm_head.weight.dtype + target_model.lm_head = target_model.lm_head.float() + target_model.lm_head.register_forward_pre_hook(cast_inputs_to_fp32) + + if target_model.config.tie_word_embeddings: + + def cast_outputs_to_original_dtype(module, args, output): + return output.to(original_dtype_local) + + # Only cast activations; weights are now fp32 (intentional for numerical stability of logits) + target_model.model.embed_tokens.register_forward_hook(cast_outputs_to_original_dtype) + + _cast_lm_head_to_fp32(model) + if self.ref_model is not None: + _cast_lm_head_to_fp32(self.ref_model) + + # Liger loss + if self.use_liger_kernel: + if not is_liger_kernel_available(): + raise ImportError( + "Liger is required to use `use_liger_kernel` as the GRPO loss. Run `pip install liger-kernel`." + ) + # redirect the model.module forward to the model forward to ensure pre-forward hooks are called + self._forward_redirection = _ForwardRedirection() + + self.liger_grpo_loss = LigerFusedLinearGRPOLoss( + beta=self.beta, + epsilon_low=self.epsilon_low, + epsilon_high=self.epsilon_high, + temperature=self.temperature, + use_ref_model=self.beta != 0.0, + loss_type=self.loss_type, + max_completion_length=self.max_completion_length, + importance_sampling_level=self.importance_sampling_level, + ) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + self._current_train_step_time = 0.0 + self.log_completions = args.log_completions + self.log_unique_prompts = args.log_unique_prompts + self.num_completions_to_print = args.num_completions_to_print + # Keep logs sized to the generation batch to record only outputs from the latest model update. + self._logs = { + "images": deque(maxlen=args.generation_batch_size), + "prompt": deque(maxlen=args.generation_batch_size), + "completion": deque(maxlen=args.generation_batch_size), + "rewards": defaultdict(lambda: deque(maxlen=args.generation_batch_size)), + "advantages": deque(maxlen=args.generation_batch_size), + "extra": defaultdict(lambda: deque(maxlen=args.generation_batch_size)), + } + # Buffers for user-logged data from reward functions, flushed after gathering + self._pending_extra_logs = defaultdict(list) + self._pending_metrics = defaultdict(list) + + # Ensure each process receives a unique seed to prevent duplicate completions when generating with + # transformers if num_generations exceeds per_device_train_batch_size. We could skip it if we use vLLM, but + # it's safer to set it in all cases. + set_seed(args.seed, device_specific=True) + + if self.use_vllm: + # Initialize vLLM generation backend + self.vllm_generation = VLLMGeneration( + model=self.model, + accelerator=self.accelerator, + is_fsdp_enabled=self.is_fsdp_enabled, + processing_class=self.processing_class, + # vLLM configuration + mode=args.vllm_mode, + structured_outputs_regex=args.vllm_structured_outputs_regex, + # Server mode configuration + server_base_url=args.vllm_server_base_url, + server_host=args.vllm_server_host, + server_port=args.vllm_server_port, + group_port=args.vllm_group_port, + server_timeout=args.vllm_server_timeout, + # Colocate mode configuration + tensor_parallel_size=args.vllm_tensor_parallel_size, + gpu_memory_utilization=args.vllm_gpu_memory_utilization, + max_model_length=args.vllm_max_model_length, + max_num_seqs=args.per_device_train_batch_size + * args.vllm_tensor_parallel_size + * args.steps_per_generation, + enable_sleep_mode=args.vllm_enable_sleep_mode, + model_impl=args.vllm_model_impl, + # Generation configuration + repetition_penalty=self.repetition_penalty, + temperature=self.temperature, + top_p=self.top_p, + top_k=self.top_k, + min_p=self.min_p, + max_completion_length=self.max_completion_length, + logprobs=0, # we only need the generated token logprobs for the importance sampling correction + generation_kwargs=args.generation_kwargs, + ) + self._last_loaded_step = -1 # tag to avoid useless loading during grad accumulation + else: + generation_kwargs = { + "max_new_tokens": self.max_completion_length, + "do_sample": True, + "pad_token_id": self._tokenizer.pad_token_id, + "bos_token_id": self._tokenizer.bos_token_id, + "eos_token_id": self._tokenizer.eos_token_id, + "temperature": self.temperature, + "top_p": self.top_p, + "top_k": self.top_k, + "min_p": self.min_p, + "repetition_penalty": self.repetition_penalty, + "cache_implementation": args.cache_implementation, + } + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + self.generation_config = GenerationConfig(**generation_kwargs, disable_compile=True) + # Keep training-specific generation kwargs to overwrite model's original generation config + self.generation_kwargs = generation_kwargs + + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + if self.ref_model is not None: + if self.is_deepspeed_enabled: + self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) + elif self.is_fsdp_enabled: + self.ref_model = prepare_fsdp(self.ref_model, self.accelerator) + else: + self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) + + if args.sync_ref_model: + if self.beta == 0.0: + raise ValueError( + "You passed `sync_ref_model=True` while `beta=0.0`, which means the reference model is not used " + "during training. Consequently, GRPOTrainer does not create a `ref_model` instance, and there is " + "nothing to synchronize. Please set `sync_ref_model=False`, or set `beta` to a non-zero value." + ) + if is_peft_model(model): + raise NotImplementedError( + "You passed `sync_ref_model=True` while using a PEFT model, which is currently not supported. " + "With PEFT, GRPOTrainer does not keep a separate reference model in memory; instead, it recovers " + "reference behavior by temporarily disabling the adapter. As a result, there is no standalone " + "`ref_model` instance to synchronize. Use `sync_ref_model=False`, or opt for full fine-tuning if " + "you need a synced reference model. If you need `sync_ref_model` to work with PEFT, please open a " + "feature request at https://github.com/huggingface/trl/issues." + ) + self.add_callback(SyncRefModelCallback(ref_model=self.ref_model, accelerator=self.accelerator)) + + for i, reward_func in enumerate(self.reward_funcs): + if isinstance(reward_func, PreTrainedModel): + if self.is_deepspeed_enabled: + self.reward_funcs[i] = prepare_deepspeed(reward_func, self.accelerator) + else: + # set device placement to True to make `prepare_model` move `reward_func` to device when using fsdp + self.reward_funcs[i] = self.accelerator.prepare_model( + reward_func, evaluation_mode=True, device_placement=True + ) + + if self.accelerator.is_main_process and self.log_completions: + os.makedirs(os.path.join(self.args.output_dir, "completions"), exist_ok=True) + if self.args.log_completions_hub_repo is not None: + repo_id = self.args.log_completions_hub_repo + create_repo(repo_id, private=self.args.hub_private_repo, repo_type="dataset", exist_ok=True) + template_path = pkg_resources.files("trl").joinpath("templates/completions_dataset_card.md") + card_data = DatasetCardData( + pretty_name="TRL Completion logs", + tags=["trl", "trl-logs", "completions"], + ) + card = DatasetCard.from_template( + card_data=card_data, + template_path=str(template_path), + repo_id=repo_id, + hub_model_id=self.args.hub_model_id, + ) + card.push_to_hub(repo_id) + self.commit_scheduler = CommitScheduler( + repo_id=repo_id, + repo_type="dataset", + folder_path=f"{self.args.output_dir}/completions", + every=2, # minutes + allow_patterns=["*.parquet"], + ) + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). In GRPOTrainer, we preprocess data, so using the model's signature columns doesn't + # work. Instead, we set them to the columns expected by the `training_step` method, hence the override. + if self._signature_columns is None: + self._signature_columns = ["prompt", "image", "images"] + + # This method overrides `Trainer.get_train_dataloader` to support our custom batching strategy. + # Instead of returning a standard per-step batch (i.e., `per_device_batch_size), our dataloader loads an + # *generation* batch (i.e., `per_device_batch_size × steps_per_generation`). This allows us to generate completions + # once every steps_per_generation step—rather than once per accumulation step—which is significantly more + # efficient. The only change from the original implementation is multiplying the batch size by + # `steps_per_generation`. Thus, `_prepare_inputs` is called with this *generation* batch, and it handles the + # splitting internally. + # Maintenance note: This method is a copy-paste of the original `Trainer.get_train_dataloader` with only one line + # modification. + def get_train_dataloader(self): + return self._get_dataloader( + dataset=self.train_dataset, + description="Training", + batch_size=self._train_batch_size * self.args.steps_per_generation, # < this is the change + sampler_fn=self._get_train_sampler, + is_training=True, + ) + + def _get_train_sampler(self, dataset: Dataset | None = None) -> Sampler: + # Returns a sampler that + # 1. ensures each prompt is repeated across multiple processes. This guarantees that identical prompts are + # distributed to different GPUs, allowing rewards to be computed and normalized correctly within each prompt + # group. Using the same seed across processes ensures consistent prompt assignment, preventing discrepancies + # in group formation. + # 2. repeats the batch multiple times to allow reusing generations across multiple updates. Refer to + # _prepare_inputs to see how the generations are stored and reused. + + # In the following figure, the values are the prompt indices. The first row shows the first sampled batch, the + # second row shows the second sampled batch, and so on. + # + # | GPU 0 | GPU 1 | + # + # global_step step <-───> num_generations=2 + # <-───────> per_device_train_batch_size=3 + # grad_accum ▲ ▲ 0 0 0 0 1 1 2 2 <- Generate for the first `steps_per_generation` (prompts 0 to 11); store the completions; use the first slice to compute the loss + # =2 ▼ | 0 1 3 3 4 4 5 5 <- Take the stored generations and use the second slice to compute the loss + # | + # | 1 2 6 6 7 7 8 8 <- Take the stored generations and use the third slice to compute the loss + # steps_per_gen=4 ▼ 1 3 9 9 10 10 11 11 <- Take the stored generations and use the fourth slice to compute the loss + # + # 2 4 12 12 13 13 14 14 <- Generate for the second `steps_per_generation` (prompts 12 to 23); store the completions; use the first slice to compute the loss + # 2 5 15 15 16 16 17 17 <- Take the stored generations and use the second slice to compute the loss + # ... + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size // self.num_generations, + repeat_count=self.num_iterations * self.args.steps_per_generation, + shuffle=self.shuffle_dataset, + seed=self.args.seed, + ) + + def _get_eval_sampler(self, eval_dataset) -> Sampler: + # See _get_train_sampler for an explanation of the sampler. + return RepeatSampler( + data_source=eval_dataset, + mini_repeat_count=self.num_generations_eval, + seed=self.args.seed, + ) + + @profiling_decorator + def _get_last_hidden_state( + self, + unwrapped_model, + input_ids, + attention_mask, + logits_to_keep, + pixel_values=None, + image_grid_thw=None, + pixel_attention_mask=None, + image_sizes=None, + image_position_ids=None, + ): + if is_peft_model(unwrapped_model): + unwrapped_model = unwrapped_model.base_model.model + + # Build model inputs - check if the model supports logits_to_keep (some models and VLMs don't) + model_inputs = {"input_ids": input_ids, "attention_mask": attention_mask} + + # For Qwen models: + if image_grid_thw is not None and pixel_values is not None: + model_inputs["image_grid_thw"] = image_grid_thw + # For Gemma, SmolVLM2, LLaVa-Next etc.: + if pixel_values is not None: + model_inputs["pixel_values"] = pixel_values + # For SmolVLM2 + if pixel_attention_mask is not None: + model_inputs["pixel_attention_mask"] = pixel_attention_mask + # For LLaVa-Next + if image_sizes is not None: + model_inputs["image_sizes"] = image_sizes + if image_position_ids is not None: + model_inputs["image_position_ids"] = image_position_ids + + # Only add logits_to_keep if the model supports it + if "logits_to_keep" in self.model_kwarg_keys: + # We add 1 to `logits_to_keep` because the last logits of the sequence is later excluded + model_inputs["logits_to_keep"] = logits_to_keep + 1 + + model_inputs["use_cache"] = False # only used in generation; set False to suppress warnings + + last_hidden_state = unwrapped_model.model(**model_inputs).last_hidden_state + # Exclude the last value: it corresponds to the next token pred + last_hidden_state = last_hidden_state[:, :-1, :] # (B, L-1, H) + # Only keep the last logits_to_keep. For model that support logits_to_keep, this is a no-op. + last_hidden_state = last_hidden_state[:, -logits_to_keep:, :] # (B, logits_to_keep, H) + return last_hidden_state + + def get_high_entropy_mask(self, entropies: torch.Tensor, mask: torch.Tensor, threshold: float) -> torch.Tensor: + """ + Returns a binary mask identifying tokens whose entropy exceeds a given quantile threshold. + + Args: + entropies (`torch.Tensor`): + Tensor of shape (batch_size, seq_len) with per-token entropy values. + mask (`torch.Tensor`): + Binary mask of the same shape as `entropies`, where `1` indicates valid tokens and `0` padding. + threshold (`float`): + Quantile threshold between `0.0` and `1.0` to select high-entropy tokens. + + Returns: + `torch.Tensor`: + Boolean mask of shape (batch_size, seq_len), where `True` indicates tokens with entropy >= threshold + and `False` otherwise. + """ + local = entropies[mask.bool()].float() + + # Use a negative pad_value as a sentinel because entropy values are always >= 0. + # This guarantees that the sentinel cannot collide with any real entropy value. + pad_value = -1e9 + + # Pad across processes so that every rank has the same tensor length + padded = self.accelerator.pad_across_processes(local, dim=0, pad_index=pad_value) + gathered = self.accelerator.gather(padded) + + # Drop sentinel values (safe because no entropy can be negative) + gathered = gathered[gathered != pad_value] + + if gathered.numel() == 0: + return torch.zeros_like(entropies, dtype=torch.bool) + + entropy_threshold = torch.quantile(gathered, threshold) + masked_entropies = entropies * mask.float() + entropy_mask = masked_entropies >= entropy_threshold + return entropy_mask & mask.bool() # ensure padding tokens are always masked out + + @profiling_decorator + def _get_per_token_logps_and_entropies( + self, + model, + input_ids, + attention_mask, + logits_to_keep, + batch_size=None, + compute_entropy=False, + pixel_values=None, + image_grid_thw=None, + num_images=None, + pixel_attention_mask=None, + image_sizes=None, + token_type_ids=None, + mm_token_type_ids=None, + image_position_ids=None, + ) -> tuple[torch.Tensor, torch.Tensor | None]: + """Compute log-probs and (optionally) entropies for each token.""" + batch_size = batch_size or input_ids.size(0) # Chunk inputs into smaller batches to reduce memory peak + all_logps = [] + all_entropies = [] + for start in range(0, input_ids.size(0), batch_size): + input_ids_batch = input_ids[start : start + batch_size] + attention_mask_batch = attention_mask[start : start + batch_size] + + # Build model inputs + model_inputs = {"input_ids": input_ids_batch, "attention_mask": attention_mask_batch} + if image_grid_thw is not None and pixel_values is not None: + rows_per_image = image_grid_thw.prod(dim=-1) + rows_per_sample = torch.split(rows_per_image, num_images) + rows_per_sample = torch.stack([s.sum() for s in rows_per_sample]) + cum_rows = torch.cat([torch.tensor([0], device=rows_per_sample.device), rows_per_sample.cumsum(0)]) + row_start, row_end = cum_rows[start].item(), cum_rows[start + batch_size].item() + model_inputs["pixel_values"] = pixel_values[row_start:row_end] + cum_imgs = torch.tensor([0] + num_images).cumsum(0) + img_start, img_end = cum_imgs[start], cum_imgs[start + batch_size] + model_inputs["image_grid_thw"] = image_grid_thw[img_start:img_end] + elif image_position_ids is not None and pixel_values is not None: + cum_imgs = torch.tensor([0] + num_images).cumsum(0) + img_start, img_end = cum_imgs[start], cum_imgs[start + batch_size] + model_inputs["pixel_values"] = pixel_values[img_start:img_end] + model_inputs["image_position_ids"] = image_position_ids[img_start:img_end] + elif pixel_values is not None: + model_inputs["pixel_values"] = pixel_values[start : start + batch_size] + if pixel_attention_mask is not None: + model_inputs["pixel_attention_mask"] = pixel_attention_mask[start : start + batch_size] + if image_sizes is not None: + model_inputs["image_sizes"] = image_sizes[start : start + batch_size] + if token_type_ids is not None: + model_inputs["token_type_ids"] = token_type_ids[start : start + batch_size] + if mm_token_type_ids is not None: + model_inputs["mm_token_type_ids"] = mm_token_type_ids[start : start + batch_size] + + # Only add logits_to_keep if the model supports it + if "logits_to_keep" in self.model_kwarg_keys: + # We add 1 to `logits_to_keep` because the last logits of the sequence is later excluded + model_inputs["logits_to_keep"] = logits_to_keep + 1 + + model_inputs["use_cache"] = False # only used in generation; set False to suppress warnings + + logits = model(**model_inputs).logits + # Exclude the last value: it corresponds to the next token pred + logits = logits[:, :-1, :] # (B, L-1, H) + # Only keep the last logits_to_keep. For model that support logits_to_keep, this is a no-op. + logits = logits[:, -logits_to_keep:, :] # (B, logits_to_keep, H) + # Divide logits by sampling temperature. + # See https://huggingface.co/blog/the_n_implementation_details_of_rlhf_with_ppo#policy-training-implementation-details + logits.div_(self.temperature) + completion_ids = input_ids_batch[:, -logits_to_keep:] + logps = selective_log_softmax(logits, completion_ids) # compute logprobs + all_logps.append(logps) + + if compute_entropy: + with torch.no_grad(): + entropies = entropy_from_logits(logits) + all_entropies.append(entropies) + + logps = torch.cat(all_logps, dim=0) + entropies = torch.cat(all_entropies, dim=0) if compute_entropy else None + return logps, entropies + + def training_step(self, model, inputs, num_items_in_batch): + time_before = time.perf_counter() + output = super().training_step(model, inputs, num_items_in_batch) + self._step += 1 + time_after = time.perf_counter() + self._current_train_step_time += time_after - time_before + if self._step % self.current_gradient_accumulation_steps == 0: + self._metrics["train"]["step_time"].append(self._current_train_step_time) + self._current_train_step_time = 0.0 + return output + + @profiling_decorator + def _prepare_inputs(self, generation_batch: dict[str, torch.Tensor | Any]) -> dict[str, torch.Tensor | Any]: + # Prepares inputs for model training/evaluation by managing completion generation and batch handling. + # During training: + # - Receives the local generation batch (Per-GPU batch size × steps per generation) + # from the modified training dataloader instead of the standard local batch + # - Generates completions once for the entire generation batch and splits it into batches of size + # `per_device_train_batch_size` + # - Buffers these completions and returns the appropriate slice for the current accumulation step + # - Optimizes by regenerating completions only periodically (every steps_per_generation * num_iterations) + # During evaluation: + # - The input is treated as a standard local batch (no accumulation, no multiple iterations) + # - Completions are generated for each batch without buffering or reuse + # Returns a single local batch in both cases. + + mode = "train" if self.model.training else "eval" + if mode == "train": + generate_every = self.args.steps_per_generation * self.num_iterations + if self._step % generate_every == 0 or self._buffered_inputs is None: + # self._buffered_inputs=None can occur when resuming from a checkpoint + generation_batch = self._generate_and_score_completions(generation_batch) + generation_batch = split_pixel_values_by_grid(generation_batch) + generation_batch = shuffle_sequence_dict(generation_batch) + generation_batches = split_tensor_dict(generation_batch, self.args.steps_per_generation) + self._buffered_inputs = [unsplit_pixel_values_by_grid(batch) for batch in generation_batches] + inputs = self._buffered_inputs[self._step % self.args.steps_per_generation] + else: + # In evaluation, there is neither batch grouping for generation, nor multiple iterations, hence + # local generation batch == local eval batch + inputs = self._generate_and_score_completions(generation_batch) + return inputs + + def _log_completion_extra(self, column: str, values: list): + """ + Log extra columns to the completions table. Called from reward functions via the `log_extra` kwarg. + + Args: + column (`str`): + Name of the column to add. + values (`list`): + Values for the column, one per sample in the batch. + """ + self._pending_extra_logs[column].extend(values) + + def _log_metric(self, name: str, value: float): + """ + Log a scalar metric from a reward function. Called via the `log_metric` kwarg. Values are averaged over each + logging step and reported alongside built-in metrics like `kl` and `entropy`. + + Args: + name (`str`): + Name of the metric. + value (`float`): + Scalar value for this batch. + """ + self._pending_metrics[name].append(value) + + @profiling_decorator + def _calculate_rewards(self, inputs, prompts, completions, completion_ids_list): + device = self.accelerator.device + rewards_per_func = torch.zeros(len(prompts), len(self.reward_funcs), device=device) + + # Repeat all input columns (but "prompt", "completion", and "completion_ids") to match the num of generations + keys = [key for key in inputs[0] if key not in ["prompt", "completion", "completion_ids"]] + reward_kwargs = {key: [example[key] for example in inputs] for key in keys} + + # This allows for dynamic reward shaping based on training progress. + reward_kwargs["trainer_state"] = self.state + + # Allow reward functions to log extra columns to the completions table. + reward_kwargs["log_extra"] = self._log_completion_extra + + # Allow reward functions to log additional scalar metrics. + reward_kwargs["log_metric"] = self._log_metric + + async_funcs_info = [] # async custom functions for asyncio.gather + + for i, (reward_func, reward_processing_class, reward_func_name) in enumerate( + zip(self.reward_funcs, self.reward_processing_classes, self.reward_func_names, strict=True) + ): + if isinstance(reward_func, nn.Module): # Module (no PretrainedModel) for compat with compiled models + with profiling_context(self, reward_func_name): + if is_conversational(inputs[0]): + messages = [{"messages": p + c} for p, c in zip(prompts, completions, strict=True)] + texts = [ + apply_chat_template(x, reward_processing_class, **self.chat_template_kwargs)["text"] + for x in messages + ] + else: + texts = [p + c for p, c in zip(prompts, completions, strict=True)] + reward_inputs = reward_processing_class( + text=texts, return_tensors="pt", padding=True, padding_side="right", add_special_tokens=False + ) + reward_inputs = super()._prepare_inputs(reward_inputs) + with torch.inference_mode(): + rewards_per_func[:, i] = reward_func(**reward_inputs).logits[:, 0] # Shape (B*G,) + elif inspect.iscoroutinefunction(reward_func): # Separate async reward funcs to run them in parallel later + async_funcs_info.append((i, reward_func, reward_func_name)) + else: + # Run synchronous reward function + with profiling_context(self, reward_func_name): + if self.environments is not None: + reward_kwargs["environments"] = self.environments + output_reward_func = reward_func( + prompts=prompts, completions=completions, completion_ids=completion_ids_list, **reward_kwargs + ) + # Convert None values to NaN + output_reward_func = [reward if reward is not None else torch.nan for reward in output_reward_func] + rewards_per_func[:, i] = torch.tensor(output_reward_func, dtype=torch.float32, device=device) + + # Execute async custom functions in parallel using asyncio.gather + if async_funcs_info: + + async def _invoke_async(index, func, func_name): + with profiling_context(self, func_name): + output = await func( + prompts=prompts, completions=completions, completion_ids=completion_ids_list, **reward_kwargs + ) + output = [r if r is not None else torch.nan for r in output] + return index, output + + async def _run_async_funcs(): + coros = [_invoke_async(i, func, func_name) for (i, func, func_name) in async_funcs_info] + return await asyncio.gather(*coros) + + async_results = asyncio.run_coroutine_threadsafe(_run_async_funcs(), self.async_loop).result() + for idx, output_reward_func in async_results: + rewards_per_func[:, idx] = torch.tensor(output_reward_func, dtype=torch.float32, device=device) + + # If all reward functions return None for a given row, issue a detailed warning + if torch.isnan(rewards_per_func).all(dim=1).any(): + nan_row_idx = torch.isnan(rewards_per_func).all(dim=1).nonzero(as_tuple=True)[0][0] + row_reward_kwargs = { + key: value[nan_row_idx] + for key, value in reward_kwargs.items() + if key not in ("trainer_state", "log_extra", "log_metric") + } + row_reward_kwargs["prompt"] = prompts[nan_row_idx] + row_reward_kwargs["completion"] = completions[nan_row_idx] + logger.warning( + f"All reward functions returned None for the following kwargs:\n{row_reward_kwargs}\n" + "Please ensure that at least one reward function returns a valid reward." + ) + + # Gather the reward per function: this part is crucial, because the rewards are normalized per group and the + # completions may be distributed across processes + rewards_per_func = gather(rewards_per_func) + return rewards_per_func + + def _tokenize_prompts(self, prompts: list): + """Tokenize prompts and extract images/multimodal fields for generation.""" + if is_conversational({"prompt": prompts[0]}): + # Normalize string content to content blocks for VLM processors that don't handle plain strings. + if self._is_vlm: + prompts = [prepare_multimodal_messages(prompt) for prompt in prompts] + + # Extract images from messages for VLM support + images = [] + has_images = False + for prompt in prompts: + prompt_images = [] + for message in prompt: + if isinstance(message["content"], list): + for part in message["content"]: + if part["type"] == "image": + prompt_images.append(part["image"]) + has_images = True + images.append(prompt_images if prompt_images else None) + images = images if has_images else None + + # Workaround for a bug in transformers 5.3.0 where some processors (e.g. Qwen2.5-VL) crash on + # batched unpadded input (transformers#44514). + # Fixed in transformers 5.4.0 (transformers#44563). + needs_padding_workaround = Version("5.3.0") <= Version(transformers.__version__) < Version("5.4.0") + tokenized = self.processing_class.apply_chat_template( + conversation=prompts, + tools=self.tools or None, # `or None`: Llama bug: it renders tool boilerplate for tools=[] + chat_template=self.chat_template, + add_generation_prompt=True, + tokenize=True, + return_dict=True, + **({"padding": True} if needs_padding_workaround else {}), + **self.chat_template_kwargs, + ) + if needs_padding_workaround: + # Unpad input_ids: remove padding tokens using attention_mask to get per-sequence lists + prompt_ids = [ + [tok for tok, m in zip(ids, mask, strict=True) if m] + for ids, mask in zip(tokenized["input_ids"], tokenized["attention_mask"], strict=True) + ] + else: + prompt_ids = tokenized["input_ids"] + # For VLMs, the processor returns extra multimodal fields (pixel_values, image_grid_thw, etc.) + multimodal_fields = {k: v for k, v in tokenized.items() if k not in ("input_ids", "attention_mask")} + else: + prompt_ids = self.processing_class(text=prompts)["input_ids"] + images = None + multimodal_fields = {} + return prompt_ids, images, multimodal_fields + + def _generate_single_turn(self, prompt_ids, images, multimodal_fields): + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + # Generate completions using either vLLM or regular generation + if self.use_vllm: + # Sync weights if training step changed + if self.state.global_step != self._last_loaded_step: + with profiling_context(self, "sync_weights"): + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + # Generate using vLLM with raw token IDs + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + _, completion_ids, logprobs, _ = self.vllm_generation.generate( + prompts=prompt_ids, + images=images, + num_generations=num_generations, + profiler=profiling_context(self, "vLLM.generate"), + ) + # vLLM returns per-token top-k logprobs; keep only the top-1 (sampled token) logprob + logprobs = [[lp[0] for lp in seq] for seq in logprobs] + + elif self.use_transformers_paged: + with ( + profiling_context(self, "transformers.generate_batch"), + unwrap_model_for_generation( + self.model_wrapped, self.accelerator, gather_deepspeed3_params=self.args.ds3_gather_for_generation + ) as unwrapped_model, + torch.no_grad(), + FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), + ): + # Cast to the appropriate dtype based on training configuration + if self.args.bf16: + unwrapped_model.to(torch.bfloat16) + elif self.args.fp16: + unwrapped_model.to(torch.float16) + if self.args.cast_lm_head_to_fp32: + unwrapped_model.lm_head.to(torch.float32) + with torch.inference_mode(): + # Continuous batching API expects 'inputs' arg only + all_outputs = unwrapped_model.generate_batch( + prompt_ids, generation_config=self.generation_config, progress_bar=False + ) + unwrapped_model.train() # restore training mode, as generate_batch forces eval mode + completion_ids = [output.generated_tokens for output in all_outputs.values()] + logprobs = None # not used in this case + + else: + # Regular generation path: left-pad token IDs into tensors + prompt_tensors = [torch.tensor(ids) for ids in prompt_ids] + padded_ids = pad(prompt_tensors, padding_value=self._tokenizer.pad_token_id, padding_side="left") + attention_mask = pad([torch.ones_like(t) for t in prompt_tensors], padding_value=0, padding_side="left") + generate_inputs = {"input_ids": padded_ids, "attention_mask": attention_mask} + # For VLMs, include multimodal fields as tensors (pixel_values, image_grid_thw, etc.) + for k, v in multimodal_fields.items(): + if isinstance(v, torch.Tensor): + generate_inputs[k] = v + elif isinstance(v, list) and v and isinstance(v[0], list): + # Per-token field (e.g., token_type_ids): left-pad like input_ids + generate_inputs[k] = pad([torch.tensor(x) for x in v], padding_value=0, padding_side="left") + else: + generate_inputs[k] = torch.tensor(np.array(v)) + generate_inputs = super()._prepare_inputs(generate_inputs) + + with ( + profiling_context(self, "transformers.generate"), + unwrap_model_for_generation( + self.model_wrapped, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model, + torch.no_grad(), + FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), + ): + prompt_completion_ids = unwrapped_model.generate( + **generate_inputs, generation_config=self.generation_config + ) + # Compute prompt length and extract completion ids + prompt_length = generate_inputs["input_ids"].size(1) + completion_ids = prompt_completion_ids[:, prompt_length:] + + # Mask everything after the first EOS token + is_eos = completion_ids == self._tokenizer.eos_token_id + eos_idx = torch.full((is_eos.size(0),), is_eos.size(1), dtype=torch.long, device=device) + eos_idx[is_eos.any(dim=1)] = is_eos.int().argmax(dim=1)[is_eos.any(dim=1)] + sequence_indices = torch.arange(is_eos.size(1), device=device).expand(is_eos.size(0), -1) + completion_mask = (sequence_indices <= eos_idx.unsqueeze(1)).int() + completion_ids = [ + c[m].tolist() for c, m in zip(completion_ids.cpu(), completion_mask.bool().cpu(), strict=True) + ] + logprobs = None # not used in this case + + return completion_ids, logprobs + + def _get_tool_suffix_ids(self, tool_messages): + """Get token IDs for tool result formatting by using a minimal dummy conversation.""" + # Use the real tool name instead of a dummy: some templates (e.g. GPT-OSS) derive the tool response + # header from the assistant's tool call name. + dummy_tool_calls = [{"type": "function", "function": {"name": tool_messages[0]["name"], "arguments": {}}}] + dummy_messages = [ + {"role": "user", "content": "dummy"}, + { + "role": "assistant", + # "content" is required here because VLM processors crash on tokenize=True without it + # (KeyError in processing_utils.py). See huggingface/transformers#45290. + "content": "", + "tool_calls": dummy_tool_calls, + }, + ] + if self._is_vlm: + dummy_messages = prepare_multimodal_messages(dummy_messages) + tool_messages = prepare_multimodal_messages(tool_messages) + + prefix_ids = self.processing_class.apply_chat_template( + dummy_messages, + add_generation_prompt=False, + tokenize=True, + chat_template=self.chat_template, + return_dict=False, + **self.chat_template_kwargs, + ) + full_ids = self.processing_class.apply_chat_template( + dummy_messages + tool_messages, + add_generation_prompt=True, + tokenize=True, + chat_template=self.chat_template, + return_dict=False, + **self.chat_template_kwargs, + ) + # VLM processors return batched output (list of lists), unbatch for single conversation + if self._is_vlm: + prefix_ids = prefix_ids[0] + full_ids = full_ids[0] + + # Some chat templates (notably Qwen3/Qwen3.5) render "...<|im_end|>\n" after an assistant/tool block. + # When we compute `suffix_ids` by slicing `full_ids`, we must align the slicing boundary to + # EOS (not EOS + newline). Templates that don't use EOS as end-of-turn (e.g. Gemma uses + # ) skip this trimming. + eos_positions = [i for i, tok_id in enumerate(prefix_ids) if tok_id == self._tokenizer.eos_token_id] + if eos_positions: + prefix_ids = prefix_ids[: eos_positions[-1] + 1] + + if full_ids[: len(prefix_ids)] != prefix_ids: + raise ValueError("Unexpected tokenization: the EOS-trimmed prefix IDs are not a prefix of the full IDs.") + return full_ids[len(prefix_ids) :] + + def _tool_call_loop(self, prompts, prompt_ids, completion_ids, completions, logprobs, images, multimodal_fields): + # Tool execution loop: execute tools, then regenerate completions with tool results appended to the prompt + tool_calls = [completion[0].get("tool_calls") for completion in completions] + idxs_with_tool = [idx for idx, tool_call in enumerate(tool_calls) if tool_call] + tool_calls = [tool_calls[idx] for idx in idxs_with_tool] + tool_mask = [[1] * len(ids) for ids in completion_ids] # 0 for tool result tokens, 1 elsewhere + # Collect images from multimodal tool responses for the forward pass + tool_images = [[] for _ in completion_ids] + tool_call_count = 0 + tool_failure_count = 0 + iteration_num = 0 + + while idxs_with_tool and iteration_num < self.max_tool_calling_iterations: + prompt_completion_tools = [prompts[i] for i in idxs_with_tool] # select only prompts that need tool calls + # Snapshot state so we can rollback tool results that would exceed max_completion_length + completions_len_before = [len(completions[i]) for i in idxs_with_tool] + tool_images_len_before = [len(tool_images[i]) for i in idxs_with_tool] + prompts_len_before = [len(prompts[i]) for i in idxs_with_tool] + + # Call the tools, and build the new prompt for generation + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + tool_call_list = tool_calls[idx] + prompt_completion_tool = prompt_completion_tools[idx] + sync_tool_dict = self._sync_tool_dicts[idx_with_tool] + async_tool_dict = self._async_tool_dicts[idx_with_tool] + # Append the last assistant message (which triggered tool_calls) to the prompt + prompt_completion_tool.append(completions[idx_with_tool][-1]) + async_coros = [] + tool_call_results = [] + for tool_call in tool_call_list: + tool_call_count += 1 + if tool_call["type"] == "function": + function = tool_call["function"] + name = function["name"] + try: + if name in sync_tool_dict: + tool_call_results.append((name, sync_tool_dict[name](**function["arguments"]))) + elif name in async_tool_dict: + async_coros.append((name, async_tool_dict[name](**function["arguments"]))) + else: + raise ValueError(f"Tool {name} not found.") + except Exception as e: + tool_failure_count += 1 + result = {"error": str(e)} + tool_call_results.append((name, result)) + else: + tool_failure_count += 1 + name = tool_call.get("name", "unknown") + tool_call_results.append((name, {"error": f"Unsupported tool call type: {tool_call['type']}"})) + + if async_coros: + + async def _run_async_tools(async_coros): + coros = [coro for _, coro in async_coros] + results = await asyncio.gather(*coros, return_exceptions=True) + return [(name, result) for (name, _), result in zip(async_coros, results, strict=False)] + + async_results = asyncio.run_coroutine_threadsafe( + _run_async_tools(async_coros), self.async_loop + ).result() + + for name, result in async_results: + if isinstance(result, Exception): + tool_failure_count += 1 + tool_call_results.append((name, {"error": str(result)})) + else: + tool_call_results.append((name, result)) + + for name, result in tool_call_results: + # Support multimodal tool responses: if the tool returns a list of content blocks + # (e.g., [{"type": "image", "image": ...}, {"type": "text", "text": "..."}]), + # pass them through directly so _tokenize_prompts can extract images for VLMs. + content = result if isinstance(result, list) else str(result) + tool_message = {"role": "tool", "name": name, "content": content} + # Collect images from multimodal tool responses + if isinstance(content, list): + for part in content: + if isinstance(part, dict) and part.get("type") == "image": + tool_images[idx_with_tool].append(part["image"]) + prompt_completion_tool.append(tool_message) + completions[idx_with_tool].append(tool_message) + + # Build token IDs by concatenation: prompt + completion + tool_suffix. + prompt_completion_tool_ids = [] + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + # Extract trailing tool messages from completions + tool_messages = [] + for message in reversed(completions[idx_with_tool]): + if message["role"] == "tool": + tool_messages.insert(0, message) + else: + break + suffix_ids = self._get_tool_suffix_ids(tool_messages) + prompt_completion_tool_ids.append( + prompt_ids[idx_with_tool] + completion_ids[idx_with_tool] + suffix_ids + ) + + # Drop tool results whose addition would push the sequence past max_completion_length (the completion + # budget) or past the backend context ceiling (vLLM and transformers will error out on inputs longer than + # the model's max length). The sample exits the loop with its completion as-is, and the tool + # messages/images appended this iteration are rolled back so completions and tool_images stay consistent + # with completion_ids. + if self.use_vllm and self.vllm_mode == "colocate": + max_model_len = self.vllm_generation.llm.llm_engine.model_config.max_model_len + else: + config = self.model.config.text_config if self._is_vlm else self.model.config + max_model_len = config.max_position_embeddings + overlong = [ + len(pct) - len(prompt_ids[i]) > self.max_completion_length or len(pct) >= max_model_len + for i, pct in zip(idxs_with_tool, prompt_completion_tool_ids, strict=True) + ] + for idx in range(len(idxs_with_tool)): + if overlong[idx]: + idx_with_tool = idxs_with_tool[idx] + del completions[idx_with_tool][completions_len_before[idx] :] + del tool_images[idx_with_tool][tool_images_len_before[idx] :] + del prompts[idx_with_tool][prompts_len_before[idx] :] + # Keep only non-overlong items for further processing + idxs_with_tool = [idx for idx, o in zip(idxs_with_tool, overlong, strict=True) if not o] + prompt_completion_tool_ids = [ + pct for pct, o in zip(prompt_completion_tool_ids, overlong, strict=True) if not o + ] + if not idxs_with_tool: + break # all overlong, exit tool loop + + # Filter images and multimodal fields to match the current subset (index into full batch). + # Merge tool response images so the model can see visual feedback during generation. + merged_images = images + if any(imgs for imgs in tool_images): + if merged_images is None: + merged_images = [imgs if imgs else None for imgs in tool_images] + else: + merged_images = [ + (existing or []) + new for existing, new in zip(merged_images, tool_images, strict=True) + ] + loop_images = [merged_images[i] for i in idxs_with_tool] if merged_images else None + if multimodal_fields: + loop_multimodal_fields = {} + for k, v in multimodal_fields.items(): + selected = [v[i] for i in idxs_with_tool] + # Per-token fields (e.g. token_type_ids) need zero-padding to match extended prompt length + if isinstance(selected[0], list): + selected = [ + s + [0] * (len(pct) - len(s)) + for s, pct in zip(selected, prompt_completion_tool_ids, strict=True) + ] + loop_multimodal_fields[k] = selected + else: + loop_multimodal_fields = {} + + # Generate new completions after tool execution (using concatenated IDs, no re-tokenization) + post_tool_ids, post_tool_logprobs = self._generate_single_turn( + prompt_completion_tool_ids, loop_images, loop_multimodal_fields + ) + + # Truncate so that pct[len(prompt_ids[idx]) :] + post_tool does not exceed max_completion_length. + # The pre-regen check guarantees len(completion_tool_ids) <= max_completion_length, so any + # excess can only come from post_tool_ids. post_tool_ids is model-generated text and never + # contains image tokens, so a plain slice is safe. + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + completion_tool_length = len(prompt_completion_tool_ids[idx]) - len(prompt_ids[idx_with_tool]) + excess_length = completion_tool_length + len(post_tool_ids[idx]) - self.max_completion_length + if excess_length > 0: + new_len = len(post_tool_ids[idx]) - excess_length + post_tool_ids[idx] = post_tool_ids[idx][:new_len] + if logprobs is not None: + post_tool_logprobs[idx] = post_tool_logprobs[idx][:new_len] + + # Update tool_mask: the tool result should be 0 and the post-tool 1 + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + prompt_completion_tool_length = len(prompt_completion_tool_ids[idx]) + prompt_length = len(prompt_ids[idx_with_tool]) + completion_length = len(completion_ids[idx_with_tool]) + post_tool_length = len(post_tool_ids[idx]) + tool_length = prompt_completion_tool_length - prompt_length - completion_length + tool_mask[idx_with_tool] += [0] * tool_length + [1] * post_tool_length + if logprobs is not None: + logprobs[idx_with_tool] += [0.0] * tool_length + post_tool_logprobs[idx] + + # Update completion_ids with the new completions (after tool execution) + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + prompt_length = len(prompt_ids[idx_with_tool]) + pct = prompt_completion_tool_ids[idx] # = prompt-completion-tool + completion_ids[idx_with_tool] = pct[prompt_length:] + post_tool_ids[idx] + + # Decode post-tool completions. + post_tool_completions = [parse_response(self._tokenizer, ids) if ids else {} for ids in post_tool_ids] + + # Add post-tool completions to the existing completions + for idx in range(len(idxs_with_tool)): + idx_with_tool = idxs_with_tool[idx] + if post_tool_completions[idx]: # {} if post-tool completions completely truncated + completions[idx_with_tool].append(post_tool_completions[idx]) + + # Check for further tool calls + tool_calls = [completion.get("tool_calls") for completion in post_tool_completions] + idxs_with_tool = [idx for idx, tool_call in zip(idxs_with_tool, tool_calls, strict=True) if tool_call] + tool_calls = [tool_call for tool_call in tool_calls if tool_call] + iteration_num += 1 + + return tool_mask, completions, completion_ids, logprobs, tool_call_count, tool_failure_count, tool_images + + def _generate(self, prompts: list): + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + # Copy the prompts to avoid modifying the original list + prompts = copy.deepcopy(prompts) + + if self.rollout_func is not None: + # Keep vLLM weights in sync for custom rollouts that rely on vLLM utilities. + if self.use_vllm and self.state.global_step != self._last_loaded_step: + with profiling_context(self, "sync_weights"): + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + # Pass prompts to rollout_func preserving structured messages. + # Chat templating must happen inside rollout_func, at the backend boundary, so that + # multimodal content (images, typed content blocks) is not lost before rollout logic runs. + output = self.rollout_func(prompts, self) + required_keys = {"prompt_ids", "completion_ids", "logprobs"} + missing_keys = required_keys - output.keys() + if missing_keys: + missing_keys_list = sorted(missing_keys) + raise ValueError(f"rollout_func must return keys {missing_keys_list} in its output dict.") + extra_fields = {k: v for k, v in output.items() if k not in required_keys} + prompt_ids, completion_ids, logprobs = output["prompt_ids"], output["completion_ids"], output["logprobs"] + images = None + multimodal_fields = {} + else: + prompt_ids, images, multimodal_fields = self._tokenize_prompts(prompts) + completion_ids, logprobs = self._generate_single_turn(prompt_ids, images, multimodal_fields) + extra_fields = {} + + # Decode completions. It's important to use `parse_response` when possible, because it handles tool calls. + if is_conversational({"prompt": prompts[0]}): + if ( + Version(transformers.__version__) >= Version("5.0.0") # parse_response added in v5 + and hasattr(self._tokenizer, "response_schema") # attribute not set by default for now + and self._tokenizer.response_schema is not None # only works if the tokenizer has a schema + ): + completions = [[parse_response(self._tokenizer, ids)] for ids in completion_ids] + else: + contents = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + completions = [[{"role": "assistant", "content": content}] for content in contents] + else: + completions = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Extract tool calls from the completions and (possibly) execute them + tool_images = [] + if self.tools: + ( + tool_mask, + completions, + completion_ids, + logprobs, + tool_call_count, + tool_failure_count, + tool_images, + ) = self._tool_call_loop( + prompts, prompt_ids, completion_ids, completions, logprobs, images, multimodal_fields + ) + # Merge tool response images into the images list for the forward pass + if any(imgs for imgs in tool_images): + if images is None: + images = [imgs if imgs else None for imgs in tool_images] + else: + images = [(existing or []) + new for existing, new in zip(images, tool_images, strict=True)] + else: + # Support custom env_mask from rollout_func (e.g., for environment feedback masking) + # Internally treated as tool_mask - marks model tokens (1) vs external tokens (0) + tool_mask = extra_fields.pop("env_mask", None) + + # Get completion length per sequence, used for logging + prompt_lengths = torch.tensor([len(ids) for ids in prompt_ids], device=device) + if tool_mask is not None: # count only model-generated tokens (tool_mask=1) + completion_lengths = torch.tensor([sum(mask) for mask in tool_mask], device=device) + else: + completion_lengths = torch.tensor([len(ids) for ids in completion_ids], device=device) + agg_prompt_lengths = self.accelerator.gather(prompt_lengths) + agg_completion_lengths = self.accelerator.gather(completion_lengths) + total_prompt_tokens = agg_prompt_lengths.sum() + total_completion_tokens = agg_completion_lengths.sum() # = num_items_in_batch, required for the DAPO loss + + # Log the metrics + if mode == "train": + self.state.num_input_tokens_seen += (total_prompt_tokens + total_completion_tokens).item() + self._metrics[mode]["num_tokens"] = [self.state.num_input_tokens_seen] + + # Log completion lengths, mean, min, max + self._metrics[mode]["completions/mean_length"].append(agg_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_length"].append(agg_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_length"].append(agg_completion_lengths.float().max().item()) + + # Identify sequences that terminated with EOS and log their lengths + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids], device=device) + agg_is_truncated = self.accelerator.gather(is_truncated) + self._metrics[mode]["completions/clipped_ratio"].append(agg_is_truncated.float().mean().item()) + term_completion_lengths = agg_completion_lengths[~agg_is_truncated] + if len(term_completion_lengths) == 0: # edge case where no terminated sequences are found + term_completion_lengths = torch.zeros(1, device=device) + self._metrics[mode]["completions/mean_terminated_length"].append(term_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_terminated_length"].append(term_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_terminated_length"].append(term_completion_lengths.float().max().item()) + + if self.tools: + agg_tool_call_count = self.accelerator.gather(torch.tensor(tool_call_count, device=device)).sum() + tool_call_frequency = (agg_tool_call_count / len(agg_prompt_lengths)).item() + self._metrics[mode]["tools/call_frequency"].append(tool_call_frequency) + agg_tool_failure_count = self.accelerator.gather(torch.tensor(tool_failure_count, device=device)).sum() + failure_frequency = ( + (agg_tool_failure_count / agg_tool_call_count).item() if agg_tool_call_count > 0 else 0.0 + ) + self._metrics[mode]["tools/failure_frequency"].append(failure_frequency) + + return ( + prompt_ids, + completion_ids, + tool_mask, + completions, + total_completion_tokens, + logprobs, + extra_fields, + images, + tool_images, + ) + + def _generate_and_score_completions( + self, inputs: list[dict[str, torch.Tensor | Any]] + ) -> dict[str, torch.Tensor | Any]: + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + prompts = [x["prompt"] for x in inputs] + + if self.environments: + for prompt, environment, reset_kwargs in zip(prompts, self.environments, inputs, strict=True): + observation = environment.reset(**reset_kwargs) + if observation is None: + continue + if isinstance(observation, list) and isinstance(prompt[-1]["content"], str): + prompt[-1]["content"] = [{"type": "text", "text": prompt[-1]["content"]}] + if isinstance(observation, str) and isinstance(prompt[-1]["content"], list): + observation = [{"type": "text", "text": observation}] + prompt[-1]["content"] += observation + + if "images" in inputs[0]: + images = [example.get("images") for example in inputs] + elif "image" in inputs[0]: + images = [[example.get("image")] if example.get("image") is not None else None for example in inputs] + else: + images = None + # Transformers requires at least one image in the batch, otherwise it throws an error + if images is not None and all(img_list == [] for img_list in images): + images = None + + # If the prompts are conversational and the inputs contain images, we need to convert the prompts from + # [{"role": "user", "content": "What color is the sky?"}] to + # [{"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What color is the sky?"}]}] + if images is not None: + if not is_conversational(inputs[0]): + raise ValueError( + "Multimodal training requires conversational prompts. It looks like the dataset contains " + "non-conversational inputs, likely because a chat template was applied before passing the dataset " + "to the trainer. Please provide the raw conversational prompts and let the trainer apply the chat " + "template internally." + ) + prompts = [ + prepare_multimodal_messages(prompt, images=image_list) + for prompt, image_list in zip(prompts, images, strict=True) + ] + + dataset_images = images # preserve dataset images before _generate may overwrite + ( + prompt_ids_list, + completion_ids_list, + tool_mask_list, + completions, + num_items_in_batch, + sampling_per_token_logps_list, + extra_fields, + images, + tool_images, + ) = self._generate(prompts) + if images is None: + images = dataset_images # restore dataset images (rollout_func path returns None) + + # Convert lists of token IDs to padded tensors + prompt_ids = [torch.tensor(ids) for ids in prompt_ids_list] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + prompt_ids = pad( + prompt_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + prompt_mask = pad( + prompt_mask, padding_value=0, padding_side="left", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + completion_ids = [torch.tensor(ids) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + completion_ids = pad( + completion_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_mask = pad( + completion_mask, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + if sampling_per_token_logps_list is not None: + sampling_per_token_logps = [torch.tensor(logps) for logps in sampling_per_token_logps_list] + sampling_per_token_logps = pad( + sampling_per_token_logps, + padding_value=0.0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + else: + sampling_per_token_logps = None + if tool_mask_list is not None: + tool_mask = [torch.tensor(mask) for mask in tool_mask_list] + tool_mask = pad( + tool_mask, padding_value=1, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + else: + tool_mask = None + + # If mask_truncated_completions is enabled, zero out truncated completions for attention and loss masking + if self.mask_truncated_completions: + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + # Mask completion_mask for attention masking + completion_mask = completion_mask * (~is_truncated).unsqueeze(1).int() + # Also mask tool_mask for consistency in multi-turn training + if tool_mask is not None: + tool_mask = tool_mask * (~is_truncated).unsqueeze(1).int() + + # Concatenate prompt_mask with completion_mask for logit computation + prompt_completion_ids = torch.cat([prompt_ids, completion_ids], dim=1) # (B, P+C) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) # (B, P+C) + + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_size + + num_images = [len(img_list) if img_list else 0 for img_list in images] if images is not None else None + + # Get forward_kwargs for models with multimodal inputs. + # When tool images are present (from _tool_call_loop), use image_processor directly and build + # mm_token_type_ids from prompt_completion_ids. Otherwise, use the full processor pipeline + # which returns model-specific keys (image_sizes, pixel_attention_mask, etc.). + if self.tools and any(imgs for imgs in tool_images) and self._is_vlm: + flat_images = [img for img_list in images if img_list for img in img_list] + image_inputs = self.processing_class.image_processor(images=flat_images, return_tensors="pt") + image_inputs = super()._prepare_inputs(image_inputs) + forward_kwargs = dict(image_inputs) + elif images is not None: + prompts_text = [ + apply_chat_template( + {"prompt": prompt}, self.processing_class, tools=self.tools, **self.chat_template_kwargs + )["prompt"] + for prompt in prompts + ] + prompt_inputs = self.processing_class(images=images, text=prompts_text, padding=True, return_tensors="pt") + prompt_inputs = super()._prepare_inputs(prompt_inputs) + forward_kwargs = {k: v for k, v in prompt_inputs.items() if k not in ["input_ids", "attention_mask"]} + else: + forward_kwargs = {} + + # If token_type_ids are used, extend them with zeros for the completion part + if "token_type_ids" in forward_kwargs: + token_type_ids = forward_kwargs["token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and token_type_ids must have equal len + padding_size = prompt_ids.size(1) - token_type_ids.size(1) + if padding_size > 0: + token_type_ids = torch.cat( + [token_type_ids.new_zeros((token_type_ids.size(0), padding_size)), token_type_ids], dim=1 + ) + forward_kwargs["token_type_ids"] = torch.cat( + [token_type_ids, token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + # If mm_token_type_ids are used, extend them with zeros for the completion part + if "mm_token_type_ids" in forward_kwargs: + mm_token_type_ids = forward_kwargs["mm_token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and mm_token_type_ids must have equal len + padding_size = prompt_ids.size(1) - mm_token_type_ids.size(1) + if padding_size > 0: + mm_token_type_ids = torch.cat( + [mm_token_type_ids.new_zeros((mm_token_type_ids.size(0), padding_size)), mm_token_type_ids], + dim=1, + ) + forward_kwargs["mm_token_type_ids"] = torch.cat( + [mm_token_type_ids, mm_token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + + # For VLM tool images: build token type IDs from the full prompt_completion_ids. + # This must happen AFTER the token_type_ids/mm_token_type_ids extension blocks above, + # because our version already covers the full sequence (images are in the completion, + # not just the prompt). + if self.tools and any(imgs for imgs in tool_images) and self._is_vlm: + mm_ids = torch.zeros_like(prompt_completion_ids) + if self._image_pad_token_id is not None: + mm_ids[prompt_completion_ids == self._image_pad_token_id] = 1 + if self._video_pad_token_id is not None: + mm_ids[prompt_completion_ids == self._video_pad_token_id] = 2 + + # Use the same key the model expects: token_type_ids for models like Gemma, + # mm_token_type_ids for models like Qwen. + image_grid_thw = forward_kwargs.get("image_grid_thw") + if image_grid_thw is not None: + forward_kwargs["mm_token_type_ids"] = mm_ids + else: + forward_kwargs["token_type_ids"] = mm_ids + + # Truncation safety (Qwen-style models with image_grid_thw only): if + # max_completion_length truncated some image tokens, the number of image pad tokens + # in input_ids won't match pixel_values features. Check per-sample and drop ALL + # images for any sample with a mismatch (safe fallback). + if image_grid_thw is not None and num_images is not None: + merge_length = getattr(self.processing_class.image_processor, "merge_size", 2) ** 2 + img_offset = 0 + has_mismatch = False + for b in range(mm_ids.shape[0]): + sample_tokens = (mm_ids[b] == 1).sum().item() + sample_features = 0 + for i in range(num_images[b]): + grid_idx = img_offset + i + if grid_idx < image_grid_thw.shape[0]: + sample_features += image_grid_thw[grid_idx].prod().item() // merge_length + if sample_tokens != sample_features: + has_mismatch = True + break + img_offset += num_images[b] + + if has_mismatch: + # Drop all images: safer than partial trim which is error-prone + forward_kwargs.pop("pixel_values", None) + forward_kwargs.pop("image_grid_thw", None) + mm_ids.zero_() + forward_kwargs["mm_token_type_ids"] = mm_ids + num_images = None + + # When gradient checkpointing is enabled with use_reentrant=True (non default), calling the model inside a + # torch.no_grad() block triggers a harmless PyTorch warning ("None of the inputs have requires_grad=True"). + # Temporarily disable checkpointing to avoid this warning during inference. + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + # If the generation and optimization steps are misaligned—i.e., if generation does not occur at the end of + # a full optimizer step (when gradient_accumulation_steps is not a multiple of generate_every)—then the + # samples may come from an earlier version of the model. In that case, we need to track old_per_token_logps + # for importance sampling. If the steps are aligned, importance sampling isn't necessary and we set + # old_per_token_logps to None. + # When using vLLM, we always compute old_per_token_logps for importance sampling, it was shown that the + # distribution mismatch between vLLM and the training model can be large and harm the training. + generate_every = self.args.steps_per_generation * self.num_iterations # generation frequency + if self.args.gradient_accumulation_steps % generate_every != 0 or ( + self.use_vllm and self.vllm_importance_sampling_correction + ): + old_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask, image_sizes, image_position_ids + ) + else: + old_per_token_logps = None + + # Compute the importance sampling ratio when using vLLM, to correct for potential distribution mismatch + if self.use_vllm and self.vllm_importance_sampling_correction: + mask = completion_mask if tool_mask is None else completion_mask * tool_mask + per_token_logps_diff = (old_per_token_logps - sampling_per_token_logps) * mask + + sequence_level_is = self.vllm_importance_sampling_mode in ["sequence_mask", "sequence_truncate"] + if sequence_level_is: + per_sequence_logps_diff = per_token_logps_diff.sum(dim=-1, keepdim=True) + logps_diff = per_sequence_logps_diff + else: + logps_diff = per_token_logps_diff + + vllm_importance_sampling_ratio = torch.exp(logps_diff) + + # vllm_importance_sampling_ratio.shape: + # token_* modes: (B, T) (per-token ratio) + # sequence_* modes: (B, 1) (per-sequence ratio) + + if self.vllm_importance_sampling_mode in ["sequence_truncate", "token_truncate"]: + vllm_importance_sampling_ratio = torch.clamp( + vllm_importance_sampling_ratio, max=self.vllm_importance_sampling_cap + ) + elif self.vllm_importance_sampling_mode in ["sequence_mask", "token_mask"]: + vllm_importance_sampling_ratio = vllm_importance_sampling_ratio.masked_fill( + vllm_importance_sampling_ratio > self.vllm_importance_sampling_cap, value=0.0 + ) + else: + raise ValueError( + f"Unknown vLLM importance sampling level: {self.vllm_importance_sampling_mode}. Possible values are 'token_truncate', 'token_mask', 'sequence_truncate', and 'sequence_mask'." + ) + + # Compute the per-token log probabilities for the reference model + if self.beta != 0.0: + if self.ref_model is not None: + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.ref_model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask, image_sizes, image_position_ids + ) + else: + # When training a PEFT adapter, how we obtain the reference depends on the setup: + # - New adapter: disabling adapters yields the base model. + # - Re-training an existing adapter: an initial copy is loaded under the name "ref". + model = self.accelerator.unwrap_model(self.model) + with use_adapter(model, adapter_name="ref" if "ref" in model.peft_config else None): + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask, image_sizes, image_position_ids + ) + else: + ref_per_token_logps = None + + # Decode + prompts_text = self.processing_class.batch_decode(prompt_ids, skip_special_tokens=True) + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Merge extra_fields from rollout_func into inputs for reward functions + if extra_fields: + for i, inp in enumerate(inputs): + for key, values in extra_fields.items(): + if isinstance(values, list) and i < len(values): + inp[key] = values[i] + elif not isinstance(values, list): + inp[key] = values + + # Calculate rewards for each reward function. rewards_per_func aggregates rewards across all processes. This is + # important because rewards will be normalized per group, and completions are distributed. We will later slice + # rewards_per_func to extract each process's subset. + rewards_per_func = self._calculate_rewards(inputs, prompts, completions, completion_ids_list) + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + + if self.multi_objective_aggregation == "sum_then_normalize": + # Apply weights to each reward function's output and sum + rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + mean_grouped_rewards = rewards.view(-1, num_generations).mean(dim=1) + mean_grouped_rewards = mean_grouped_rewards.repeat_interleave(num_generations, dim=0) + if self.scale_rewards in ["group", "none"]: + # If self.scale_rewards = "none", we'll only use std_rewards to check for zero std for logging + if num_generations > 1: + std_rewards = rewards.view(-1, num_generations).std(dim=1) + std_rewards = std_rewards.repeat_interleave(num_generations, dim=0) + else: # doesn't occur during training, but could occur in eval when num_generations_eval=1 + std_rewards = torch.zeros_like(rewards) + elif self.scale_rewards == "batch": + # Compute global std + if rewards.numel() > 1: + std_rewards = rewards.std().expand_as(rewards) + else: # doesn't occur during training, but could occur in eval when num_generations_eval=batch_size=1 + std_rewards = torch.zeros_like(rewards) + else: + raise ValueError( + f"Invalid value for scale_rewards: {self.scale_rewards}. Must be one of 'batch', 'group', or 'none'." + ) + + advantages = rewards - mean_grouped_rewards + if self.scale_rewards != "none": + advantages = advantages / (std_rewards + 1e-4) + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) # for logging + + elif self.multi_objective_aggregation == "normalize_then_sum": + grouped = rewards_per_func.view(-1, num_generations, len(self.reward_funcs)) + mean_k = torch.nanmean(grouped, dim=1, keepdim=True) + std_k = nanstd(grouped, dim=1, keepdim=True) if num_generations > 1 else torch.zeros_like(mean_k) + reward_k = (grouped - mean_k) / (std_k + 1e-4) + reward_k = reward_k.view(-1, len(self.reward_funcs)) + rewards = (reward_k * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + std_rewards = rewards.std().expand_as(rewards) if rewards.numel() > 1 else torch.zeros_like(rewards) + advantages = (rewards - rewards.mean()) / (std_rewards + 1e-4) + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) # for logging + + else: + raise ValueError( + f"Invalid multi_objective_aggregation: {self.multi_objective_aggregation}. Must be " + "'sum_then_normalize' or 'normalize_then_sum'." + ) + + # Slice to keep only the local part of the data + process_slice = slice( + self.accelerator.process_index * len(prompts), + (self.accelerator.process_index + 1) * len(prompts), + ) + all_process_advantages = advantages.clone() # keep the aggregated advantages for logging + advantages = advantages[process_slice] + + # Calculate mean reward per function, but only for samples where the function was applied (non-NaN values) + for i, reward_func_name in enumerate(self.reward_func_names): + mean_rewards = torch.nanmean(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/mean"].append(mean_rewards) + std_func_rewards = nanstd(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/std"].append(std_func_rewards) + rewards = (rewards_per_func * self.reward_weights.to(rewards_per_func.device).unsqueeze(0)).nansum(dim=1) + self._metrics[mode]["reward"].append(rewards.mean().item()) + self._metrics[mode]["reward_std"].append(rewards.std().item()) + self._metrics[mode]["frac_reward_zero_std"].append(is_std_zero.float().mean().item()) + + # Log prompt and completion texts + self._logs["prompt"].extend(gather_object(prompts_text)) + self._logs["completion"].extend(gather_object(completions_text)) + for i, name in enumerate(self.reward_func_names): + self._logs["rewards"][name].extend(rewards_per_func[:, i].tolist()) + self._logs["advantages"].extend(all_process_advantages.tolist()) + + # Flush user-logged extra columns (from log_extra), gathering across processes. + # Keys must be sorted so that all ranks call gather_object in the same order, otherwise values + # get mis-attributed across columns (dict insertion order may differ between processes). + for column in sorted(self._pending_extra_logs): + self._logs["extra"][column].extend(gather_object(self._pending_extra_logs[column])) + self._pending_extra_logs.clear() + + # Flush user-logged metrics (from log_metric), averaging across processes. + # Keys must be sorted so that all ranks call accelerator.gather in the same order, otherwise values + # get mis-attributed across metrics (dict insertion order may differ between processes). + for name in sorted(self._pending_metrics): + values = self._pending_metrics[name] + local_mean = sum(values) / len(values) + global_mean = self.accelerator.gather(torch.tensor(local_mean, device=device)).mean().item() + self._metrics[mode][name].append(global_mean) + self._pending_metrics.clear() + + if images is not None: + self._logs["images"].extend(gather_object(images)) + + if self.use_vllm and self.vllm_importance_sampling_correction: + delta = torch.abs(old_per_token_logps - sampling_per_token_logps) + mask = completion_mask.bool() if tool_mask is None else (completion_mask * tool_mask).bool() + delta = delta[mask] + mean_delta = torch.mean(delta) if delta.numel() > 0 else torch.tensor(0.0, device=device) + max_delta = torch.max(delta) if delta.numel() > 0 else torch.tensor(0.0, device=device) + self._metrics[mode]["sampling/sampling_logp_difference/mean"].append( + self.accelerator.gather(mean_delta).mean().item() + ) + self._metrics[mode]["sampling/sampling_logp_difference/max"].append( + self.accelerator.gather(max_delta).max().item() + ) + if sequence_level_is: + flat_is_ratio = vllm_importance_sampling_ratio.flatten() + else: + flat_is_ratio = vllm_importance_sampling_ratio[mask] + + min_importance_sampling_ratio = ( + torch.min(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + mean_importance_sampling_ratio = ( + torch.mean(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + max_importance_sampling_ratio = ( + torch.max(flat_is_ratio) if flat_is_ratio.numel() > 0 else torch.tensor(0.0, device=device) + ) + self._metrics[mode]["sampling/importance_sampling_ratio/min"].append( + nanmin(self.accelerator.gather(min_importance_sampling_ratio)).item() + ) + self._metrics[mode]["sampling/importance_sampling_ratio/mean"].append( + self.accelerator.gather(mean_importance_sampling_ratio).nanmean().item() + ) + self._metrics[mode]["sampling/importance_sampling_ratio/max"].append( + nanmax(self.accelerator.gather(max_importance_sampling_ratio)).item() + ) + + output = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "advantages": advantages, + "num_items_in_batch": num_items_in_batch, + } + if old_per_token_logps is not None: + output["old_per_token_logps"] = old_per_token_logps + if self.use_vllm and self.vllm_importance_sampling_correction: + output["importance_sampling_ratio"] = vllm_importance_sampling_ratio + if sampling_per_token_logps is not None: + output["sampling_per_token_logps"] = sampling_per_token_logps + if ref_per_token_logps is not None: + output["ref_per_token_logps"] = ref_per_token_logps + if "pixel_values" in forward_kwargs: + output["pixel_values"] = forward_kwargs["pixel_values"] + if "image_grid_thw" in forward_kwargs: + output["image_grid_thw"] = forward_kwargs["image_grid_thw"] + if "pixel_attention_mask" in forward_kwargs: + output["pixel_attention_mask"] = forward_kwargs["pixel_attention_mask"] + if "image_sizes" in forward_kwargs: + output["image_sizes"] = forward_kwargs["image_sizes"] + if "token_type_ids" in forward_kwargs: + output["token_type_ids"] = forward_kwargs["token_type_ids"] + if "mm_token_type_ids" in forward_kwargs: + output["mm_token_type_ids"] = forward_kwargs["mm_token_type_ids"] + if "image_position_ids" in forward_kwargs: + output["image_position_ids"] = forward_kwargs["image_position_ids"] + if images is not None: + output["num_images"] = num_images + if tool_mask is not None: + output["tool_mask"] = tool_mask + return output + + def compute_liger_loss(self, unwrapped_model, inputs): + # Compute the per-token log probabilities for the model + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + + # Get the last hidden state of the model + last_hidden_state = self._get_last_hidden_state( + unwrapped_model, + input_ids, + attention_mask, + logits_to_keep, + inputs.get("pixel_values"), + inputs.get("image_grid_thw"), + inputs.get("pixel_attention_mask"), + inputs.get("image_sizes"), + inputs.get("image_position_ids"), + ) + + # Apply tool_mask (from env_mask) for loss computation in multi-turn training scenarios + loss_mask = completion_mask if "tool_mask" not in inputs else completion_mask * inputs["tool_mask"] + # Compute loss and metrics using liger grpo loss + loss, metrics = self.liger_grpo_loss( + _input=last_hidden_state, + lin_weight=unwrapped_model.lm_head.weight, + selected_token_ids=completion_ids, + # The attention_mask parameter in liger loss is actually used as a loss mask (not model attention) + attention_mask=loss_mask, + advantages=inputs["advantages"], + bias=unwrapped_model.lm_head.bias, + old_per_token_logps=inputs.get("old_per_token_logps"), + ref_per_token_logps=inputs.get("ref_per_token_logps"), + vllm_is_ratio=inputs.get("importance_sampling_ratio"), + ) + # Extract metrics from the liger_grpo_loss output + # KL divergence is the first metric when beta is non-zero + mean_kl = metrics[0] if self.beta != 0.0 else None + clip_ratio = metrics[-1] + + mode = "train" if self.model.training else "eval" + if self.beta != 0.0: + self._metrics[mode]["kl"].append(self.accelerator.gather(mean_kl).mean().item()) + self._metrics[mode]["clip_ratio"].append(self.accelerator.gather(clip_ratio).mean().item()) + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + return loss / normalizer + + @profiling_decorator + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if return_outputs: + raise ValueError("The GRPOTrainer does not support returning outputs") + if self.use_liger_kernel: + # Compute the loss using the liger grpo loss + unwrapped_model = self.accelerator.unwrap_model(model) + return self._forward_redirection(model, unwrapped_model, self.compute_liger_loss, unwrapped_model, inputs) + else: + return self._compute_loss(model, inputs) + + @staticmethod + def get_off_policy_mask( + advantages: torch.Tensor, + per_token_logps: torch.Tensor, + sampling_per_token_logps: torch.Tensor, + mask: torch.Tensor, + off_policy_threshold: float, + ) -> torch.Tensor: + """ + Computes the Off-Policy Sequence Mask from DeepSeek-V3.2 paper. Returns a (B, 1) tensor where 1.0 indicates + "Keep" and 0.0 indicates "Drop". + """ + # forward KL div: log(pi_old) - log(pi_theta) + kl_div = sampling_per_token_logps - per_token_logps.detach() + # Sequence-level Mean KL (ignoring prompt+padding) + seq_kl_sum = (kl_div * mask).sum(dim=1, keepdim=True) + avg_seq_kl = seq_kl_sum / mask.sum(dim=1, keepdim=True).clamp(min=1.0) + # Keep if (Advantage >= 0) OR (KL <= delta) + is_pos_adv = advantages >= 0 + is_low_kl = avg_seq_kl <= off_policy_threshold + return (is_pos_adv | is_low_kl).to(dtype=mask.dtype) # (B, 1) + + @staticmethod + @torch.no_grad() + def get_gamma_weights( + advantages: torch.Tensor, + log_ratio_per_token: torch.Tensor, + mask: torch.Tensor, + importance_sampling_ratio: torch.Tensor | None, # (B, T) + k_pos: float = 2.0, + lambda_pos: float = 3.0, + k_neg: float = 3.0, + lambda_neg: float = 2.0, + ) -> torch.Tensor: + """ + Computes the Gamma weights for the VESPO loss. For reference: + φ(w) = e^λ × w^k × e^{-λw} is the gamma weighting (normalized so φ(1)=1) + with w = sequence-level importance sampling ratio + note: we will compute φ(w) in log space + + φ(w) is detached via @torch.no_grad(), only acts as gradient scaling coefficient + + VESPO loss = -φ(w) × A × log_prob, gradient naturally gives φ(w) × A × ∇log π + """ + # reducing clamp range directly to log(1e-8) ~ -18.42, to avoid recomputing log_w=log(w.clamp(min=1e-8)) later + # This is solely for matching truthfully the original implementation, otherwise keeping -20 could be fine. + lower_clamp = math.log(1e-8) + + # Sequence-level log ratio Σ log(π_θ/π_old) (not a mean like for `log_importance_weights`) + log_ratio_clamped = torch.clamp(log_ratio_per_token, -20.0, 20.0) + seq_log_ratio = torch.sum(log_ratio_clamped * mask, dim=-1, keepdim=True) # (B, 1) + + # Apply token-level TIS or MIS correction (in log space) + if importance_sampling_ratio is not None: + log_is_ratio = torch.clamp(torch.log(importance_sampling_ratio), lower_clamp, 20.0) + # log(w) = log(π_θ/π_old) + log(π_old/π_sampler) + seq_log_ratio += torch.sum(log_is_ratio, dim=-1, keepdim=True) + + log_w_seq = torch.clamp(seq_log_ratio, lower_clamp, 20.0) + w_seq = torch.exp(log_w_seq) + + # compute k and lambda based on advantage sign + is_nonneg_adv = advantages >= 0 + k_seq = torch.where(is_nonneg_adv, k_pos, k_neg) + lambda_seq = torch.where(is_nonneg_adv, lambda_pos, lambda_neg).clamp(min=1e-4) + + # log(φ(w)) = λ + k × log(w) - λ × w + log_phi = lambda_seq + k_seq * log_w_seq - lambda_seq * w_seq + phi_seq = torch.exp(log_phi).nan_to_num(nan=0.0, posinf=0.0, neginf=0.0) + + return phi_seq # (B, 1) + + def _compute_loss(self, model, inputs): + # Compute the per-token log probabilities for the model + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + mask = completion_mask if "tool_mask" not in inputs else completion_mask * inputs["tool_mask"] + + # Compute the per_token_logps and the entropy at each position in the completion + per_token_logps, entropies = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=True, + pixel_values=inputs.get("pixel_values"), + image_grid_thw=inputs.get("image_grid_thw"), + num_images=inputs.get("num_images"), + pixel_attention_mask=inputs.get("pixel_attention_mask"), + image_sizes=inputs.get("image_sizes"), + token_type_ids=inputs.get("token_type_ids"), + mm_token_type_ids=inputs.get("mm_token_type_ids"), + image_position_ids=inputs.get("image_position_ids"), + ) + + if self.top_entropy_quantile < 1.0: + entropy_mask = self.get_high_entropy_mask(entropies, mask, 1 - self.top_entropy_quantile) + else: + entropy_mask = None + + # Compute the loss + advantages = inputs["advantages"] + # In the base GRPO implementation, advantages are expected to have shape (B,). To support subclasses that + # provide advantages with shape (B, T) (e.g., MiniLLM), we *conditionally* unsqueeze the tensor. + if advantages.dim() == 1: + advantages = advantages.unsqueeze(1) + # When num_iterations == 1 and steps_per_generation <= gradient_accumulation_steps, + # old_per_token_logps == per_token_logps. In this case we can skip its computation + # (see _generate_and_score_completions) and instead use per_token_logps.detach(). + # The exception is when using vLLM, where we always compute old_per_token_logps + # for importance sampling + old_per_token_logps = inputs.get("old_per_token_logps") + old_per_token_logps = per_token_logps.detach() if old_per_token_logps is None else old_per_token_logps + + if self.off_policy_mask_threshold is not None: + # OPSM should use inference-time logprobs to detect both sources of off-policyness: + # 1. Drift from gradient updates (always present) + # 2. Drift from training-inference mismatch (when using vLLM) + # When using vLLM, prioritize sampling_per_token_logps, otherwise use old_per_token_logps + sampling_per_token_logps = inputs.get("sampling_per_token_logps", old_per_token_logps) + + off_policy_mask = self.get_off_policy_mask( + advantages=advantages, + per_token_logps=per_token_logps, + sampling_per_token_logps=sampling_per_token_logps, + mask=mask, + off_policy_threshold=self.off_policy_mask_threshold, + ) + + log_ratio = per_token_logps - old_per_token_logps + if self.importance_sampling_level == "token": + log_importance_weights = log_ratio + elif self.importance_sampling_level == "sequence": + log_importance_weights = (log_ratio * mask).sum(-1) / mask.sum(-1).clamp(min=1.0) + log_importance_weights = log_importance_weights.unsqueeze(-1) + else: + raise ValueError( + f"Unknown importance sampling level: {self.importance_sampling_level}. Possible values are 'token' " + "and 'sequence'." + ) + + coef_1 = torch.exp(log_importance_weights) + + # Compute the KL divergence between the model and the reference model + if self.beta != 0.0: + ref_per_token_logps = inputs["ref_per_token_logps"] + per_token_kl = ( + torch.exp(ref_per_token_logps - per_token_logps) - (ref_per_token_logps - per_token_logps) - 1 + ) + # Importance sampling correction for the KL divergence + if self.args.use_bias_correction_kl: + per_token_kl = per_token_kl * coef_1 + + # From here, log_importance_weights (and all subsequent tensors, coef_1, coef_2, etc.) shape depends on + # importance_sampling_level: "token" level: (B, T); "sequence" level: (B, 1) + if self.loss_type == "cispo": + clamped_ratios = torch.clamp(coef_1, max=self.epsilon_high).detach() + per_token_loss = -clamped_ratios * advantages * per_token_logps + elif self.loss_type in ["grpo", "bnpo", "dr_grpo", "dapo", "luspo"]: + coef_2 = torch.clamp(coef_1, 1 - self.epsilon_low, 1 + self.epsilon_high) + # Two-sided clipping + if self.args.delta is not None: + coef_1 = torch.clamp(coef_1, max=self.args.delta) + + per_token_loss1 = coef_1 * advantages + per_token_loss2 = coef_2 * advantages + per_token_loss = -torch.min(per_token_loss1, per_token_loss2) + elif self.loss_type == "sapo": + temperatures = torch.where(advantages > 0, self.args.sapo_temperature_pos, self.args.sapo_temperature_neg) + soft_coef_1 = torch.sigmoid(temperatures * (coef_1 - 1)) * 4 / temperatures + per_token_loss = -soft_coef_1 * advantages + elif self.loss_type == "vespo": + phi_seq = self.get_gamma_weights( + advantages=advantages, + log_ratio_per_token=log_ratio, + mask=mask, + importance_sampling_ratio=inputs.get("importance_sampling_ratio"), + k_pos=self.args.vespo_k_pos, + lambda_pos=self.args.vespo_lambda_pos, + k_neg=self.args.vespo_k_neg, + lambda_neg=self.args.vespo_lambda_neg, + ) + per_token_loss = -phi_seq * advantages * per_token_logps + else: + raise ValueError(f"Unknown loss type: {self.loss_type}") + + if self.off_policy_mask_threshold is not None: + per_token_loss = per_token_loss * off_policy_mask + + if entropy_mask is not None: + per_token_loss = per_token_loss * entropy_mask + + if self.use_vllm and self.vllm_importance_sampling_correction and self.loss_type != "vespo": + per_token_loss = per_token_loss * inputs["importance_sampling_ratio"] + + if self.beta != 0.0: + per_token_loss = per_token_loss + self.beta * per_token_kl + + mode = "train" if self.model.training else "eval" + if self.loss_type in ["grpo", "sapo"]: + loss = ((per_token_loss * mask).sum(-1) / mask.sum(-1).clamp(min=1.0)).mean() + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + loss = loss / normalizer + elif self.loss_type == "bnpo": + loss = (per_token_loss * mask).sum() / mask.sum().clamp(min=1.0) + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + loss = loss / normalizer + elif self.loss_type == "dr_grpo": + loss = (per_token_loss * mask).sum() / (per_token_loss.size(0) * self.max_completion_length) + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 # no accum in eval + loss = loss / normalizer + elif self.loss_type in ["cispo", "dapo", "vespo"]: + normalizer = inputs["num_items_in_batch"] / self.accelerator.num_processes + loss = (per_token_loss * mask).sum() / normalizer + elif self.loss_type == "luspo": + # Unless importance_sampling_level="token" (not recommended here), per_token_loss is expected to be (B, 1) + loss = (per_token_loss * mask.sum(1, keepdim=True)).mean() + normalizer = self.current_gradient_accumulation_steps if mode == "train" else 1.0 + loss = loss / normalizer + else: + raise ValueError(f"Unknown loss type: {self.loss_type}") + + # Log the metrics + completion_token_count = mask.sum().clamp(min=1.0) + + def masked_batch_mean(x): + if x.shape[1] == 1: # when importance_sampling_level == "sequence" + return x.mean() + else: + return (x * mask).sum() / completion_token_count + + if self.beta != 0.0: + mean_kl = masked_batch_mean(per_token_kl) + self._metrics[mode]["kl"].append(self.accelerator.gather(mean_kl).nanmean().item()) + + mean_entropy = masked_batch_mean(entropies) + self._metrics[mode]["entropy"].append(self.accelerator.gather(mean_entropy).nanmean().item()) + + if self.loss_type in ["grpo", "bnpo", "dr_grpo", "dapo", "luspo"]: + # Compute the clipped probability ratios + is_low_clipped = (coef_1 < 1 - self.epsilon_low) & (advantages < 0) + is_high_clipped = (coef_1 > 1 + self.epsilon_high) & (advantages > 0) + is_region_clipped = is_low_clipped | is_high_clipped + + low_clip = masked_batch_mean(is_low_clipped.float()) + high_clip = masked_batch_mean(is_high_clipped.float()) + clip_ratio = masked_batch_mean(is_region_clipped.float()) + + gathered_low_clip = self.accelerator.gather(low_clip) + self._metrics[mode]["clip_ratio/low_mean"].append(gathered_low_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/low_min"].append(nanmin(gathered_low_clip).item()) + gathered_high_clip = self.accelerator.gather(high_clip) + self._metrics[mode]["clip_ratio/high_mean"].append(gathered_high_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/high_max"].append(nanmax(gathered_high_clip).item()) + gathered_clip_ratio = self.accelerator.gather(clip_ratio) + self._metrics[mode]["clip_ratio/region_mean"].append(gathered_clip_ratio.nanmean().item()) + elif self.loss_type == "cispo": + is_cispo_clipped = (coef_1 > self.epsilon_high) & (advantages > 0) + cispo_clip_ratio = masked_batch_mean(is_cispo_clipped.float()) + gathered_cispo_clip_ratio = self.accelerator.gather(cispo_clip_ratio) + self._metrics[mode]["cispo_clip_ratio"].append(gathered_cispo_clip_ratio.nanmean().item()) + elif self.loss_type == "vespo": + gathered_phi_seq = self.accelerator.gather(phi_seq) + self._metrics[mode]["vespo/phi_seq_mean"].append(gathered_phi_seq.nanmean().item()) + + return loss + + # During eval, Trainer calls prediction_step. If no labels are present in the inputs, it only runs forward and + # returns logits. We override prediction_step to force compute_loss, because this trainer doesn't involve labels. + def prediction_step(self, model, inputs, prediction_loss_only, ignore_keys: list[str] | None = None): + inputs = self._prepare_inputs(inputs) + with torch.no_grad(): + with self.compute_loss_context_manager(): + loss = self.compute_loss(model, inputs) + loss = loss.mean().detach() + return loss, None, None + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + # Average the metrics + metrics = {} + for key, val in self._metrics[mode].items(): + # Filter out NaN values before averaging. A reward function that returns None for all samples + # in a batch produces NaN for that batch's metric. With logging_steps > 1, a naive sum()/len() + # would let a single NaN contaminate valid data from other batches. Only return None when no + # valid values remain (e.g. JSON loggers crash on float NaN). + valid = [v for v in val if not math.isnan(v)] + metrics[key] = sum(valid) / len(valid) if valid else None + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + if self.accelerator.is_main_process and self.log_completions: + if is_rich_available(): + print_prompt_completions_sample( + self._logs["prompt"], + self._logs["completion"], + self._logs["rewards"], + self._logs["advantages"], + self.state.global_step, + self.num_completions_to_print, + extra=dict(self._logs["extra"]), + ) + + logging_backends = [] + if self.args.report_to and "wandb" in self.args.report_to and wandb.run is not None: + logging_backends.append(wandb) + if self.args.report_to and "trackio" in self.args.report_to: + logging_backends.append(trackio) + + table = { + "step": [self.state.global_step] * len(self._logs["prompt"]), + "prompt": self._logs["prompt"], + "completion": self._logs["completion"], + **self._logs["rewards"], + **self._logs["extra"], + "advantage": self._logs["advantages"], + } + + df_base = pd.DataFrame(table) + df_base.to_parquet( + os.path.join( + self.args.output_dir, + "completions", + f"completions_{self.state.global_step:05d}.parquet", + ) + ) + + images_raw = self._logs["images"] or [] + + for logging_backend in logging_backends: + if images_raw: + images = [] + for image_list in self._logs["images"]: + if image_list: + images.append([logging_backend.Image(image) for image in image_list]) + else: + images.append([]) + df = pd.concat( + [df_base, pd.Series(images, name="image")], + axis=1, + copy=False, + ) + else: + df = df_base + + if self.log_unique_prompts: + df = df.drop_duplicates(subset=["prompt"]) + + logging_backend.log({"completions": logging_backend.Table(dataframe=df)}) + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/kto_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/kto_config.py new file mode 100644 index 0000000000000000000000000000000000000000..849648a8f74f245df98cab016a7b87fa1b628f93 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/kto_config.py @@ -0,0 +1,36 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass + +from ..import_utils import suppress_experimental_warning + + +with suppress_experimental_warning(): + from ..experimental.kto import KTOConfig as _KTOConfig + + +@dataclass +class KTOConfig(_KTOConfig): + def __post_init__(self): + warnings.warn( + "The `KTOConfig` is now located in `trl.experimental`. Please update your imports to " + "`from trl.experimental.kto import KTOConfig`. For more information, see " + "https://github.com/huggingface/trl/issues/4223. Promoting KTO to the stable API is a high-priority task. " + "Until then, this current path (`from trl import KTOConfig`) will remain, but API changes may occur.", + FutureWarning, + stacklevel=3, + ) + super().__post_init__() diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/kto_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/kto_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..110e29f0a8062efe09a87cddf2a7574d4f8d999e --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/kto_trainer.py @@ -0,0 +1,36 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass + +from ..import_utils import suppress_experimental_warning + + +with suppress_experimental_warning(): + from ..experimental.kto import KTOTrainer as _KTOTrainer + + +@dataclass +class KTOTrainer(_KTOTrainer): + def __init__(self, *args, **kwargs): + warnings.warn( + "The `KTOTrainer` is now located in `trl.experimental`. Please update your imports to " + "`from trl.experimental.kto import KTOTrainer`. For more information, see " + "https://github.com/huggingface/trl/issues/4223. Promoting KTO to the stable API is a high-priority task. " + "Until then, this current path (`from trl import KTOTrainer`) will remain, but API changes may occur.", + FutureWarning, + stacklevel=2, + ) + super().__init__(*args, **kwargs) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/model_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/model_config.py new file mode 100644 index 0000000000000000000000000000000000000000..29860a629a650c8574a19319b128a35d21c69a01 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/model_config.py @@ -0,0 +1,188 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from dataclasses import dataclass, field + + +@dataclass +class ModelConfig: + """ + Configuration class for the models. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + model_name_or_path (`str`, *optional*): + Model checkpoint for weights initialization. + model_revision (`str`, *optional*, defaults to `"main"`): + Specific model version to use. It can be a branch name, a tag name, or a commit id. + dtype (`Literal["auto", "bfloat16", "float16", "float32"]`, *optional*, defaults to `"float32"`): + Override the default `torch.dtype` and load the model under this dtype. Possible values are + + - `"bfloat16"`: `torch.bfloat16` + - `"float16"`: `torch.float16` + - `"float32"`: `torch.float32` + - `"auto"`: Automatically derive the dtype from the model's weights. + + trust_remote_code (`bool`, *optional*, defaults to `False`): + Whether to allow for custom models defined on the Hub in their own modeling files. This option should only + be set to `True` for repositories you trust and in which you have read the code, as it will execute code + present on the Hub on your local machine. + attn_implementation (`str`, *optional*): + Which attention implementation to use. More information in the [Kernels Hub Integrations + Guide](kernels_hub). + use_peft (`bool`, *optional*, defaults to `False`): + Whether to use PEFT for training. + lora_r (`int`, *optional*, defaults to `16`): + LoRA R value. + lora_alpha (`int`, *optional*, defaults to `32`): + LoRA alpha. + lora_dropout (`float`, *optional*, defaults to `0.05`): + LoRA dropout. + lora_target_modules (`str | list[str]`, *optional*): + LoRA target modules. + lora_target_parameters (`str | list[str]`, *optional*): + List of target parameters for LoRA. + lora_modules_to_save (`list[str]`, *optional*): + Model layers to unfreeze & train. + lora_task_type (`str`, *optional*, defaults to `"CAUSAL_LM"`): + Task type to pass for LoRA (use `"SEQ_CLS"` for reward modeling). + use_rslora (`bool`, *optional*, defaults to `False`): + Whether to use Rank-Stabilized LoRA, which sets the adapter scaling factor to `lora_alpha/√r`, instead of + the original default value of `lora_alpha/r`. + use_dora (`bool`, *optional*, defaults to `False`): + Enable [Weight-Decomposed Low-Rank Adaptation (DoRA)](https://huggingface.co/papers/2402.09353). This + technique decomposes the updates of the weights into two parts, magnitude and direction. Direction is + handled by normal LoRA, whereas the magnitude is handled by a separate learnable parameter. This can + improve the performance of LoRA, especially at low ranks. Right now, DoRA only supports linear and Conv2D + layers. DoRA introduces a bigger overhead than pure LoRA, so it is recommended to merge weights for + inference. + load_in_8bit (`bool`, *optional*, defaults to `False`): + Whether to use 8 bit precision for the base model. Works only with LoRA. + load_in_4bit (`bool`, *optional*, defaults to `False`): + Whether to use 4 bit precision for the base model. Works only with LoRA. + bnb_4bit_quant_type (`str`, *optional*, defaults to `"nf4"`): + Quantization type (`"fp4"` or `"nf4"`). + use_bnb_nested_quant (`bool`, *optional*, defaults to `False`): + Whether to use nested quantization. + """ + + model_name_or_path: str | None = field( + default=None, + metadata={"help": "Model checkpoint for weights initialization."}, + ) + model_revision: str = field( + default="main", + metadata={"help": "Specific model version to use. It can be a branch name, a tag name, or a commit id."}, + ) + dtype: str | None = field( + default="float32", + metadata={ + "help": "Override the default `torch.dtype` and load the model under this dtype. It defaults to `'float32'`.", + "choices": ["auto", "bfloat16", "float16", "float32"], + }, + ) + trust_remote_code: bool = field( + default=False, + metadata={ + "help": "Whether to allow for custom models defined on the Hub in their own modeling files. This option " + "should only be set to `True` for repositories you trust and in which you have read the code, as it will " + "execute code present on the Hub on your local machine." + }, + ) + attn_implementation: str | None = field( + default=None, + metadata={ + "help": "Which attention implementation to use. You can run `--attn_implementation=flash_attention_2`, in " + "which case you must install this manually by running `pip install flash-attn --no-build-isolation`." + }, + ) + use_peft: bool = field( + default=False, + metadata={"help": "Whether to use PEFT for training."}, + ) + lora_r: int = field( + default=16, + metadata={"help": "LoRA R value."}, + ) + lora_alpha: int = field( + default=32, + metadata={"help": "LoRA alpha."}, + ) + lora_dropout: float = field( + default=0.05, + metadata={"help": "LoRA dropout."}, + ) + lora_target_modules: list[str] | None = field( + default=None, + metadata={"help": "LoRA target modules."}, + ) + lora_target_parameters: list[str] | None = field( + default=None, + metadata={"help": "List of target parameters for LoRA."}, + ) + lora_modules_to_save: list[str] | None = field( + default=None, + metadata={"help": "Model layers to unfreeze & train."}, + ) + lora_task_type: str = field( + default="CAUSAL_LM", + metadata={"help": "Task type to pass for LoRA (use 'SEQ_CLS' for reward modeling)."}, + ) + use_rslora: bool = field( + default=False, + metadata={ + "help": "Whether to use Rank-Stabilized LoRA, which sets the adapter scaling factor to `lora_alpha/√r`, " + "instead of the original default value of `lora_alpha/r`." + }, + ) + use_dora: bool = field( + default=False, + metadata={ + "help": "Enable Weight-Decomposed Low-Rank Adaptation (DoRA). This technique decomposes the updates of " + "the weights into two parts, magnitude and direction. Direction is handled by normal LoRA, whereas the " + "magnitude is handled by a separate learnable parameter. This can improve the performance of LoRA, " + "especially at low ranks. Right now, DoRA only supports linear and Conv2D layers. DoRA introduces a " + "bigger overhead than pure LoRA, so it is recommended to merge weights for inference." + }, + ) + load_in_8bit: bool = field( + default=False, + metadata={"help": "Whether to use 8 bit precision for the base model. Works only with LoRA."}, + ) + load_in_4bit: bool = field( + default=False, + metadata={"help": "Whether to use 4 bit precision for the base model. Works only with LoRA."}, + ) + bnb_4bit_quant_type: str = field( + default="nf4", + metadata={"help": "Quantization type.", "choices": ["fp4", "nf4"]}, + ) + use_bnb_nested_quant: bool = field( + default=False, + metadata={"help": "Whether to use nested quantization."}, + ) + bnb_4bit_quant_storage: str | None = field( + default=None, + metadata={"help": "Quantization storage dtype"}, + ) + + def __post_init__(self): + if self.load_in_8bit and self.load_in_4bit: + raise ValueError("You can't use 8 bit and 4 bit precision at the same time") + + if hasattr(self.lora_target_modules, "__len__") and len(self.lora_target_modules) == 1: + self.lora_target_modules = self.lora_target_modules[0] diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/reward_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/reward_config.py new file mode 100644 index 0000000000000000000000000000000000000000..5740bc6e81333bef93106c7ae497cdbed7e916e1 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/reward_config.py @@ -0,0 +1,176 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from .base_config import _BaseConfig + + +@dataclass +class RewardConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`RewardTrainer`]. + + This class includes only the parameters that are specific to Reward training. For a full list of training + arguments, please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this + class may differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`RewardTrainer`] is provided as a string. If you're training a MoE architecture and want + to include the load balancing/auxiliary loss as a part of the final loss, remember to set + `output_router_logits=True` in this dictionary. + chat_template_path (`str`, *optional*): + If specified, sets the model's chat template. This can either be the path to a tokenizer (local directory + or Hugging Face Hub model) or a direct path to a Jinja template file. When using a Jinja file, you must + ensure that any special tokens referenced in the template are added to the tokenizer and that the model's + embedding layer is resized accordingly. + disable_dropout (`bool`, *optional*, defaults to `True`): + Whether to disable dropout in the model. + + > Parameters that control the data preprocessing + + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + eos_token (`str`, *optional*): + Token used to indicate the end of a turn or sequence. If `None`, it defaults to + `processing_class.eos_token`. + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the tokenized sequence. Samples are filtered out if either chosen or rejected sequence + exceeds this value. If `None`, no filtering is applied. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + + > Parameters that control the training + + center_rewards_coefficient (`float`, *optional*): + Coefficient to incentivize the reward model to output mean-zero rewards (proposed by + https://huggingface.co/papers/2312.09244, Eq. 2). Recommended value: `0.01`. + activation_offloading (`bool`, *optional*, defaults to `False`): + Whether to offload the activations to the CPU. + + > Deprecated parameters + + pad_token: + + + + Parameter `pad_token` is deprecated and will be removed in version v2.0.0. Set `tokenizer.pad_token` + directly and pass it as `processing_class` to the trainer instead. + + + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-4` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-4, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument of " + "the `RewardTrainer` is provided as a string. If you're training a MoE architecture and want to include " + "the load balancing/auxiliary loss as a part of the final loss, remember to set " + "`output_router_logits=True` in this dictionary." + }, + ) + chat_template_path: str | None = field( + default=None, + metadata={ + "help": "If specified, sets the model's chat template. This can either be the path to a tokenizer (local " + "directory or Hugging Face Hub model) or a direct path to a Jinja template file. When using a Jinja file, " + "you must ensure that any special tokens referenced in the template are added to the tokenizer and " + "that the model's embedding layer is resized accordingly." + }, + ) + disable_dropout: bool = field( + default=True, + metadata={"help": "Whether to disable dropout in the model."}, + ) + + # Parameters that control the data preprocessing + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + eos_token: str | None = field( + default=None, + metadata={ + "help": "Token used to indicate the end of a turn or sequence. If `None`, it defaults to `processing_class.eos_token`." + }, + ) + max_length: int | None = field( + default=1024, + metadata={ + "help": "Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from " + "the right. If `None`, no truncation is applied." + }, + ) + pad_to_multiple_of: int | None = field( + default=None, + metadata={"help": "If set, the sequences will be padded to a multiple of this value."}, + ) + + # Parameters that control the training + center_rewards_coefficient: float | None = field( + default=None, + metadata={ + "help": "Coefficient to incentivize the reward model to output mean-zero rewards (proposed by " + "https://huggingface.co/papers/2312.09244, Eq. 2). Recommended value: `0.01`." + }, + ) + activation_offloading: bool = field( + default=False, + metadata={"help": "Whether to offload the activations to the CPU."}, + ) + + # Deprecated parameters + pad_token: str | None = field( + default=None, + metadata={ + "help": "Deprecated. Set `tokenizer.pad_token` directly and pass it as `processing_class` to the trainer instead." + }, + ) + + def __post_init__(self): + super().__post_init__() + if self.pad_token is not None: + warnings.warn( + "`pad_token` is deprecated and will be removed in v2.0.0. " + "Set `tokenizer.pad_token` directly and pass it as `processing_class` to the trainer instead.", + FutureWarning, + stacklevel=3, + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/reward_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/reward_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..b33c9fb04dee16dd95e3916acbee1353758784a2 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/reward_trainer.py @@ -0,0 +1,700 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import contextlib +import json +import logging +import os +import re +import warnings +from collections import defaultdict +from collections.abc import Callable +from contextlib import contextmanager +from dataclasses import dataclass +from pathlib import Path +from typing import Any + +import torch +import torch.nn as nn +import transformers +from accelerate import PartialState +from accelerate.logging import get_logger +from accelerate.utils import is_peft_model +from datasets import Dataset, IterableDataset +from packaging.version import Version +from transformers import ( + AutoModelForSequenceClassification, + AutoTokenizer, + DataCollator, + PreTrainedModel, + PreTrainedTokenizerBase, + TrainerCallback, + set_seed, +) +from transformers.data.data_collator import DataCollatorMixin +from transformers.modeling_layers import GenericForSequenceClassification +from transformers.trainer_utils import EvalPrediction +from transformers.utils import is_peft_available + +from ..chat_template_utils import clone_chat_template +from ..data_utils import is_conversational +from ..models import get_act_offloading_ctx_manager +from .base_trainer import _BaseTrainer +from .reward_config import RewardConfig +from .utils import create_model_from_path, disable_dropout_in_model, get_config_model_id, pad + + +if is_peft_available(): + from peft import PeftConfig, PeftModel, get_peft_model + + +logger = get_logger(__name__) + + +# Loading a CausalLM checkpoint into AutoModelForSequenceClassification triggers harmless warnings: +# - MISSING score.weight : the new seq-clf head was not in the checkpoint and is randomly initialized. +# - UNEXPECTED lm_head.weight: the causal LM head is in the checkpoint but absent from seq-clf (>= 4.57.0 only). +# Both are expected consequences of intentional cross-architecture loading. We suppress them to avoid +# confusing users. + + +# Old approach using logging filter (for transformers < 4.57.0) +# Note: in transformers < 4.57.0, only the MISSING score.weight warning is emitted; lm_head.weight is not reported. +@contextmanager +def _suppress_seqcls_cross_arch_keys(logger: logging.Logger): + pattern = re.compile( + r"^Some weights of \S+ were not initialized from the model checkpoint at \S+ and are newly initialized: " + r"\[.*\]\nYou should probably TRAIN this model on a down-stream task to be able to use it for predictions and " + r"inference\.$" + ) + + class _Filter(logging.Filter): + def filter(self, record: logging.LogRecord) -> bool: + return not pattern.search(record.getMessage()) + + f = _Filter() + logger.addFilter(f) + try: + yield + finally: + logger.removeFilter(f) + + +# New approach using scoped override (for transformers >= 4.57.0) +@contextmanager +def _ignore_seqcls_cross_arch_keys(): + # Scoped override: ignore the expected seq-clf head key (newly added) and the causal LM head + # key (present in the checkpoint but absent from seq-clf). + old_missing = getattr(GenericForSequenceClassification, "_keys_to_ignore_on_load_missing", None) + old_unexpected = getattr(GenericForSequenceClassification, "_keys_to_ignore_on_load_unexpected", None) + + merged_missing = list(old_missing) if old_missing is not None else [] + if r"^score\.weight$" not in merged_missing: + merged_missing.append(r"^score\.weight$") + + merged_unexpected = list(old_unexpected) if old_unexpected is not None else [] + if r"^lm_head\." not in merged_unexpected: + merged_unexpected.append(r"^lm_head\.") + + GenericForSequenceClassification._keys_to_ignore_on_load_missing = merged_missing + GenericForSequenceClassification._keys_to_ignore_on_load_unexpected = merged_unexpected + try: + yield + finally: + GenericForSequenceClassification._keys_to_ignore_on_load_missing = old_missing + GenericForSequenceClassification._keys_to_ignore_on_load_unexpected = old_unexpected + + +# Version-aware wrapper that chooses the appropriate approach +@contextmanager +def suppress_seqcls_warning(): + # Use the new approach for transformers >= 4.57.0, old approach for earlier versions + # The old approach is needed for 4.56.2 to avoid meta tensor issues with device_map=None + if Version(transformers.__version__) >= Version("4.57.0"): + with _ignore_seqcls_cross_arch_keys(): + yield + else: + # Get the transformers logger + transformers_logger = logging.getLogger("transformers.modeling_utils") + with _suppress_seqcls_cross_arch_keys(transformers_logger): + yield + + +def get_dataset_column_names(dataset: Dataset | IterableDataset) -> list[str]: + return list(next(iter(dataset)).keys()) if dataset.column_names is None else dataset.column_names + + +@dataclass +class DataCollatorForPreference(DataCollatorMixin): + """ + Data collator used for preference data. Inputs are dynamically padded to the maximum length of a batch. + + This collator expects each example in the input list to be a dictionary containing the `"chosen_ids"` and + `"rejected_ids"` keys. The collator returns a dictionary containing the following keys: + - `"input_ids"`: Tensor of input IDs, padded to the maximum length of the batch. The first half of the batch + corresponds to the `"chosen_ids"` and the second half to the `"rejected_ids"`. + - `"attention_mask"`: Tensor of attention mask, padded to the maximum length of the batch. + + Optionally, the examples can contain a `"margin"` key, in which case the returned dictionary will also contain a + `"margin"` key with a tensor of margins. + + Args: + pad_token_id (`int`): + Token ID to use for padding. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + return_tensors (`str`, *optional*, defaults to `"pt"`): + Type of Tensor to return. Only `"pt"` is currently supported. + + Examples: + ```python + >>> from trl.trainer.reward_trainer import DataCollatorForPreference + + >>> collator = DataCollatorForPreference(pad_token_id=0) + >>> examples = [ + ... {"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5]}, + ... {"chosen_ids": [6, 7], "rejected_ids": [8]}, + ... ] + >>> collator(examples) + {'input_ids': tensor([[1, 2, 3], + [6, 7, 0], + [4, 5, 0], + [8, 0, 0]]), + 'attention_mask': tensor([[1, 1, 1], + [1, 1, 0], + [1, 1, 0], + [1, 0, 0]])} + + >>> examples = [ + ... {"chosen_ids": [1, 2, 3], "rejected_ids": [4, 5], "margin": 0.5}, + ... {"chosen_ids": [6, 7], "rejected_ids": [8], "margin": 0.0}, + ... ] + >>> collator(examples) + {'input_ids': tensor([[1, 2, 3], + [6, 7, 0], + [4, 5, 0], + [8, 0, 0]]), + 'attention_mask': tensor([[1, 1, 1], + [1, 1, 0], + [1, 1, 0], + [1, 0, 0]]), + 'margin': tensor([0.5, 0.0])} + ``` + """ + + pad_token_id: int + pad_to_multiple_of: int | None = None + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + # Convert to tensor + chosen_ids = [torch.tensor(example["chosen_ids"]) for example in examples] + rejected_ids = [torch.tensor(example["rejected_ids"]) for example in examples] + if "margin" in examples[0]: + margins = torch.tensor([example["margin"] for example in examples], dtype=torch.float) + input_ids = chosen_ids + rejected_ids + attention_mask = [torch.ones_like(ids) for ids in input_ids] + + output = {} + + # Pad + output["input_ids"] = pad( + input_ids, + padding_value=self.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + output["attention_mask"] = pad( + attention_mask, + padding_value=0, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + if "margin" in examples[0]: + output["margin"] = margins + return output + + +class RewardTrainer(_BaseTrainer): + """ + Trainer for Outcome-supervised Reward Models (ORM). + + This class is a wrapper around the [`~transformers.Trainer`] class and inherits all of its attributes and methods. + + Example: + + ```python + from trl import RewardTrainer + from datasets import load_dataset + + dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train") + + trainer = RewardTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `AutoModelForSequenceClassification.from_pretrained` with the keyword arguments in + `args.model_init_kwargs`. + - A sequence classification [`~transformers.PreTrainedModel`] object. + - A sequence classification [`~peft.PeftModel`] object. + args ([`RewardConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + data_collator ([`~transformers.DataCollator`], *optional*): + Function to use to form a batch from a list of elements of the processed `train_dataset` or `eval_dataset`. + Will default to [`~trainer.reward_trainer.DataCollatorForPreference`]. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. This trainer supports [preference](#preference) type (both implicit and + explicit prompt). The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + + The trainer also supports processed datasets (tokenized) as long as they contain `chosen_ids` and + `rejected_ids` fields. + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], *optional*): + Tokenizer used to process the data. If `None`, the tokenizer is loaded from the model's name with + [`~transformers.AutoTokenizer.from_pretrained`]. A padding token, `processing_class.pad_token`, must be + set. If the processing class has not set a padding token, `processing_class.eos_token` will be used as the + default. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function that will be used to compute metrics at evaluation. Must take a + [`~transformers.EvalPrediction`] and return a dictionary string to metric values. When passing + [`RewardConfig`] with `batch_eval_metrics` set to `True`, your `compute_metrics` function must take a + boolean `compute_result` argument. This will be triggered after the last eval batch to signal that the + function needs to calculate and return the global summary statistics rather than accumulating the + batch-level statistics. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + optimizer_cls_and_kwargs (`tuple[Type[torch.optim.Optimizer], Dict[str, Any]]`, *optional*): + A tuple containing the optimizer class and keyword arguments to use. Overrides `optim` and `optim_args` in + `args`. Incompatible with the `optimizers` argument. + + Unlike `optimizers`, this argument avoids the need to place model parameters on the correct devices before + initializing the Trainer. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`, *optional*): + A function that preprocess the logits right before caching them at each evaluation step. Must take two + tensors, the logits and the labels, and return the logits once processed as desired. The modifications made + by this function will be reflected in the predictions received by `compute_metrics`. + + Note that the labels (second parameter) will be `None` if the dataset does not have them. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. Note that if the loaded + model is a causal LM, it's highly recommended to set `modules_to_save=["score"]` in the PEFT configuration + to ensure that the reward head is properly trained. + """ + + _tag_names = ["trl", "reward-trainer"] + _name = "Reward" + _template_file = "rm_model_card.md" + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + args: RewardConfig | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + optimizer_cls_and_kwargs: tuple[type[torch.optim.Optimizer], dict[str, Any]] | None = None, + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: "PeftConfig | None" = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = RewardConfig(f"{model_name}-Reward") + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif isinstance(train_dataset, IterableDataset): + # IterableDataset requires dispatch_batches=False because Accelerate's dispatch mode may try to concatenate + # batches from multiple processes, leading to mismatch errors. + if args.accelerator_config.dispatch_batches is True: + logger.warning( + "You are using an `IterableDataset` for training with `dispatch_batches=True`. `dispatch_batches` " + "is forced to `False` when using an `IterableDataset`. To remove this warning, unset " + "`dispatch_batches` in `RewardConfig` or set it to `False`." + ) + args.accelerator_config.dispatch_batches = False + + # Model + # As AutoModelForSequenceClassification.from_pretrained() will add a random head for the model, set_seed must + # be done before loading the model to ensure reproducibility. + set_seed(args.seed) + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model_init_kwargs["num_labels"] = 1 # the only output of the model is the reward score + with suppress_seqcls_warning(): + model = create_model_from_path(model, AutoModelForSequenceClassification, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the `RewardConfig`, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + # Validate that the model has num_labels = 1 (required for reward models) + if getattr(model.config, "num_labels", None) != 1: + raise ValueError( + f"The model has `num_labels={model.config.num_labels}`, but reward models require `num_labels=1` " + "to output a single scalar reward per sequence. Please instantiate your model with `num_labels=1` " + "or pass a model name as a string to have it configured automatically." + ) + + # Processing class + if processing_class is None: + processing_class = AutoTokenizer.from_pretrained(get_config_model_id(model.config)) + + # Handle pad token for processors or tokenizers + if args.eos_token is not None: + if args.eos_token not in processing_class.get_vocab(): + raise ValueError( + f"The specified `eos_token` ('{args.eos_token}') is not found in the vocabulary of the given " + f"`processing_class` ({processing_class.__class__.__name__}). Ensure that the `eos_token` exists " + "in the vocabulary before using it as an EOS token." + ) + processing_class.eos_token = args.eos_token + + if args.chat_template_path is not None: + if os.path.isfile(args.chat_template_path) and args.chat_template_path.endswith((".jinja", ".j2")): + with open(args.chat_template_path, encoding="utf-8") as chat_template_file: + processing_class.chat_template = chat_template_file.read() + added_tokens = [] + else: + model, processing_class, added_tokens = clone_chat_template( + model, processing_class, args.chat_template_path + ) + else: + added_tokens = [] + + # PEFT configuration and model wrapping + if peft_config is not None: + if added_tokens: + # Ensure that the added tokens are trainable + if peft_config.trainable_token_indices is None: + peft_config.trainable_token_indices = {"embed_tokens": added_tokens} + elif "embed_tokens" not in peft_config.trainable_token_indices: + peft_config.trainable_token_indices["embed_tokens"] = added_tokens + else: + peft_config.trainable_token_indices["embed_tokens"].extend(added_tokens) + + # Ensure that the lm_head is trainable + if peft_config.modules_to_save is None or "lm_head" not in peft_config.modules_to_save: + logger.warning( + "Cloning chat template added new tokens to the tokenizer, but 'lm_head' is not in PEFT's " + "`modules_to_save`. As a result, the model may not learn to generate outputs with these new " + "tokens, leading to degraded generation quality. To fix this, add " + "`modules_to_save=['lm_head']` to your PEFT configuration." + ) + + if peft_config.modules_to_save is None: + peft_config.modules_to_save = ["lm_head"] + else: + peft_config.modules_to_save.append("lm_head") + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + + # Create PEFT model + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # When using gradient checkpointing with PEFT, we need to enable input gradients. transformers.Trainer normally + # handles this, but a bug currently prevents it; see https://github.com/huggingface/transformers/issues/42489 + if is_peft_available() and is_peft_model(model) and args.gradient_checkpointing: + model.enable_input_require_grads() + + # When using QLoRA, the PEFT adapter weights are converted to bf16 to follow the recommendations from the + # original paper (see https://huggingface.co/papers/2305.14314, paragraph 3). Normally, this can be done by + # passing `autocast_adapter_dtype=False` to `get_peft_model`, but this option is not yet supported for + # quantized models. See: https://github.com/huggingface/peft/issues/2889 + # Non-quantized models do not have the `is_loaded_in_{8,4}bit` attributes, whereas quantized models do + if getattr(model, "is_loaded_in_4bit", False) or getattr(model, "is_loaded_in_8bit", False): + for param in model.parameters(): + if param.requires_grad: + param.data = param.data.to(torch.bfloat16) + + # Disable dropout in the model + if args.disable_dropout: + disable_dropout_in_model(model) + + # Pad token (needed for SequenceClassification models) + # If not provided, use the one from the processing class or the eos token if the processing class does not have + # a pad token. + pad_token = args.pad_token or processing_class.pad_token or processing_class.eos_token + if pad_token not in processing_class.get_vocab(): + raise ValueError( + f"The specified `pad_token` ('{pad_token}') is not found in the vocabulary of the given " + f"`processing_class` ({processing_class.__class__.__name__}). Ensure that the `pad_token` exists " + "in the vocabulary before using it as a padding token." + ) + processing_class.pad_token = pad_token + + # Data collator + if data_collator is None: + data_collator = DataCollatorForPreference( + pad_token_id=processing_class.pad_token_id, + pad_to_multiple_of=args.pad_to_multiple_of, + ) + + # Dataset + train_dataset = self._prepare_dataset(train_dataset, processing_class, args, "train") + if eval_dataset is not None: + if isinstance(eval_dataset, dict): + eval_dataset = { + key: self._prepare_dataset(dataset, processing_class, args, key) + for key, dataset in eval_dataset.items() + } + else: + eval_dataset = self._prepare_dataset(eval_dataset, processing_class, args, "eval") + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + optimizer_cls_and_kwargs=optimizer_cls_and_kwargs, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # During evaluation, Trainer calls compute_loss() only if can_return_loss is True and label_names is empty. + self.can_return_loss = True + self.label_names = [] + + # Initialize activation offloading context + if self.args.activation_offloading: + self.maybe_activation_offload_context = get_act_offloading_ctx_manager(model=self.model) + else: + self.maybe_activation_offload_context = contextlib.nullcontext() + + self.aux_loss_enabled = getattr(model.config, "output_router_logits", False) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + def _prepare_dataset( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase, + args: RewardConfig, + dataset_name: str, + ) -> Dataset | IterableDataset: + # If the dataset is already preprocessed (tokenized), skip the processing steps. + column_names = get_dataset_column_names(dataset) + is_processed = "chosen_ids" in column_names and "rejected_ids" in column_names + has_legacy_processed_columns = "chosen_input_ids" in column_names and "rejected_input_ids" in column_names + if has_legacy_processed_columns and not is_processed: + warnings.warn( + "Detected legacy dataset columns `chosen_input_ids`/`rejected_input_ids`; they are deprecated and " + "will not be supported in v1. Please migrate to `chosen_ids`/`rejected_ids`.", + FutureWarning, + stacklevel=2, + ) + dataset = dataset.rename_column("chosen_input_ids", "chosen_ids") + dataset = dataset.rename_column("rejected_input_ids", "rejected_ids") + is_processed = True + + # Build the kwargs for the `map` function + map_kwargs = {} + if isinstance(dataset, Dataset): # IterableDataset does not support num_proc + map_kwargs["num_proc"] = args.dataset_num_proc + + with PartialState().main_process_first(): + if not is_processed: + # Add EOS token if needed: non-conversational only + first_example = next(iter(dataset)) + if not is_conversational(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Adding EOS to {dataset_name} dataset" + + def add_eos(example, eos_token): + if not example["chosen"].endswith(eos_token): + example["chosen"] = example["chosen"] + eos_token + if "rejected" in example and not example["rejected"].endswith(eos_token): + example["rejected"] = example["rejected"] + eos_token + return example + + dataset = dataset.map( + add_eos, + fn_kwargs={"eos_token": processing_class.eos_token}, + **map_kwargs, + ) + + # Tokenize the dataset + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Tokenizing {dataset_name} dataset" + + def tokenize_fn(example, processing_class): + tools = example.get("tools") + tools = json.loads(tools) if isinstance(tools, str) else tools + if "prompt" in example: # explicit prompt case + example["chosen"] = example["prompt"] + example["chosen"] + example["rejected"] = example["prompt"] + example["rejected"] + + if is_conversational(example): + chosen_ids = processing_class.apply_chat_template( + example["chosen"], + tools=tools, + return_dict=True, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + rejected_ids = processing_class.apply_chat_template( + example["rejected"], + tools=tools, + return_dict=True, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + output = {"chosen_ids": chosen_ids, "rejected_ids": rejected_ids} + else: + output = { + "chosen_ids": processing_class(text=example["chosen"])["input_ids"], + "rejected_ids": processing_class(text=example["rejected"])["input_ids"], + } + return output + + dataset = dataset.map(tokenize_fn, fn_kwargs={"processing_class": processing_class}, **map_kwargs) + + # Filter samples that are longer than `max_length` + if args.max_length is not None: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Filtering {dataset_name} >{args.max_length} tokens" + dataset = dataset.filter( + lambda example: len(example["chosen_ids"]) <= args.max_length + and len(example["rejected_ids"]) <= args.max_length, + **map_kwargs, + ) + + return dataset + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). + if self._signature_columns is None: + self._signature_columns = ["chosen_ids", "rejected_ids", "margin"] + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + mode = "train" if self.model.training else "eval" + + # If not set, defaults from model config and may warn since cache isn't compatible with gradient checkpointing + inputs["use_cache"] = False + outputs = model(**inputs) + + # Split the rewards into chosen and rejected + rewards_chosen, rewards_rejected = torch.chunk(outputs.logits.squeeze(-1), chunks=2) + + # Calculate loss, optionally modulate with margin + if "margin" in inputs: + loss = -nn.functional.logsigmoid(rewards_chosen - rewards_rejected - inputs["margin"]).mean() + else: + loss = -nn.functional.logsigmoid(rewards_chosen - rewards_rejected).mean() + + if self.args.center_rewards_coefficient is not None: + loss += self.args.center_rewards_coefficient * torch.mean((rewards_chosen + rewards_rejected) ** 2) + + if mode == "train": + num_tokens_in_batch = self.accelerator.gather_for_metrics(inputs["attention_mask"].sum()).sum().item() + self._total_train_tokens += num_tokens_in_batch + self._metrics[mode]["num_tokens"] = [self._total_train_tokens] + + # Compute min, mean, max, accuracy and margin + with torch.no_grad(): + all_rewards = self.accelerator.gather(outputs.logits) + self._metrics[mode]["min_reward"].append(all_rewards.min().item()) + self._metrics[mode]["mean_reward"].append(all_rewards.mean().item()) + self._metrics[mode]["max_reward"].append(all_rewards.max().item()) + + mean_accuracy = (rewards_chosen > rewards_rejected).float().mean() + mean_accuracy = self.accelerator.gather_for_metrics(mean_accuracy).mean().item() + self._metrics[mode]["accuracy"].append(mean_accuracy) + + mean_margin = (rewards_chosen - rewards_rejected).mean() + mean_margin = self.accelerator.gather_for_metrics(mean_margin).mean() + self._metrics[mode]["margin"].append(mean_margin.item()) + + return (loss, outputs) if return_outputs else loss + + # Override training step to add activation offloading context. + def training_step(self, *args, **kwargs): + with self.maybe_activation_offload_context: + return super().training_step(*args, **kwargs) + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + metrics = {key: sum(val) / len(val) for key, val in self._metrics[mode].items()} # average the metrics + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/rloo_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/rloo_config.py new file mode 100644 index 0000000000000000000000000000000000000000..5000e1120e062bee3072904355e39694cd78c488 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/rloo_config.py @@ -0,0 +1,612 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from .base_config import _BaseConfig + + +@dataclass +class RLOOConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`RLOOTrainer`]. + + This class includes only the parameters that are specific to RLOO training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model and reference model + + model_init_kwargs (`str`, `dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`RLOOTrainer`] is provided as a string. + disable_dropout (`bool`, *optional*, defaults to `False`): + Whether to disable dropout in the model. This is useful for training with a reference model, as it prevents + the model from generating different logprobs for the same input. + + > Parameters that control the data preprocessing + + remove_unused_columns (`bool`, *optional*, defaults to `False`): + Whether to only keep the column `"prompt"` in the dataset. If you use a custom reward function that + requires any column other than `"prompts"` and `"completions"`, you should keep this to `False`. + num_generations (`int`, *optional*, defaults to `2`): + Number of generations per prompt to sample. The effective batch size (num_processes * per_device_batch_size + * gradient_accumulation_steps) must be evenly divisible by this value. + num_generations_eval (`int` or `None`, *optional*): + Number of generations to sample during evaluation. This allows using fewer generations during evaluation to + save computation. If `None`, uses the value of `num_generations`. + max_completion_length (`int` or `None`, *optional*, defaults to `256`): + Maximum length of the generated completion. + ds3_gather_for_generation (`bool`, *optional*, defaults to `True`): + This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for generation, + improving generation speed. However, disabling this option allows training models that exceed the VRAM + capacity of a single GPU, albeit at the cost of slower generation. Disabling this option is not compatible + with vLLM generation. + shuffle_dataset (`bool`, *optional*, defaults to `True`): + Whether to shuffle the training dataset. + pad_to_multiple_of (`int`, *optional*): + If set, the prompts ids and completions ids will be padded to a multiple of this value. + + > Parameters that control generation + + generation_batch_size: (`int`, *optional*): + Batch size to use for generation. If `None`, it defaults to the effective training batch size: + `per_device_train_batch_size * num_processes * steps_per_generation`. In other words, there is one + generation batch processed per optimization step. Mutually exclusive with `steps_per_generation`. + steps_per_generation: (`int`, *optional*): + Number of steps per generation. If `None`, it defaults to `gradient_accumulation_steps`. Mutually exclusive + with `generation_batch_size`. + temperature (`float`, defaults to `1.0`): + Temperature for sampling. The higher the temperature, the more random the completions. + top_p (`float`, *optional*, defaults to `1.0`): + Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. Set to + `1.0` to consider all tokens. + top_k (`int`, *optional*, defaults to `0`): + Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, top-k-filtering is + disabled and all tokens are considered. + min_p (`float`, *optional*): + Minimum token probability, which will be scaled by the probability of the most likely token. It must be a + value between `0.0` and `1.0`. Typical values are in the `0.01-0.2` range. + generation_kwargs (`dict[str, Any]`, *optional*): + Additional keyword arguments to pass to [`~transformers.GenerationConfig`] (if using transformers) or + `SamplingParams` (if using vLLM) when sampling completions. This can be used to further customize the + generation behavior, such as setting `suppress_tokens`, `num_beams`, etc. If it contains keys that conflict + with the other generation parameters (like `min_p`, `top_p`, etc.), they will override them. + chat_template_kwargs (`dict[str, Any]`, *optional*): + Additional keyword arguments to pass to the `apply_chat_template` function when generating completions. + repetition_penalty (`float`, *optional*, defaults to `1.0`): + Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. + Values > `1.0` encourage the model to use new tokens, while values < `1.0` encourage the model to repeat + tokens. + cache_implementation (`str`, *optional*): + Implementation of the cache method for faster generation when `use_vllm` is set to `False`. + + > Parameters that control generation acceleration powered by vLLM + + use_vllm (`bool`, *optional*, defaults to `False`): + Whether to use vLLM for generating completions. If set to `True`, the trainer will use vLLM for generation + instead of the default model.generate(). Requires `vllm` to be installed. + vllm_mode (`str`, *optional*, defaults to `"colocate"`): + Mode to use for vLLM integration when `use_vllm` is set to `True`. Must be one of `"server"` or + `"colocate"`. + + - `"server"`: The trainer will send generation requests to a separate vLLM server. Make sure a TRL vLLM + server is running (start with `trl vllm-serve`). + - `"colocate"`: vLLM will run in the same process and share the training GPUs. This avoids the need for a + separate server but may cause resource contention with training. + vllm_model_impl (`str`, *optional*, defaults to `"vllm"`): + Model implementation to use for vLLM. Must be one of `"transformers"` or `"vllm"`. `"transformers"`: Use + the `transformers` backend for model implementation. `"vllm"`: Use the `vllm` library for model + implementation. + vllm_structured_outputs_regex (`str`, *optional*): + Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled. + + > Parameters that control the vLLM server (only used when `vllm_mode` is `"server"`) + + vllm_server_base_url (`str`, *optional*): + Base URL for the vLLM server (e.g., `"http://localhost:8000"`). If provided, `vllm_server_host` and + `vllm_server_port` are ignored. + vllm_server_host (`str`, *optional*, defaults to `"0.0.0.0"`): + Host of the vLLM server to connect to. Ignored if `vllm_server_base_url` is provided. + vllm_server_port (`int`, *optional*, defaults to `8000`): + Port of the vLLM server to connect to. Ignored if `vllm_server_base_url` is provided. + vllm_server_timeout (`float`, *optional*, defaults to `240.0`): + Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up after the + timeout, a `ConnectionError` is raised. + vllm_group_port (`int`, *optional*, defaults to `51216`): + Port number for the weight update group. This is used to communicate with the vLLM server. Unless the port + is occupied, there is no need to change it. + + > Parameters that control colocated vLLM execution (only used when `vllm_mode` is `"colocate"`) + + vllm_gpu_memory_utilization (`float`, *optional*, defaults to `0.3`): + Control the GPU memory utilization for vLLM. This setting only applies when `vllm_mode` is set to + `"colocate"`. If you are using `vllm_mode="server"`, this parameter must be passed separately when + launching the vLLM server via the `--vllm_gpu_memory_utilization` flag. + vllm_max_model_length (`int`, *optional*): + Context window for vLLM. Set it to at least the maximum prompt length in the dataset plus + `max_completion_length`; if omitted, it is inferred from the model config. + vllm_tensor_parallel_size (`int`, *optional*, defaults to `1`): + Control the tensor parallel size for vLLM. This setting only applies when `vllm_mode` is set to + `"colocate"`. If you are using `vllm_mode="server"`, this parameter must be passed separately when + launching the vLLM server via the `--vllm_tensor_parallel_size` flag. + vllm_enable_sleep_mode (`bool`, *optional*, defaults to `False`): + Enable vLLM sleep mode to offload weights/cache during the optimizer step. Keeps GPU memory usage low, but + waking the engine adds host–device transfer latency. + + > Parameters that control the training + + beta (`float`, *optional*, defaults to `0.05`): + KL coefficient. If `0.0`, the reference model is not loaded, reducing memory usage and improving training + speed. + num_iterations (`int`, *optional*, defaults to `1`): + Number of iterations per batch (denoted as μ in the algorithm). + epsilon (`float`, *optional*, defaults to `0.2`): + Epsilon value for clipping. + epsilon_high (`float`, *optional*): + Upper-bound epsilon value for clipping. If not specified, it defaults to the same value as the lower-bound + specified in argument `epsilon`. Paper [DAPO](https://huggingface.co/papers/2503.14476) recommends `0.28`. + reward_weights (`list[float]`, *optional*): + Weights for each reward function. Must match the number of reward functions. If `None`, all rewards are + weighted equally with weight `1.0`. + normalize_advantages (`bool`, *optional*, defaults to `False`): + Whether to normalize advantages. Normalization is done per generation batch to have mean `0.0` and standard + deviation of `1.0`. + reward_clip_range (`tuple[float, float]`, *optional*): + Clip range for rewards as (min, max). If `None`, no clipping is applied. + mask_truncated_completions (`bool`, *optional*, defaults to `False`): + When enabled, truncated completions are excluded from the loss calculation, preventing them from being + incorrectly penalized and introducing noise during training. According to the + [DAPO](https://huggingface.co/papers/2503.14476) paper, this is a good practice for training stability. + sync_ref_model (`bool`, *optional*, defaults to `False`): + Whether to synchronize the reference model with the active model every `ref_model_sync_steps` steps, using + the `ref_model_mixup_alpha` parameter. This synchronization originates from the + [TR-DPO](https://huggingface.co/papers/2404.09656) paper. + ref_model_mixup_alpha (`float`, *optional*, defaults to `0.6`): + α parameter from the [TR-DPO](https://huggingface.co/papers/2404.09656) paper, which controls the mix + between the current policy and the previous reference policy during updates. The reference policy is + updated according to the equation: `π_ref = α * π_θ + (1 - α) * π_ref_prev`. To use this parameter, you + must set `sync_ref_model=True`. + ref_model_sync_steps (`int`, *optional*, defaults to `512`): + τ parameter from the [TR-DPO](https://huggingface.co/papers/2404.09656) paper, which determines how + frequently the current policy is synchronized with the reference policy. To use this parameter, you must + set `sync_ref_model=True`. + + > Parameters that control the logging + + log_completions (`bool`, *optional*, defaults to `False`): + Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. If `rich` is installed, + it prints the sample. If `wandb` and/or `trackio` logging is enabled, it logs it to `wandb` and/or + `trackio`. + num_completions_to_print (`int`, *optional*): + Number of completions to print with `rich`. If `None`, all completions are logged. + log_unique_prompts (`bool`, *optional*, defaults to `False`): + Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all prompts are + logged. + + > Deprecated parameters + + use_transformers_paged: + + + + Parameter `use_transformers_paged` is deprecated and will be removed in version v2.0.0. It will be + replaced by `transformers` continuous batching support in an upcoming release. + + + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `1e-6` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=1e-6, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model and reference model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `transformers.AutoModelForCausalLM.from_pretrained`, used when the `model` " + "argument of the `RLOOTrainer` is provided as a string." + }, + ) + disable_dropout: bool = field( + default=False, + metadata={ + "help": "Whether to disable dropout in the model. This is useful for training with a reference model, as " + "it prevents the model from generating different logprobs for the same input." + }, + ) + + # Parameters that control the data preprocessing + # The default value remove_unused_columns is overwritten from the parent class, because in RLOO we usually rely on + # additional columns to compute the reward + remove_unused_columns: bool | None = field( + default=False, + metadata={ + "help": "Whether to only keep the column 'prompt' in the dataset. If you use a custom reward function " + "that requires any column other than 'prompts' and 'completions', you should keep this to `False`." + }, + ) + num_generations: int | None = field( + default=2, + metadata={ + "help": "Number of generations to sample. The effective batch size (num_processes * per_device_batch_size " + "* gradient_accumulation_steps) must be evenly divisible by this value." + }, + ) + num_generations_eval: int | None = field( + default=None, + metadata={ + "help": "Number of generations to sample during evaluation. This allows using fewer generations during " + "evaluation to save computation. If `None`, uses the value of `num_generations`." + }, + ) + max_completion_length: int | None = field( + default=256, + metadata={"help": "Maximum length of the generated completion."}, + ) + ds3_gather_for_generation: bool = field( + default=True, + metadata={ + "help": "This setting applies to DeepSpeed ZeRO-3. If enabled, the policy model weights are gathered for " + "generation, improving generation speed. However, disabling this option allows training models that " + "exceed the VRAM capacity of a single GPU, albeit at the cost of slower generation. Disabling this option " + "is not compatible with vLLM generation." + }, + ) + shuffle_dataset: bool | None = field( + default=True, + metadata={"help": "Whether to shuffle the training dataset."}, + ) + pad_to_multiple_of: int | None = field( + default=None, + metadata={"help": "If set, the prompts ids and completions ids will be padded to a multiple of this value."}, + ) + + # Parameters that control generation + generation_batch_size: int | None = field( + default=None, + metadata={ + "help": "Batch size to use for generation. If `None`, it defaults to the effective training batch size: " + "`per_device_train_batch_size * num_processes * steps_per_generation`." + }, + ) + steps_per_generation: int | None = field( + default=None, + metadata={"help": "Number of steps per generation. If `None`, it defaults to `gradient_accumulation_steps`."}, + ) + temperature: float = field( + default=1.0, + metadata={"help": "Temperature for sampling. The higher the temperature, the more random the completions."}, + ) + top_p: float = field( + default=1.0, + metadata={ + "help": "Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. " + "Set to 1.0 to consider all tokens." + }, + ) + top_k: int = field( + default=0, + metadata={ + "help": "Number of highest probability vocabulary tokens to keep for top-k-filtering. If `0`, " + "top-k-filtering is disabled and all tokens are considered." + }, + ) + min_p: float | None = field( + default=None, + metadata={ + "help": "Minimum token probability, which will be scaled by the probability of the most likely token. It " + "must be a value between 0.0 and 1.0. Typical values are in the 0.01-0.2 range." + }, + ) + generation_kwargs: dict | None = field( + default=None, + metadata={ + "help": "Additional keyword arguments to pass to `GenerationConfig` (if using transformers) or " + "`SamplingParams` (if using vLLM) when sampling completions. This can be used to further customize the " + "generation behavior, such as setting `suppress_tokens`, `num_beams`, etc. If it contains keys that " + "conflict with the other generation parameters (like `min_p`, `top_p`, etc.), they will override them." + }, + ) + chat_template_kwargs: dict | None = field( + default=None, + metadata={ + "help": "Additional keyword arguments to pass to the `apply_chat_template` function when generating " + "completions." + }, + ) + repetition_penalty: float = field( + default=1.0, + metadata={ + "help": "Float that penalizes new tokens based on whether they appear in the prompt and the generated " + "text so far. Values > 1.0 encourage the model to use new tokens, while values < 1.0 encourage the model " + "to repeat tokens." + }, + ) + cache_implementation: str | None = field( + default=None, + metadata={"help": "Implementation of the cache method for faster generation when use_vllm is set to False."}, + ) + + # Parameters that control generation acceleration powered by vLLM + use_vllm: bool = field( + default=False, + metadata={ + "help": "Whether to use vLLM for generating completions. If set to `True`, the trainer will use vLLM for " + "generation instead of the default model.generate(). Requires `vllm` to be installed." + }, + ) + vllm_mode: str = field( + default="colocate", + metadata={ + "help": "Mode to use for vLLM integration when `use_vllm` is set to `True`. Must be one of `'server'` or " + "`'colocate'`. `'server'`: The trainer will send generation requests to a separate vLLM server. Make sure " + "a TRL vLLM server is running (start with `trl vllm-serve`). `'colocate'`: vLLM will run in the same " + "process and share the training GPUs. This avoids the need for a separate server but may cause resource " + "contention with training." + }, + ) + vllm_model_impl: str = field( + default="vllm", + metadata={ + "help": "Model implementation to use for vLLM. Must be one of `transformers` or `vllm`. `transformers`: " + "Use the `transformers` backend for model implementation. `vllm`: Use the `vllm` library for " + "model implementation." + }, + ) + vllm_enable_sleep_mode: bool = field( + default=False, + metadata={ + "help": "Enable vLLM sleep mode to offload weights/cache during the optimizer step. Keeps GPU memory " + "usage low, but waking the engine adds host–device transfer latency." + }, + ) + vllm_structured_outputs_regex: str | None = field( + default=None, + metadata={"help": "Regex for vLLM structured outputs. If `None` (default), structured outputs is disabled."}, + ) + + # Parameters that control the vLLM server (only used when `vllm_mode` is `"server"`) + vllm_server_base_url: str | None = field( + default=None, + metadata={ + "help": "Base URL for the vLLM server (e.g., 'http://localhost:8000'). If provided, `vllm_server_host` " + "and `vllm_server_port` are ignored." + }, + ) + vllm_server_host: str = field( + default="0.0.0.0", + metadata={"help": "Host of the vLLM server to connect to. Ignored if vllm_server_base_url is provided."}, + ) + vllm_server_port: int = field( + default=8000, + metadata={"help": "Port of the vLLM server to connect to. Ignored if vllm_server_base_url is provided."}, + ) + vllm_server_timeout: float = field( + default=240.0, + metadata={ + "help": "Total timeout duration in seconds to wait for the vLLM server to be up. If the server is not up " + "after the timeout, a `ConnectionError` is raised." + }, + ) + vllm_group_port: int = field( + default=51216, + metadata={ + "help": "Port number for the weight update group. This is used to communicate with the vLLM server. " + "Unless the port is occupied, there is no need to change it.", + }, + ) + + # Parameters that control colocated vLLM execution (only used when `vllm_mode` is `"colocate"`) + vllm_gpu_memory_utilization: float = field( + default=0.3, + metadata={ + "help": "Control the GPU memory utilization for vLLM. This setting only applies when `vllm_mode` is set " + "to `'colocate'`. If you are using `vllm_mode='server'`, this parameter must be passed separately when " + "launching the vLLM server via the `--vllm_gpu_memory_utilization` flag." + }, + ) + vllm_max_model_length: int | None = field( + default=None, + metadata={ + "help": "Context window for vLLM. Set it to at least the maximum prompt length in the dataset plus " + "`max_completion_length`; if omitted, it is inferred from the model config." + }, + ) + vllm_tensor_parallel_size: int = field( + default=1, + metadata={ + "help": "Control the tensor parallel size for vLLM. This setting only applies when `vllm_mode` is set " + "to `'colocate'`. If you are using `vllm_mode='server'`, this parameter must be passed separately when " + "launching the vLLM server via the `--vllm_tensor_parallel_size` flag." + }, + ) + + # Parameters that control the training + beta: float = field( + default=0.05, + metadata={ + "help": "KL coefficient. If `0.0`, the reference model is not loaded, reducing memory usage and improving " + "training speed." + }, + ) + num_iterations: int = field( + default=1, + metadata={"help": "Number of iterations per batch (denoted as μ in the algorithm)."}, + ) + epsilon: float = field( + default=0.2, + metadata={"help": "Epsilon value for clipping."}, + ) + epsilon_high: float | None = field( + default=None, + metadata={ + "help": "Upper-bound epsilon value for clipping. If not specified, it defaults to the same value as the " + "lower-bound specified in argument `epsilon`. Paper DAPO recommends `0.28`." + }, + ) + reward_weights: list[float] | None = field( + default=None, + metadata={ + "help": "Weights for each reward function. Must match the number of reward functions. If `None`, all " + "rewards are weighted equally with weight `1.0`." + }, + ) + normalize_advantages: bool = field( + default=False, + metadata={ + "help": "Whether to normalize advantages. Normalization is done per generation batch to have mean `0.0` " + "and standard deviation of `1.0`." + }, + ) + reward_clip_range: tuple[float, float] | None = field( + default=None, + metadata={"help": "Clip range for rewards as (min, max). If None, no clipping is applied."}, + ) + mask_truncated_completions: bool = field( + default=False, + metadata={ + "help": "When enabled, truncated completions are excluded from the loss calculation, preventing them from " + "being incorrectly penalized and introducing noise during training. According to the DAPO paper, this is " + "a good practice for training stability." + }, + ) + sync_ref_model: bool = field( + default=False, + metadata={ + "help": "Whether to synchronize the reference model with the active model every `ref_model_sync_steps` " + "steps, using the `ref_model_mixup_alpha` parameter." + }, + ) + ref_model_mixup_alpha: float = field( + default=0.6, + metadata={ + "help": "α parameter from the TR-DPO paper, which controls the mix between the current policy and the " + "previous reference policy during updates. The reference policy is updated according to the equation: " + "`π_ref = α * π_θ + (1 - α) * π_ref_prev`. To use this parameter, you must set `sync_ref_model=True`." + }, + ) + ref_model_sync_steps: int = field( + default=512, + metadata={ + "help": "τ parameter from the TR-DPO paper, which determines how frequently the current policy is " + "synchronized with the reference policy. To use this parameter, you must set `sync_ref_model=True`." + }, + ) + + # Parameters that control the logging + log_completions: bool = field( + default=False, + metadata={ + "help": "Whether to log a sample of (prompt, completion) pairs every `logging_steps` steps. If `rich` is " + "installed, it prints the sample. If `wandb` logging is enabled, it logs it to `wandb`." + }, + ) + num_completions_to_print: int | None = field( + default=None, + metadata={"help": "Number of completions to print with `rich`. If `None`, all completions are logged."}, + ) + log_unique_prompts: bool = field( + default=False, + metadata={ + "help": "Whether to log unique prompts. If `True`, only unique prompts are logged. If `False`, all " + "prompts are logged." + }, + ) + + # Deprecated parameters + use_transformers_paged: bool = field( + default=False, + metadata={ + "help": "Deprecated. It will be replaced by `transformers` continuous batching support in an upcoming " + "release." + }, + ) + + def __post_init__(self): + super().__post_init__() + + if self.use_transformers_paged: + warnings.warn( + "`use_transformers_paged` is deprecated and will be removed in v2.0.0. It will be replaced by " + "`transformers` continuous batching support in an upcoming release.", + FutureWarning, + stacklevel=3, + ) + + num_processes = self.world_size + # The current default effective batch size + if self.generation_batch_size is None and self.steps_per_generation is None: + self.steps_per_generation = self.gradient_accumulation_steps + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + elif self.generation_batch_size is not None and self.steps_per_generation is None: + # Just ensure the value is divisible by the global batch size + if self.generation_batch_size % (self.per_device_train_batch_size * num_processes) != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by the global batch size " + f"({self.per_device_train_batch_size * num_processes})." + ) + self.steps_per_generation = self.generation_batch_size // ( + self.per_device_train_batch_size * num_processes + ) + elif self.generation_batch_size is None and self.steps_per_generation is not None: + self.generation_batch_size = self.per_device_train_batch_size * num_processes * self.steps_per_generation + else: + raise ValueError( + "'generation_batch_size' and 'steps_per_generation' can not be both configured at the same time" + ) + + if self.do_eval and self.eval_strategy != "no": + # Determine the number of generations to use for evaluation + num_generations = self.num_generations_eval or self.num_generations + + # Just ensure the value is divisible by the global batch size + if (self.per_device_eval_batch_size * num_processes) % num_generations != 0: + raise ValueError( + f"The global eval batch size ({self.per_device_eval_batch_size} * {num_processes}) must be " + f"divisible by the number of generations used for evaluation ({num_generations})." + ) + + # The generation batch must contain full prompt groups (no partials), so it must be divisible by + # num_generations. + if self.generation_batch_size % self.num_generations != 0: + raise ValueError( + f"generation_batch_size ({self.generation_batch_size}) must be divisible by num_generations " + f"({self.num_generations})." + ) + + if self.num_generations < 2: + raise ValueError( + "RLOO requires at least 2 generations per prompt to calculate the advantages. You provided " + f"{self.num_generations}, which is less than the minimum required." + ) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/rloo_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/rloo_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..416b7b19554b307d0a8d154f7d883944e4fe9328 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/rloo_trainer.py @@ -0,0 +1,1524 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +import atexit +import copy +import inspect +import math +import textwrap +import time +from collections import defaultdict, deque +from collections.abc import Callable +from contextlib import nullcontext +from pathlib import Path +from typing import Any + +import numpy as np +import pandas as pd +import torch +import torch.utils.data +import transformers +from accelerate.logging import get_logger +from accelerate.utils import gather, gather_object, is_peft_model, set_seed +from datasets import Dataset, IterableDataset +from packaging.version import Version +from torch import nn +from torch.distributed.fsdp import FullyShardedDataParallel as FSDP +from torch.utils.data import Sampler +from transformers import ( + AutoModelForSequenceClassification, + AutoProcessor, + AutoTokenizer, + GenerationConfig, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainerCallback, + is_trackio_available, + is_wandb_available, +) +from transformers.utils import is_peft_available, is_rich_available + +from ..data_utils import apply_chat_template, is_conversational, prepare_multimodal_messages +from ..extras.profiling import profiling_context, profiling_decorator +from ..generation.vllm_generation import VLLMGeneration +from ..models import prepare_deepspeed, prepare_fsdp, unwrap_model_for_generation +from ..models.utils import disable_gradient_checkpointing +from .base_trainer import _BaseTrainer +from .callbacks import SyncRefModelCallback +from .rloo_config import RLOOConfig +from .utils import ( + RepeatSampler, + create_model_from_path, + disable_dropout_in_model, + entropy_from_logits, + get_config_model_id, + identity, + nanmax, + nanmin, + nanstd, + pad, + print_prompt_completions_sample, + selective_log_softmax, + shuffle_sequence_dict, + shutdown_event_loop_in_daemon, + split_pixel_values_by_grid, + split_tensor_dict, + start_event_loop_in_daemon, + unsplit_pixel_values_by_grid, + use_adapter, +) + + +if is_peft_available(): + from peft import PeftConfig, PeftModel, get_peft_model + + +if is_wandb_available(): + import wandb + +if is_trackio_available(): + import trackio + + +logger = get_logger(__name__) + +# A reward function can be a string, interpreted as a model ID and loaded as a pretrained model, a pretrained model, or +# a callable that returns a list of floats (the rewards). The callable receives prompts, completions, and additional +# arguments from the trainer (refer to the trainer's source for details). To ensure forward compatibility, it should +# accept **kwargs. +RewardFunc = str | PreTrainedModel | Callable[..., list[float | None]] + + +class RLOOTrainer(_BaseTrainer): + """ + Trainer for the Reinforce Leave One Out (RLOO) method. This algorithm was initially proposed in the paper [Back to + Basics: Revisiting REINFORCE Style Optimization for Learning from Human Feedback in + LLMs](https://huggingface.co/papers/2402.14740). + + Example: + + ```python + from trl import RLOOTrainer + from trl.rewards import accuracy_reward + from datasets import load_dataset + + dataset = load_dataset("trl-lib/DeepMath-103K", split="train") + + trainer = RLOOTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + reward_funcs=accuracy_reward, + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + reward_funcs (`RewardFunc | list[RewardFunc]`): + Reward functions to be used for computing the rewards. To compute the rewards, we call all the reward + functions with the prompts and completions and sum the rewards. Can be either: + + - A single reward function, such as: + - A string: The *model ID* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using [`~transformers.AutoModelForSequenceClassification.from_pretrained`] with `num_labels=1` and the + keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object: Only sequence classification models are supported. + - A custom reward function: The function is provided with the prompts and the generated completions, + plus any additional columns in the dataset. It should return a list of rewards. Custom reward + functions can be either synchronous or asynchronous and can also return `None` when the reward is + not applicable to those samples. This is useful for multi-task training where different reward + functions apply to different types of samples. When a reward function returns `None` for a sample, + that reward function is excluded from the reward calculation for that sample. For more details, see + [Using a custom reward + function](#using-a-custom-reward-function). + + The trainer's state is also passed to the reward function. The trainer's state is an instance of + [`~transformers.TrainerState`] and can be accessed by accessing the `trainer_state` argument to the + reward function's signature. + - A list of reward functions, where each item can independently be any of the above types. Mixing different + types within the list (e.g., a string model ID and a custom reward function) is allowed. + args ([`RLOOConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. It must include a column `"prompt"`. Any additional columns in the dataset is + ignored. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. The padding side must be set to "left". If `None`, the + processing class is loaded from the model's name with [`~transformers.AutoProcessor.from_pretrained`]. A + padding token, `tokenizer.pad_token`, must be set. If the processing class has not set a padding token, + `tokenizer.eos_token` will be used as the default. + reward_processing_classes ([`~transformers.PreTrainedTokenizerBase`] or `list[PreTrainedTokenizerBase]`, *optional*): + Processing classes corresponding to the reward functions specified in `reward_funcs`. Can be either: + + - A single processing class: Used when `reward_funcs` contains only one reward function. + - A list of processing classes: Must match the order and length of the reward functions in `reward_funcs`. + If set to `None`, or if an element of the list corresponding to a [`~transformers.PreTrainedModel`] is + `None`, the tokenizer for the model is automatically loaded using + [`~transformers.AutoTokenizer.from_pretrained`]. For elements in `reward_funcs` that are custom reward + functions (not [`~transformers.PreTrainedModel`]), the corresponding entries in `reward_processing_classes` + are ignored. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + """ + + _tag_names = ["trl", "rloo"] + _name = "RLOO" + _paper = { + "title": "Back to Basics: Revisiting REINFORCE-Style Optimization for Learning from Human Feedback in LLMs", + "id": "2402.14740", + # docstyle-ignore + "citation": textwrap.dedent("""\ + @inproceedings{ahmadian2024back, + title = {{Back to Basics: Revisiting REINFORCE-Style Optimization for Learning from Human Feedback in LLMs}}, + author = {Arash Ahmadian and Chris Cremer and Matthias Gall{\'{e}} and Marzieh Fadaee and Julia Kreutzer and Olivier Pietquin and Ahmet {\"{U}}st{\"{u}}n and Sara Hooker}, + year = 2024, + booktitle = {Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), {ACL} 2024, Bangkok, Thailand, August 11-16, 2024}, + pages = {12248--12267}, + publisher = {Association for Computational Linguistics}, + editor = {Lun{-}Wei Ku and Andre Martins and Vivek Srikumar}, + }"""), + } + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + reward_funcs: RewardFunc | list[RewardFunc], + args: RLOOConfig | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + reward_processing_classes: PreTrainedTokenizerBase | list[PreTrainedTokenizerBase] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + peft_config: "PeftConfig | None" = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = RLOOConfig(f"{model_name}-RLOO") + + # Model + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the `RLOOConfig`, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + + # Some models (SmolVLM/Idefics3) don't support `logits_to_keep` argument and error out if we pass it + # Inspect the forward method before we wrap the model with PEFT + self.model_kwarg_keys = ( + inspect.signature(model.forward).parameters.keys() + if not hasattr(model, "get_base_model") + else inspect.signature(model.get_base_model().forward).parameters.keys() + ) + + # Processing class + if processing_class is None: + processing_class = AutoProcessor.from_pretrained( + get_config_model_id(model.config), truncation_side="left", padding_side="left" + ) + + # Handle pad token for processors or tokenizers + if isinstance(processing_class, ProcessorMixin): + self._tokenizer = processing_class.tokenizer + elif isinstance(processing_class, PreTrainedTokenizerBase): + self._tokenizer = processing_class + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if self._tokenizer.pad_token is None: + self._tokenizer.pad_token = self._tokenizer.eos_token + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + if is_peft_available() and is_peft_model(model): + # If the model is a PEFT model with a pretrained adapter, we need to create a "ref" adapter that is a copy + # of the "default" adapter, so that we can use it as the reference model during the training. + model.add_adapter("ref", model.peft_config["default"]) + for name, param in model.named_parameters(): + if ".default." in name: + ref_name = name.replace(".default.", ".ref.") + ref_param = model.get_parameter(ref_name) + ref_param.data.copy_(param.data) + + # Create PEFT model + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # When using gradient checkpointing with PEFT, we need to enable input gradients. transformers.Trainer normally + # handles this, but a bug currently prevents it; see https://github.com/huggingface/transformers/issues/42489 + if is_peft_available() and is_peft_model(model) and args.gradient_checkpointing: + model.enable_input_require_grads() + + # When using QLoRA, the PEFT adapter weights are converted to bf16 to follow the recommendations from the + # original paper (see https://huggingface.co/papers/2305.14314, paragraph 3). Normally, this can be done by + # passing `autocast_adapter_dtype=False` to `get_peft_model`, but this option is not yet supported for + # quantized models. See: https://github.com/huggingface/peft/issues/2889 + # Non-quantized models do not have the `is_loaded_in_{8,4}bit` attributes, whereas quantized models do + if getattr(model, "is_loaded_in_4bit", False) or getattr(model, "is_loaded_in_8bit", False): + for param in model.parameters(): + if param.requires_grad: + param.data = param.data.to(torch.bfloat16) + + # Reward functions + if not isinstance(reward_funcs, list): + reward_funcs = [reward_funcs] + self.reward_func_names = [] + for i, reward_func in enumerate(reward_funcs): + if isinstance(reward_func, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + reward_funcs[i] = AutoModelForSequenceClassification.from_pretrained( + reward_func, num_labels=1, **model_init_kwargs + ) + if isinstance(reward_funcs[i], nn.Module): # Use Module over PretrainedModel for compat w/ compiled models + self.reward_func_names.append(get_config_model_id(reward_funcs[i].config).split("/")[-1]) + else: + self.reward_func_names.append(reward_funcs[i].__name__) + self.reward_funcs = reward_funcs + + self._has_async_funcs = any(inspect.iscoroutinefunction(func) for func in self.reward_funcs) + if self._has_async_funcs: + self.async_loop_thread, self.async_loop, self.async_loop_ready_event = start_event_loop_in_daemon( + name="RLOOTrainer-AsyncRewardLoop" + ) + # wait until the event loop is running in the daemon thread + self.async_loop_ready_event.wait() + atexit.register(shutdown_event_loop_in_daemon, self.async_loop_thread, self.async_loop) + + # Reward weights + if args.reward_weights is not None: + if len(args.reward_weights) != len(reward_funcs): + raise ValueError( + f"Number of reward weights ({len(args.reward_weights)}) must match number of reward " + f"functions ({len(reward_funcs)})" + ) + self.reward_weights = torch.tensor(args.reward_weights, dtype=torch.float32) + else: + self.reward_weights = torch.ones(len(reward_funcs), dtype=torch.float32) + + # Reward processing class + if reward_processing_classes is None: + reward_processing_classes = [None] * len(reward_funcs) + elif not isinstance(reward_processing_classes, list): + reward_processing_classes = [reward_processing_classes] + if len(reward_processing_classes) != len(reward_funcs): + raise ValueError( + f"The number of reward processing classes ({len(reward_processing_classes)}) must match the number of " + f"reward functions ({len(reward_funcs)})." + ) + + for i, (reward_processing_class, reward_func) in enumerate( + zip(reward_processing_classes, reward_funcs, strict=True) + ): + if isinstance(reward_func, PreTrainedModel): + if reward_processing_class is None: + reward_processing_class = AutoTokenizer.from_pretrained(get_config_model_id(reward_func.config)) + if reward_processing_class.pad_token_id is None: + reward_processing_class.pad_token = reward_processing_class.eos_token + # The reward model computes the reward for the latest non-padded token in the input sequence. + # So it's important to set the pad token ID to the padding token ID of the processing class. + reward_func.config.pad_token_id = reward_processing_class.pad_token_id + reward_processing_classes[i] = reward_processing_class + + self.reward_processing_classes = reward_processing_classes + + # Training arguments + self.max_completion_length = args.max_completion_length + self.num_generations = args.num_generations + self.num_generations_eval = args.num_generations_eval or self.num_generations + self.chat_template_kwargs = args.chat_template_kwargs or {} + self.temperature = args.temperature + self.top_p = args.top_p + self.top_k = args.top_k + self.min_p = args.min_p + self.repetition_penalty = args.repetition_penalty + self.use_transformers_paged = args.use_transformers_paged + self.pad_to_multiple_of = args.pad_to_multiple_of + self.use_vllm = args.use_vllm + self.vllm_mode = args.vllm_mode + self.vllm_gpu_memory_utilization = args.vllm_gpu_memory_utilization # only applies to colocation mode + self.vllm_tensor_parallel_size = args.vllm_tensor_parallel_size # only applies to colocation mode + self.normalize_advantages = args.normalize_advantages + self.mask_truncated_completions = args.mask_truncated_completions + self.reward_clip_range = args.reward_clip_range + + # Datasets + self.shuffle_dataset = args.shuffle_dataset + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif ( + isinstance(train_dataset, IterableDataset) + or isinstance(eval_dataset, IterableDataset) + or ( + isinstance(eval_dataset, dict) and any(isinstance(ds, IterableDataset) for ds in eval_dataset.values()) + ) + ): + # See https://github.com/huggingface/trl/issues/3213 + raise NotImplementedError( + "Iterable datasets are not yet supported in RLOOTrainer. Please use a standard dataset instead." + ) + + # Multi-step + self.num_iterations = args.num_iterations + self.epsilon_low = args.epsilon + self.epsilon_high = args.epsilon_high if args.epsilon_high is not None else args.epsilon + # Tracks the number of iterations (forward + backward passes), including those within a grad accum cycle + self._step = 0 + # Buffer the batch to reuse generated outputs across multiple updates. For more details, see + # `_get_train_sampler` and `_prepare_inputs`. + self._buffered_inputs = None + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=identity, # No data collation is needed in RLOO + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + callbacks=callbacks, + optimizers=optimizers, + ) + + # Reference model + self.beta = args.beta + if self.beta == 0.0: + # If beta is 0.0, the reference model is not needed + self.ref_model = None + elif is_peft_model(model): + # If PEFT is used, the reference model is not needed since the adapter can be disabled + # to revert to the initial model. + self.ref_model = None + else: + # For deepspeed, fsdp or non-distributed models, create a reference model from scratch + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if self.args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + self.ref_model = create_model_from_path(get_config_model_id(self.model.config), **model_init_kwargs) + + # Disable dropout in the models + if args.disable_dropout: + disable_dropout_in_model(model) + if self.ref_model is not None: + disable_dropout_in_model(self.ref_model) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + self._current_train_step_time = 0.0 + self.log_completions = args.log_completions + self.log_unique_prompts = args.log_unique_prompts + self.num_completions_to_print = args.num_completions_to_print + # Keep logs sized to the generation batch to record only outputs from the latest model update. + self._logs = { + "images": deque(maxlen=args.generation_batch_size), + "prompt": deque(maxlen=args.generation_batch_size), + "completion": deque(maxlen=args.generation_batch_size), + "rewards": defaultdict(lambda: deque(maxlen=args.generation_batch_size)), + "advantages": deque(maxlen=args.generation_batch_size), + "extra": defaultdict(lambda: deque(maxlen=args.generation_batch_size)), + } + # Buffers for user-logged data from reward functions, flushed after gathering + self._pending_extra_logs = defaultdict(list) + self._pending_metrics = defaultdict(list) + + # Ensure each process receives a unique seed to prevent duplicate completions when generating with + # transformers if num_generations exceeds per_device_train_batch_size. We could skip it if we use vLLM, but + # it's safer to set it in all cases. + set_seed(args.seed, device_specific=True) + + if self.use_vllm: + # Initialize vLLM generation backend + self.vllm_generation = VLLMGeneration( + model=self.model, + accelerator=self.accelerator, + is_fsdp_enabled=self.is_fsdp_enabled, + processing_class=self.processing_class, + # vLLM configuration + mode=args.vllm_mode, + structured_outputs_regex=args.vllm_structured_outputs_regex, + # Server mode configuration + server_base_url=args.vllm_server_base_url, + server_host=args.vllm_server_host, + server_port=args.vllm_server_port, + group_port=args.vllm_group_port, + server_timeout=args.vllm_server_timeout, + # Colocate mode configuration + tensor_parallel_size=args.vllm_tensor_parallel_size, + gpu_memory_utilization=args.vllm_gpu_memory_utilization, + max_model_length=args.vllm_max_model_length, + max_num_seqs=args.per_device_train_batch_size + * args.vllm_tensor_parallel_size + * args.steps_per_generation, + enable_sleep_mode=args.vllm_enable_sleep_mode, + model_impl=args.vllm_model_impl, + # Generation configuration + repetition_penalty=self.repetition_penalty, + temperature=self.temperature, + top_p=self.top_p, + top_k=self.top_k, + min_p=self.min_p, + max_completion_length=self.max_completion_length, + logprobs=None, # we don't need logprobs from vLLM in RLOO + generation_kwargs=args.generation_kwargs, + ) + self._last_loaded_step = -1 # tag to avoid useless loading during grad accumulation + else: + generation_kwargs = { + "max_new_tokens": self.max_completion_length, + "do_sample": True, + "pad_token_id": self._tokenizer.pad_token_id, + "bos_token_id": self._tokenizer.bos_token_id, + "eos_token_id": self._tokenizer.eos_token_id, + "temperature": self.temperature, + "top_p": self.top_p, + "top_k": self.top_k, + "min_p": self.min_p, + "repetition_penalty": self.repetition_penalty, + "cache_implementation": args.cache_implementation, + } + if args.generation_kwargs is not None: + generation_kwargs.update(args.generation_kwargs) + self.generation_config = GenerationConfig(**generation_kwargs, disable_compile=True) + # Keep training-specific generation kwargs to overwrite model's original generation config + self.generation_kwargs = generation_kwargs + + # Gradient accumulation requires scaled loss. Normally, loss scaling in the parent class depends on whether the + # model accepts loss-related kwargs. Since we compute our own loss, this check is irrelevant. We set + # self.model_accepts_loss_kwargs to False to enable scaling. + self.model_accepts_loss_kwargs = False + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + if self.ref_model is not None: + if self.is_deepspeed_enabled: + self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) + elif self.is_fsdp_enabled: + self.ref_model = prepare_fsdp(self.ref_model, self.accelerator) + else: + self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) + + if args.sync_ref_model: + if self.beta == 0.0: + raise ValueError( + "You passed `sync_ref_model=True` while `beta=0.0`, which means the reference model is not used " + "during training. Consequently, RLOOTrainer does not create a `ref_model` instance, and there is " + "nothing to synchronize. Please set `sync_ref_model=False`, or set `beta` to a non-zero value." + ) + if is_peft_model(model): + raise NotImplementedError( + "You passed `sync_ref_model=True` while using a PEFT model, which is currently not supported. " + "With PEFT, RLOOTrainer does not keep a separate reference model in memory; instead, it recovers " + "reference behavior by temporarily disabling the adapter. As a result, there is no standalone " + "`ref_model` instance to synchronize. Use `sync_ref_model=False`, or opt for full fine-tuning if " + "you need a synced reference model. If you need `sync_ref_model` to work with PEFT, please open a " + "feature request at https://github.com/huggingface/trl/issues." + ) + self.add_callback(SyncRefModelCallback(ref_model=self.ref_model, accelerator=self.accelerator)) + + for i, reward_func in enumerate(self.reward_funcs): + if isinstance(reward_func, PreTrainedModel): + if self.is_deepspeed_enabled: + self.reward_funcs[i] = prepare_deepspeed(reward_func, self.accelerator) + else: + # set device placement to True to make `prepare_model` move `reward_func` to device when using fsdp + self.reward_funcs[i] = self.accelerator.prepare_model( + reward_func, evaluation_mode=True, device_placement=True + ) + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). In RLOOTrainer, we preprocess data, so using the model's signature columns doesn't + # work. Instead, we set them to the columns expected by the `training_step` method, hence the override. + if self._signature_columns is None: + self._signature_columns = ["prompt", "image", "images"] + + # This method overrides `Trainer.get_train_dataloader` to support our custom batching strategy. + # Instead of returning a standard per-step batch (i.e., `per_device_batch_size), our dataloader loads an + # *generation* batch (i.e., `per_device_batch_size × steps_per_generation`). This allows us to generate completions + # once every steps_per_generation step—rather than once per accumulation step—which is significantly more + # efficient. The only change from the original implementation is multiplying the batch size by + # `steps_per_generation`. Thus, `_prepare_inputs` is called with this *generation* batch, and it handles the + # splitting internally. + # Maintenance note: This method is a copy-paste of the original `Trainer.get_train_dataloader` with only one line + # modification. + def get_train_dataloader(self): + return self._get_dataloader( + dataset=self.train_dataset, + description="Training", + batch_size=self._train_batch_size * self.args.steps_per_generation, # < this is the change + sampler_fn=self._get_train_sampler, + is_training=True, + ) + + def _get_train_sampler(self, dataset: Dataset | None = None) -> Sampler: + # Returns a sampler that + # 1. ensures each prompt is repeated across multiple processes. This guarantees that identical prompts are + # distributed to different GPUs, allowing rewards to be computed and normalized correctly within each prompt + # group. Using the same seed across processes ensures consistent prompt assignment, preventing discrepancies + # in group formation. + # 2. repeats the batch multiple times to allow reusing generations across multiple updates. Refer to + # _prepare_inputs to see how the generations are stored and reused. + + # In the following figure, the values are the prompt indices. The first row shows the first sampled batch, the + # second row shows the second sampled batch, and so on. + # + # | GPU 0 | GPU 1 | + # + # global_step step <-───> num_generations=2 + # <-───────> per_device_train_batch_size=3 + # grad_accum ▲ ▲ 0 0 0 0 1 1 2 2 <- Generate for the first `steps_per_generation` (prompts 0 to 11); store the completions; use the first slice to compute the loss + # =2 ▼ | 0 1 3 3 4 4 5 5 <- Take the stored generations and use the second slice to compute the loss + # | + # | 1 2 6 6 7 7 8 8 <- Take the stored generations and use the third slice to compute the loss + # steps_per_gen=4 ▼ 1 3 9 9 10 10 11 11 <- Take the stored generations and use the fourth slice to compute the loss + # + # 2 4 12 12 13 13 14 14 <- Generate for the second `steps_per_generation` (prompts 12 to 23); store the completions; use the first slice to compute the loss + # 2 5 15 15 16 16 17 17 <- Take the stored generations and use the second slice to compute the loss + # ... + if dataset is None: + dataset = self.train_dataset + return RepeatSampler( + data_source=dataset, + mini_repeat_count=self.num_generations, + batch_size=self.args.generation_batch_size // self.num_generations, + repeat_count=self.num_iterations * self.args.steps_per_generation, + shuffle=self.shuffle_dataset, + seed=self.args.seed, + ) + + def _get_eval_sampler(self, eval_dataset) -> Sampler: + # See _get_train_sampler for an explanation of the sampler. + return RepeatSampler( + data_source=eval_dataset, + mini_repeat_count=self.num_generations_eval, + seed=self.args.seed, + ) + + @profiling_decorator + def _get_per_token_logps_and_entropies( + self, + model, + input_ids, + attention_mask, + logits_to_keep, + batch_size=None, + compute_entropy=False, + pixel_values=None, + image_grid_thw=None, + num_images=None, + pixel_attention_mask=None, + image_sizes=None, + token_type_ids=None, + mm_token_type_ids=None, + image_position_ids=None, + ) -> tuple[torch.Tensor, torch.Tensor | None]: + """Compute log-probs and (optionally) entropies for each token.""" + batch_size = batch_size or input_ids.size(0) # Chunk inputs into smaller batches to reduce memory peak + all_logps = [] + all_entropies = [] + for start in range(0, input_ids.size(0), batch_size): + input_ids_batch = input_ids[start : start + batch_size] + attention_mask_batch = attention_mask[start : start + batch_size] + + # Build model inputs + model_inputs = {"input_ids": input_ids_batch, "attention_mask": attention_mask_batch} + if image_grid_thw is not None and pixel_values is not None: + rows_per_image = image_grid_thw.prod(dim=-1) + rows_per_sample = torch.split(rows_per_image, num_images) + rows_per_sample = torch.stack([s.sum() for s in rows_per_sample]) + cum_rows = torch.cat([torch.tensor([0], device=rows_per_sample.device), rows_per_sample.cumsum(0)]) + row_start, row_end = cum_rows[start].item(), cum_rows[start + batch_size].item() + model_inputs["pixel_values"] = pixel_values[row_start:row_end] + cum_imgs = torch.tensor([0] + num_images).cumsum(0) + img_start, img_end = cum_imgs[start], cum_imgs[start + batch_size] + model_inputs["image_grid_thw"] = image_grid_thw[img_start:img_end] + elif image_position_ids is not None and pixel_values is not None: + cum_imgs = torch.tensor([0] + num_images).cumsum(0) + img_start, img_end = cum_imgs[start], cum_imgs[start + batch_size] + model_inputs["pixel_values"] = pixel_values[img_start:img_end] + model_inputs["image_position_ids"] = image_position_ids[img_start:img_end] + elif pixel_values is not None: + model_inputs["pixel_values"] = pixel_values[start : start + batch_size] + if pixel_attention_mask is not None: + model_inputs["pixel_attention_mask"] = pixel_attention_mask[start : start + batch_size] + if image_sizes is not None: + model_inputs["image_sizes"] = image_sizes[start : start + batch_size] + if token_type_ids is not None: + model_inputs["token_type_ids"] = token_type_ids[start : start + batch_size] + if mm_token_type_ids is not None: + model_inputs["mm_token_type_ids"] = mm_token_type_ids[start : start + batch_size] + + # Only add logits_to_keep if the model supports it + if "logits_to_keep" in self.model_kwarg_keys: + # We add 1 to `logits_to_keep` because the last logits of the sequence is later excluded + model_inputs["logits_to_keep"] = logits_to_keep + 1 + + model_inputs["use_cache"] = False # only used in generation; set False to suppress warnings + + logits = model(**model_inputs).logits + # Exclude the last value: it corresponds to the next token pred + logits = logits[:, :-1, :] # (B, L-1, H) + # Only keep the last logits_to_keep. For model that support logits_to_keep, this is a no-op. + logits = logits[:, -logits_to_keep:, :] # (B, logits_to_keep, H) + # Divide logits by sampling temperature. + # See https://huggingface.co/blog/the_n_implementation_details_of_rlhf_with_ppo#policy-training-implementation-details + logits.div_(self.temperature) + completion_ids = input_ids_batch[:, -logits_to_keep:] + logps = selective_log_softmax(logits, completion_ids) # compute logprobs + all_logps.append(logps) + + if compute_entropy: + with torch.no_grad(): + entropies = entropy_from_logits(logits) + all_entropies.append(entropies) + + logps = torch.cat(all_logps, dim=0) + entropies = torch.cat(all_entropies, dim=0) if compute_entropy else None + return logps, entropies + + def training_step(self, model, inputs, num_items_in_batch): + time_before = time.perf_counter() + output = super().training_step(model, inputs, num_items_in_batch) + self._step += 1 + time_after = time.perf_counter() + self._current_train_step_time += time_after - time_before + if self._step % self.current_gradient_accumulation_steps == 0: + self._metrics["train"]["step_time"].append(self._current_train_step_time) + self._current_train_step_time = 0.0 + return output + + @profiling_decorator + def _prepare_inputs(self, generation_batch: dict[str, torch.Tensor | Any]) -> dict[str, torch.Tensor | Any]: + # Prepares inputs for model training/evaluation by managing completion generation and batch handling. + # During training: + # - Receives the local generation batch (Per-GPU batch size × steps per generation) + # from the modified training dataloader instead of the standard local batch + # - Generates completions once for the entire generation batch and splits it into batches of size + # `per_device_train_batch_size` + # - Buffers these completions and returns the appropriate slice for the current accumulation step + # - Optimizes by regenerating completions only periodically (every steps_per_generation * num_iterations) + # During evaluation: + # - The input is treated as a standard local batch (no accumulation, no multiple iterations) + # - Completions are generated for each batch without buffering or reuse + # Returns a single local batch in both cases. + + mode = "train" if self.model.training else "eval" + if mode == "train": + generate_every = self.args.steps_per_generation * self.num_iterations + if self._step % generate_every == 0 or self._buffered_inputs is None: + # self._buffered_inputs=None can occur when resuming from a checkpoint + generation_batch = self._generate_and_score_completions(generation_batch) + generation_batch = split_pixel_values_by_grid(generation_batch) + generation_batch = shuffle_sequence_dict(generation_batch) + generation_batches = split_tensor_dict(generation_batch, self.args.steps_per_generation) + self._buffered_inputs = [unsplit_pixel_values_by_grid(batch) for batch in generation_batches] + inputs = self._buffered_inputs[self._step % self.args.steps_per_generation] + else: + # In evaluation, there is neither batch grouping for generation, nor multiple iterations, hence + # local generation batch == local eval batch + inputs = self._generate_and_score_completions(generation_batch) + return inputs + + def _log_completion_extra(self, column: str, values: list): + """ + Log extra columns to the completions table. Called from reward functions via the `log_extra` kwarg. + + Args: + column (`str`): + Name of the column to add. + values (`list`): + Values for the column, one per sample in the batch. + """ + self._pending_extra_logs[column].extend(values) + + def _log_metric(self, name: str, value: float): + """ + Log a scalar metric from a reward function. Called via the `log_metric` kwarg. Values are averaged over each + logging step and reported alongside built-in metrics like `kl` and `entropy`. + + Args: + name (`str`): + Name of the metric. + value (`float`): + Scalar value for this batch. + """ + self._pending_metrics[name].append(value) + + @profiling_decorator + def _calculate_rewards(self, inputs, prompts, completions, completion_ids_list): + device = self.accelerator.device + rewards_per_func = torch.zeros(len(prompts), len(self.reward_funcs), device=device) + + # Repeat all input columns (but "prompt", "completion", and "completion_ids") to match the num of generations + keys = [key for key in inputs[0] if key not in ["prompt", "completion", "completion_ids"]] + reward_kwargs = {key: [example[key] for example in inputs] for key in keys} + + # This allows for dynamic reward shaping based on training progress. + reward_kwargs["trainer_state"] = self.state + + # Allow reward functions to log extra columns to the completions table. + reward_kwargs["log_extra"] = self._log_completion_extra + + # Allow reward functions to log additional scalar metrics. + reward_kwargs["log_metric"] = self._log_metric + + async_funcs_info = [] # async custom functions for asyncio.gather + + for i, (reward_func, reward_processing_class, reward_func_name) in enumerate( + zip(self.reward_funcs, self.reward_processing_classes, self.reward_func_names, strict=True) + ): + if isinstance(reward_func, nn.Module): # Module (no PretrainedModel) for compat with compiled models + with profiling_context(self, reward_func_name): + if is_conversational(inputs[0]): + messages = [{"messages": p + c} for p, c in zip(prompts, completions, strict=True)] + texts = [ + apply_chat_template(x, reward_processing_class, **self.chat_template_kwargs)["text"] + for x in messages + ] + else: + texts = [p + c for p, c in zip(prompts, completions, strict=True)] + reward_inputs = reward_processing_class( + text=texts, return_tensors="pt", padding=True, padding_side="right", add_special_tokens=False + ) + reward_inputs = super()._prepare_inputs(reward_inputs) + with torch.inference_mode(): + rewards_per_func[:, i] = reward_func(**reward_inputs).logits[:, 0] # Shape (B*G,) + elif inspect.iscoroutinefunction(reward_func): # Separate async reward funcs to run them in parallel later + async_funcs_info.append((i, reward_func, reward_func_name)) + else: + # Run synchronous reward function + with profiling_context(self, reward_func_name): + output_reward_func = reward_func( + prompts=prompts, completions=completions, completion_ids=completion_ids_list, **reward_kwargs + ) + # Convert None values to NaN + output_reward_func = [reward if reward is not None else torch.nan for reward in output_reward_func] + rewards_per_func[:, i] = torch.tensor(output_reward_func, dtype=torch.float32, device=device) + + # Execute async custom functions in parallel using asyncio.gather + if async_funcs_info: + + async def _invoke_async(index, func, func_name): + with profiling_context(self, func_name): + output = await func( + prompts=prompts, completions=completions, completion_ids=completion_ids_list, **reward_kwargs + ) + output = [r if r is not None else torch.nan for r in output] + return index, output + + async def _run_async_funcs(): + coros = [_invoke_async(i, func, func_name) for (i, func, func_name) in async_funcs_info] + return await asyncio.gather(*coros) + + async_results = asyncio.run_coroutine_threadsafe(_run_async_funcs(), self.async_loop).result() + for idx, output_reward_func in async_results: + rewards_per_func[:, idx] = torch.tensor(output_reward_func, dtype=torch.float32, device=device) + + # If all reward functions return None for a given row, issue a detailed warning + if torch.isnan(rewards_per_func).all(dim=1).any(): + nan_row_idx = torch.isnan(rewards_per_func).all(dim=1).nonzero(as_tuple=True)[0][0] + row_reward_kwargs = { + key: value[nan_row_idx] + for key, value in reward_kwargs.items() + if key not in ("trainer_state", "log_extra", "log_metric") + } + row_reward_kwargs["prompt"] = prompts[nan_row_idx] + row_reward_kwargs["completion"] = completions[nan_row_idx] + logger.warning( + f"All reward functions returned None for the following kwargs:\n{row_reward_kwargs}\n" + "Please ensure that at least one reward function returns a valid reward." + ) + + # Gather the reward per function: this part is crucial, because the rewards are normalized per group and the + # completions may be distributed across processes + rewards_per_func = gather(rewards_per_func) + return rewards_per_func + + def _tokenize_prompts(self, prompts: list): + """Tokenize prompts and extract images/multimodal fields for generation.""" + if is_conversational({"prompt": prompts[0]}): + # Extract images from messages for VLM support + images = [] + has_images = False + for prompt in prompts: + prompt_images = [] + for message in prompt: + if isinstance(message["content"], list): + for part in message["content"]: + if part["type"] == "image": + prompt_images.append(part["image"]) + has_images = True + images.append(prompt_images if prompt_images else None) + images = images if has_images else None + + # Workaround for a bug in transformers 5.3.0 where some processors (e.g. Qwen2.5-VL) crash on + # batched unpadded input (transformers#44514). + # Fixed in transformers 5.4.0 (transformers#44563). + needs_padding_workaround = Version("5.3.0") <= Version(transformers.__version__) < Version("5.4.0") + tokenized = self.processing_class.apply_chat_template( + conversation=prompts, + add_generation_prompt=True, + tokenize=True, + return_dict=True, + **({"padding": True} if needs_padding_workaround else {}), + **self.chat_template_kwargs, + ) + if needs_padding_workaround: + # Unpad input_ids: remove padding tokens using attention_mask to get per-sequence lists + prompt_ids = [ + [tok for tok, m in zip(ids, mask, strict=True) if m] + for ids, mask in zip(tokenized["input_ids"], tokenized["attention_mask"], strict=True) + ] + else: + prompt_ids = tokenized["input_ids"] + # For VLMs, the processor returns extra multimodal fields (pixel_values, image_grid_thw, etc.) + multimodal_fields = {k: v for k, v in tokenized.items() if k not in ("input_ids", "attention_mask")} + else: + prompt_ids = self.processing_class(text=prompts)["input_ids"] + images = None + multimodal_fields = {} + return prompt_ids, images, multimodal_fields + + def _generate_single_turn(self, prompt_ids, images, multimodal_fields): + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + # Generate completions using either vLLM or regular generation + if self.use_vllm: + # Sync weights if training step changed + if self.state.global_step != self._last_loaded_step: + with profiling_context(self, "sync_weights"): + self.vllm_generation.sync_weights() + self._last_loaded_step = self.state.global_step + + # Generate using vLLM (note: RLOO doesn't use logprobs from generation, so we ignore them) + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + _, completion_ids, _, _ = self.vllm_generation.generate( + prompts=prompt_ids, + images=images, + num_generations=num_generations, + profiler=profiling_context(self, "vLLM.generate"), + ) + + elif self.use_transformers_paged: + with ( + profiling_context(self, "transformers.generate_batch"), + unwrap_model_for_generation( + self.model_wrapped, self.accelerator, gather_deepspeed3_params=self.args.ds3_gather_for_generation + ) as unwrapped_model, + torch.no_grad(), + FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), + ): + # Cast to the appropriate dtype based on training configuration + if self.args.bf16: + unwrapped_model.to(torch.bfloat16) + elif self.args.fp16: + unwrapped_model.to(torch.float16) + with torch.inference_mode(): + # Continuous batching API expects 'inputs' arg only + all_outputs = unwrapped_model.generate_batch( + prompt_ids, generation_config=self.generation_config, progress_bar=False + ) + unwrapped_model.train() # restore training mode, as generate_batch forces eval mode + completion_ids = [output.generated_tokens for output in all_outputs.values()] + + else: + # Regular generation path: left-pad token IDs into tensors + prompt_tensors = [torch.tensor(ids) for ids in prompt_ids] + padded_ids = pad(prompt_tensors, padding_value=self._tokenizer.pad_token_id, padding_side="left") + attention_mask = pad([torch.ones_like(t) for t in prompt_tensors], padding_value=0, padding_side="left") + generate_inputs = {"input_ids": padded_ids, "attention_mask": attention_mask} + # For VLMs, include multimodal fields as tensors (pixel_values, image_grid_thw, etc.) + for k, v in multimodal_fields.items(): + if isinstance(v, torch.Tensor): + generate_inputs[k] = v + elif isinstance(v, list) and v and isinstance(v[0], list): + # Per-token field (e.g., token_type_ids): left-pad like input_ids + generate_inputs[k] = pad([torch.tensor(x) for x in v], padding_value=0, padding_side="left") + else: + generate_inputs[k] = torch.tensor(np.array(v)) + generate_inputs = super()._prepare_inputs(generate_inputs) + + with ( + profiling_context(self, "transformers.generate"), + unwrap_model_for_generation( + self.model_wrapped, + self.accelerator, + gather_deepspeed3_params=self.args.ds3_gather_for_generation, + generation_kwargs=self.generation_kwargs, # Override model.generation_config with generation_kwargs to fix transformers#42762 + ) as unwrapped_model, + torch.no_grad(), + FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), + ): + prompt_completion_ids = unwrapped_model.generate( + **generate_inputs, generation_config=self.generation_config + ) + # Compute prompt length and extract completion ids + prompt_length = generate_inputs["input_ids"].size(1) + completion_ids = prompt_completion_ids[:, prompt_length:] + + # Mask everything after the first EOS token + is_eos = completion_ids == self._tokenizer.eos_token_id + eos_idx = torch.full((is_eos.size(0),), is_eos.size(1), dtype=torch.long, device=device) + eos_idx[is_eos.any(dim=1)] = is_eos.int().argmax(dim=1)[is_eos.any(dim=1)] + sequence_indices = torch.arange(is_eos.size(1), device=device).expand(is_eos.size(0), -1) + completion_mask = (sequence_indices <= eos_idx.unsqueeze(1)).int() + completion_ids = [ + c[m].tolist() for c, m in zip(completion_ids.cpu(), completion_mask.bool().cpu(), strict=True) + ] + + return completion_ids + + def _generate(self, prompts: list): + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + # Copy the prompts to avoid modifying the original list + prompts = copy.deepcopy(prompts) + + prompt_ids, images, multimodal_fields = self._tokenize_prompts(prompts) + completion_ids = self._generate_single_turn(prompt_ids, images, multimodal_fields) + + # Decode completions. It's important to use `parse_response` when possible, because it handles tool calls. + if is_conversational({"prompt": prompts[0]}): + contents = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + completions = [[{"role": "assistant", "content": content}] for content in contents] + else: + completions = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Get completion length per sequence, used for logging + prompt_lengths = torch.tensor([len(ids) for ids in prompt_ids], device=device) + completion_lengths = torch.tensor([len(ids) for ids in completion_ids], device=device) + agg_prompt_lengths = self.accelerator.gather(prompt_lengths) + agg_completion_lengths = self.accelerator.gather(completion_lengths) + total_prompt_tokens = agg_prompt_lengths.sum() + total_completion_tokens = agg_completion_lengths.sum() # = num_items_in_batch, required for the DAPO loss + + # Log the metrics + if mode == "train": + self.state.num_input_tokens_seen += (total_prompt_tokens + total_completion_tokens).item() + self._metrics[mode]["num_tokens"] = [self.state.num_input_tokens_seen] + + # Log completion lengths, mean, min, max + self._metrics[mode]["completions/mean_length"].append(agg_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_length"].append(agg_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_length"].append(agg_completion_lengths.float().max().item()) + + # Identify sequences that terminated with EOS and log their lengths + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids], device=device) + agg_is_truncated = self.accelerator.gather(is_truncated) + self._metrics[mode]["completions/clipped_ratio"].append(agg_is_truncated.float().mean().item()) + term_completion_lengths = agg_completion_lengths[~agg_is_truncated] + if len(term_completion_lengths) == 0: # edge case where no terminated sequences are found + term_completion_lengths = torch.zeros(1, device=device) + self._metrics[mode]["completions/mean_terminated_length"].append(term_completion_lengths.float().mean().item()) + self._metrics[mode]["completions/min_terminated_length"].append(term_completion_lengths.float().min().item()) + self._metrics[mode]["completions/max_terminated_length"].append(term_completion_lengths.float().max().item()) + + return prompt_ids, completion_ids, completions + + def _generate_and_score_completions( + self, inputs: list[dict[str, torch.Tensor | Any]] + ) -> dict[str, torch.Tensor | Any]: + device = self.accelerator.device + mode = "train" if self.model.training else "eval" + + prompts = [x["prompt"] for x in inputs] + + if "images" in inputs[0]: + images = [example.get("images") for example in inputs] + elif "image" in inputs[0]: + images = [[example.get("image")] if example.get("image") is not None else None for example in inputs] + else: + images = None + # Transformers requires at least one image in the batch, otherwise it throws an error + if images is not None and all(img_list == [] for img_list in images): + images = None + + # If the prompts are conversational and the inputs contain images, we need to convert the prompts from + # [{"role": "user", "content": "What color is the sky?"}] to + # [{"role": "user", "content": [{"type": "image", "image": }, {"type": "text", "text": "What color is the sky?"}]}] + if images is not None: + if not is_conversational(inputs[0]): + raise ValueError( + "Multimodal training requires conversational prompts. It looks like the dataset contains " + "non-conversational inputs, likely because a chat template was applied before passing the dataset " + "to the trainer. Please provide the raw conversational prompts and let the trainer apply the chat " + "template internally." + ) + prompts = [ + prepare_multimodal_messages(prompt, images=image_list) + for prompt, image_list in zip(prompts, images, strict=True) + ] + + prompt_ids_list, completion_ids_list, completions = self._generate(prompts) + + # Convert lists of token IDs to padded tensors + prompt_ids = [torch.tensor(ids) for ids in prompt_ids_list] + prompt_mask = [torch.ones_like(ids, dtype=torch.long) for ids in prompt_ids] + prompt_ids = pad( + prompt_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="left", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + prompt_mask = pad( + prompt_mask, padding_value=0, padding_side="left", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + completion_ids = [torch.tensor(ids) for ids in completion_ids_list] + completion_mask = [torch.ones_like(ids, dtype=torch.long) for ids in completion_ids] + completion_ids = pad( + completion_ids, + padding_value=self._tokenizer.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ).to(device=device) + completion_mask = pad( + completion_mask, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ).to(device=device) + + # If mask_truncated_completions is enabled, zero out truncated completions in completion_mask + if self.mask_truncated_completions: + eos_and_pad = [self._tokenizer.eos_token_id, self._tokenizer.pad_token_id] + # Mask completion_mask for attention masking + is_truncated = torch.tensor([ids[-1] not in eos_and_pad for ids in completion_ids_list], device=device) + completion_mask = completion_mask * (~is_truncated).unsqueeze(1).int() + + # Concatenate prompt_mask with completion_mask for logit computation + prompt_completion_ids = torch.cat([prompt_ids, completion_ids], dim=1) # (B, P+C) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) # (B, P+C) + + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_size + + num_images = [len(img_list) if img_list else 0 for img_list in images] if images is not None else None + + # Get forward_kwargs for models with multimodal inputs + if images is not None: + prompts_text = [ + apply_chat_template({"prompt": prompt}, self.processing_class, **self.chat_template_kwargs)["prompt"] + for prompt in prompts + ] + prompt_inputs = self.processing_class(images=images, text=prompts_text, padding=True, return_tensors="pt") + prompt_inputs = super()._prepare_inputs(prompt_inputs) + forward_kwargs = {k: v for k, v in prompt_inputs.items() if k not in ["input_ids", "attention_mask"]} + else: + forward_kwargs = {} + + # If token_type_ids are used, extend them with zeros for the completion part + if "token_type_ids" in forward_kwargs: + token_type_ids = forward_kwargs["token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and token_type_ids must have equal len + padding_size = prompt_ids.size(1) - token_type_ids.size(1) + if padding_size > 0: + token_type_ids = torch.cat( + [token_type_ids.new_zeros((token_type_ids.size(0), padding_size)), token_type_ids], dim=1 + ) + forward_kwargs["token_type_ids"] = torch.cat( + [token_type_ids, token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + # If mm_token_type_ids are used, extend them with zeros for the completion part + if "mm_token_type_ids" in forward_kwargs: + mm_token_type_ids = forward_kwargs["mm_token_type_ids"] + if self.pad_to_multiple_of is not None: + # Needed only with pad_to_multiple_of: otherwise prompt_ids and mm_token_type_ids must have equal len + padding_size = prompt_ids.size(1) - mm_token_type_ids.size(1) + if padding_size > 0: + mm_token_type_ids = torch.cat( + [mm_token_type_ids.new_zeros((mm_token_type_ids.size(0), padding_size)), mm_token_type_ids], + dim=1, + ) + forward_kwargs["mm_token_type_ids"] = torch.cat( + [mm_token_type_ids, mm_token_type_ids.new_zeros(completion_ids.shape)], dim=1 + ) + + # When gradient checkpointing is enabled with use_reentrant=True (non default), calling the model inside a + # torch.no_grad() block triggers a harmless PyTorch warning ("None of the inputs have requires_grad=True"). + # Temporarily disable checkpointing to avoid this warning during inference. + with torch.no_grad(), disable_gradient_checkpointing(self.model, self.args.gradient_checkpointing_kwargs): + # Compute the per-token log probabilities for the current model + old_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask, image_sizes, image_position_ids + ) + old_logps = (old_per_token_logps * completion_mask).sum(1) # mask out padding and tokens after EOS + + # Compute the per-token log probabilities for the reference model + if self.beta != 0.0: + if self.ref_model is not None: + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.ref_model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask, image_sizes, image_position_ids + ) + else: + # When training a PEFT adapter, how we obtain the reference depends on the setup: + # - New adapter: disabling adapters yields the base model. + # - Re-training an existing adapter: an initial copy is loaded under the name "ref". + model = self.accelerator.unwrap_model(self.model) + with use_adapter(model, adapter_name="ref" if "ref" in model.peft_config else None): + ref_per_token_logps, _ = self._get_per_token_logps_and_entropies( + self.model, + prompt_completion_ids, + attention_mask, + logits_to_keep, + batch_size=batch_size, + num_images=num_images, + **forward_kwargs, # may contain pixel_values, image_grid_thw, pixel_attention_mask, image_sizes, image_position_ids + ) + else: + ref_per_token_logps = None + + # Decode + prompts_text = self.processing_class.batch_decode(prompt_ids, skip_special_tokens=True) + completions_text = self.processing_class.batch_decode(completion_ids, skip_special_tokens=True) + + # Calculate rewards for each reward function. rewards_per_func aggregates rewards across all processes. This is + # important because rewards will be normalized per group, and completions are distributed. We will later slice + # rewards_per_func to extract each process's subset. + rewards_per_func = self._calculate_rewards(inputs, prompts, completions, completion_ids_list) + num_generations = self.num_generations if mode == "train" else self.num_generations_eval + + # Apply weights to each reward function's output and sum + rewards = (rewards_per_func * self.reward_weights.to(device).unsqueeze(0)).nansum(dim=1) + + # Apply reward clipping if specified + if self.reward_clip_range: + rewards = rewards.clamp(min=self.reward_clip_range[0], max=self.reward_clip_range[1]) + + # Include the KL penalty in the reward + if self.beta != 0.0: + per_token_kl = old_per_token_logps - ref_per_token_logps + # Apply sequence-level KL penalty to rewards (sum KL across tokens first, then apply to each sequence) + kl = (per_token_kl * completion_mask).sum(-1) + kl = gather(kl) # rewards are gathered, so kl must be too + rewards = rewards - self.beta * kl + + grouped_rewards = rewards.view(-1, num_generations) + mean_grouped_rewards = grouped_rewards.mean(dim=1) + if num_generations > 1: + std_rewards = grouped_rewards.std(dim=1) + else: # doesn't occur during training, but could occur in eval when num_generations_eval=1 + std_rewards = torch.zeros_like(mean_grouped_rewards) + + # RLOO advantages computation + grouped_sum = grouped_rewards.sum(dim=1, keepdim=True) # (num_prompts, 1) + if num_generations > 1: + baselines = (grouped_sum - grouped_rewards) / (num_generations - 1) # (num_prompts, num_generations) + baselines = baselines.view(-1) # Flatten back to match rewards shape + advantages = rewards - baselines + else: # this case doesn't occur during training, but could in eval when num_generations_eval=1 + advantages = torch.zeros_like(rewards) + + # Normalize advantages + if self.normalize_advantages: + advantages = (advantages - advantages.mean()) / (advantages.std() + 1e-4) + + is_std_zero = torch.isclose(std_rewards, torch.zeros_like(std_rewards)) # for logging + + # Slice to keep only the local part of the data + process_slice = slice( + self.accelerator.process_index * len(prompts), + (self.accelerator.process_index + 1) * len(prompts), + ) + all_process_advantages = advantages.clone() # keep the aggregated advantages for logging + advantages = advantages[process_slice] + + # Calculate and log the mean KL divergence between current and reference model + if self.beta != 0.0: + mean_kl = (per_token_kl * completion_mask).sum() / completion_mask.sum().clamp(min=1.0) + self._metrics[mode]["kl"].append(self.accelerator.gather(mean_kl).nanmean().item()) + + # Calculate mean reward per function, but only for samples where the function was applied (non-NaN values) + for i, reward_func_name in enumerate(self.reward_func_names): + mean_rewards = torch.nanmean(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/mean"].append(mean_rewards) + std_func_rewards = nanstd(rewards_per_func[:, i]).item() + self._metrics[mode][f"rewards/{reward_func_name}/std"].append(std_func_rewards) + rewards = (rewards_per_func * self.reward_weights.to(rewards_per_func.device).unsqueeze(0)).nansum(dim=1) + self._metrics[mode]["reward"].append(rewards.mean().item()) + self._metrics[mode]["reward_std"].append(rewards.std().item()) + self._metrics[mode]["frac_reward_zero_std"].append(is_std_zero.float().mean().item()) + + # Log prompt and completion texts + self._logs["prompt"].extend(gather_object(prompts_text)) + self._logs["completion"].extend(gather_object(completions_text)) + for i, name in enumerate(self.reward_func_names): + self._logs["rewards"][name].extend(rewards_per_func[:, i].tolist()) + self._logs["advantages"].extend(all_process_advantages.tolist()) + + # Flush user-logged extra columns (from log_extra), gathering across processes. + # Keys must be sorted so that all ranks call gather_object in the same order, otherwise values + # get mis-attributed across columns (dict insertion order may differ between processes). + for column in sorted(self._pending_extra_logs): + self._logs["extra"][column].extend(gather_object(self._pending_extra_logs[column])) + self._pending_extra_logs.clear() + + # Flush user-logged metrics (from log_metric), averaging across processes. + # Keys must be sorted so that all ranks call accelerator.gather in the same order, otherwise values + # get mis-attributed across metrics (dict insertion order may differ between processes). + for name in sorted(self._pending_metrics): + values = self._pending_metrics[name] + local_mean = sum(values) / len(values) + global_mean = self.accelerator.gather(torch.tensor(local_mean, device=device)).mean().item() + self._metrics[mode][name].append(global_mean) + self._pending_metrics.clear() + + if images is not None: + self._logs["images"].extend(gather_object(images)) + + output = { + "prompt_ids": prompt_ids, + "prompt_mask": prompt_mask, + "completion_ids": completion_ids, + "completion_mask": completion_mask, + "old_logps": old_logps, + "advantages": advantages, + } + if "pixel_values" in forward_kwargs: + output["pixel_values"] = forward_kwargs["pixel_values"] + if "image_grid_thw" in forward_kwargs: + output["image_grid_thw"] = forward_kwargs["image_grid_thw"] + if "pixel_attention_mask" in forward_kwargs: + output["pixel_attention_mask"] = forward_kwargs["pixel_attention_mask"] + if "image_sizes" in forward_kwargs: + output["image_sizes"] = forward_kwargs["image_sizes"] + if "token_type_ids" in forward_kwargs: + output["token_type_ids"] = forward_kwargs["token_type_ids"] + if "mm_token_type_ids" in forward_kwargs: + output["mm_token_type_ids"] = forward_kwargs["mm_token_type_ids"] + if "image_position_ids" in forward_kwargs: + output["image_position_ids"] = forward_kwargs["image_position_ids"] + if images is not None: + output["num_images"] = num_images + return output + + @profiling_decorator + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + if return_outputs: + raise ValueError("The RLOOTrainer does not support returning outputs") + return self._compute_loss(model, inputs) + + def _compute_loss(self, model, inputs): + # Compute the per-token log probabilities for the model + prompt_ids, prompt_mask = inputs["prompt_ids"], inputs["prompt_mask"] + completion_ids, completion_mask = inputs["completion_ids"], inputs["completion_mask"] + input_ids = torch.cat([prompt_ids, completion_ids], dim=1) + attention_mask = torch.cat([prompt_mask, completion_mask], dim=1) + logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens + + # Compute the per_token_logps and the entropy at each position in the completion + per_token_logps, entropies = self._get_per_token_logps_and_entropies( + model, + input_ids, + attention_mask, + logits_to_keep, + compute_entropy=True, + pixel_values=inputs.get("pixel_values"), + image_grid_thw=inputs.get("image_grid_thw"), + num_images=inputs.get("num_images"), + pixel_attention_mask=inputs.get("pixel_attention_mask"), + image_sizes=inputs.get("image_sizes"), + token_type_ids=inputs.get("token_type_ids"), + mm_token_type_ids=inputs.get("mm_token_type_ids"), + image_position_ids=inputs.get("image_position_ids"), + ) + + logps = (per_token_logps * completion_mask).sum(1) # mask out padding and tokens after EOS + old_logps = inputs["old_logps"] + log_ratio = logps - old_logps + + # Compute the loss + advantages = inputs["advantages"] + coef_1 = torch.exp(log_ratio) + coef_2 = torch.clamp(coef_1, 1 - self.epsilon_low, 1 + self.epsilon_high) + per_sequence_loss1 = coef_1 * advantages + per_sequence_loss2 = coef_2 * advantages + per_sequence_loss = -torch.min(per_sequence_loss1, per_sequence_loss2) + loss = per_sequence_loss.mean() + + # Log the metrics + mode = "train" if self.model.training else "eval" + + # Entropy + mean_entropy = (entropies * completion_mask).sum() / completion_mask.sum().clamp(min=1.0) + self._metrics[mode]["entropy"].append(self.accelerator.gather(mean_entropy).nanmean().item()) + + # Compute the clipped probability ratios + is_low_clipped = (coef_1 < 1 - self.epsilon_low) & (advantages < 0) + is_high_clipped = (coef_1 > 1 + self.epsilon_high) & (advantages > 0) + is_region_clipped = is_low_clipped | is_high_clipped + gathered_low_clip = self.accelerator.gather(is_low_clipped.float().mean()) + self._metrics[mode]["clip_ratio/low_mean"].append(gathered_low_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/low_min"].append(nanmin(gathered_low_clip).item()) + gathered_high_clip = self.accelerator.gather(is_high_clipped.float().mean()) + self._metrics[mode]["clip_ratio/high_mean"].append(gathered_high_clip.nanmean().item()) + self._metrics[mode]["clip_ratio/high_max"].append(nanmax(gathered_high_clip).item()) + gathered_clip_ratio = self.accelerator.gather(is_region_clipped.float().mean()) + self._metrics[mode]["clip_ratio/region_mean"].append(gathered_clip_ratio.nanmean().item()) + return loss + + # During eval, Trainer calls prediction_step. If no labels are present in the inputs, it only runs forward and + # returns logits. We override prediction_step to force compute_loss, because this trainer doesn't involve labels. + def prediction_step(self, model, inputs, prediction_loss_only, ignore_keys: list[str] | None = None): + inputs = self._prepare_inputs(inputs) + with torch.no_grad(): + with self.compute_loss_context_manager(): + loss = self.compute_loss(model, inputs) + loss = loss.mean().detach() + return loss, None, None + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + # Average the metrics + metrics = {} + for key, val in self._metrics[mode].items(): + # Filter out NaN values before averaging. A reward function that returns None for all samples + # in a batch produces NaN for that batch's metric. With logging_steps > 1, a naive sum()/len() + # would let a single NaN contaminate valid data from other batches. Only return None when no + # valid values remain (e.g. JSON loggers crash on float NaN). + valid = [v for v in val if not math.isnan(v)] + metrics[key] = sum(valid) / len(valid) if valid else None + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + if self.accelerator.is_main_process and self.log_completions: + if is_rich_available(): + print_prompt_completions_sample( + self._logs["prompt"], + self._logs["completion"], + self._logs["rewards"], + self._logs["advantages"], + self.state.global_step, + self.num_completions_to_print, + extra=dict(self._logs["extra"]), + ) + + logging_backends = [] + if self.args.report_to and "wandb" in self.args.report_to and wandb.run is not None: + logging_backends.append(wandb) + if self.args.report_to and "trackio" in self.args.report_to: + logging_backends.append(trackio) + + table = { + "step": [self.state.global_step] * len(self._logs["prompt"]), + "prompt": self._logs["prompt"], + "completion": self._logs["completion"], + **self._logs["rewards"], + **self._logs["extra"], + "advantage": self._logs["advantages"], + } + + df_base = pd.DataFrame(table) + images_raw = self._logs["images"] or [] + + for logging_backend in logging_backends: + if images_raw: + images = [] + for image_list in self._logs["images"]: + images.append([logging_backend.Image(image) for image in image_list]) + df = pd.concat( + [df_base, pd.Series(images, name="image")], + axis=1, + copy=False, + ) + else: + df = df_base + + if self.log_unique_prompts: + df = df.drop_duplicates(subset=["prompt"]) + + logging_backend.log({"completions": logging_backend.Table(dataframe=df)}) + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/sft_config.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/sft_config.py new file mode 100644 index 0000000000000000000000000000000000000000..240790f7fb5b1c1369ed25f894a510a6b54a6a87 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/sft_config.py @@ -0,0 +1,301 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any + +from .base_config import _BaseConfig + + +@dataclass +class SFTConfig(_BaseConfig): + # docstyle-ignore + r""" + Configuration class for the [`SFTTrainer`]. + + This class includes only the parameters that are specific to SFT training. For a full list of training arguments, + please refer to the [`~transformers.TrainingArguments`] documentation. Note that default values in this class may + differ from those in [`~transformers.TrainingArguments`]. + + Using [`~transformers.HfArgumentParser`] we can turn this class into + [argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the + command line. + + Parameters: + > Parameters that control the model + + model_init_kwargs (`dict[str, Any]`, *optional*): + Keyword arguments for [`~transformers.AutoModelForCausalLM.from_pretrained`], used when the `model` + argument of the [`SFTTrainer`] is provided as a string. If you're training a MoE architecture and want to + include the load balancing/auxiliary loss as a part of the final loss, remember to set + `output_router_logits=True` in this dictionary. + chat_template_path (`str`, *optional*): + If specified, sets the model's chat template. This can either be the path to a tokenizer (local directory + or Hugging Face Hub model) or a direct path to a Jinja template file. When using a Jinja file, you must + ensure that any special tokens referenced in the template are added to the tokenizer and that the model's + embedding layer is resized accordingly. + + > Parameters that control the data preprocessing + + dataset_text_field (`str`, *optional*, defaults to `"text"`): + Name of the column that contains text data in the dataset. + dataset_kwargs (`dict[str, Any]`, *optional*): + Dictionary of optional keyword arguments for the dataset preparation. The only supported key is + `skip_prepare_dataset`. When the model is a VLM, `skip_prepare_dataset` is automatically treated as `True` + regardless of the provided value, since preprocessing is done on the fly. + dataset_num_proc (`int`, *optional*): + Number of processes to use for processing the dataset. + eos_token (`str`, *optional*): + Token used to indicate the end of a turn or sequence. If `None`, it defaults to + `processing_class.eos_token`. + max_length (`int` or `None`, *optional*, defaults to `1024`): + Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from the left + or right depending on `truncation_mode`. If `None`, no truncation is applied. When packing is enabled, + this value sets the sequence length. + truncation_mode (`str`, *optional*, defaults to `"keep_start"`): + Truncation mode to use when the sequence exceeds `max_length`. The only supported value is + `"keep_start"`. The `"keep_end"` value is deprecated and will be removed in v2.0.0. + shuffle_dataset (`bool`, *optional*, defaults to `False`): + Whether to shuffle the dataset. + packing (`bool`, *optional*, defaults to `False`): + Whether to group multiple sequences into fixed-length blocks to improve computational efficiency and reduce + padding. Uses `max_length` to define sequence length. + packing_strategy (`str`, *optional*, defaults to `"bfd"`): + Strategy for packing sequences. Can be `"bfd"` (best-fit decreasing, truncates overflow), `"bfd_split"` + (best-fit decreasing, splits overflow sequences), or `"wrapped"` (aggressive, cuts mid-sequence). + padding_free (`bool`, *optional*, defaults to `False`): + Whether to perform forward passes without padding by flattening all sequences in the batch into a single + continuous sequence. This reduces memory usage by eliminating padding overhead. Currently, this is only + supported with the FlashAttention 2 or 3, which can efficiently handle the flattened batch structure. When + packing is enabled with strategy `"bfd"`, padding-free is enabled, regardless of the value of this + parameter. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + eval_packing (`bool`, *optional*): + Whether to pack the eval dataset. If `None`, uses the same value as `packing`. + + > Parameters that control the training + + completion_only_loss (`bool`, *optional*): + Whether to compute loss only on the completion part of the sequence. If set to `True`, loss is computed + only on the completion, which is supported only for [prompt-completion](#prompt-completion) datasets. If + `False`, loss is computed on the entire sequence. If `None` (default), the behavior depends on the dataset: + loss is computed on the completion for [prompt-completion](#prompt-completion) datasets, and on the full + sequence for [language modeling](#language-modeling) datasets. + assistant_only_loss (`bool`, *optional*, defaults to `False`): + Whether to compute loss only on the assistant part of the sequence. If set to `True`, loss is computed only + on the assistant responses, which is supported only for [conversational](#conversational) datasets. If + `False`, loss is computed on the entire sequence. + loss_type (`str`, *optional*, defaults to `"nll"`): + Type of loss to use. Possible values are `"nll"` (negative log-likelihood, default) and `"dft"` (Dynamic + Fine-Tuning, as described in [this paper](https://huggingface.co/papers/2508.05629)). + activation_offloading (`bool`, *optional*, defaults to `False`): + Whether to offload the activations to the CPU. + + > Deprecated parameters + + pad_token: + + + + Parameter `pad_token` is deprecated and will be removed in version v2.0.0. Set `tokenizer.pad_token` + directly and pass it as `processing_class` to the trainer instead. + + + + > [!NOTE] + > These parameters have default values different from [`~transformers.TrainingArguments`]: + > - `logging_steps`: Defaults to `10` instead of `500`. + > - `gradient_checkpointing`: Defaults to `True` instead of `False`. + > - `bf16`: Defaults to `True` if `fp16` is not set, instead of `False`. + > - `learning_rate`: Defaults to `2e-5` instead of `5e-5`. + """ + + _VALID_DICT_FIELDS = _BaseConfig._VALID_DICT_FIELDS + ["model_init_kwargs"] + + # Parameters whose default values are overridden from TrainingArguments + learning_rate: float = field( + default=2e-5, + metadata={"help": "The initial learning rate for AdamW."}, + ) + + # Parameters that control the model + model_init_kwargs: dict[str, Any] | str | None = field( + default=None, + metadata={ + "help": "Keyword arguments for `AutoModelForCausalLM.from_pretrained`, used when the `model` argument of " + "the `SFTTrainer` is provided as a string. If you're training a MoE architecture and want to include the " + "load balancing/auxiliary loss as a part of the final loss, remember to set `output_router_logits=True` " + "in this dictionary." + }, + ) + chat_template_path: str | None = field( + default=None, + metadata={ + "help": "If specified, sets the model's chat template. This can either be the path to a tokenizer (local " + "directory or Hugging Face Hub model) or a direct path to a Jinja template file. When using a Jinja file, " + "you must ensure that any special tokens referenced in the template are added to the tokenizer and " + "that the model's embedding layer is resized accordingly." + }, + ) + + # Parameters that control the data preprocessing + dataset_text_field: str = field( + default="text", + metadata={"help": "Name of the column that contains text data in the dataset."}, + ) + dataset_kwargs: dict[str, Any] | None = field( + default=None, + metadata={ + "help": "Dictionary of optional keyword arguments for the dataset preparation. The only supported key is " + "`skip_prepare_dataset`. If the model is a VLM, `skip_prepare_dataset` value is ignored. When the model " + "is a VLM, `skip_prepare_dataset` is automatically treated as `True` regardless of the provided value, " + "since preprocessing is done on the fly." + }, + ) + dataset_num_proc: int | None = field( + default=None, + metadata={"help": "Number of processes to use for processing the dataset."}, + ) + eos_token: str | None = field( + default=None, + metadata={ + "help": "Token used to indicate the end of a turn or sequence. If `None`, it defaults to `processing_class.eos_token`." + }, + ) + max_length: int | None = field( + default=1024, + metadata={ + "help": "Maximum length of the tokenized sequence. Sequences longer than `max_length` are truncated from " + "the left or right depending on the `truncation_mode`. If `None`, no truncation is applied. When packing " + "is enabled, this value sets the sequence length." + }, + ) + truncation_mode: str = field( + default="keep_start", + metadata={ + "help": "Truncation mode to use when the sequence exceeds `max_length`. The only supported value is " + "`'keep_start'`. The `'keep_end'` value is deprecated and will be removed in v2.0.0.", + "choices": ["keep_end", "keep_start"], + }, + ) + shuffle_dataset: bool = field( + default=False, + metadata={"help": "Whether to shuffle the dataset."}, + ) + packing: bool = field( + default=False, + metadata={ + "help": "Whether to group multiple sequences into fixed-length blocks to improve computational efficiency " + "and reduce padding. Uses `max_length` to define sequence length." + }, + ) + packing_strategy: str = field( + default="bfd", + metadata={ + "help": "Strategy for packing sequences. Can be `'bfd'` (best-fit decreasing, truncates overflow), " + "`'bfd_split'` (best-fit decreasing, splits overflow sequences), or `'wrapped'` (aggressive, cuts " + "mid-sequence).", + "choices": ["bfd", "bfd_split", "wrapped"], + }, + ) + padding_free: bool = field( + default=False, + metadata={ + "help": "Whether to perform forward passes without padding by flattening all sequences in the batch into " + "a single continuous sequence. This reduces memory usage by eliminating padding overhead. Currently, this " + "is only supported with the FlashAttention 2 or 3, which can efficiently handle the flattened batch " + "structure. When packing is enabled with strategy `'bfd'`, padding-free is enabled, regardless of the " + "value of this parameter." + }, + ) + pad_to_multiple_of: int | None = field( + default=None, + metadata={"help": "If set, the sequences will be padded to a multiple of this value."}, + ) + eval_packing: bool | None = field( + default=None, + metadata={"help": "Whether to pack the eval dataset. If `None`, uses the same value as `packing`."}, + ) + + # Parameters that control the training + completion_only_loss: bool | None = field( + default=None, + metadata={ + "help": ( + "Whether to compute loss only on the completion part of the sequence. If set to `True`, loss is " + "computed only on the completion, which is supported only for prompt-completion datasets. If `False`, " + "loss is computed on the entire sequence. If `None` (default), the behavior depends on the dataset: " + "loss is computed on the completion for prompt-completion datasets, and on the full sequence for " + "language modeling datasets." + ) + }, + ) + assistant_only_loss: bool = field( + default=False, + metadata={ + "help": ( + "Whether to compute loss only on the assistant part of the sequence. If set to `True`, loss is " + "computed only on the assistant responses, which is supported only for conversational datasets. If `False`, " + "loss is computed on the entire sequence." + ) + }, + ) + loss_type: str = field( + default="nll", + metadata={ + "help": ( + 'Type of loss to use. Possible values are `"nll"` (negative log-likelihood, default) and `"dft"` ' + "(Dynamic Fine-Tuning, as described in https://huggingface.co/papers/2508.05629)." + ) + }, + ) + activation_offloading: bool = field( + default=False, + metadata={"help": "Whether to offload the activations to the CPU."}, + ) + + # Deprecated parameters + pad_token: str | None = field( + default=None, + metadata={ + "help": "Deprecated. Set `tokenizer.pad_token` directly and pass it as `processing_class` to the trainer instead." + }, + ) + + def __post_init__(self): + super().__post_init__() + if self.pad_token is not None: + warnings.warn( + "`pad_token` is deprecated and will be removed in v2.0.0. " + "Set `tokenizer.pad_token` directly and pass it as `processing_class` to the trainer instead.", + FutureWarning, + stacklevel=3, + ) + if self.truncation_mode == "keep_end": + warnings.warn( + "The `'keep_end'` truncation mode is deprecated and will be removed in v2.0.0. " + "Use `truncation_mode='keep_start'` (the default) instead.", + FutureWarning, + stacklevel=3, + ) + if self.packing_strategy == "bfd-requeue": + warnings.warn( + "The `bfd-requeue` packing strategy has been renamed to `bfd_split`. Please update your configuration accordingly. " + "The `bfd-requeue` strategy is deprecated and will be removed in v2.0.0.", + FutureWarning, + stacklevel=3, + ) + self.packing_strategy = "bfd_split" diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/sft_trainer.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/sft_trainer.py new file mode 100644 index 0000000000000000000000000000000000000000..ad2601b9762c89d99c11bcc3923d0e92a461f3a8 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/sft_trainer.py @@ -0,0 +1,1417 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import contextlib +import json +import os +import warnings +from collections import defaultdict +from collections.abc import Callable +from dataclasses import dataclass +from pathlib import Path +from typing import Any + +import torch +import torch.nn as nn +import transformers +from accelerate import PartialState +from accelerate.logging import get_logger +from accelerate.utils import is_peft_model +from datasets import Dataset, IterableDataset +from packaging.version import Version +from transformers import ( + AutoProcessor, + DataCollator, + PreTrainedModel, + PreTrainedTokenizerBase, + ProcessorMixin, + TrainingArguments, +) +from transformers.data.data_collator import DataCollatorMixin +from transformers.trainer_callback import TrainerCallback +from transformers.trainer_utils import EvalPrediction +from transformers.utils import is_peft_available + +from ..chat_template_utils import clone_chat_template, get_training_chat_template +from ..data_utils import ( + apply_chat_template, + is_conversational, + is_conversational_from_value, + maybe_convert_to_chatml, + pack_dataset, + prepare_multimodal_messages, +) +from ..models import get_act_offloading_ctx_manager +from .base_trainer import _BaseTrainer +from .sft_config import SFTConfig +from .utils import ( + create_model_from_path, + entropy_from_logits, + flush_left, + get_config_model_id, + pad, + selective_log_softmax, +) + + +if is_peft_available(): + from peft import PeftConfig, PeftModel, PeftType, get_peft_model + + +logger = get_logger(__name__) + + +FLASH_ATTENTION_VARIANTS = { + "flash_attention_2", + "flash_attention_3", + "kernels-community/flash-attn2", + "kernels-community/flash-attn3", + "kernels-community/vllm-flash-attn3", +} + + +def get_dataset_column_names(dataset: Dataset | IterableDataset) -> list[str]: + return list(next(iter(dataset)).keys()) if dataset.column_names is None else dataset.column_names + + +@dataclass +class DataCollatorForLanguageModeling(DataCollatorMixin): + """ + Data collator used for language modeling data. Inputs are dynamically padded to the maximum length of a batch. + + This collator expects each example in the input list to be a dictionary containing at least the `"input_ids"` key. + If the input contains a `"completion_mask"`, it is used to set the labels to `-100` for tokens that are not in the + completion. If `"assistant_masks"` are present, they are used to set the labels to `-100` for tokens that are not + in the assistant part of the sequence. The collator returns a dictionary containing the following keys: + - `"input_ids"`: Tensor of input IDs, padded to the maximum length of the batch. + - `"labels"`: Tensor of labels, padded to the maximum length of the batch. If `completion_only_loss` is set to + `True`, tokens that are not in the completion are set to -100. If `assistant_masks` are present, tokens that are + not in the assistant part of the sequence are set to -100. If `padding_free` is set to `False`, the following key + is also returned: + - `"attention_mask"`: Tensor of attention masks, padded to the maximum length of the batch. + If `padding_free` is set to `True`, the following key is also returned: + - `"position_ids"`: Tensor of position IDs, padded to the maximum length of the batch. + + Args: + pad_token_id (`int`): + Token ID to use for padding. + max_length (`int`, *optional*): + Maximum length of the sequences in the batch. Sequences longer than `max_length` are truncated to + `max_length`. + truncation_mode (`str`, *optional*, defaults to `"keep_start"`): + Truncation mode to use when the sequence exceeds `max_length`. Possible values are `"keep_end"` and + `"keep_start"`. + completion_only_loss (`bool`, *optional*, defaults to `True`): + When the input contains a completion mask (`completion_mask`), the labels are set to -100 for the tokens + that are no in the completion. + padding_free (`bool`, *optional*, defaults to `False`): + If set to `True`, the sequences will be flattened into a single sequence, and the position IDs will be + generated accordingly and returned instead of the attention mask. + pad_to_multiple_of (`int`, *optional*): + If set, the sequences will be padded to a multiple of this value. + return_tensors (`str`, *optional*, defaults to `"pt"`): + Type of Tensor to return. Only `"pt"` is currently supported. + + Examples: + ```python + >>> from trl.trainer.sft_trainer import DataCollatorForLanguageModeling + + >>> collator = DataCollatorForLanguageModeling(pad_token_id=0) + >>> examples = [{"input_ids": [1, 2, 3]}, {"input_ids": [4, 5]}] + >>> collator(examples) + {'input_ids': tensor([[ 1, 2, 3], + [ 4, 5, 0]]), + 'attention_mask': tensor([[ 1, 1, 1], + [ 1, 1, 0]]), + 'labels': tensor([[ 1, 2, 3], + [ 4, 5, -100]])} + + >>> # With completion mask + >>> examples = [ + ... {"input_ids": [1, 2, 3], "completion_mask": [0, 1, 1]}, + ... {"input_ids": [4, 5], "completion_mask": [0, 1]}, + ... ] + >>> collator(examples) + {'input_ids': tensor([[ 1, 2, 3], + [ 4, 5, 0]]), + 'attention_mask': tensor([[ 1, 1, 1], + [ 1, 1, 0]]), + 'labels': tensor([[-100, 2, 3], + [-100, 5, -100]])} + + >>> # With padding_free + >>> collator = DataCollatorForLanguageModeling(pad_token_id=0, padding_free=True) + >>> collator(examples) + {'input_ids': tensor([[ 1, 2, 3, 4, 5]]), + 'position_ids': tensor([[0, 1, 2, 0, 1]]), + 'labels': tensor([[1, 2, 3, 4, 5]])} + ``` + """ + + pad_token_id: int + max_length: int | None = None + truncation_mode: str = "keep_start" + completion_only_loss: bool = True + padding_free: bool = False + pad_to_multiple_of: int | None = None + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + input_ids = [example["input_ids"] for example in examples] + batch_seq_lengths = [example["seq_lengths"] for example in examples] if "seq_lengths" in examples[0] else None + labels = [example.get("labels", example["input_ids"]) for example in examples] + completion_mask = ( + [example["completion_mask"] for example in examples] + if self.completion_only_loss and "completion_mask" in examples[0] + else None + ) + assistant_masks = ( + [example["assistant_masks"] for example in examples] if "assistant_masks" in examples[0] else None + ) + + # Truncate per sequence if necessary + if self.max_length is not None and not self.padding_free: + if self.truncation_mode == "keep_start": + sl = slice(None, self.max_length) + elif self.truncation_mode == "keep_end": + sl = slice(-self.max_length, None) + else: + raise ValueError( + f"Unsupported truncation mode: {self.truncation_mode}, expected 'keep_start' or 'keep_end'" + ) + input_ids = [ids[sl] for ids in input_ids] + labels = [lbl[sl] for lbl in labels] + if completion_mask is not None: + completion_mask = [m[sl] for m in completion_mask] + if assistant_masks is not None: + assistant_masks = [m[sl] for m in assistant_masks] + + # Convert to tensor + input_ids = [torch.tensor(ids) for ids in input_ids] + labels = [torch.tensor(lbl) for lbl in labels] + if completion_mask is not None: + completion_mask = [torch.tensor(m) for m in completion_mask] + if assistant_masks is not None: + assistant_masks = [torch.tensor(m) for m in assistant_masks] + + # For padding-free, we should NOT create attention_mask as it causes FlashAttention to ignore position_ids and + # compute wrong cu_seq_lens from the all-1s mask + if self.padding_free: + if batch_seq_lengths is not None: + position_ids = self.get_position_ids_from_packed_seq_lengths(batch_seq_lengths) + else: + position_ids = [torch.arange(len(ids)) for ids in input_ids] + else: + attention_mask = [torch.ones_like(ids) for ids in input_ids] + + # If padding_free, flatten everything into a single sequence + output = {} + if self.padding_free: + input_ids = [torch.cat(input_ids, dim=0)] + labels = [torch.cat(labels, dim=0)] + position_ids = [torch.cat(position_ids, dim=0)] + if completion_mask is not None: + completion_mask = [torch.cat(completion_mask, dim=0)] + if assistant_masks is not None: + assistant_masks = [torch.cat(assistant_masks, dim=0)] + + # Pad + output["input_ids"] = pad( + input_ids, + padding_value=self.pad_token_id, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + ) + output["labels"] = pad( + labels, padding_value=-100, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ) + if self.padding_free: + output["position_ids"] = pad( + position_ids, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ) + output["labels"][output["position_ids"] == 0] = -100 + else: + output["attention_mask"] = pad( + attention_mask, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ) + if completion_mask is not None: + completion_mask = pad( + completion_mask, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ) + output["labels"][completion_mask == 0] = -100 # mask everything that is not in the completion + if assistant_masks is not None: + assistant_masks = pad( + assistant_masks, padding_value=0, padding_side="right", pad_to_multiple_of=self.pad_to_multiple_of + ) + output["labels"][assistant_masks == 0] = -100 + return output + + @staticmethod + def get_position_ids_from_packed_seq_lengths(batch_seq_lengths: list[list[int]]) -> list[torch.Tensor]: + """ + Get position IDs for packed sequences. + + Args: + batch_seq_lengths (`list[list[int]]`): + A list of lists containing the lengths of each individual document in the packed batch. + + Return: + `list[torch.Tensor]`: + A list of tensors containing the position IDs for each packed sequence. + """ + # Get lengths per row + example_lengths = [sum(seq_lengths) for seq_lengths in batch_seq_lengths] + # Flat list of lengths + batch_seq_lengths = torch.tensor( + [seq_length for seq_lengths in batch_seq_lengths for seq_length in seq_lengths] + ) + position_ids = torch.ones(sum(example_lengths), dtype=batch_seq_lengths.dtype) + position_ids[0] = 0 + # Reset position ids to 0 at the start of each sequence + position_ids[batch_seq_lengths[:-1].cumsum(0)] = -(batch_seq_lengths[:-1] - 1) + position_ids = position_ids.cumsum(0) + # Split back into one tensor per example + return list(position_ids.split(example_lengths)) + + +@dataclass +class DataCollatorForVisionLanguageModeling(DataCollatorMixin): + """ + Data collator for vision-language modeling tasks. + + Unlike text-only datasets, where the collator typically receives pre-tokenized inputs ready for batching, + vision-language data processing involves converting images into pixel values. This conversion is disk-intensive, + making upfront preprocessing of the entire dataset impractical. Therefore, this collator performs tokenization and + image processing on-the-fly to efficiently prepare batches. + + Each input example should be a dictionary containing at least: + - An `"images"` key holding a list of images, or an `"image"` key holding a single image. + - [language modeling](#language-modeling) type: either a `"messages"` key for conversational inputs or a `"text"` + key for standard text inputs. + - [prompt-completion](#prompt-completion) type: keys `"prompt"` and `"completion"` for the prompt and completion. + + The collator outputs a dictionary including: + - `"input_ids"`: Tensor of token IDs. + - `"attention_mask"`: Tensor indicating attention mask. + - `"pixel_values"`: Tensor representing image pixel values. + - `"labels"`: Tensor for training labels. + + Additional keys may be present depending on the processor, such as `"image_grid_thw"` or `"image_position_ids"`. + + Args: + processor ([`~transformers.ProcessorMixin`]): + The processor used to tokenize text and process images. It must be a subclass of + [`~transformers.ProcessorMixin`] and include a `tokenizer` with a defined `pad_token_id`. + max_length (`int` or `None`, optional, defaults to `None`): + Maximum sequence length for input tokens. If `None`, no truncation is applied. + completion_only_loss (`bool`, *optional*, defaults to `False`): + Whether to compute loss only on the completion part of the sequence. When `True`, the labels for the prompt + part are set to -100. It requires the dataset type to be prompt-completion. + pad_to_multiple_of (`int` or `None`, optional, defaults to `None`): + If set, the sequences will be padded to a multiple of this value. + dataset_text_field (`str`, optional, defaults to `"text"`): + Name of the column that contains text data in the dataset. This parameter is only relevant for [standard + datasets format](dataset_formats#standard). + return_tensors (`str`, optional, defaults to `"pt"`): + The tensor type to return. Currently, only `"pt"` (PyTorch tensors) is supported. + + Example: + ```python + >>> from trl.trainer.sft_trainer import DataCollatorForVisionLanguageModeling + >>> from transformers import AutoProcessor + + >>> processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct") + >>> collator = DataCollatorForVisionLanguageModeling(processor) + >>> examples = [ + ... {"images": [Image.open("image_0.png")], "messages": [{"role": "user", "content": "What is this?"}]}, + ... {"images": [Image.open("image_1.png")], "messages": [{"role": "user", "content": "Describe this image."}]}, + ... ] + >>> collator(examples) + {'input_ids': tensor([[151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, + 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 3838, 374, + 419, 30, 151645, 198], + [151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, + 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 74785, 419, + 2168, 13, 151645, 198]]), + 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]), + 'pixel_values': tensor([[-0.9893, 0.1785, 1.5362, ..., -0.0582, 0.8661, -0.2431], + [-0.2302, 0.9522, -1.1061, ..., 0.0555, 1.3354, -0.6412], + [ 1.2150, 0.9084, 0.7041, ..., 0.2404, -0.8403, -0.5133], + ..., + [ 0.6895, 0.2807, 0.2515, ..., -0.2004, -1.2100, 0.0555], + [ 0.8209, -0.9748, 1.5654, ..., 1.6055, -0.4706, 0.5817], + [-1.0915, 0.4559, 0.9230, ..., 0.5106, 0.0982, -0.1720]]), + 'image_grid_thw': tensor([[1, 4, 4], + [1, 4, 4]]), + 'labels': tensor([[151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, + 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 3838, 374, + 419, 30, 151645, 198], + [151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, + 151644, 872, 198, 151652, 151655, 151655, 151655, 151655, 151653, 74785, 419, + 2168, 13, 151645, 198]])} + ``` + """ + + processor: ProcessorMixin + max_length: int | None = None + completion_only_loss: bool = False # default not used in practice; SFTTrainer always passes the relevant value + pad_to_multiple_of: int | None = None + dataset_text_field: str = "text" + return_tensors: str = "pt" + + def torch_call(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + if "messages" in examples[0] or self.dataset_text_field in examples[0]: + if self.completion_only_loss: + raise ValueError( + "The `completion_only_loss` argument is not supported for language modeling datasets." + ) + return self._collate_language_modeling(examples) + elif "prompt" in examples[0] and "completion" in examples[0]: + return self._collate_prompt_completion(examples) + else: + raise KeyError(f"Unexpected input keys in examples: {list(examples[0].keys())}.") + + def _collate_language_modeling(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + if "image" in examples[0]: + for example in examples: + example["images"] = [example.pop("image")] + images = [example["images"] for example in examples] + # Transformers requires at least one image in the batch, otherwise it throws an error + if all(img_list == [] for img_list in images): + images = None + + if "messages" in examples[0]: # conversational case + messages = [ + prepare_multimodal_messages(example["messages"], images=example["images"]) for example in examples + ] + texts = self.processor.apply_chat_template(messages) + elif self.dataset_text_field in examples[0]: # standard case + texts = [example[self.dataset_text_field] for example in examples] + else: + raise KeyError( + "The input examples must contain either 'messages' for conversational data or 'text' for standard " + "data." + ) + + output = self.processor( + images=images, + text=texts, + padding=True, + padding_side="right", + pad_to_multiple_of=self.pad_to_multiple_of, + truncation=self.max_length is not None, + max_length=self.max_length, + return_tensors=self.return_tensors, + add_special_tokens=False, # to avoid adding the BOS, twice see https://huggingface.co/blog/qgallouedec/gotchas-in-tokenizer-behavior#7-chat-template-and-tokenization-dont-compose-due-to-special-tokens + ) + labels = output["input_ids"].clone() + labels[output["attention_mask"] == 0] = -100 + # We mask only padding tokens (-100) in the labels. Vision tokens are left unchanged because their handling in + # loss computation has to be done by the model, and masking them here would be infeasible in practice as vision + # token definitions vary across architectures. + output["labels"] = labels + return output + + def _collate_prompt_completion(self, examples: list[dict[str, Any]]) -> dict[str, Any]: + if self.pad_to_multiple_of is not None: + raise NotImplementedError( + "Padding to a multiple of a value is not yet implemented for vision-language modeling and " + "prompt-completion data." + ) + if "image" in examples[0]: + for example in examples: + example["images"] = [example.pop("image")] + images = [example["images"] for example in examples] + # Transformers requires at least one image in the batch, otherwise it throws an error + if all(img_list == [] for img_list in images): + images = None + if is_conversational(examples[0]): # conversational case + for example in examples: + example["prompt"] = prepare_multimodal_messages(example["prompt"], images=example["images"]) + example["completion"] = prepare_multimodal_messages(example["completion"]) + examples = [apply_chat_template(example, self.processor) for example in examples] + + prompts = [example["prompt"] for example in examples] + completions = [example["completion"] for example in examples] + + processed_prompts = self.processor( + images=images, + text=prompts, + padding=True, + padding_side="left", + return_tensors=self.return_tensors, + add_special_tokens=False, # to avoid adding the BOS, twice see https://huggingface.co/blog/qgallouedec/gotchas-in-tokenizer-behavior#7-chat-template-and-tokenization-dont-compose-due-to-special-tokens + ) + processed_completions = self.processor( + text=completions, + padding=True, + padding_side="right", + return_tensors=self.return_tensors, + add_special_tokens=False, # to avoid adding the BOS, twice see https://huggingface.co/blog/qgallouedec/gotchas-in-tokenizer-behavior#7-chat-template-and-tokenization-dont-compose-due-to-special-tokens + ) + + # Concatenate prompts and completions + prompt_ids, prompt_mask = processed_prompts["input_ids"], processed_prompts["attention_mask"] + completion_ids, completion_mask = processed_completions["input_ids"], processed_completions["attention_mask"] + input_ids = torch.cat((prompt_ids, completion_ids), dim=1) + attention_mask = torch.cat((prompt_mask, completion_mask), dim=1) + completion_mask = torch.cat((torch.zeros_like(prompt_mask), completion_mask), dim=1) + if "token_type_ids" in processed_prompts: # special case for Gemma + prompt_token_type_ids = processed_prompts["token_type_ids"] + completion_token_type_ids = processed_completions["token_type_ids"] + token_type_ids = torch.cat((prompt_token_type_ids, completion_token_type_ids), dim=1) + if "mm_token_type_ids" in processed_prompts: # special case for ERNIE-VL + prompt_mm_token_type_ids = processed_prompts["mm_token_type_ids"] + completion_mm_token_type_ids = processed_completions.get( + "mm_token_type_ids", torch.zeros_like(completion_ids) + ) + mm_token_type_ids = torch.cat((prompt_mm_token_type_ids, completion_mm_token_type_ids), dim=1) + + # Flush left to reduce padding + if "token_type_ids" in processed_prompts and "mm_token_type_ids" in processed_prompts: + attention_mask, input_ids, completion_mask, token_type_ids, mm_token_type_ids = flush_left( + attention_mask, input_ids, completion_mask, token_type_ids, mm_token_type_ids + ) + elif "token_type_ids" in processed_prompts: + attention_mask, input_ids, completion_mask, token_type_ids = flush_left( + attention_mask, input_ids, completion_mask, token_type_ids + ) + elif "mm_token_type_ids" in processed_prompts: + attention_mask, input_ids, completion_mask, mm_token_type_ids = flush_left( + attention_mask, input_ids, completion_mask, mm_token_type_ids + ) + else: + attention_mask, input_ids, completion_mask = flush_left(attention_mask, input_ids, completion_mask) + + # Truncate if necessary + if self.max_length is not None: + input_ids = input_ids[:, : self.max_length] + attention_mask = attention_mask[:, : self.max_length] + completion_mask = completion_mask[:, : self.max_length] + if "token_type_ids" in processed_prompts: + token_type_ids = token_type_ids[:, : self.max_length] + if "mm_token_type_ids" in processed_prompts: + mm_token_type_ids = mm_token_type_ids[:, : self.max_length] + + # Create labels and mask padding tokens + labels = input_ids.clone() + labels[attention_mask == 0] = -100 + if self.completion_only_loss: + labels[completion_mask == 0] = -100 + + # Build the output dictionary + output = processed_prompts # we take processed_prompts because it contains the images + output["input_ids"] = input_ids + output["attention_mask"] = attention_mask + output["labels"] = labels + if "token_type_ids" in processed_prompts: + output["token_type_ids"] = token_type_ids + if "mm_token_type_ids" in processed_prompts: + output["mm_token_type_ids"] = mm_token_type_ids + return output + + +def dft_loss(outputs, labels, num_items_in_batch=None): + """ + DFT loss function, as presented in [On the Generalization of SFT: A Reinforcement Learning Perspective with Reward + Rectification](https://huggingface.co/papers/2508.05629) + """ + labels = nn.functional.pad(labels, (0, 1), value=-100) + shift_labels = labels[..., 1:].contiguous() + loss_mask = shift_labels != -100 + shift_labels[~loss_mask] = 0 + logprobs = selective_log_softmax(outputs.logits, shift_labels) + per_token_loss = -logprobs.exp().detach() * logprobs + if num_items_in_batch is None: + num_items_in_batch = loss_mask.sum() + loss = (per_token_loss * loss_mask).sum() / num_items_in_batch + return loss + + +class SFTTrainer(_BaseTrainer): + """ + Trainer for Supervised Fine-Tuning (SFT) method. + + This class is a wrapper around the [`~transformers.Trainer`] class and inherits all of its attributes and methods. + + Example: + + ```python + from trl import SFTTrainer + from datasets import load_dataset + + dataset = load_dataset("roneneldan/TinyStories", split="train[:1%]") + + trainer = SFTTrainer( + model="Qwen/Qwen2.5-0.5B-Instruct", + train_dataset=dataset, + ) + trainer.train() + ``` + + Args: + model (`str` or [`~transformers.PreTrainedModel`] or [`~peft.PeftModel`]): + Model to be trained. Can be either: + + - A string, being the *model id* of a pretrained model hosted inside a model repo on huggingface.co, or a + path to a *directory* containing model weights saved using + [`~transformers.PreTrainedModel.save_pretrained`], e.g., `'./my_model_directory/'`. The model is loaded + using `.from_pretrained` (where `` is derived from the model + config) with the keyword arguments in `args.model_init_kwargs`. + - A [`~transformers.PreTrainedModel`] object. Only causal language models are supported. + - A [`~peft.PeftModel`] object. Only causal language models are supported. + If you're training a model with an MoE architecture and want to include the load balancing/auxiliary loss + as a part of the final loss, remember to set the `output_router_logits` config of the model to `True`. + args ([`SFTConfig`], *optional*): + Configuration for this trainer. If `None`, a default configuration is used. + data_collator ([`~transformers.DataCollator`], *optional*): + Function to use to form a batch from a list of elements of the processed `train_dataset` or `eval_dataset`. + Will default to [`~trainer.sft_trainer.DataCollatorForLanguageModeling`] if the model is a language model + and [`~trainer.sft_trainer.DataCollatorForVisionLanguageModeling`] if the model is a vision-language model. + Custom collators must truncate sequences before padding; the trainer does not apply post-collation + truncation. + train_dataset ([`~datasets.Dataset`] or [`~datasets.IterableDataset`]): + Dataset to use for training. This trainer supports both [language modeling](#language-modeling) type and + [prompt-completion](#prompt-completion) type. The format of the samples can be either: + + - [Standard](dataset_formats#standard): Each sample contains plain text. + - [Conversational](dataset_formats#conversational): Each sample contains structured messages (e.g., role + and content). + + The trainer also supports processed datasets (tokenized) as long as they contain an `input_ids` field. + eval_dataset ([`~datasets.Dataset`], [`~datasets.IterableDataset`] or `dict[str, Dataset | IterableDataset]`): + Dataset to use for evaluation. It must meet the same requirements as `train_dataset`. + processing_class ([`~transformers.PreTrainedTokenizerBase`], [`~transformers.ProcessorMixin`], *optional*): + Processing class used to process the data. If `None`, the processing class is loaded from the model's name + with [`~transformers.AutoProcessor.from_pretrained`]. A padding token, `tokenizer.pad_token`, must be set. + If the processing class has not set a padding token, `tokenizer.eos_token` will be used as the default. + compute_loss_func (`Callable`, *optional*): + A function that accepts the raw model outputs, labels, and the number of items in the entire accumulated + batch (batch_size * gradient_accumulation_steps) and returns the loss. For example, see the default [loss + function](https://github.com/huggingface/transformers/blob/052e652d6d53c2b26ffde87e039b723949a53493/src/transformers/trainer.py#L3618) + used by [`Trainer`]. + compute_metrics (`Callable[[EvalPrediction], dict]`, *optional*): + The function that will be used to compute metrics at evaluation. Must take a + [`~transformers.EvalPrediction`] and return a dictionary string to metric values. When passing + [`SFTConfig`] with `batch_eval_metrics` set to `True`, your `compute_metrics` function must take a boolean + `compute_result` argument. This will be triggered after the last eval batch to signal that the function + needs to calculate and return the global summary statistics rather than accumulating the batch-level + statistics. + callbacks (list of [`~transformers.TrainerCallback`], *optional*): + List of callbacks to customize the training loop. Will add those to the list of default callbacks detailed + in [here](https://huggingface.co/docs/transformers/main_classes/callback). + + If you want to remove one of the default callbacks used, use the [`~transformers.Trainer.remove_callback`] + method. + optimizers (`tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None]`, *optional*, defaults to `(None, None)`): + A tuple containing the optimizer and the scheduler to use. Will default to an instance of `AdamW` on your + model and a scheduler given by [`~transformers.get_linear_schedule_with_warmup`] controlled by `args`. + optimizer_cls_and_kwargs (`tuple[Type[torch.optim.Optimizer], Dict[str, Any]]`, *optional*): + A tuple containing the optimizer class and keyword arguments to use. Overrides `optim` and `optim_args` in + `args`. Incompatible with the `optimizers` argument. + + Unlike `optimizers`, this argument avoids the need to place model parameters on the correct devices before + initializing the Trainer. + preprocess_logits_for_metrics (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`, *optional*): + A function that preprocess the logits right before caching them at each evaluation step. Must take two + tensors, the logits and the labels, and return the logits once processed as desired. The modifications made + by this function will be reflected in the predictions received by `compute_metrics`. + + Note that the labels (second parameter) will be `None` if the dataset does not have them. + peft_config ([`~peft.PeftConfig`], *optional*): + PEFT configuration used to wrap the model. If `None`, the model is not wrapped. + formatting_func (`Callable`, *optional*): + Formatting function applied to the dataset before tokenization. Applying the formatting function explicitly + converts the dataset into a [language modeling](#language-modeling) type. + """ + + _tag_names = ["trl", "sft"] + _name = "SFT" + + def __init__( + self, + model: "str | PreTrainedModel | PeftModel", + args: SFTConfig | TrainingArguments | None = None, + data_collator: DataCollator | None = None, + train_dataset: Dataset | IterableDataset | None = None, + eval_dataset: Dataset | IterableDataset | dict[str, Dataset | IterableDataset] | None = None, + processing_class: PreTrainedTokenizerBase | ProcessorMixin | None = None, + compute_loss_func: Callable | None = None, + compute_metrics: Callable[[EvalPrediction], dict] | None = None, + callbacks: list[TrainerCallback] | None = None, + optimizers: tuple[torch.optim.Optimizer | None, torch.optim.lr_scheduler.LambdaLR | None] = (None, None), + optimizer_cls_and_kwargs: tuple[type[torch.optim.Optimizer], dict[str, Any]] | None = None, + preprocess_logits_for_metrics: Callable[[torch.Tensor, torch.Tensor], torch.Tensor] | None = None, + peft_config: "PeftConfig | None" = None, + formatting_func: Callable[[dict], str] | None = None, + ): + # Args + if args is None: + model_name = model if isinstance(model, str) else get_config_model_id(model.config) + model_name = model_name.split("/")[-1] + args = SFTConfig(f"{model_name}-SFT") + elif isinstance(args, TrainingArguments) and not isinstance(args, SFTConfig): + dict_args = args.to_dict() + dict_args["hub_token"] = args.hub_token # to_dict hides the hub_token + if Version(transformers.__version__) < Version("5.0.0"): + dict_args.pop("push_to_hub_token") + args = SFTConfig(**dict_args) + + if train_dataset is None: + raise ValueError("`train_dataset` is required") + elif isinstance(train_dataset, IterableDataset): + # IterableDataset requires dispatch_batches=False because Accelerate's dispatch mode may try to concatenate + # batches from multiple processes, leading to mismatch errors. + if args.accelerator_config.dispatch_batches is True: + logger.warning( + "You are using an `IterableDataset` for training with `dispatch_batches=True`. `dispatch_batches` " + "is forced to `False` when using an `IterableDataset`. To remove this warning, unset " + "`dispatch_batches` in `SFTConfig` or set it to `False`." + ) + args.accelerator_config.dispatch_batches = False + + # Model + if isinstance(model, str): + model_init_kwargs = args.model_init_kwargs or {} + # Distributed training requires device_map=None ("auto" fails) + if args.distributed_state.distributed_type in ["MULTI_GPU", "DEEPSPEED"]: + model_init_kwargs["device_map"] = None + model = create_model_from_path(model, **model_init_kwargs) + else: + if args.model_init_kwargs is not None: + logger.warning( + "You passed `model_init_kwargs` to the `SFTConfig`, but your model is already instantiated. " + "The `model_init_kwargs` will be ignored." + ) + + # Processing class + if processing_class is None: + processing_class = AutoProcessor.from_pretrained(get_config_model_id(model.config)) + + # Handle pad token for processors or tokenizers + if isinstance(processing_class, ProcessorMixin): + self._tokenizer = processing_class.tokenizer + self._is_vlm = True + elif isinstance(processing_class, PreTrainedTokenizerBase): + self._tokenizer = processing_class + self._is_vlm = False + else: + raise TypeError("The `processing_class` must be either a `PreTrainedTokenizerBase` or a `ProcessorMixin`") + + if args.eos_token is not None: + if args.eos_token not in self._tokenizer.get_vocab(): + raise ValueError( + f"The specified `eos_token` ('{args.eos_token}') is not found in the vocabulary of the given " + f"`processing_class` ({processing_class.__class__.__name__}). Ensure that the `eos_token` exists " + "in the vocabulary before using it as an EOS token." + ) + self._tokenizer.eos_token = args.eos_token + + if args.chat_template_path is not None: + if os.path.isfile(args.chat_template_path) and args.chat_template_path.endswith((".jinja", ".j2")): + with open(args.chat_template_path, encoding="utf-8") as chat_template_file: + processing_class.chat_template = chat_template_file.read() + added_tokens = [] + else: + model, processing_class, added_tokens = clone_chat_template( + model, processing_class, args.chat_template_path + ) + else: + added_tokens = [] + + # Catch some wrong configurations related to VLMs + if self._is_vlm and args.packing: + raise ValueError( + "Packing is not supported for vision-language models. Please set `packing=False` in the SFTConfig." + ) + if self._is_vlm and args.padding_free: + raise ValueError( + "Padding-free training is yet not supported for vision-language models. Please set " + "`padding_free=False` in the `SFTConfig`." + ) + if self._is_vlm and args.assistant_only_loss: + raise ValueError( + "Assistant-only loss is not yet supported for vision-language models. Please set " + "`assistant_only_loss=False` in the `SFTConfig`." + ) + if self._is_vlm and args.max_length is not None and args.truncation_mode == "keep_end": + raise ValueError( + "truncation_mode='keep_end' is not supported for vision-language models. Image tokens reside " + "inside the prompt portion of the sequence; depending on the example, keep_end may silently " + "drop them, causing pixel_values to be forwarded to the model with no corresponding visual " + "tokens in input_ids. Use truncation_mode='keep_start' (the default) or set max_length=None." + ) + + # PEFT configuration and model wrapping + if peft_config is not None: + if added_tokens: + # Ensure that the added tokens are trainable + if peft_config.trainable_token_indices is None: + peft_config.trainable_token_indices = {"embed_tokens": added_tokens} + elif "embed_tokens" not in peft_config.trainable_token_indices: + peft_config.trainable_token_indices["embed_tokens"] = added_tokens + else: + peft_config.trainable_token_indices["embed_tokens"].extend(added_tokens) + + # Ensure that the lm_head is trainable + if peft_config.modules_to_save is None or "lm_head" not in peft_config.modules_to_save: + logger.warning( + "Cloning chat template added new tokens to the tokenizer, but 'lm_head' is not in PEFT's " + "`modules_to_save`. As a result, the model may not learn to generate outputs with these new " + "tokens, leading to degraded generation quality. To fix this, add " + "`modules_to_save=['lm_head']` to your PEFT configuration." + ) + + if peft_config.modules_to_save is None: + peft_config.modules_to_save = ["lm_head"] + else: + peft_config.modules_to_save.append("lm_head") + + if is_peft_available() and is_peft_model(model) and peft_config is not None: + raise ValueError( + "You passed a `PeftModel` instance together with a `peft_config` to the trainer. Please first merge " + "and unload the existing adapter, save the resulting base model, and then pass that base model along " + "with the new `peft_config` to the trainer." + ) + + # Create PEFT model + if peft_config is not None: + model = get_peft_model(model, peft_config) + + # PEFT + DeepSpeed ZeRO-3 requires reentrant checkpointing. For more details, see + # https://github.com/huggingface/trl/issues/2514#issuecomment-2692152703 + if ( + is_peft_model(model) + and args.deepspeed_plugin is not None + and args.deepspeed_plugin.zero_stage == 3 + and args.gradient_checkpointing + ): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + use_reentrant = args.gradient_checkpointing_kwargs.get("use_reentrant") + if use_reentrant is False: + logger.warning( + "You are using PEFT with DeepSpeed ZeRO-3 and gradient checkpointing with `use_reentrant=False`. " + "`use_reentrant` is forced to `True` in this configuration to ensure correct training. To remove " + "this warning, unset `use_reentrant` in `gradient_checkpointing_kwargs` or set it to `True`." + ) + args.gradient_checkpointing_kwargs["use_reentrant"] = True + + # When using gradient checkpointing with PEFT, we need to enable input gradients. transformers.Trainer normally + # handles this, but a bug currently prevents it; see https://github.com/huggingface/transformers/issues/42489 + if is_peft_available() and is_peft_model(model) and args.gradient_checkpointing: + model.enable_input_require_grads() + + # When using QLoRA, the PEFT adapter weights are converted to bf16 to follow the recommendations from the + # original paper (see https://huggingface.co/papers/2305.14314, paragraph 3). Normally, this can be done by + # passing `autocast_adapter_dtype=False` to `get_peft_model`, but this option is not yet supported for + # quantized models. See: https://github.com/huggingface/peft/issues/2889 + # Non-quantized models do not have the `is_loaded_in_{8,4}bit` attributes, whereas quantized models do + if getattr(model, "is_loaded_in_4bit", False) or getattr(model, "is_loaded_in_8bit", False): + for param in model.parameters(): + if param.requires_grad: + param.data = param.data.to(torch.bfloat16) + + # In Prompt Tuning a small set of trainable virtual tokens (continuous prompt embeddings) is prepended to the + # input. We store the number of these tokens so we can account for them correctly when calculating accuracy. + self.num_virtual_tokens = 0 + if is_peft_available() and is_peft_model(model): + if model.active_adapter in model.peft_config: + peft_model_config = model.peft_config[model.active_adapter] + self.num_virtual_tokens = getattr(peft_model_config, "num_virtual_tokens", 0) + + # Data collator + # BFD packing requires padding-free mode; otherwise, the collator outputs padded attention masks, causing + # FlashAttention to ignore position_ids and recompute them incorrectly from the padded attention mask. + self.padding_free = args.padding_free or (args.packing and args.packing_strategy in {"bfd", "bfd_split"}) + use_flash_attention = model.config._attn_implementation in FLASH_ATTENTION_VARIANTS + if self.padding_free: + if data_collator is not None: + raise ValueError("Passing a custom data collator is not supported when using padding-free.") + if args.packing and args.packing_strategy == "wrapped": + logger.warning( + "You are passing `padding_free=True` with the 'wrapped' packing strategy, which is not " + "recommended. Please refer to the documentation to understand why this is not recommended." + ) + if not use_flash_attention: + logger.warning( + "Padding-free training is enabled, but the attention implementation is not set to a supported " + "flash attention variant. Padding-free training flattens batches into a single sequence, and only " + "the following implementations are known to reliably support this: " + f"{', '.join(sorted(FLASH_ATTENTION_VARIANTS))}. Using other implementations may lead to " + "unexpected behavior. To ensure compatibility, set `attn_implementation` in the model " + "configuration to one of these supported options or verify that your attention mechanism can " + "handle flattened sequences." + ) + + if args.per_device_train_batch_size == 1 and not args.packing: + logger.warning( + "You are using a per_device_train_batch_size of 1 with padding-free training. Using a batch size " + "of 1 annihilate the benefits of padding-free training. Please consider increasing the batch size " + "to at least 2." + ) + + # Decide whether to use completion-only loss: if not specified, then it is set to True if the dataset format + # is prompt-completion, and False if the dataset format is language modeling. + dataset_sample = next(iter(train_dataset)) + if args.completion_only_loss is None: + self.completion_only_loss = "prompt" in dataset_sample and "completion" in dataset_sample + else: + self.completion_only_loss = args.completion_only_loss + + self._is_vision_dataset = "image" in dataset_sample or "images" in dataset_sample + if self._is_vision_dataset and not self._is_vlm: + raise ValueError( + "The dataset appears to be vision-related (contains 'image' or 'images' keys), but the provided " + "model does not seem to be a vision-language model. Please check your model and dataset." + ) + + if data_collator is None and not self._is_vision_dataset: + # Get the pad token: if not provided, use the one from the processing class or the eos token + # if the processing class does not have a pad token. + pad_token = args.pad_token or self._tokenizer.pad_token or self._tokenizer.eos_token + if pad_token not in self._tokenizer.get_vocab(): + raise ValueError( + f"The specified `pad_token` ('{pad_token}') is not found in the vocabulary of the given " + f"`processing_class` ({processing_class.__class__.__name__}). Ensure that the `pad_token` exists " + "in the vocabulary before using it as a padding token." + ) + self._tokenizer.pad_token = pad_token + data_collator = DataCollatorForLanguageModeling( + pad_token_id=self._tokenizer.pad_token_id, + max_length=None if self.padding_free else args.max_length, + truncation_mode=args.truncation_mode, + completion_only_loss=self.completion_only_loss, + padding_free=self.padding_free, + pad_to_multiple_of=args.pad_to_multiple_of, + ) + elif data_collator is None and self._is_vision_dataset: + data_collator = DataCollatorForVisionLanguageModeling( + processor=processing_class, + max_length=args.max_length, + completion_only_loss=self.completion_only_loss, + pad_to_multiple_of=args.pad_to_multiple_of, + dataset_text_field=args.dataset_text_field, + ) + + if args.packing and args.packing_strategy in {"bfd", "bfd_split"} and not use_flash_attention: + logger.warning( + "You are using packing, but the attention implementation is not set to a supported flash attention " + "variant. Packing gathers multiple samples into a single sequence, and only the following " + f"implementations are known to reliably support this: {', '.join(sorted(FLASH_ATTENTION_VARIANTS))}. " + "Using other implementations may lead to cross-contamination between samples. To avoid this, either " + "disable packing by setting `packing=False`, or set `attn_implementation` in the model configuration " + "to one of these supported options." + ) + if args.assistant_only_loss and not is_conversational(dataset_sample): + raise ValueError( + "You set `assistant_only_loss=True`, but the dataset is not conversational. This option is only " + "supported for conversational datasets." + ) + + # When assistant_only_loss is enabled, swap in a training chat template with {% generation %} markers + # if the current template doesn't already have them. + if args.assistant_only_loss and "{% generation %}" not in processing_class.chat_template: + self.chat_template = get_training_chat_template(processing_class) + else: + self.chat_template = None + + # Dataset + if self.padding_free and not args.packing and args.max_length is not None and not self._is_vision_dataset: + raise ValueError( + "When `padding_free=True` without packing, `max_length` is not enforced. Either enable packing " + "(e.g., `packing=True, packing_strategy='bfd'`), provide already truncated inputs, or set " + "`max_length=None`." + ) + # Skip dataset preparation if `skip_prepare_dataset=True` in `dataset_kwargs`, or if it's a VLM, where + # preprocessing (e.g., image-to-pixel conversion) is too costly and done on the fly instead. + skip_prepare_dataset = ( + args.dataset_kwargs is not None + and args.dataset_kwargs.get("skip_prepare_dataset", False) + or self._is_vision_dataset + ) + if not skip_prepare_dataset: + if self.completion_only_loss and formatting_func: + raise ValueError( + "A formatting function was provided while `completion_only_loss=True`, which is incompatible. " + "Using a formatter converts the dataset to a language modeling type, conflicting with " + "completion-only loss. To resolve this, apply your formatting function before passing the " + "dataset, or disable `completion_only_loss` in `SFTConfig`." + ) + train_dataset = self._prepare_dataset( + train_dataset, processing_class, args, args.packing, formatting_func, "train" + ) + if eval_dataset is not None: + packing = args.packing if args.eval_packing is None else args.eval_packing + if isinstance(eval_dataset, dict): + eval_dataset = { + key: self._prepare_dataset(dataset, processing_class, args, packing, formatting_func, key) + for key, dataset in eval_dataset.items() + } + else: + eval_dataset = self._prepare_dataset( + eval_dataset, processing_class, args, packing, formatting_func, "eval" + ) + + # Loss function + if not args.use_liger_kernel: # liger supports dft loss by just passing use_token_scaling=True + if args.loss_type == "nll": + pass # use the default loss + elif args.loss_type == "dft": + if compute_loss_func is not None: + raise ValueError( + "You passed a `compute_loss_func` together with `loss_type='dft'` to the `SFTTrainer`. " + "When using `loss_type='dft'`, the loss function is internally set to the DFT loss, so " + "passing a `compute_loss_func` is not allowed." + ) + compute_loss_func = dft_loss + else: + raise ValueError(f"Invalid `loss_type` {args.loss_type} passed. Supported values are 'nll' and 'dft'.") + + # Transformers explicitly set use_reentrant=True in the past to silence a PyTorch warning, but the default was + # never updated once PyTorch switched to recommending use_reentrant=False. Until that change lands upstream + # (see https://github.com/huggingface/transformers/pull/43203) and is released (most likely in 5.0.0), we + # default to the recommended non-reentrant behavior here, while preserving any user-provided value. + if args.gradient_checkpointing and Version(transformers.__version__) < Version("5.0.0"): + args.gradient_checkpointing_kwargs = args.gradient_checkpointing_kwargs or {} + args.gradient_checkpointing_kwargs.setdefault("use_reentrant", False) + + super().__init__( + model=model, + args=args, + data_collator=data_collator, + train_dataset=train_dataset, + eval_dataset=eval_dataset, + processing_class=processing_class, + compute_loss_func=compute_loss_func, + compute_metrics=compute_metrics, + callbacks=callbacks, + optimizers=optimizers, + optimizer_cls_and_kwargs=optimizer_cls_and_kwargs, + preprocess_logits_for_metrics=preprocess_logits_for_metrics, + ) + + # Initialize activation offloading context + if self.args.activation_offloading: + self.maybe_activation_offload_context = get_act_offloading_ctx_manager(model=self.model) + else: + self.maybe_activation_offload_context = contextlib.nullcontext() + + self.aux_loss_enabled = getattr(model.config, "output_router_logits", False) + + # Initialize the metrics + self._metrics = {"train": defaultdict(list), "eval": defaultdict(list)} + self._total_train_tokens = 0 + + # Add tags to the model + self.model.add_model_tags(self._tag_names) + + def _tokenize( + self, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + input: str | list, + **kwargs, + ) -> dict[str, list]: + """Tokenize a single example for dataset preprocessing. + + Dispatches to `apply_chat_template` for conversational input (list of message dicts) and to `__call__` for + non-conversational input (str). For VLMs, normalizes the batch dimension that processors emit even for single + examples. + + Args: + processing_class ([`~transformers.PreTrainedTokenizerBase`] or [`~transformers.ProcessorMixin`]): + The tokenizer or processor to use. + input (`str` or `list`): + A string for non-conversational input, or a list of message dicts for conversational input. + **kwargs: + Forwarded to `apply_chat_template` (e.g. `add_generation_prompt`, `return_assistant_tokens_mask`). + + Returns: + `dict` with at least an `"input_ids"` key mapping to a flat `list[int]`. + """ + if isinstance(input, list): # conversational: list of message dicts + if self._is_vlm: + input = prepare_multimodal_messages(input) + result = processing_class.apply_chat_template( + input, tokenize=True, return_dict=True, chat_template=self.chat_template, **kwargs + ) + else: # non-conversational: plain text string + result = processing_class(text=input) + # VLMs emit a batch dimension even for single examples; unwrap it + if self._is_vlm: + return {k: v[0] for k, v in result.items()} + return result + + def _prepare_dataset( + self, + dataset: Dataset | IterableDataset, + processing_class: PreTrainedTokenizerBase | ProcessorMixin, + args: SFTConfig, + packing: bool, + formatting_func: Callable[[dict], str] | None, + dataset_name: str, + ) -> Dataset | IterableDataset: + # If the dataset is already preprocessed (tokenized), skip the processing steps. + column_names = get_dataset_column_names(dataset) + is_processed = "input_ids" in column_names + + # Build the kwargs for the `map` function + map_kwargs = {} + if isinstance(dataset, Dataset): # IterableDataset does not support num_proc + map_kwargs["num_proc"] = args.dataset_num_proc + + with PartialState().main_process_first(): + # Apply the formatting function if any + if formatting_func is not None and is_processed: + logger.warning( + "You passed a dataset that is already processed (contains an `input_ids` field) together with a " + "formatting function. Therefore `formatting_func` will be ignored. Either remove the " + "`formatting_func` or pass a dataset that is not already processed.", + ) + + if formatting_func is not None and not is_processed: + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Applying formatting function to {dataset_name} dataset" + + def _func(example): + return {"text": formatting_func(example)} + + dataset = dataset.map(_func, batched=False, **map_kwargs) + + if not is_processed: + # Convert the dataset to ChatML if needed + first_example = next(iter(dataset)) + if is_conversational_from_value(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Converting {dataset_name} dataset to ChatML" + column_names = get_dataset_column_names(dataset) + dataset = dataset.map( + maybe_convert_to_chatml, + remove_columns="conversations" if "conversations" in column_names else None, + **map_kwargs, + ) + + # Add EOS token if needed: non-conversational only + first_example = next(iter(dataset)) + if not is_conversational(first_example): + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Adding EOS to {dataset_name} dataset" + + def add_eos(example, eos_token): + if "text" in example and not example["text"].endswith(eos_token): # language modeling case + example["text"] = example["text"] + eos_token + elif "completion" in example and not example["completion"].endswith(eos_token): + example["completion"] = example["completion"] + eos_token + return example + + dataset = dataset.map( + add_eos, + fn_kwargs={"eos_token": self._tokenizer.eos_token}, + remove_columns="messages" if "messages" in column_names else None, # renamed to "text" + **map_kwargs, + ) + + # Tokenize the dataset + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Tokenizing {dataset_name} dataset" + + def tokenize_fn(example, processing_class, dataset_text_field, assistant_only_loss): + tools = example.get("tools") + tools = json.loads(tools) if isinstance(tools, str) else tools + if "prompt" in example: # prompt-completion case + output = {} + if is_conversational(example): + prompt_ids = self._tokenize( + processing_class, + example["prompt"], + tools=tools, + add_generation_prompt=True, + **example.get("chat_template_kwargs", {}), + )["input_ids"] + prompt_completion_processed = self._tokenize( + processing_class, + example["prompt"] + example["completion"], + tools=tools, + return_assistant_tokens_mask=assistant_only_loss, + **example.get("chat_template_kwargs", {}), + ) + prompt_completion_ids = prompt_completion_processed["input_ids"] + if "assistant_masks" in prompt_completion_processed: + output["assistant_masks"] = prompt_completion_processed["assistant_masks"] + else: + prompt_ids = self._tokenize(processing_class, example["prompt"])["input_ids"] + prompt_completion_ids = self._tokenize( + processing_class, example["prompt"] + example["completion"] + )["input_ids"] + + # Check if the tokenized prompt starts with the tokenized prompt+completion + if not prompt_completion_ids[: len(prompt_ids)] == prompt_ids: + logger.warning( + "Mismatch between tokenized prompt and the start of tokenized prompt+completion. " + "This may be due to unexpected tokenizer behavior, whitespace issues, or special " + "token handling. Verify that the tokenizer is processing text consistently." + ) + + # Create completion mask + completion_mask = [0] * len(prompt_ids) + [1] * (len(prompt_completion_ids) - len(prompt_ids)) + output["input_ids"] = prompt_completion_ids + output["completion_mask"] = completion_mask + + else: # language modeling case + if is_conversational(example): + processed = self._tokenize( + processing_class, + example["messages"], + tools=tools, + return_assistant_tokens_mask=assistant_only_loss, + **example.get("chat_template_kwargs", {}), + ) + output = {k: processed[k] for k in ("input_ids", "assistant_masks") if k in processed} + else: + output = { + "input_ids": self._tokenize(processing_class, example[dataset_text_field])["input_ids"] + } + + if "assistant_masks" in output and 1 not in output["assistant_masks"]: + raise RuntimeError( + "You're using `assistant_only_loss=True`, but at least one example has no assistant " + "tokens. This usually means the tokenizer's chat template doesn't generate assistant " + "masks — it may be missing the `{% generation %}` keyword. Please check the template and " + "ensure it's correctly configured to support assistant masking." + ) + return output + + dataset = dataset.map( + tokenize_fn, + fn_kwargs={ + "processing_class": processing_class, + "dataset_text_field": args.dataset_text_field, + "assistant_only_loss": args.assistant_only_loss, + }, + **map_kwargs, + ) + + # Pack + if packing: + if args.max_length is None: + raise ValueError("When packing is enabled, `max_length` can't be `None`.") + if isinstance(dataset, Dataset): # `IterableDataset.map` does not support `desc` + map_kwargs["desc"] = f"Packing {dataset_name} dataset" + + columns = ["input_ids"] + if "completion_mask" in get_dataset_column_names(dataset): + columns.append("completion_mask") + if "assistant_masks" in get_dataset_column_names(dataset): + columns.append("assistant_masks") + + dataset = dataset.select_columns(columns) + + # Shuffle the dataset before packing. When using wrapped packing, it's important to shuffle before + # packing as well to avoid correlations between sequences packed together. + if args.shuffle_dataset: + dataset = dataset.shuffle(seed=args.seed) + + # Packing adds new column "seq_lengths" needed for document aware FlashAttention + dataset = pack_dataset(dataset, args.max_length, args.packing_strategy, map_kwargs) + # For Liger kernel, ensure only the essential columns + if args.use_liger_kernel: + collator_expected_keys = {"input_ids", "seq_lengths", "completion_mask", "assistant_masks"} + column_names = get_dataset_column_names(dataset) + dataset = dataset.select_columns(collator_expected_keys.intersection(column_names)) + + if args.shuffle_dataset: + dataset = dataset.shuffle(seed=args.seed) + + return dataset + + def _set_signature_columns_if_needed(self): + # If `self.args.remove_unused_columns` is True, non-signature columns are removed. + # By default, this method sets `self._signature_columns` to the model's expected inputs (usually, "input_ids" + # and "attention_mask"). When using `train_on_completion_only` we add a "completion_mask" column to the + # dataset. So we need to override the default signature columns to include "completion_mask" as well. + if self._signature_columns is None: + if self._is_vision_dataset: + self._signature_columns = ["messages", "prompt", "completion", "image", "images"] + else: + self._signature_columns = ["input_ids", "labels", "seq_lengths", "completion_mask", "assistant_masks"] + + def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None): + mode = "train" if self.model.training else "eval" + prediction_loss_only = inputs.pop("_prediction_loss_only", None) + + # Set aside labels as it will be dropped by super().compute_loss() if a custom `compute_loss_func` is used. + # This can be removed when this issue is fixed. + # When using CP or SP, labels are pre-shifted, we must use shift_labels instead. + labels = inputs["labels"] if "shift_labels" not in inputs else None + + # If not set, defaults from model config and may warn since cache isn't compatible with gradient checkpointing + inputs["use_cache"] = False + + # Request token accuracy from Liger kernel and set token scaling if using DFT loss + if self.args.use_liger_kernel: + # Avoid materializing full logits during eval unless explicitly needed. + # By default, liger kernel only skips logits during training (self.training=True). + # When only loss is needed for eval (no compute_metrics), we can safely skip logits. + # prediction_step communicates whether logits are expected via `_prediction_loss_only`; + # this prevents skipping logits during `predict()` where outputs are requested. + # Keep logits when preprocess_logits_for_metrics is set, even if compute_metrics is None. + # to prevent massive vRAM spikes from the lm_head projection. + # See: https://github.com/huggingface/trl/issues/4679 + inputs["skip_logits"] = ( + self.model.training + or self.args.prediction_loss_only + or ( + self.compute_metrics is None + and self.preprocess_logits_for_metrics is None + and prediction_loss_only is not False + ) + ) + inputs["return_token_accuracy"] = True + inputs["use_token_scaling"] = self.args.loss_type == "dft" + + (loss, outputs) = super().compute_loss( + model, inputs, return_outputs=True, num_items_in_batch=num_items_in_batch + ) + + # Compute entropy + if not self.args.use_liger_kernel: # liger doesn't return logits + with torch.no_grad(): + if "shift_labels" in inputs: + # When using CP or SP, labels are pre-shifted. + shift_logits = outputs.logits.contiguous() + shift_labels = inputs["shift_labels"] + else: + shift_logits = outputs.logits[..., :-1, :].contiguous() + shift_labels = labels[..., 1:].contiguous() + + # Prompt Tuning and P-Tuning output logits for virtual tokens but Prefix-Tuning does not. + if ( + self.num_virtual_tokens > 0 + and model.peft_config[model.active_adapter].peft_type != PeftType.PREFIX_TUNING + ): + shift_logits = shift_logits[:, self.num_virtual_tokens :, :] + + per_token_entropy = entropy_from_logits(shift_logits) + mask = shift_labels != -100 + entropy_sum = (per_token_entropy * mask).sum() + total_tokens = mask.sum() + + # Gather counts across ranks and weight-average + entropy_sum = self.accelerator.gather_for_metrics(entropy_sum).sum() + total_tokens = self.accelerator.gather_for_metrics(total_tokens).sum() + entropy = (entropy_sum / total_tokens).item() if total_tokens > 0 else 0.0 + self._metrics[mode]["entropy"].append(entropy) + + if mode == "train": + # When using padding-free, the attention_mask is not present in the inputs, instead we have cu_seq_lens_q, + # cu_seq_lens_k, and max_length_k, max_length_q and position_ids. + if "attention_mask" in inputs: + num_tokens_in_batch = self.accelerator.gather_for_metrics(inputs["attention_mask"].sum()).sum().item() + elif "position_ids" in inputs: + local_num_tokens = torch.tensor(inputs["position_ids"].size(1), device=inputs["position_ids"].device) + num_tokens_in_batch = self.accelerator.gather_for_metrics(local_num_tokens).sum().item() + else: + raise ValueError("Expected 'attention_mask' or 'position_ids' in inputs.") + self._total_train_tokens += num_tokens_in_batch + self._metrics[mode]["num_tokens"] = [self._total_train_tokens] + + if self.args.use_liger_kernel: + if hasattr(outputs, "token_accuracy") and outputs.token_accuracy is not None: + token_accuracy = self.accelerator.gather_for_metrics(outputs.token_accuracy).mean().item() + self._metrics[mode]["mean_token_accuracy"].append(token_accuracy) + else: + warnings.warn( + "liger-kernel did not return token_accuracy when requested. The mean_token_accuracy metric will " + "not be logged. This is unexpected; please report it to the liger-kernel repository.", + stacklevel=2, + ) + else: + # Compute accuracy from logits using argmax (traditional method) + with torch.no_grad(): + if "shift_labels" in inputs: + # When using CP or SP, labels are pre-shifted. We must use these (and cannot manually shift) because: + # - The first discarded token from inputs["labels"] actually belongs to process n-1 + # - The last logits require the label from process n+1 + shift_logits = outputs.logits.contiguous() + shift_labels = inputs["shift_labels"] + else: + shift_logits = outputs.logits[..., :-1, :].contiguous() + shift_labels = labels[..., 1:].contiguous() + + # Prompt Tuning and P-Tuning output logits for virtual tokens but Prefix-Tuning does not. + if ( + self.num_virtual_tokens > 0 + and model.peft_config[model.active_adapter].peft_type != PeftType.PREFIX_TUNING + ): + shift_logits = shift_logits[:, self.num_virtual_tokens :, :] + + # Get predictions + predictions = shift_logits.argmax(dim=-1) + + # Create mask for non-padding tokens (assuming ignore_index is -100) + mask = shift_labels != -100 + + # Calculate accuracy only on non-padding tokens + correct_predictions = (predictions == shift_labels) & mask + total_tokens = mask.sum() + correct_tokens = correct_predictions.sum() + + # Gather the correct_tokens and total_tokens across all processes + correct_tokens = self.accelerator.gather_for_metrics(correct_tokens) + total_tokens = self.accelerator.gather_for_metrics(total_tokens) + + # Compute the mean token accuracy and log it + total_sum = total_tokens.sum() + accuracy = (correct_tokens.sum() / total_sum).item() if total_sum > 0 else 0.0 + self._metrics[mode]["mean_token_accuracy"].append(accuracy) + + # Log auxiliary loss if enabled (applies to both Liger and non-Liger) + if self.aux_loss_enabled: + aux_loss = outputs.aux_loss + aux_loss = self.accelerator.gather_for_metrics(aux_loss).mean().item() + self._metrics[mode]["aux_loss"].append(aux_loss) + + return (loss, outputs) if return_outputs else loss + + def prediction_step(self, model, inputs, prediction_loss_only, ignore_keys=None): + # Preserve the eval loop intent so compute_loss can decide whether logits are needed. + inputs["_prediction_loss_only"] = prediction_loss_only + return super().prediction_step(model, inputs, prediction_loss_only, ignore_keys=ignore_keys) + + # Override training step to add activation offloading context. + def training_step(self, *args, **kwargs): + with self.maybe_activation_offload_context: + return super().training_step(*args, **kwargs) + + def log(self, logs: dict[str, float], start_time: float | None = None) -> None: + mode = "train" if self.model.training else "eval" + metrics = {key: sum(val) / len(val) for key, val in self._metrics[mode].items()} # average the metrics + + # This method can be called both in training and evaluation. When called in evaluation, the keys in `logs` + # start with "eval_". We need to add the prefix "eval_" to the keys in `metrics` to match the format. + if mode == "eval": + metrics = {f"eval_{key}": val for key, val in metrics.items()} + + logs = {**logs, **metrics} + super().log(logs, start_time) + self._metrics[mode].clear() + + # Ensure the model card is saved along with the checkpoint + def _save_checkpoint(self, model, trial): + if self.args.hub_model_id is None: + model_name = Path(self.args.output_dir).name + else: + model_name = self.args.hub_model_id.split("/")[-1] + self.create_model_card(model_name=model_name) + super()._save_checkpoint(model, trial) diff --git a/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/utils.py b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..2fdae036c70286164a9c6cb76396e5309c5812bb --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/source/trl/trainer/utils.py @@ -0,0 +1,1321 @@ +# Copyright 2020-2026 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +import hashlib +import importlib.resources as pkg_resources +import os +import random +import socket +import threading +import types +from collections.abc import Mapping, Sequence, Sized +from contextlib import contextmanager +from importlib.metadata import version +from itertools import accumulate +from typing import TypeVar + +import numpy as np +import pandas as pd +import torch +import torch.nn.functional as F +import transformers +from accelerate import PartialState, logging +from huggingface_hub import ModelCard, ModelCardData +from torch.utils.data import Sampler +from transformers import ( + AutoConfig, + BitsAndBytesConfig, + PretrainedConfig, + PreTrainedModel, + is_comet_available, + is_trackio_available, +) +from transformers.models.auto.auto_factory import _BaseAutoModelClass +from transformers.utils import ( + is_peft_available, + is_rich_available, + is_torch_xpu_available, +) + +from ..trainer.model_config import ModelConfig + + +if is_rich_available(): + from rich.console import Console + from rich.panel import Panel + from rich.table import Table + from rich.text import Text + +if is_comet_available(): + import comet_ml + +if is_peft_available(): + from peft import LoraConfig, PeftConfig, PeftModel + + +logger = logging.get_logger(__name__) + + +def _is_port_free(port: int, host: str = "127.0.0.1") -> bool: + try: + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.bind((host, port)) + return True + except OSError: + return False + + +def _find_free_port() -> int: + candidates = (29500, 23456, 12355, 12345) + for p in candidates: + if _is_port_free(p): + return p + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.bind(("", 0)) + return s.getsockname()[1] + + +def ensure_master_addr_port(addr: str | None = None, port: int | None = None) -> None: + """ + Ensure `MASTER_ADDR`/`MASTER_PORT` are set safely. + + - Respects existing environment variables. + - Defaults `MASTER_ADDR` to localhost if unset. + - Chooses a free TCP port if `MASTER_PORT` is unset to avoid collisions. + - If `MASTER_PORT` is set to `"0"` or `"auto"`, it is resolved to a free port. + """ + os.environ["MASTER_ADDR"] = os.environ.get("MASTER_ADDR") or addr or "localhost" + + env_port = os.environ.get("MASTER_PORT", "").strip().lower() + if port is None and env_port not in {"", "0", "auto"}: + try: + port = int(env_port) + except ValueError: + pass + + os.environ["MASTER_PORT"] = str(_find_free_port() if port in (None, 0) else port) + + +def pad( + tensors: list[torch.Tensor], + padding_value: int = 0, + padding_side: str = "right", + pad_to_multiple_of: int | None = None, +) -> torch.Tensor: + """ + Pads a list of tensors to the same shape along the first dimension. + + Args: + tensors (`list[torch.Tensor]`): + List of input tensors to pad. + padding_value (`int`): + Value to use for padding. Default is 0. + padding_side (`str`): + Side on which to add padding. Must be 'left' or 'right'. Default is 'right'. + pad_to_multiple_of (`int`, *optional*): + If set will pad the sequence to a multiple of the provided value. + + Returns: + `torch.Tensor`: + A single tensor containing the padded tensors. + + Examples: + ```python + >>> import torch + + >>> pad([torch.tensor([1, 2, 3]), torch.tensor([4, 5])]) + tensor([[1, 2, 3], + [4, 5, 0]]) + + >>> pad([torch.tensor([[1, 2], [3, 4]]), torch.tensor([[5, 6]])]) + tensor([[[1, 2], + [3, 4]], + [[5, 6], + [0, 0]]]) + ``` + """ + # Determine the maximum shape for each dimension + output_shape = np.max([t.shape for t in tensors], 0).tolist() + + # Apply pad_to_multiple_of to the first (sequence) dimension + if pad_to_multiple_of is not None: + remainder = output_shape[0] % pad_to_multiple_of + if remainder != 0: + output_shape[0] += pad_to_multiple_of - remainder + + # Create an output tensor filled with the padding value + output = torch.full((len(tensors), *output_shape), padding_value, dtype=tensors[0].dtype, device=tensors[0].device) + + for i, t in enumerate(tensors): + if padding_side == "left": + seq_start = output_shape[0] - t.shape[0] + elif padding_side == "right": + seq_start = 0 + else: + raise ValueError("padding_side must be 'left' or 'right'") + + # Define the slices + seq_slice = slice(seq_start, seq_start + t.shape[0]) + slices = (seq_slice,) + tuple(slice(0, s) for s in t.shape[1:]) + output[i][slices] = t + + return output + + +def disable_dropout_in_model(model: torch.nn.Module) -> None: + for module in model.modules(): + if isinstance(module, torch.nn.Dropout): + module.p = 0 + + +def get_quantization_config(model_args: ModelConfig) -> BitsAndBytesConfig | None: + if model_args.load_in_4bit: + quantization_config = BitsAndBytesConfig( + load_in_4bit=True, + bnb_4bit_compute_dtype=model_args.dtype, # For consistency with model weights, we use the same value as `dtype` + bnb_4bit_quant_type=model_args.bnb_4bit_quant_type, + bnb_4bit_use_double_quant=model_args.use_bnb_nested_quant, + bnb_4bit_quant_storage=model_args.bnb_4bit_quant_storage, + ) + elif model_args.load_in_8bit: + quantization_config = BitsAndBytesConfig( + load_in_8bit=True, + ) + else: + quantization_config = None + + return quantization_config + + +def get_kbit_device_map() -> dict[str, int] | None: + if torch.cuda.is_available() or is_torch_xpu_available(): + return {"": PartialState().local_process_index} + else: + return None + + +def get_peft_config(model_args: ModelConfig) -> "PeftConfig | None": + if model_args.use_peft is False: + return None + + if not is_peft_available(): + raise ValueError( + "You need to have PEFT library installed in your environment, make sure to install `peft`. " + "Make sure to run `pip install -U peft`." + ) + + peft_config = LoraConfig( + task_type=model_args.lora_task_type, + r=model_args.lora_r, + target_modules=model_args.lora_target_modules, + target_parameters=model_args.lora_target_parameters, + lora_alpha=model_args.lora_alpha, + lora_dropout=model_args.lora_dropout, + bias="none", + use_rslora=model_args.use_rslora, + use_dora=model_args.use_dora, + modules_to_save=model_args.lora_modules_to_save, + ) + + return peft_config + + +def generate_model_card( + base_model: str | None, + model_name: str, + hub_model_id: str, + dataset_name: str | None, + tags: list[str], + wandb_url: str | None, + trackio_url: str | None, + trainer_name: str, + trainer_citation: str | None = None, + template_file: str | None = None, + paper_title: str | None = None, + paper_id: str | None = None, + comet_url: str | None = None, +) -> ModelCard: + """ + Generate a [`~huggingface_hub.ModelCard`] from a template. + + Args: + base_model (`str` or `None`): + Base model name. + model_name (`str`): + Model name. + hub_model_id (`str`): + Hub model ID as `username/model_id`. + dataset_name (`str` or `None`): + Dataset name. + tags (`list[str]`): + Tags. + wandb_url (`str` or `None`): + Weights & Biases run URL. + trackio_url (`str` or `None`): + Trackio Space URL. + comet_url (`str` or `None`): + Comet experiment URL. + trainer_name (`str`): + Trainer name. + trainer_citation (`str` or `None`, defaults to `None`): + Trainer citation as a BibTeX entry. + template_file (`str` *optional*): + Template file name located in the `trl/templates` directory. Defaults to `lm_model_card.md`. + paper_title (`str` or `None`, defaults to `None`): + Paper title. + paper_id (`str` or `None`, defaults to `None`): + ArXiv paper ID as `YYMM.NNNNN`. + + Returns: + [`~huggingface_hub.ModelCard`]: + A ModelCard object. + """ + card_data = ModelCardData( + base_model=base_model, + datasets=dataset_name, + library_name="transformers", + licence="license", + model_name=model_name, + tags=["generated_from_trainer", *tags], + ) + template_file = template_file or "lm_model_card.md" + card = ModelCard.from_template( + card_data, + template_path=str(pkg_resources.files("trl").joinpath(f"templates/{template_file}")), + base_model=base_model, + model_name=model_name, + hub_model_id=hub_model_id, + dataset_name=dataset_name, + wandb_url=wandb_url, + trackio_url=trackio_url, + comet_url=comet_url, + trainer_name=trainer_name, + trainer_citation=trainer_citation, + paper_title=paper_title, + paper_id=paper_id, + trl_version=version("trl"), + transformers_version=version("transformers"), + pytorch_version=version("torch"), + datasets_version=version("datasets"), + tokenizers_version=version("tokenizers"), + ) + return card + + +def get_comet_experiment_url() -> str | None: + """ + If Comet integration is enabled, return the URL of the current Comet experiment; otherwise, return `None`. + """ + if not is_comet_available(): + return None + + if comet_ml.get_running_experiment() is not None: + return comet_ml.get_running_experiment().url + + return None + + +def get_trackio_space_url() -> str | None: + """ + If Trackio integration is enabled, return the URL of the current Trackio Space; otherwise, return `None`. + """ + if not is_trackio_available(): + return None + + from trackio import context_vars + + run = context_vars.current_run.get() + if run is None: + return None + space_id = run._space_id + if space_id is None: + return None + space_id = space_id.replace("/", "-") + project = run.project + name = run.name + return f"https://{space_id}.hf.space?project={project}&runs={name}&sidebar=collapsed" + + +def log_table_to_comet_experiment(name: str, table: pd.DataFrame) -> None: + """ + If Comet integration is enabled logs a table to the Comet experiment if it is currently running. + + Args: + name (`str`): + Table name. + table (`pandas.DataFrame`): + The Pandas DataFrame containing the table to log. + """ + if not is_comet_available(): + raise ModuleNotFoundError("The comet-ml is not installed. Please install it first: pip install comet-ml") + + experiment = comet_ml.get_running_experiment() + if experiment is not None: + experiment.log_table(tabular_data=table, filename=name) + + +def flush_left(mask: torch.Tensor, *tensors: torch.Tensor) -> torch.Tensor | tuple[torch.Tensor, ...]: + """ + Shift non-zero elements in the mask and corresponding tensors to the left. + + This function operates on a binary mask and any number of additional tensors with the same dimensions as the mask. + For each row, non-zero values are shifted to the leftmost positions. Then, columns that contain only zeros across + all rows are truncated from the mask and tensors. Visually, this operation can be represented as follows: + + ``` + [[0, 0, x, x, x, x], -> [[x, x, x, x], + [0, x, x, x, 0, 0]] [x, x, x, 0]] + ``` + + Args: + mask (`torch.Tensor`): + 2D tensor (binary mask) with shape `(N, M)`. + *tensors (`torch.Tensor`): + One or more 2D tensors with the same shape as `mask`. These tensors will be processed alongside `mask`, + with non-zero values shifted and excess zero columns truncated in the same manner. + + Returns: + `torch.Tensor`: + Updated binary mask with non-zero values flushed to the left and trailing zero columns removed. + `*torch.Tensor` + Updated tensors, processed in the same way as the mask. + + Example: + ```python + >>> mask = torch.tensor([[0, 0, 1, 1, 1], [0, 1, 1, 0, 0]]) + >>> tensor = torch.tensor([[9, 9, 2, 3, 4], [9, 5, 6, 9, 9]]) + >>> new_mask, new_tensor = flush_left(mask, tensor) + >>> print(new_mask) + tensor([[1, 1, 1], + [1, 1, 0]]) + + >>> print(new_tensor) + tensor([[2, 3, 4], + [5, 6, 0]]) + ``` + """ + _, M = mask.shape + + # Create copy of mask and tensors + mask_copy = mask.clone() + tensors = [t.clone() for t in tensors] + + # Shift non-zero values to the left + first_non_zero = mask_copy.argmax(dim=1) + pos = torch.arange(M, device=mask_copy.device).unsqueeze(0) + idx_roll = (pos + first_non_zero.unsqueeze(1)) % M + mask_roll = mask_copy.gather(1, idx_roll) + rolled_tensors = [t.gather(1, idx_roll) for t in tensors] + + # Truncate trailing columns that are all zeros in mask_roll + col_sums = mask_roll.sum(dim=0) + empty_cols = col_sums == 0 + first_empty_col = int(empty_cols.to(torch.int8).argmax()) if empty_cols.any() else M + flushed_mask = mask_roll[:, :first_empty_col] + flushed_tensors = [t[:, :first_empty_col] for t in rolled_tensors] + + if not flushed_tensors: + return flushed_mask + return flushed_mask, *flushed_tensors + + +def selective_log_softmax(logits, index) -> torch.Tensor: + """ + A memory-efficient implementation of the common `log_softmax -> gather` operation. + + This function is equivalent to the following naive implementation: + ```python + # for index with shape (...): + logps = torch.gather(logits.log_softmax(-1), dim=-1, index=index.unsqueeze(-1)).squeeze(-1) + # for index with shape (..., K): + logps = torch.gather(logits.log_softmax(-1), dim=-1, index=index) + ``` + + Args: + logits (`torch.Tensor`): + Logits tensor of shape `(..., num_classes)`. + index (`torch.Tensor`): + Index tensor of shape `(..., K)` or `(...)`, specifying the positions to gather from the log-softmax + output. When the last case is used, `K` log-probabilities are gathered per position (e.g. for top-K) + + Returns: + `torch.Tensor`: + Gathered log probabilities with the same shape as `index`. + """ + squeeze = index.ndim == logits.ndim - 1 + if squeeze: + index = index.unsqueeze(-1) + + if logits.dtype in [torch.float32, torch.float64]: + selected_logits = torch.gather(logits, dim=-1, index=index) + # loop to reduce peak mem consumption + logsumexp_values = torch.stack([torch.logsumexp(lg, dim=-1) for lg in logits]) + per_token_logps = selected_logits - logsumexp_values.unsqueeze(-1) # log_softmax(x_i) = x_i - logsumexp(x) + else: + # logsumexp approach is unstable with bfloat16, fall back to slightly less efficient approach + per_token_logps = [] + for row_logits, row_labels in zip(logits, index, strict=True): # loop to reduce peak mem consumption + row_logps = F.log_softmax(row_logits, dim=-1) + row_per_token_logps = row_logps.gather(dim=-1, index=row_labels) + per_token_logps.append(row_per_token_logps) + per_token_logps = torch.stack(per_token_logps) + + if squeeze: + per_token_logps = per_token_logps.squeeze(-1) + + return per_token_logps + + +def entropy_from_logits(logits: torch.Tensor, chunk_size: int = 128) -> torch.Tensor: + """ + Compute the Shannon entropy (in nats) for each row of *logits* in a memory-efficient way. + + Instead of materializing the full softmax for all rows at once, the logits are flattened to shape (N, num_classes), + where N is the product of all leading dimensions. Computation is then performed in chunks of size `chunk_size` + along this flattened dimension, reducing peak memory usage. The result is reshaped back to match the input's + leading dimensions. + + Args: + logits (`torch.Tensor`): + Logits tensor of shape `(..., num_classes)`. Entropy is taken along the last axis; all leading dimensions + are preserved in the output. + chunk_size (`int`, *optional*, defaults to `128`): + Number of rows from the flattened logits to process per iteration. Smaller values reduce memory usage at + the cost of more iterations. + + Returns: + `torch.Tensor`: + Entropy values with shape `logits.shape[:-1]`. + """ + original_shape = logits.shape[:-1] # all dims except num_classes + num_classes = logits.shape[-1] + + # Flatten all leading dimensions into one + flat_logits = logits.reshape(-1, num_classes) + + entropies = [] + for chunk in flat_logits.split(chunk_size, dim=0): + logps = F.log_softmax(chunk, dim=-1) + chunk_entropy = -(torch.exp(logps) * logps).sum(-1) + entropies.append(chunk_entropy) + + entropies = torch.cat(entropies, dim=0) + return entropies.reshape(original_shape) + + +def print_prompt_completions_sample( + prompts: list, + completions: list, + rewards: dict[str, list[float]], + advantages: list[float], + step: int, + num_samples: int = None, + extra: dict[str, list] | None = None, +) -> None: + """ + Print out a sample of model completions to the console with multiple reward metrics. + + This function creates a nicely formatted table showing prompt-completion pairs, useful for monitoring model outputs + during training. It requires the `rich` library to be installed. + + Args: + prompts (`list`): + List of prompts. Can be either strings or lists of messages. + completions (`list`): + List of completions corresponding to the prompts. Can be either strings or lists of messages. + rewards (`dict[str, list[float]]`): + Dictionary where keys are reward names and values are lists of rewards. + advantages (`list[float]`): + List of advantages corresponding to the prompts and completions. + step (`int`): + Current training step number, used in the output title. + num_samples (`int`, *optional*): + Number of random samples to display. If `None` (default), all items will be displayed. + extra (`dict[str, list]`, *optional*): + Additional columns to display after the advantage column. Keys are column names and values are lists of + per-completion data (strings or any value convertible to string). Typically populated via `log_extra` in + reward functions. If `None` (default), no extra columns are shown. + + Example: + ```python + >>> from trl.trainer.utils import print_prompt_completions_sample + + >>> prompts = ["The sky is", "The sun is"] + >>> completions = [" blue.", " in the sky."] + >>> rewards = {"Correctness": [0.123, 0.456], "Format": [0.789, 0.101]} + >>> advantages = [0.987, 0.654] + >>> extra = {"source": ["dataset_A", "dataset_B"]} + >>> print_prompt_completions_sample(prompts, completions, rewards, advantages, 42, extra=extra) + ╭────────────────────────────────── Step 42 ───────────────────────────────────╮ + │ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┓ │ + │ ┃ Prompt ┃ Completion ┃ Correctness ┃ Format ┃ Advantage ┃ source ┃ │ + │ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━┩ │ + │ │ The sky is │ blue. │ 0.12 │ 0.79 │ 0.99 │ dataset_A │ │ + │ ├────────────┼──────────────┼─────────────┼────────┼───────────┼───────────┤ │ + │ │ The sun is │ in the sky. │ 0.46 │ 0.10 │ 0.65 │ dataset_B │ │ + │ └────────────┴──────────────┴─────────────┴────────┴───────────┴───────────┘ │ + ╰──────────────────────────────────────────────────────────────────────────────╯ + ``` + """ + if not is_rich_available(): + raise ImportError( + "The function `print_prompt_completions_sample` requires the `rich` library. Please install it with " + "`pip install rich`." + ) + console = Console() + table = Table(show_header=True, header_style="bold white", expand=True) + + extra = extra or {} + + # Add columns + table.add_column("Prompt", style="bright_yellow") + table.add_column("Completion", style="bright_green") + for reward_name in rewards.keys(): + table.add_column(reward_name, style="bold cyan", justify="right") + table.add_column("Advantage", style="bold magenta", justify="right") + for extra_name in extra.keys(): + table.add_column(extra_name, style="bright_white") + + def format_entry(entry) -> Text: + t = Text() + if isinstance(entry, list) and all(isinstance(m, dict) for m in entry): + for j, msg in enumerate(entry): + role = msg.get("role", "") + if "content" in msg or "reasoning_content" in msg or "thinking" in msg: + # Chat message + t.append(f"{role.upper()}\n", style="bold red") + reasoning = msg.get("reasoning_content") or msg.get("thinking") + if reasoning: + t.append(reasoning, style="italic dim white") + t.append("\n") + if "content" in msg: + t.append(msg["content"]) + elif "name" in msg and "args" in msg: + # Tool call + t.append(f"{role.upper()}\n", style="bold red") + t.append(f"{msg['name']}({msg['args']})") + else: + # Fallback + t.append(str(msg)) + if j < len(entry) - 1: + t.append("\n\n") + else: + t.append(str(entry)) + return t + + # Some basic input validation + if num_samples is not None: + if num_samples >= len(prompts): + num_samples = None + elif num_samples <= 0: + return + + # Subsample data if num_samples is specified + if num_samples is not None: + indices = random.sample(range(len(prompts)), num_samples) + prompts = [prompts[i] for i in indices] + completions = [completions[i] for i in indices] + rewards = {key: [val[i] for i in indices] for key, val in rewards.items()} + advantages = [advantages[i] for i in indices] + extra = {key: [val[i] for i in indices] for key, val in extra.items()} + + for i in range(len(prompts)): + reward_values = [f"{rewards[key][i]:.2f}" for key in rewards.keys()] # 2 decimals + extra_values = [format_entry(extra[key][i]) for key in extra.keys()] + table.add_row( + format_entry(prompts[i]), + format_entry(completions[i]), + *reward_values, + f"{advantages[i]:.2f}", + *extra_values, + ) + table.add_section() # Adds a separator between rows + + panel = Panel(table, expand=False, title=f"Step {step}", border_style="bold white") + console.print(panel) + + +class RepeatSampler(Sampler): + """ + Sampler that repeats the indices of a dataset in a structured manner. + + Args: + data_source (`Sized`): + Dataset to sample from. + mini_repeat_count (`int`): + Number of times to repeat each index per batch. + batch_size (`int`, *optional*, defaults to `1`): + Number of unique indices per batch. + repeat_count (`int`, *optional*, defaults to `1`): + Number of times to repeat the full sampling process. + shuffle (`bool`, *optional*, defaults to `True`): + Whether to shuffle the dataset. + seed (`int`, *optional*): + Random seed for reproducibility (only affects this sampler). + + Example: + ```python + >>> sampler = RepeatSampler(["a", "b", "c", "d", "e", "f", "g"], mini_repeat_count=2, batch_size=3, repeat_count=4) + >>> list(sampler) + [4, 4, 3, 3, 0, 0, + 4, 4, 3, 3, 0, 0, + 4, 4, 3, 3, 0, 0, + 4, 4, 3, 3, 0, 0, + 1, 1, 2, 2, 6, 6, + 1, 1, 2, 2, 6, 6, + 1, 1, 2, 2, 6, 6, + 1, 1, 2, 2, 6, 6] + ``` + + ```txt + mini_repeat_count = 3 + - - - + [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, | + 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, | + 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, | + repeat_count = 2 + 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, | + 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, | + 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, ...] | + --------- --------- --------- --------- + --------- --------- --------- --------- + --------- --------- --------- --------- + batch_size = 12 + ``` + """ + + def __init__( + self, + data_source: Sized, + mini_repeat_count: int, + batch_size: int = 1, + repeat_count: int = 1, + shuffle: bool = True, + seed: int | None = None, + ): + self.data_source = data_source + self.mini_repeat_count = mini_repeat_count + self.batch_size = batch_size + self.repeat_count = repeat_count + self.num_samples = len(data_source) + self.shuffle = shuffle + self.seed = seed + + if shuffle: + self.generator = torch.Generator() # Create a local random generator + if seed is not None: + self.generator.manual_seed(seed) + + def __iter__(self): + if self.shuffle: + # E.g., [2, 4, 3, 1, 0, 6, 5] (num_samples = 7) + indexes = torch.randperm(self.num_samples, generator=self.generator).tolist() + else: + indexes = list(range(self.num_samples)) + + # [2, 4, 3, 1, 0, 6, 5] + # -> [[2, 4, 3], [1, 0, 6], [5]] (batch_size = 3) + indexes = [indexes[i : i + self.batch_size] for i in range(0, len(indexes), self.batch_size)] + + # [[2, 4, 3], [1, 0, 6], [5]] + # -> [[2, 4, 3], [1, 0, 6]] + indexes = [chunk for chunk in indexes if len(chunk) == self.batch_size] + + for chunk in indexes: + for _ in range(self.repeat_count): + for index in chunk: + for _ in range(self.mini_repeat_count): + yield index + + def __len__(self) -> int: + return (self.num_samples // self.batch_size) * self.batch_size * self.mini_repeat_count * self.repeat_count + + +# torch.nanstd doesn't exist, so we define it here +def nanstd(tensor: torch.Tensor, dim: int | tuple[int, ...] | None = None, keepdim: bool = False) -> torch.Tensor: + """ + Compute the standard deviation of a tensor, ignoring NaNs. + + Args: + tensor (`torch.Tensor`): + Input tensor. + dim (`int` or `tuple[int, ...]`, *optional*): + Dimension(s) to reduce. Defaults to all dimensions. + keepdim (`bool`, *optional*, defaults to `False`): + Whether to keep reduced dimensions. + + Returns: + `torch.Tensor`: + Standard deviation of the tensor, ignoring NaNs. + """ + # Compute variance ignoring NaNs + mean = torch.nanmean(tensor, dim=dim, keepdim=True) + variance = torch.nanmean((tensor - mean) ** 2, dim=dim, keepdim=True) + count = torch.sum(~torch.isnan(tensor), dim=dim, keepdim=True) # count of non-NaN values + correction = count / (count - 1) + correction = torch.where(count > 1, correction, torch.full_like(correction, float("nan"))) + variance *= correction # Bessel's correction + std = torch.sqrt(variance) + if keepdim: + return std + if dim is None: + return std.squeeze() + if isinstance(dim, int): + return std.squeeze(dim) + dims = [(d if d >= 0 else d + std.ndim) for d in dim] + for d in sorted(dims, reverse=True): + std = std.squeeze(d) + return std + + +def split_tensor_dict( + tensor_dict: dict[str, torch.Tensor | None], num_chunks: int +) -> list[dict[str, torch.Tensor | None]]: + """ + Splits a dictionary of tensors along the first dimension into `num_chunks` equal parts. + + Example: + ```python + >>> x = torch.arange(12).reshape(6, 2) + >>> y = torch.arange(6).reshape(6, 1) + >>> tensor_dict = {"x": x, "y": y} + >>> split_tensor_dict(tensor_dict, 3) + [ + {"x": tensor([[0, 1], [2, 3]]), "y": tensor([[0], [1]])}, + {"x": tensor([[4, 5], [6, 7]]), "y": tensor([[2], [3]])}, + {"x": tensor([[ 8, 9], [10, 11]]), "y": tensor([[4], [5]])} + ] + ``` + """ + first_tensor = next(tensor for tensor in tensor_dict.values() if tensor is not None) + chunk_size = first_tensor.shape[0] // num_chunks + chunks = [] + for i in range(num_chunks): + chunk_dict = {} + for key, tensor in tensor_dict.items(): + if tensor is not None and (isinstance(tensor, list) or tensor.ndim > 0): + chunk_dict[key] = tensor[i * chunk_size : (i + 1) * chunk_size] + elif tensor is not None and tensor.ndim == 0: + chunk_dict[key] = tensor + else: + chunk_dict[key] = None + chunks.append(chunk_dict) + return chunks + + +def shuffle_sequence_dict(seq_dict: dict[str, Sequence | None]) -> dict[str, Sequence | None]: + """ + Shuffles all sequence-like values in a dictionary along the first dimension in unison. + + Example: + ```python + >>> x = torch.arange(6).reshape(3, 2) + >>> y = ["a", "b", "c"] + >>> seq_dict = {"x": x, "y": y} + >>> shuffle_sequence_dict(seq_dict) + {'x': tensor([[2, 3], + [0, 1], + [4, 5]]), + 'y': ['b', 'a', 'c']} + ``` + """ + # Determine batch size from the first non-None sequence + batch_size = len(next(v for v in seq_dict.values() if v is not None)) + permutation = torch.randperm(batch_size) + + def permute(v: Sequence | None) -> Sequence | None: + if v is None: + return None + if isinstance(v, torch.Tensor) and v.ndim == 0: + return v + if isinstance(v, torch.Tensor) and v.ndim >= 1: + return v[permutation] + return [v[i] for i in permutation] + + return {key: permute(val) for key, val in seq_dict.items()} + + +def nanmin(tensor: torch.Tensor) -> torch.Tensor: + """ + Compute the minimum value of a tensor, ignoring NaNs. This function only supports 1D tensors. + + Args: + tensor (`torch.Tensor`): Input tensor of shape `(N,)`. + + Returns: + `torch.Tensor`: Minimum value of the tensor, ignoring NaNs. Returns NaN if all values are NaN. + """ + if torch.isnan(tensor).all(): + return torch.tensor(float("nan"), dtype=tensor.dtype, device=tensor.device) + return torch.min(tensor[~torch.isnan(tensor)]) + + +def nanmax(tensor: torch.Tensor) -> torch.Tensor: + """ + Compute the maximum value of a tensor, ignoring NaNs. This function only supports 1D tensors. + + Args: + tensor (`torch.Tensor`): Input tensor of shape `(N,)`. + + Returns: + `torch.Tensor`: Maximum value of the tensor, ignoring NaNs. Returns NaN if all values are NaN. + """ + if torch.isnan(tensor).all(): + return torch.tensor(float("nan"), dtype=tensor.dtype, device=tensor.device) + return torch.max(tensor[~torch.isnan(tensor)]) + + +def identity(x): + """Do we really need docs for this?""" + return x + + +def split_pixel_values_by_grid(batch: dict[str, torch.Tensor]) -> dict[str, torch.Tensor | list[torch.Tensor]]: + """ + Splits `batch["pixel_values"]` into a list of tensors, one per sample, based on `batch["num_images"]`. + + For models with `image_grid_thw` (e.g. Qwen), the grid dimensions determine how many rows of `pixel_values` belong + to each image. For models with `image_position_ids` instead (e.g. Gemma), `pixel_values` is indexed directly by + image count. + """ + if "pixel_values" not in batch or "num_images" not in batch: + return batch + + num_images = batch["num_images"] + pixel_values = batch["pixel_values"] # [total, feature_dim] + + if "image_grid_thw" in batch: + lengths = batch["image_grid_thw"].prod(-1).tolist() # [num_images] + if sum(lengths) != pixel_values.size(0): + raise ValueError( + f"Mismatch: sum(lengths) = {sum(lengths)} != pixel_values.size(0) = {pixel_values.size(0)}" + ) + + boundaries = [0, *accumulate(num_images)] + image_grid_thw = batch["image_grid_thw"] # [total, 3] + sections = [sum(lengths[boundaries[i] : boundaries[i + 1]]) for i in range(len(num_images))] + split_pixel_values = list(torch.split(pixel_values, sections, dim=0)) + split_image_grid_thw = list(torch.split(image_grid_thw, num_images, dim=0)) + return {**batch, "pixel_values": split_pixel_values, "image_grid_thw": split_image_grid_thw} + + if "image_position_ids" in batch: + image_position_ids = batch["image_position_ids"] # [total] + split_pixel_values = list(torch.split(pixel_values, num_images, dim=0)) + split_image_position_ids = list(torch.split(image_position_ids, num_images, dim=0)) + return {**batch, "pixel_values": split_pixel_values, "image_position_ids": split_image_position_ids} + + return batch + + +def unsplit_pixel_values_by_grid(batch: dict[str, torch.Tensor | list[torch.Tensor]]) -> dict[str, torch.Tensor]: + """ + Opposite of `split_pixel_values_by_grid`. Merges a list of tensors in `batch["pixel_values"]` back into a single + tensor along the first dimension. + """ + pixel_values = batch.get("pixel_values") + if isinstance(pixel_values, list): + merged = torch.cat(pixel_values, dim=0) + batch = {**batch, "pixel_values": merged} + + image_grid_thw = batch.get("image_grid_thw") + if isinstance(image_grid_thw, list): + merged = torch.cat(image_grid_thw, dim=0) + batch = {**batch, "image_grid_thw": merged} + + image_position_ids = batch.get("image_position_ids") + if isinstance(image_position_ids, list): + merged = torch.cat(image_position_ids, dim=0) + batch = {**batch, "image_position_ids": merged} + + return batch + + +TListOrMapping = TypeVar("TListOrMapping", list, Mapping) + + +# This function is intentionally not used internally. It is provided as a utility for users whose datasets contain +# `None` values inserted by tabular backends (e.g., Arrow/Parquet) for missing keys in nested structures. This +# situation arises when loading datasets created before `datasets` v4.7.0 (which introduced the Json dtype), or when +# datasets created after that version were saved without using the Json feature. In both cases, users can apply this +# function via `dataset = dataset.with_transform(remove_none_values)` before training to strip the spurious `None` +# values. See the migration guide for more details. +def remove_none_values(example: TListOrMapping) -> TListOrMapping: + """ + Recursively removes entries with `None` values from a nested structure (list or dictionary). + + Args: + example (`list` or `Mapping`): + Input nested structure (list or dictionary) from which to remove `None`. + + Examples: + ```python + >>> dataset = dataset.with_transform(remove_none_values) + ``` + ```python + >>> [ + ... { + ... "a": {"aa": None, "ab": 1}, + ... "b": "my_string", + ... } + ... ] + >>> remove_none_values(example) + [{'a': {'ab': 1}, 'b': 'my_string'}] + ``` + """ + if isinstance(example, list): + return [remove_none_values(value) if isinstance(value, (dict, list)) else value for value in example] + elif isinstance(example, Mapping): + return { + key: remove_none_values(value) if isinstance(value, (dict, list)) else value + for key, value in example.items() + if value is not None + } + else: + raise TypeError("Input must be a list or a dictionary.") + + +def create_model_from_path( + model_id: str, architecture: _BaseAutoModelClass | None = None, **kwargs +) -> PreTrainedModel: + """ + Create a model from a given path using the specified initialization arguments. + + Args: + model_id (`str`): + Path to the model. Can be either a local directory or a model identifier from the Hugging Face Hub. + architecture (`_BaseAutoModelClass` or `None`, *optional*): + Model architecture class to instantiate. The model is initialized using the `from_pretrained` method of + this class. If `None`, the architecture will be inferred from the model's configuration. + kwargs (`dict`): + Initialization keyword arguments to pass to the model's `from_pretrained` method. When `'dtype'` is + specified, it can be either a `torch.dtype` or one of the strings: `'bfloat16'`, `'float16'`, `'float32'`, + or `'auto'`. If not explicitly set, `dtype` defaults to `'float32'`. + + Returns: + [`~transformers.PreTrainedModel`]: + The instantiated model. + """ + dtype = kwargs.get("dtype", "float32") + if isinstance(dtype, torch.dtype) or dtype == "auto" or dtype is None: + pass # dtype is already a torch.dtype or "auto" or None + elif isinstance(dtype, str) and dtype in ["bfloat16", "float16", "float32"]: + kwargs["dtype"] = getattr(torch, dtype) + else: + raise ValueError( + "Invalid `dtype` passed to the config. Expected either 'auto' or a string representing " + f"a valid `torch.dtype` (e.g., 'float32'), but got {dtype}." + ) + kwargs["device_map"] = kwargs.get("device_map", "auto") + if architecture is None: + config = AutoConfig.from_pretrained(model_id) + architecture = getattr(transformers, config.architectures[0]) + model = architecture.from_pretrained(model_id, **kwargs) + return model + + +def hash_module(module: torch.nn.Module) -> str: + h = hashlib.sha256() + for _, tensor in sorted(module.state_dict().items()): + tensor = tensor.cpu() + h.update(str(tensor.dtype).encode()) + if tensor.dtype in [torch.bfloat16, torch.float8_e4m3fn, torch.float8_e5m2]: + tensor = tensor.to(torch.float32) + h.update(tensor.numpy().tobytes()) + return h.hexdigest() + + +def get_config_model_id(config: PretrainedConfig) -> str: + """ + Retrieve the model identifier from a given model configuration. + + Args: + config ([`~transformers.PreTrainedConfig`]): + Configuration from which to extract the model identifier. + + Returns: + `str`: + The model identifier associated with the model configuration. + """ + return getattr(config, "_name_or_path", "") + + +@contextmanager +def use_adapter(model: "PeftModel", adapter_name: str | None): + """ + Context manager to temporarily set and reset the active adapter in a PEFT model. + + Args: + model ([`~peft.PeftModel`]): + PEFT model to manage. + adapter_name (`str` or `None`): + Name of the adapter to set as active. If `None`, the context manager will disable all adapters. + + Example: + ```python + >>> from trl.trainer.utils import use_adapter + >>> from peft import AutoPeftModelForCausalLM + >>> import torch + + >>> model = AutoPeftModelForCausalLM.from_pretrained("path/to/model") + >>> input_ids = torch.tensor([[1, 2, 3]]) + >>> with use_adapter(model, "adapter_name"): + ... outputs = model(input_ids) + ``` + """ + + if not is_peft_available(): + raise ImportError( + "You're trying to use a PEFT adapter but PEFT is not installed. Please install it with `pip install peft`." + ) + if adapter_name is None: + with model.disable_adapter(): + yield + else: + previous_adapter = model.active_adapter + model.set_adapter(adapter_name) + try: + yield + finally: + model.set_adapter(previous_adapter) + + +def start_event_loop_in_daemon( + name: str | None = None, +) -> tuple[threading.Thread, asyncio.AbstractEventLoop, threading.Event]: + """ + This function creates a new daemon thread that runs the provided event loop. + + Args: + name (`str`, *optional*): + Name of the thread. If `None`, the default thread naming will be used. + + Returns: + `threading.Thread`: + The thread running the event loop. + `asyncio.AbstractEventLoop`: + The event loop being run in the thread. + `threading.Event`: + An event that is set when the loop is ready. + """ + loop = asyncio.new_event_loop() + loop_ready_event = threading.Event() + + def run_loop(): + asyncio.set_event_loop(loop) + loop_ready_event.set() + loop.run_forever() + + thread = threading.Thread(target=run_loop, name=name, daemon=True) + thread.start() + return thread, loop, loop_ready_event + + +def shutdown_event_loop_in_daemon( + thread: threading.Thread | None, + loop: asyncio.AbstractEventLoop | None, +) -> None: + """ + Shutdown an asyncio event loop running in a separate thread. + + This function stops the event loop and waits for the associated thread to finish execution. + + Args: + thread (`threading.Thread`): + The thread running the event loop. + loop (`asyncio.AbstractEventLoop`): + The asyncio event loop to shut down. + """ + if loop is None or thread is None: + return + loop.call_soon_threadsafe(loop.stop) + thread.join(timeout=5) + + +class _ChunkedLogProbFunction(torch.autograd.Function): + """Compute per-token log-probs and entropy without materializing [N, V] logits. + + Processes the lm_head in chunks and uses online logsumexp + """ + + @staticmethod + def forward( + ctx, + last_hidden: torch.Tensor, # [N, H] + weight: torch.Tensor, # [V, H] + targets: torch.Tensor, # [N] + temperature: float, + chunk_size: int, + logit_scale: float = 1.0, + ) -> tuple[torch.Tensor, torch.Tensor]: + device = last_hidden.device + N, _ = last_hidden.shape + vocab, _ = weight.shape + inv_t = logit_scale / temperature + + # NOTE(@aminediro): always acc in fp32 for stability + max_old = torch.full((N,), float("-inf"), device=device, dtype=torch.float32) + sum_exp = torch.zeros((N,), device=device, dtype=torch.float32) + x_sum_exp = torch.zeros((N,), device=device, dtype=torch.float32) + target_logit = torch.zeros((N,), device=device, dtype=torch.float32) + + # Pre-allocate reusable buffers to avoid per-chunk allocation + mm_buf = torch.empty((N, chunk_size), device=device, dtype=last_hidden.dtype) + logits_buf = torch.empty((N, chunk_size), device=device, dtype=torch.float32) + + for start in range(0, vocab, chunk_size): + end = min(start + chunk_size, vocab) + C = end - start + # using fp16=True, the model's hidden states get cast to float16 by autocast, but the mm_buf is allocated + # with last_hidden.dtype (float16) while w_chunk (the lm_head weights) is not auto casted + w_chunk = weight[start:end].to(last_hidden.dtype) # [C, H] + torch.mm(last_hidden, w_chunk.t(), out=mm_buf[:, :C]) + logits_chunk = logits_buf[:, :C] + logits_chunk.copy_(mm_buf[:, :C]) + logits_chunk.mul_(inv_t) # [N, C] + + # Online logsumexp update + chunk_max = logits_chunk.amax(dim=-1) # [N] + max_new = torch.maximum(max_old, chunk_max) + rescale = torch.exp(max_old - max_new) + chunk_exp = torch.exp(logits_chunk - max_new.unsqueeze(-1)) # [N, C] + + sum_exp = sum_exp * rescale + chunk_exp.sum(dim=-1) + x_sum_exp = x_sum_exp * rescale + (chunk_exp * logits_chunk).sum(dim=-1) + max_old = max_new + + # Gather target logits for labels in this chunk + in_chunk_cond = (targets >= start) & (targets < end) + local_idx = torch.clamp(targets - start, 0, end - start - 1) + # take the new logit if target_idx is in this chunk bounds else 0 + target_logit += logits_chunk[torch.arange(N, device=device), local_idx] * in_chunk_cond + + log_z = max_old + torch.log(sum_exp) + logprobs = target_logit - log_z + entropy = log_z - x_sum_exp / sum_exp + + ctx.save_for_backward(last_hidden, weight, targets, log_z) + ctx.temperature = temperature + ctx.chunk_size = chunk_size + ctx.logit_scale = logit_scale + + return logprobs, entropy + + @staticmethod + def backward(ctx, grad_logprobs: torch.Tensor, grad_entropy: torch.Tensor): # type: ignore + hidden, weight, labels, log_z = ctx.saved_tensors + temperature: float = ctx.temperature + chunk_size: int = ctx.chunk_size + logit_scale: float = ctx.logit_scale + inv_t = logit_scale / temperature + + N, _ = hidden.shape + vocab = weight.shape[0] + + # NOTE(@aminediro): always acc in fp32 even if input is not + grad_hidden = torch.zeros(hidden.shape, device=hidden.device, dtype=torch.float32) + grad_weight = torch.zeros(weight.shape, device=weight.device, dtype=torch.float32) + + # Pre-allocate reusable buffers to avoid per-chunk allocation + mm_buf = torch.empty((N, chunk_size), device=hidden.device, dtype=hidden.dtype) + logits_buf = torch.empty((N, chunk_size), device=hidden.device, dtype=torch.float32) + + g = grad_logprobs.to(torch.float32) # [N] + row_idx = torch.arange(N, device=hidden.device) + + for start in range(0, vocab, chunk_size): + end = min(start + chunk_size, vocab) + C = end - start + w_chunk = weight[start:end] # [C, H] + + torch.mm(hidden, w_chunk.t(), out=mm_buf[:, :C]) + logits_chunk = logits_buf[:, :C] + logits_chunk.copy_(mm_buf[:, :C]) + logits_chunk.mul_(inv_t) # [N, C] + probs = torch.exp(logits_chunk - log_z.unsqueeze(-1)) # [N, C] + + # dL/d(logits) = g * (1_[label] - p) + grad_logits = (-g).unsqueeze(-1) * probs # [N, C] + + in_chunk_cond = (labels >= start) & (labels < end) + local_idx = torch.clamp(labels - start, 0, end - start - 1) + # If label in chunk add g to grad else it stays the same + grad_logits[row_idx, local_idx] += g * in_chunk_cond + grad_logits = grad_logits * inv_t + + grad_hidden.add_(grad_logits @ w_chunk.float()) + grad_weight[start:end].add_(grad_logits.t() @ hidden.float()) + + return grad_hidden.to(hidden.dtype), grad_weight.to(weight.dtype), None, None, None, None + + +def patch_chunked_lm_head(model: torch.nn.Module, chunk_size: int, temperature: float) -> None: + if getattr(model.config, "final_logit_softcapping", None) is not None: + raise NotImplementedError( + "The model uses `final_logit_softcapping` which is not yet supported. Please open an issue if you " + "want your model to be supported." + ) + + def _chunked_forward( + self: torch.nn.Module, + input_ids: torch.Tensor | None = None, + attention_mask: torch.Tensor | None = None, + labels: torch.Tensor | None = None, + completion_mask: torch.Tensor | None = None, + use_cache: bool = False, + **kwargs, + ) -> dict[str, torch.Tensor]: + assert labels is not None, "requires labels to not be None for logprob computation" + + outputs = self.model(input_ids=input_ids, attention_mask=attention_mask, use_cache=use_cache, **kwargs) + # NOTE(@aminediro): supporting Cohere2 models + logit_scale = getattr(self.config, "logit_scale", 1.0) + hidden_states = outputs.last_hidden_state # [B, S+1, H] + + # Shift: predict next token + hidden_states = hidden_states[:, :-1, :] # [B, S-1, H] + labels = labels[:, 1:] # [B, S-1] + + b, s, h = hidden_states.shape + hidden_flat = hidden_states.reshape(b * s, h).contiguous() + targets_flat = labels.reshape(b * s).contiguous() + + # Filter to completion tokens only to avoid expensive matmuls on prompt tokens and tool results + valid_mask = None + if completion_mask is not None: + completion_mask = completion_mask[:, 1:] # same shift as labels + valid_mask = completion_mask.bool().reshape(b * s) + hidden_flat = hidden_flat[valid_mask] # [N_valid, H] + targets_flat = targets_flat[valid_mask] # [N_valid] + + logprobs_valid, entropy_valid = _ChunkedLogProbFunction.apply( + hidden_flat, self.lm_head.weight, targets_flat, temperature, chunk_size, logit_scale + ) + + if valid_mask is not None: + logprobs = torch.zeros(b * s, device=logprobs_valid.device, dtype=logprobs_valid.dtype) + entropy = torch.zeros(b * s, device=entropy_valid.device, dtype=entropy_valid.dtype) + logprobs[valid_mask] = logprobs_valid + entropy[valid_mask] = entropy_valid + else: + logprobs = logprobs_valid + entropy = entropy_valid + + return { + "log_probs": logprobs.reshape(b, s), + "entropy": entropy.reshape(b, s), + } + + model.forward = types.MethodType(_chunked_forward, model) diff --git a/tasks/tasksmith-1c108f674e97/tests/test.sh b/tasks/tasksmith-1c108f674e97/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c92b552378bd5c90e06861fb4c3cf5e93ef8dd72 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -eu +exec /opt/tasksmith-venv/bin/python -I /tests/grade.py diff --git a/tasks/tasksmith-1c108f674e97/tests/test_driver.py b/tasks/tasksmith-1c108f674e97/tests/test_driver.py new file mode 100644 index 0000000000000000000000000000000000000000..3d47bdfd18bf0d184d186cb919f64637213b6c60 --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/test_driver.py @@ -0,0 +1,38 @@ +"""Private pytest entry point with a bounded framework-tampering check. + +The host still owns reward parsing. This guard detects replacement or in-place +editing of unittest assertions, a demonstrated attack against repository tests. +It does not claim to isolate arbitrary test and solution code in one interpreter. +""" + +from __future__ import annotations + +import sys +import unittest + + +def run(arguments: list[str]) -> int: + import pytest + + # Capture before pytest imports any repository modules. Retain code objects + # too: an attacker can mutate function.__code__ without replacing a method. + original = { + name: (value, getattr(value, "__code__", None)) + for name, value in vars(unittest.TestCase).items() + if name.startswith("assert") and callable(value) + } + case = unittest.TestCase + code = int(pytest.main(arguments)) + changed = [] + for name, (method, implementation) in original.items(): + current = getattr(case, name, None) + if current is not method or getattr(current, "__code__", None) is not implementation: + changed.append(name) + if unittest.TestCase is not case or changed: + sys.stderr.write("Verifier framework was modified: " + ", ".join(changed) + "\n") + return 254 + return code + + +if __name__ == "__main__": + raise SystemExit(run(sys.argv[1:])) diff --git a/tasks/tasksmith-1c108f674e97/tests/test_results.py b/tasks/tasksmith-1c108f674e97/tests/test_results.py new file mode 100644 index 0000000000000000000000000000000000000000..05ce2c730e38e02bad44f2344e88e5f1cb02cb8d --- /dev/null +++ b/tasks/tasksmith-1c108f674e97/tests/test_results.py @@ -0,0 +1,65 @@ +"""Strict test evidence used by repository recipes and their exported verifiers.""" + +from __future__ import annotations + +from dataclasses import dataclass +from xml.etree import ElementTree + + +@dataclass(frozen=True) +class TestResults: + __test__ = False + statuses: dict[str, str] + returncode: int + + @property + def passed(self) -> set[str]: + return {name for name, status in self.statuses.items() if status == "passed"} + + +def parse_junit(text: str, *, returncode: int) -> TestResults: + if " dict[str, list[str]]: + if healthy.returncode != 0 or not healthy.passed: + raise ValueError("Reference must execute successfully with passing tests") + if healthy.statuses.keys() != defective.statuses.keys(): + raise ValueError("Mutation changed test collection; contrast is not comparable") + failing = sorted( + name for name in healthy.passed if defective.statuses[name] in {"failed", "error"} + ) + if not failing or defective.returncode != 1: + raise ValueError("No intended fail-to-pass contrast") + return {"FAIL_TO_PASS": failing, "PASS_TO_PASS": sorted(healthy.passed - set(failing))} diff --git a/tasks/tasksmith-1c5704b1f07f/environment/Dockerfile b/tasks/tasksmith-1c5704b1f07f/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3a037636958fa4230801a53d2402425ca4e929ce --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.12-slim-bookworm +WORKDIR /workspace +RUN python -m pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu torch==2.11.0+cpu numpy==2.5.3 packaging==26.3 parameterized==0.9.0 pillow==12.3.0 pytest==8.4.2 setuptools==78.1.0 wheel==0.48.0 huggingface-hub==0.36.2 safetensors==0.5.3 filelock==3.32.6 requests==2.32.3 regex==2024.11.6 importlib_metadata==8.5.0 tokenizers==0.21.4 transformers==4.52.4 pyyaml==6.0.2 fsspec==2024.10.0 tqdm==4.67.1 typing-extensions==4.12.2 requests-mock==1.12.1 accelerate==1.15.0 httpx==0.28.1 +COPY source /workspace +RUN python -m pip install --no-cache-dir --no-deps --no-build-isolation -e . +ENV PYTHONDONTWRITEBYTECODE=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 +ENV HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 HF_DATASETS_OFFLINE=1 +RUN apt-get update && apt-get install -y --no-install-recommends tmux && rm -rf /var/lib/apt/lists/* +RUN useradd -m learner && chown -R learner:learner /workspace diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/.gitignore b/tasks/tasksmith-1c5704b1f07f/environment/source/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a55026febd5ada75a9b6eaa2a26c2105d00aebaa --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/.gitignore @@ -0,0 +1,181 @@ +# Initially taken from GitHub's Python gitignore file + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# tests and logs +tests/fixtures/cached_*_text.txt +logs/ +lightning_logs/ +lang_code_data/ + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a Python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# vscode +.vs +.vscode + +# Cursor +.cursor + +# Pycharm +.idea + +# TF code +tensorflow_code + +# Models +proc_data + +# examples +runs +/runs_old +/wandb +/examples/runs +/examples/**/*.args +/examples/rag/sweep + +# data +/data +serialization_dir + +# emacs +*.*~ +debug.env + +# vim +.*.swp + +# ctags +tags + +# pre-commit +.pre-commit* + +# .lock +*.lock + +# DS_Store (MacOS) +.DS_Store + +# RL pipelines may produce mp4 outputs +*.mp4 + +# dependencies +/transformers + +# ruff +.ruff_cache + +# wandb +wandb \ No newline at end of file diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/CITATION.cff b/tasks/tasksmith-1c5704b1f07f/environment/source/CITATION.cff new file mode 100644 index 0000000000000000000000000000000000000000..09fc6c744d06407fa6b4707af1afe3cc9529b4db --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/CITATION.cff @@ -0,0 +1,52 @@ +cff-version: 1.2.0 +title: 'Diffusers: State-of-the-art diffusion models' +message: >- + If you use this software, please cite it using the + metadata from this file. +type: software +authors: + - given-names: Patrick + family-names: von Platen + - given-names: Suraj + family-names: Patil + - given-names: Anton + family-names: Lozhkov + - given-names: Pedro + family-names: Cuenca + - given-names: Nathan + family-names: Lambert + - given-names: Kashif + family-names: Rasul + - given-names: Mishig + family-names: Davaadorj + - given-names: Dhruv + family-names: Nair + - given-names: Sayak + family-names: Paul + - given-names: Steven + family-names: Liu + - given-names: William + family-names: Berman + - given-names: Yiyi + family-names: Xu + - given-names: Thomas + family-names: Wolf +repository-code: 'https://github.com/huggingface/diffusers' +abstract: >- + Diffusers provides pretrained diffusion models across + multiple modalities, such as vision and audio, and serves + as a modular toolbox for inference and training of + diffusion models. +keywords: + - deep-learning + - pytorch + - image-generation + - hacktoberfest + - diffusion + - text2image + - image2image + - score-based-generative-modeling + - stable-diffusion + - stable-diffusion-diffusers +license: Apache-2.0 +version: 0.12.1 diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/CODE_OF_CONDUCT.md b/tasks/tasksmith-1c5704b1f07f/environment/source/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000000000000000000000000000000000..2139079964fbd53692380985e60ef90e2fa05dad --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/CODE_OF_CONDUCT.md @@ -0,0 +1,130 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall Diffusers community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Spamming issues or PRs with links to projects unrelated to this library +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +feedback@huggingface.co. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/CONTRIBUTING.md b/tasks/tasksmith-1c5704b1f07f/environment/source/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..ec18df88264121675cb0ba0fe04083be5dd326ab --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/CONTRIBUTING.md @@ -0,0 +1,506 @@ + + +# How to contribute to Diffusers 🧨 + +We ❤️ contributions from the open-source community! Everyone is welcome, and all types of participation –not just code– are valued and appreciated. Answering questions, helping others, reaching out, and improving the documentation are all immensely valuable to the community, so don't be afraid and get involved if you're up for it! + +Everyone is encouraged to start by saying 👋 in our public Discord channel. We discuss the latest trends in diffusion models, ask questions, show off personal projects, help each other with contributions, or just hang out ☕. Join us on Discord + +Whichever way you choose to contribute, we strive to be part of an open, welcoming, and kind community. Please, read our [code of conduct](https://github.com/huggingface/diffusers/blob/main/CODE_OF_CONDUCT.md) and be mindful to respect it during your interactions. We also recommend you become familiar with the [ethical guidelines](https://huggingface.co/docs/diffusers/conceptual/ethical_guidelines) that guide our project and ask you to adhere to the same principles of transparency and responsibility. + +We enormously value feedback from the community, so please do not be afraid to speak up if you believe you have valuable feedback that can help improve the library - every message, comment, issue, and pull request (PR) is read and considered. + +## Overview + +You can contribute in many ways ranging from answering questions on issues to adding new diffusion models to +the core library. + +In the following, we give an overview of different ways to contribute, ranked by difficulty in ascending order. All of them are valuable to the community. + +* 1. Asking and answering questions on [the Diffusers discussion forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers) or on [Discord](https://discord.gg/G7tWnz98XR). +* 2. Opening new issues on [the GitHub Issues tab](https://github.com/huggingface/diffusers/issues/new/choose). +* 3. Answering issues on [the GitHub Issues tab](https://github.com/huggingface/diffusers/issues). +* 4. Fix a simple issue, marked by the "Good first issue" label, see [here](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22). +* 5. Contribute to the [documentation](https://github.com/huggingface/diffusers/tree/main/docs/source). +* 6. Contribute a [Community Pipeline](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3Acommunity-examples). +* 7. Contribute to the [examples](https://github.com/huggingface/diffusers/tree/main/examples). +* 8. Fix a more difficult issue, marked by the "Good second issue" label, see [here](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22). +* 9. Add a new pipeline, model, or scheduler, see ["New Pipeline/Model"](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22) and ["New scheduler"](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22) issues. For this contribution, please have a look at [Design Philosophy](https://github.com/huggingface/diffusers/blob/main/PHILOSOPHY.md). + +As said before, **all contributions are valuable to the community**. +In the following, we will explain each contribution a bit more in detail. + +For all contributions 4-9, you will need to open a PR. It is explained in detail how to do so in [Opening a pull request](#how-to-open-a-pr). + +### 1. Asking and answering questions on the Diffusers discussion forum or on the Diffusers Discord + +Any question or comment related to the Diffusers library can be asked on the [discussion forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/) or on [Discord](https://discord.gg/G7tWnz98XR). Such questions and comments include (but are not limited to): +- Reports of training or inference experiments in an attempt to share knowledge +- Presentation of personal projects +- Questions to non-official training examples +- Project proposals +- General feedback +- Paper summaries +- Asking for help on personal projects that build on top of the Diffusers library +- General questions +- Ethical questions regarding diffusion models +- ... + +Every question that is asked on the forum or on Discord actively encourages the community to publicly +share knowledge and might very well help a beginner in the future who has the same question you're +having. Please do pose any questions you might have. +In the same spirit, you are of immense help to the community by answering such questions because this way you are publicly documenting knowledge for everybody to learn from. + +**Please** keep in mind that the more effort you put into asking or answering a question, the higher +the quality of the publicly documented knowledge. In the same way, well-posed and well-answered questions create a high-quality knowledge database accessible to everybody, while badly posed questions or answers reduce the overall quality of the public knowledge database. +In short, a high quality question or answer is *precise*, *concise*, *relevant*, *easy-to-understand*, *accessible*, and *well-formatted/well-posed*. For more information, please have a look through the [How to write a good issue](#how-to-write-a-good-issue) section. + +**NOTE about channels**: +[*The forum*](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63) is much better indexed by search engines, such as Google. Posts are ranked by popularity rather than chronologically. Hence, it's easier to look up questions and answers that we posted some time ago. +In addition, questions and answers posted in the forum can easily be linked to. +In contrast, *Discord* has a chat-like format that invites fast back-and-forth communication. +While it will most likely take less time for you to get an answer to your question on Discord, your +question won't be visible anymore over time. Also, it's much harder to find information that was posted a while back on Discord. We therefore strongly recommend using the forum for high-quality questions and answers in an attempt to create long-lasting knowledge for the community. If discussions on Discord lead to very interesting answers and conclusions, we recommend posting the results on the forum to make the information more available for future readers. + +### 2. Opening new issues on the GitHub issues tab + +The 🧨 Diffusers library is robust and reliable thanks to the users who notify us of +the problems they encounter. So thank you for reporting an issue. + +Remember, GitHub issues are reserved for technical questions directly related to the Diffusers library, bug reports, feature requests, or feedback on the library design. + +In a nutshell, this means that everything that is **not** related to the **code of the Diffusers library** (including the documentation) should **not** be asked on GitHub, but rather on either the [forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63) or [Discord](https://discord.gg/G7tWnz98XR). + +**Please consider the following guidelines when opening a new issue**: +- Make sure you have searched whether your issue has already been asked before (use the search bar on GitHub under Issues). +- Please never report a new issue on another (related) issue. If another issue is highly related, please +open a new issue nevertheless and link to the related issue. +- Make sure your issue is written in English. Please use one of the great, free online translation services, such as [DeepL](https://www.deepl.com/translator) to translate from your native language to English if you are not comfortable in English. +- Check whether your issue might be solved by updating to the newest Diffusers version. Before posting your issue, please make sure that `python -c "import diffusers; print(diffusers.__version__)"` is higher or matches the latest Diffusers version. +- Remember that the more effort you put into opening a new issue, the higher the quality of your answer will be and the better the overall quality of the Diffusers issues. + +New issues usually include the following. + +#### 2.1. Reproducible, minimal bug reports + +A bug report should always have a reproducible code snippet and be as minimal and concise as possible. +This means in more detail: +- Narrow the bug down as much as you can, **do not just dump your whole code file**. +- Format your code. +- Do not include any external libraries except for Diffusers depending on them. +- **Always** provide all necessary information about your environment; for this, you can run: `diffusers-cli env` in your shell and copy-paste the displayed information to the issue. +- Explain the issue. If the reader doesn't know what the issue is and why it is an issue, she cannot solve it. +- **Always** make sure the reader can reproduce your issue with as little effort as possible. If your code snippet cannot be run because of missing libraries or undefined variables, the reader cannot help you. Make sure your reproducible code snippet is as minimal as possible and can be copy-pasted into a simple Python shell. +- If in order to reproduce your issue a model and/or dataset is required, make sure the reader has access to that model or dataset. You can always upload your model or dataset to the [Hub](https://huggingface.co) to make it easily downloadable. Try to keep your model and dataset as small as possible, to make the reproduction of your issue as effortless as possible. + +For more information, please have a look through the [How to write a good issue](#how-to-write-a-good-issue) section. + +You can open a bug report [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=bug&projects=&template=bug-report.yml). + +#### 2.2. Feature requests + +A world-class feature request addresses the following points: + +1. Motivation first: +* Is it related to a problem/frustration with the library? If so, please explain +why. Providing a code snippet that demonstrates the problem is best. +* Is it related to something you would need for a project? We'd love to hear +about it! +* Is it something you worked on and think could benefit the community? +Awesome! Tell us what problem it solved for you. +2. Write a *full paragraph* describing the feature; +3. Provide a **code snippet** that demonstrates its future use; +4. In case this is related to a paper, please attach a link; +5. Attach any additional information (drawings, screenshots, etc.) you think may help. + +You can open a feature request [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feature_request.md&title=). + +#### 2.3 Feedback + +Feedback about the library design and why it is good or not good helps the core maintainers immensely to build a user-friendly library. To understand the philosophy behind the current design philosophy, please have a look [here](https://huggingface.co/docs/diffusers/conceptual/philosophy). If you feel like a certain design choice does not fit with the current design philosophy, please explain why and how it should be changed. If a certain design choice follows the design philosophy too much, hence restricting use cases, explain why and how it should be changed. +If a certain design choice is very useful for you, please also leave a note as this is great feedback for future design decisions. + +You can open an issue about feedback [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=). + +#### 2.4 Technical questions + +Technical questions are mainly about why certain code of the library was written in a certain way, or what a certain part of the code does. Please make sure to link to the code in question and please provide detail on +why this part of the code is difficult to understand. + +You can open an issue about a technical question [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=bug&template=bug-report.yml). + +#### 2.5 Proposal to add a new model, scheduler, or pipeline + +If the diffusion model community released a new model, pipeline, or scheduler that you would like to see in the Diffusers library, please provide the following information: + +* Short description of the diffusion pipeline, model, or scheduler and link to the paper or public release. +* Link to any of its open-source implementation. +* Link to the model weights if they are available. + +If you are willing to contribute to the model yourself, let us know so we can best guide you. Also, don't forget +to tag the original author of the component (model, scheduler, pipeline, etc.) by GitHub handle if you can find it. + +You can open a request for a model/pipeline/scheduler [here](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=New+model%2Fpipeline%2Fscheduler&template=new-model-addition.yml). + +### 3. Answering issues on the GitHub issues tab + +Answering issues on GitHub might require some technical knowledge of Diffusers, but we encourage everybody to give it a try even if you are not 100% certain that your answer is correct. +Some tips to give a high-quality answer to an issue: +- Be as concise and minimal as possible. +- Stay on topic. An answer to the issue should concern the issue and only the issue. +- Provide links to code, papers, or other sources that prove or encourage your point. +- Answer in code. If a simple code snippet is the answer to the issue or shows how the issue can be solved, please provide a fully reproducible code snippet. + +Also, many issues tend to be simply off-topic, duplicates of other issues, or irrelevant. It is of great +help to the maintainers if you can answer such issues, encouraging the author of the issue to be +more precise, provide the link to a duplicated issue or redirect them to [the forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63) or [Discord](https://discord.gg/G7tWnz98XR). + +If you have verified that the issued bug report is correct and requires a correction in the source code, +please have a look at the next sections. + +For all of the following contributions, you will need to open a PR. It is explained in detail how to do so in the [Opening a pull request](#how-to-open-a-pr) section. + +### 4. Fixing a "Good first issue" + +*Good first issues* are marked by the [Good first issue](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) label. Usually, the issue already +explains how a potential solution should look so that it is easier to fix. +If the issue hasn't been closed and you would like to try to fix this issue, you can just leave a message "I would like to try this issue.". There are usually three scenarios: +- a.) The issue description already proposes a fix. In this case and if the solution makes sense to you, you can open a PR or draft PR to fix it. +- b.) The issue description does not propose a fix. In this case, you can ask what a proposed fix could look like and someone from the Diffusers team should answer shortly. If you have a good idea of how to fix it, feel free to directly open a PR. +- c.) There is already an open PR to fix the issue, but the issue hasn't been closed yet. If the PR has gone stale, you can simply open a new PR and link to the stale PR. PRs often go stale if the original contributor who wanted to fix the issue suddenly cannot find the time anymore to proceed. This often happens in open-source and is very normal. In this case, the community will be very happy if you give it a new try and leverage the knowledge of the existing PR. If there is already a PR and it is active, you can help the author by giving suggestions, reviewing the PR or even asking whether you can contribute to the PR. + + +### 5. Contribute to the documentation + +A good library **always** has good documentation! The official documentation is often one of the first points of contact for new users of the library, and therefore contributing to the documentation is a **highly +valuable contribution**. + +Contributing to the library can have many forms: + +- Correcting spelling or grammatical errors. +- Correct incorrect formatting of the docstring. If you see that the official documentation is weirdly displayed or a link is broken, we are very happy if you take some time to correct it. +- Correct the shape or dimensions of a docstring input or output tensor. +- Clarify documentation that is hard to understand or incorrect. +- Update outdated code examples. +- Translating the documentation to another language. + +Anything displayed on [the official Diffusers doc page](https://huggingface.co/docs/diffusers/index) is part of the official documentation and can be corrected, adjusted in the respective [documentation source](https://github.com/huggingface/diffusers/tree/main/docs/source). + +Please have a look at [this page](https://github.com/huggingface/diffusers/tree/main/docs) on how to verify changes made to the documentation locally. + + +### 6. Contribute a community pipeline + +[Pipelines](https://huggingface.co/docs/diffusers/api/pipelines/overview) are usually the first point of contact between the Diffusers library and the user. +Pipelines are examples of how to use Diffusers [models](https://huggingface.co/docs/diffusers/api/models/overview) and [schedulers](https://huggingface.co/docs/diffusers/api/schedulers/overview). +We support two types of pipelines: + +- Official Pipelines +- Community Pipelines + +Both official and community pipelines follow the same design and consist of the same type of components. + +Official pipelines are tested and maintained by the core maintainers of Diffusers. Their code +resides in [src/diffusers/pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines). +In contrast, community pipelines are contributed and maintained purely by the **community** and are **not** tested. +They reside in [examples/community](https://github.com/huggingface/diffusers/tree/main/examples/community) and while they can be accessed via the [PyPI diffusers package](https://pypi.org/project/diffusers/), their code is not part of the PyPI distribution. + +The reason for the distinction is that the core maintainers of the Diffusers library cannot maintain and test all +possible ways diffusion models can be used for inference, but some of them may be of interest to the community. +Officially released diffusion pipelines, +such as Stable Diffusion are added to the core src/diffusers/pipelines package which ensures +high quality of maintenance, no backward-breaking code changes, and testing. +More bleeding edge pipelines should be added as community pipelines. If usage for a community pipeline is high, the pipeline can be moved to the official pipelines upon request from the community. This is one of the ways we strive to be a community-driven library. + +To add a community pipeline, one should add a .py file to [examples/community](https://github.com/huggingface/diffusers/tree/main/examples/community) and adapt the [examples/community/README.md](https://github.com/huggingface/diffusers/tree/main/examples/community/README.md) to include an example of the new pipeline. + +An example can be seen [here](https://github.com/huggingface/diffusers/pull/2400). + +Community pipeline PRs are only checked at a superficial level and ideally they should be maintained by their original authors. + +Contributing a community pipeline is a great way to understand how Diffusers models and schedulers work. Having contributed a community pipeline is usually the first stepping stone to contributing an official pipeline to the +core package. + +### 7. Contribute to training examples + +Diffusers examples are a collection of training scripts that reside in [examples](https://github.com/huggingface/diffusers/tree/main/examples). + +We support two types of training examples: + +- Official training examples +- Research training examples + +Research training examples are located in [examples/research_projects](https://github.com/huggingface/diffusers/tree/main/examples/research_projects) whereas official training examples include all folders under [examples](https://github.com/huggingface/diffusers/tree/main/examples) except the `research_projects` and `community` folders. +The official training examples are maintained by the Diffusers' core maintainers whereas the research training examples are maintained by the community. +This is because of the same reasons put forward in [6. Contribute a community pipeline](#6-contribute-a-community-pipeline) for official pipelines vs. community pipelines: It is not feasible for the core maintainers to maintain all possible training methods for diffusion models. +If the Diffusers core maintainers and the community consider a certain training paradigm to be too experimental or not popular enough, the corresponding training code should be put in the `research_projects` folder and maintained by the author. + +Both official training and research examples consist of a directory that contains one or more training scripts, a `requirements.txt` file, and a `README.md` file. In order for the user to make use of the +training examples, it is required to clone the repository: + +```bash +git clone https://github.com/huggingface/diffusers +``` + +as well as to install all additional dependencies required for training: + +```bash +cd diffusers +pip install -r examples//requirements.txt +``` + +Therefore when adding an example, the `requirements.txt` file shall define all pip dependencies required for your training example so that once all those are installed, the user can run the example's training script. See, for example, the [DreamBooth `requirements.txt` file](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/requirements.txt). + +Training examples of the Diffusers library should adhere to the following philosophy: +- All the code necessary to run the examples should be found in a single Python file. +- One should be able to run the example from the command line with `python .py --args`. +- Examples should be kept simple and serve as **an example** on how to use Diffusers for training. The purpose of example scripts is **not** to create state-of-the-art diffusion models, but rather to reproduce known training schemes without adding too much custom logic. As a byproduct of this point, our examples also strive to serve as good educational materials. + +To contribute an example, it is highly recommended to look at already existing examples such as [dreambooth](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py) to get an idea of how they should look like. +We strongly advise contributors to make use of the [Accelerate library](https://github.com/huggingface/accelerate) as it's tightly integrated +with Diffusers. +Once an example script works, please make sure to add a comprehensive `README.md` that states how to use the example exactly. This README should include: +- An example command on how to run the example script as shown [here e.g.](https://github.com/huggingface/diffusers/tree/main/examples/dreambooth#running-locally-with-pytorch). +- A link to some training results (logs, models, ...) that show what the user can expect as shown [here e.g.](https://api.wandb.ai/report/patrickvonplaten/xm6cd5q5). +- If you are adding a non-official/research training example, **please don't forget** to add a sentence that you are maintaining this training example which includes your git handle as shown [here](https://github.com/huggingface/diffusers/tree/main/examples/research_projects/intel_opts#diffusers-examples-with-intel-optimizations). + +If you are contributing to the official training examples, please also make sure to add a test to [examples/test_examples.py](https://github.com/huggingface/diffusers/blob/main/examples/test_examples.py). This is not necessary for non-official training examples. + +### 8. Fixing a "Good second issue" + +*Good second issues* are marked by the [Good second issue](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22) label. Good second issues are +usually more complicated to solve than [Good first issues](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22). +The issue description usually gives less guidance on how to fix the issue and requires +a decent understanding of the library by the interested contributor. +If you are interested in tackling a good second issue, feel free to open a PR to fix it and link the PR to the issue. If you see that a PR has already been opened for this issue but did not get merged, have a look to understand why it wasn't merged and try to open an improved PR. +Good second issues are usually more difficult to get merged compared to good first issues, so don't hesitate to ask for help from the core maintainers. If your PR is almost finished the core maintainers can also jump into your PR and commit to it in order to get it merged. + +### 9. Adding pipelines, models, schedulers + +Pipelines, models, and schedulers are the most important pieces of the Diffusers library. +They provide easy access to state-of-the-art diffusion technologies and thus allow the community to +build powerful generative AI applications. + +By adding a new model, pipeline, or scheduler you might enable a new powerful use case for any of the user interfaces relying on Diffusers which can be of immense value for the whole generative AI ecosystem. + +Diffusers has a couple of open feature requests for all three components - feel free to gloss over them +if you don't know yet what specific component you would like to add: +- [Model or pipeline](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22) +- [Scheduler](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22) + +Before adding any of the three components, it is strongly recommended that you give the [Philosophy guide](https://github.com/huggingface/diffusers/blob/main/PHILOSOPHY.md) a read to better understand the design of any of the three components. Please be aware that +we cannot merge model, scheduler, or pipeline additions that strongly diverge from our design philosophy +as it will lead to API inconsistencies. If you fundamentally disagree with a design choice, please +open a [Feedback issue](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=) instead so that it can be discussed whether a certain design +pattern/design choice shall be changed everywhere in the library and whether we shall update our design philosophy. Consistency across the library is very important for us. + +Please make sure to add links to the original codebase/paper to the PR and ideally also ping the +original author directly on the PR so that they can follow the progress and potentially help with questions. + +If you are unsure or stuck in the PR, don't hesitate to leave a message to ask for a first review or help. + +## How to write a good issue + +**The better your issue is written, the higher the chances that it will be quickly resolved.** + +1. Make sure that you've used the correct template for your issue. You can pick between *Bug Report*, *Feature Request*, *Feedback about API Design*, *New model/pipeline/scheduler addition*, *Forum*, or a blank issue. Make sure to pick the correct one when opening [a new issue](https://github.com/huggingface/diffusers/issues/new/choose). +2. **Be precise**: Give your issue a fitting title. Try to formulate your issue description as simple as possible. The more precise you are when submitting an issue, the less time it takes to understand the issue and potentially solve it. Make sure to open an issue for one issue only and not for multiple issues. If you found multiple issues, simply open multiple issues. If your issue is a bug, try to be as precise as possible about what bug it is - you should not just write "Error in diffusers". +3. **Reproducibility**: No reproducible code snippet == no solution. If you encounter a bug, maintainers **have to be able to reproduce** it. Make sure that you include a code snippet that can be copy-pasted into a Python interpreter to reproduce the issue. Make sure that your code snippet works, *i.e.* that there are no missing imports or missing links to images, ... Your issue should contain an error message **and** a code snippet that can be copy-pasted without any changes to reproduce the exact same error message. If your issue is using local model weights or local data that cannot be accessed by the reader, the issue cannot be solved. If you cannot share your data or model, try to make a dummy model or dummy data. +4. **Minimalistic**: Try to help the reader as much as you can to understand the issue as quickly as possible by staying as concise as possible. Remove all code / all information that is irrelevant to the issue. If you have found a bug, try to create the easiest code example you can to demonstrate your issue, do not just dump your whole workflow into the issue as soon as you have found a bug. E.g., if you train a model and get an error at some point during the training, you should first try to understand what part of the training code is responsible for the error and try to reproduce it with a couple of lines. Try to use dummy data instead of full datasets. +5. Add links. If you are referring to a certain naming, method, or model make sure to provide a link so that the reader can better understand what you mean. If you are referring to a specific PR or issue, make sure to link it to your issue. Do not assume that the reader knows what you are talking about. The more links you add to your issue the better. +6. Formatting. Make sure to nicely format your issue by formatting code into Python code syntax, and error messages into normal code syntax. See the [official GitHub formatting docs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for more information. +7. Think of your issue not as a ticket to be solved, but rather as a beautiful entry to a well-written encyclopedia. Every added issue is a contribution to publicly available knowledge. By adding a nicely written issue you not only make it easier for maintainers to solve your issue, but you are helping the whole community to better understand a certain aspect of the library. + +## How to write a good PR + +1. Be a chameleon. Understand existing design patterns and syntax and make sure your code additions flow seamlessly into the existing code base. Pull requests that significantly diverge from existing design patterns or user interfaces will not be merged. +2. Be laser focused. A pull request should solve one problem and one problem only. Make sure to not fall into the trap of "also fixing another problem while we're adding it". It is much more difficult to review pull requests that solve multiple, unrelated problems at once. +3. If helpful, try to add a code snippet that displays an example of how your addition can be used. +4. The title of your pull request should be a summary of its contribution. +5. If your pull request addresses an issue, please mention the issue number in +the pull request description to make sure they are linked (and people +consulting the issue know you are working on it); +6. To indicate a work in progress please prefix the title with `[WIP]`. These +are useful to avoid duplicated work, and to differentiate it from PRs ready +to be merged; +7. Try to formulate and format your text as explained in [How to write a good issue](#how-to-write-a-good-issue). +8. Make sure existing tests pass; +9. Add high-coverage tests. No quality testing = no merge. +- If you are adding new `@slow` tests, make sure they pass using +`RUN_SLOW=1 python -m pytest tests/test_my_new_model.py`. +CircleCI does not run the slow tests, but GitHub Actions does every night! +10. All public methods must have informative docstrings that work nicely with markdown. See [`pipeline_latent_diffusion.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py) for an example. +11. Due to the rapidly growing repository, it is important to make sure that no files that would significantly weigh down the repository are added. This includes images, videos, and other non-text files. We prefer to leverage a hf.co hosted `dataset` like +[`hf-internal-testing`](https://huggingface.co/hf-internal-testing) or [huggingface/documentation-images](https://huggingface.co/datasets/huggingface/documentation-images) to place these files. +If an external contribution, feel free to add the images to your PR and ask a Hugging Face member to migrate your images +to this dataset. + +## How to open a PR + +Before writing code, we strongly advise you to search through the existing PRs or +issues to make sure that nobody is already working on the same thing. If you are +unsure, it is always a good idea to open an issue to get some feedback. + +You will need basic `git` proficiency to be able to contribute to +🧨 Diffusers. `git` is not the easiest tool to use but it has the greatest +manual. Type `git --help` in a shell and enjoy. If you prefer books, [Pro +Git](https://git-scm.com/book/en/v2) is a very good reference. + +Follow these steps to start contributing ([supported Python versions](https://github.com/huggingface/diffusers/blob/42f25d601a910dceadaee6c44345896b4cfa9928/setup.py#L270)): + +1. Fork the [repository](https://github.com/huggingface/diffusers) by +clicking on the 'Fork' button on the repository's page. This creates a copy of the code +under your GitHub user account. + +2. Clone your fork to your local disk, and add the base repository as a remote: + + ```bash + $ git clone git@github.com:/diffusers.git + $ cd diffusers + $ git remote add upstream https://github.com/huggingface/diffusers.git + ``` + +3. Create a new branch to hold your development changes: + + ```bash + $ git checkout -b a-descriptive-name-for-my-changes + ``` + +**Do not** work on the `main` branch. + +4. Set up a development environment by running the following command in a virtual environment: + + ```bash + $ pip install -e ".[dev]" + ``` + +If you have already cloned the repo, you might need to `git pull` to get the most recent changes in the +library. + +5. Develop the features on your branch. + +As you work on the features, you should make sure that the test suite +passes. You should run the tests impacted by your changes like this: + + ```bash + $ pytest tests/.py + ``` + +Before you run the tests, please make sure you install the dependencies required for testing. You can do so +with this command: + + ```bash + $ pip install -e ".[test]" + ``` + +You can also run the full test suite with the following command, but it takes +a beefy machine to produce a result in a decent amount of time now that +Diffusers has grown a lot. Here is the command for it: + + ```bash + $ make test + ``` + +🧨 Diffusers relies on `ruff` and `isort` to format its source code +consistently. After you make changes, apply automatic style corrections and code verifications +that can't be automated in one go with: + + ```bash + $ make style + ``` + +🧨 Diffusers also uses `ruff` and a few custom scripts to check for coding mistakes. Quality +control runs in CI, however, you can also run the same checks with: + + ```bash + $ make quality + ``` + +Once you're happy with your changes, add changed files using `git add` and +make a commit with `git commit` to record your changes locally: + + ```bash + $ git add modified_file.py + $ git commit -m "A descriptive message about your changes." + ``` + +It is a good idea to sync your copy of the code with the original +repository regularly. This way you can quickly account for changes: + + ```bash + $ git pull upstream main + ``` + +Push the changes to your account using: + + ```bash + $ git push -u origin a-descriptive-name-for-my-changes + ``` + +6. Once you are satisfied, go to the +webpage of your fork on GitHub. Click on 'Pull request' to send your changes +to the project maintainers for review. + +7. It's ok if maintainers ask you for changes. It happens to core contributors +too! So everyone can see the changes in the Pull request, work in your local +branch and push the changes to your fork. They will automatically appear in +the pull request. + +### Tests + +An extensive test suite is included to test the library behavior and several examples. Library tests can be found in +the [tests folder](https://github.com/huggingface/diffusers/tree/main/tests). + +We like `pytest` and `pytest-xdist` because it's faster. From the root of the +repository, here's how to run tests with `pytest` for the library: + +```bash +$ python -m pytest -n auto --dist=loadfile -s -v ./tests/ +``` + +In fact, that's how `make test` is implemented! + +You can specify a smaller set of tests in order to test only the feature +you're working on. + +By default, slow tests are skipped. Set the `RUN_SLOW` environment variable to +`yes` to run them. This will download many gigabytes of models — make sure you +have enough disk space and a good Internet connection, or a lot of patience! + +```bash +$ RUN_SLOW=yes python -m pytest -n auto --dist=loadfile -s -v ./tests/ +``` + +`unittest` is fully supported, here's how to run tests with it: + +```bash +$ python -m unittest discover -s tests -t . -v +$ python -m unittest discover -s examples -t examples -v +``` + +### Syncing forked main with upstream (HuggingFace) main + +To avoid pinging the upstream repository which adds reference notes to each upstream PR and sends unnecessary notifications to the developers involved in these PRs, +when syncing the main branch of a forked repository, please, follow these steps: +1. When possible, avoid syncing with the upstream using a branch and PR on the forked repository. Instead, merge directly into the forked main. +2. If a PR is absolutely necessary, use the following steps after checking out your branch: +```bash +$ git checkout -b your-branch-for-syncing +$ git pull --squash --no-commit upstream main +$ git commit -m '' +$ git push --set-upstream origin your-branch-for-syncing +``` + +### Style guide + +For documentation strings, 🧨 Diffusers follows the [Google style](https://google.github.io/styleguide/pyguide.html). diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/Dockerfile b/tasks/tasksmith-1c5704b1f07f/environment/source/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f45ba795061ad2fa76fb11886b81cdabeaf45468 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.12-slim-bookworm +WORKDIR /workspace +RUN python -m pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu torch==2.11.0+cpu numpy==2.5.3 packaging==26.3 parameterized==0.9.0 pillow==12.3.0 pytest==8.4.2 setuptools==78.1.0 wheel==0.48.0 huggingface-hub==0.36.2 safetensors==0.5.3 filelock==3.32.6 requests==2.32.3 regex==2024.11.6 importlib_metadata==8.5.0 tokenizers==0.21.4 transformers==4.52.4 pyyaml==6.0.2 fsspec==2024.10.0 tqdm==4.67.1 typing-extensions==4.12.2 requests-mock==1.12.1 accelerate==1.15.0 httpx==0.28.1 +COPY . /workspace +RUN python -m pip install --no-cache-dir --no-deps --no-build-isolation -e . +RUN rm -rf /workspace/.git /root/.cache/pip +ENV PYTHONDONTWRITEBYTECODE=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 +ENV HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 HF_DATASETS_OFFLINE=1 diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/LICENSE b/tasks/tasksmith-1c5704b1f07f/environment/source/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/MANIFEST.in b/tasks/tasksmith-1c5704b1f07f/environment/source/MANIFEST.in new file mode 100644 index 0000000000000000000000000000000000000000..b22fe1a28a1ef881fdb36af3c30b14c0a5d10aa5 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/MANIFEST.in @@ -0,0 +1,2 @@ +include LICENSE +include src/diffusers/utils/model_card_template.md diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/Makefile b/tasks/tasksmith-1c5704b1f07f/environment/source/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9af2e8b1a5c9993411ffa06e7e48f9cfec3bd164 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/Makefile @@ -0,0 +1,96 @@ +.PHONY: deps_table_update modified_only_fixup extra_style_checks quality style fixup fix-copies test test-examples + +# make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!) +export PYTHONPATH = src + +check_dirs := examples scripts src tests utils benchmarks + +modified_only_fixup: + $(eval modified_py_files := $(shell python utils/get_modified_files.py $(check_dirs))) + @if test -n "$(modified_py_files)"; then \ + echo "Checking/fixing $(modified_py_files)"; \ + ruff check $(modified_py_files) --fix; \ + ruff format $(modified_py_files);\ + else \ + echo "No library .py files were modified"; \ + fi + +# Update src/diffusers/dependency_versions_table.py + +deps_table_update: + @python setup.py deps_table_update + +deps_table_check_updated: + @md5sum src/diffusers/dependency_versions_table.py > md5sum.saved + @python setup.py deps_table_update + @md5sum -c --quiet md5sum.saved || (printf "\nError: the version dependency table is outdated.\nPlease run 'make fixup' or 'make style' and commit the changes.\n\n" && exit 1) + @rm md5sum.saved + +# autogenerating code + +autogenerate_code: deps_table_update + +# Check that the repo is in a good state + +repo-consistency: + python utils/check_dummies.py + python utils/check_repo.py + python utils/check_inits.py + +# this target runs checks on all files + +quality: + ruff check $(check_dirs) setup.py + ruff format --check $(check_dirs) setup.py + doc-builder style src/diffusers docs/source --max_len 119 --check_only + python utils/check_doc_toc.py + +# Format source code automatically and check is there are any problems left that need manual fixing + +extra_style_checks: + python utils/custom_init_isort.py + python utils/check_doc_toc.py --fix_and_overwrite + +# this target runs checks on all files and potentially modifies some of them + +style: + ruff check $(check_dirs) setup.py --fix + ruff format $(check_dirs) setup.py + doc-builder style src/diffusers docs/source --max_len 119 + ${MAKE} autogenerate_code + ${MAKE} extra_style_checks + +# Super fast fix and check target that only works on relevant modified files since the branch was made + +fixup: modified_only_fixup extra_style_checks autogenerate_code repo-consistency + +# Make marked copies of snippets of codes conform to the original + +fix-copies: + python utils/check_copies.py --fix_and_overwrite + python utils/check_dummies.py --fix_and_overwrite + +# Run tests for the library + +test: + python -m pytest -n auto --dist=loadfile -s -v ./tests/ + +# Run tests for examples + +test-examples: + python -m pytest -n auto --dist=loadfile -s -v ./examples/ + + +# Release stuff + +pre-release: + python utils/release.py + +pre-patch: + python utils/release.py --patch + +post-release: + python utils/release.py --post_release + +post-patch: + python utils/release.py --post_release --patch diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/PHILOSOPHY.md b/tasks/tasksmith-1c5704b1f07f/environment/source/PHILOSOPHY.md new file mode 100644 index 0000000000000000000000000000000000000000..d30d314931d3ec1463f836555315a5efe04c3a43 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/PHILOSOPHY.md @@ -0,0 +1,110 @@ + + +# Philosophy + +🧨 Diffusers provides **state-of-the-art** pretrained diffusion models across multiple modalities. +Its purpose is to serve as a **modular toolbox** for both inference and training. + +We aim to build a library that stands the test of time and therefore take API design very seriously. + +In a nutshell, Diffusers is built to be a natural extension of PyTorch. Therefore, most of our design choices are based on [PyTorch's Design Principles](https://pytorch.org/docs/stable/community/design.html#pytorch-design-philosophy). Let's go over the most important ones: + +## Usability over Performance + +- While Diffusers has many built-in performance-enhancing features (see [Memory and Speed](https://huggingface.co/docs/diffusers/optimization/fp16)), models are always loaded with the highest precision and lowest optimization. Therefore, by default diffusion pipelines are always instantiated on CPU with float32 precision if not otherwise defined by the user. This ensures usability across different platforms and accelerators and means that no complex installations are required to run the library. +- Diffusers aims to be a **light-weight** package and therefore has very few required dependencies, but many soft dependencies that can improve performance (such as `accelerate`, `safetensors`, `onnx`, etc...). We strive to keep the library as lightweight as possible so that it can be added without much concern as a dependency on other packages. +- Diffusers prefers simple, self-explainable code over condensed, magic code. This means that short-hand code syntaxes such as lambda functions, and advanced PyTorch operators are often not desired. + +## Simple over easy + +As PyTorch states, **explicit is better than implicit** and **simple is better than complex**. This design philosophy is reflected in multiple parts of the library: +- We follow PyTorch's API with methods like [`DiffusionPipeline.to`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.to) to let the user handle device management. +- Raising concise error messages is preferred to silently correct erroneous input. Diffusers aims at teaching the user, rather than making the library as easy to use as possible. +- Complex model vs. scheduler logic is exposed instead of magically handled inside. Schedulers/Samplers are separated from diffusion models with minimal dependencies on each other. This forces the user to write the unrolled denoising loop. However, the separation allows for easier debugging and gives the user more control over adapting the denoising process or switching out diffusion models or schedulers. +- Separately trained components of the diffusion pipeline, *e.g.* the text encoder, the UNet, and the variational autoencoder, each has their own model class. This forces the user to handle the interaction between the different model components, and the serialization format separates the model components into different files. However, this allows for easier debugging and customization. DreamBooth or Textual Inversion training +is very simple thanks to Diffusers' ability to separate single components of the diffusion pipeline. + +## Tweakable, contributor-friendly over abstraction + +For large parts of the library, Diffusers adopts an important design principle of the [Transformers library](https://github.com/huggingface/transformers), which is to prefer copy-pasted code over hasty abstractions. This design principle is very opinionated and stands in stark contrast to popular design principles such as [Don't repeat yourself (DRY)](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). +In short, just like Transformers does for modeling files, Diffusers prefers to keep an extremely low level of abstraction and very self-contained code for pipelines and schedulers. +Functions, long code blocks, and even classes can be copied across multiple files which at first can look like a bad, sloppy design choice that makes the library unmaintainable. +**However**, this design has proven to be extremely successful for Transformers and makes a lot of sense for community-driven, open-source machine learning libraries because: +- Machine Learning is an extremely fast-moving field in which paradigms, model architectures, and algorithms are changing rapidly, which therefore makes it very difficult to define long-lasting code abstractions. +- Machine Learning practitioners like to be able to quickly tweak existing code for ideation and research and therefore prefer self-contained code over one that contains many abstractions. +- Open-source libraries rely on community contributions and therefore must build a library that is easy to contribute to. The more abstract the code, the more dependencies, the harder to read, and the harder to contribute to. Contributors simply stop contributing to very abstract libraries out of fear of breaking vital functionality. If contributing to a library cannot break other fundamental code, not only is it more inviting for potential new contributors, but it is also easier to review and contribute to multiple parts in parallel. + +At Hugging Face, we call this design the **single-file policy** which means that almost all of the code of a certain class should be written in a single, self-contained file. To read more about the philosophy, you can have a look +at [this blog post](https://huggingface.co/blog/transformers-design-philosophy). + +In Diffusers, we follow this philosophy for both pipelines and schedulers, but only partly for diffusion models. The reason we don't follow this design fully for diffusion models is because almost all diffusion pipelines, such +as [DDPM](https://huggingface.co/docs/diffusers/api/pipelines/ddpm), [Stable Diffusion](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview#stable-diffusion-pipelines), [unCLIP (DALL·E 2)](https://huggingface.co/docs/diffusers/api/pipelines/unclip) and [Imagen](https://imagen.research.google/) all rely on the same diffusion model, the [UNet](https://huggingface.co/docs/diffusers/api/models/unet2d-cond). + +Great, now you should have generally understood why 🧨 Diffusers is designed the way it is 🤗. +We try to apply these design principles consistently across the library. Nevertheless, there are some minor exceptions to the philosophy or some unlucky design choices. If you have feedback regarding the design, we would ❤️ to hear it [directly on GitHub](https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=). + +## Design Philosophy in Details + +Now, let's look a bit into the nitty-gritty details of the design philosophy. Diffusers essentially consists of three major classes: [pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines), [models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models), and [schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers). +Let's walk through more detailed design decisions for each class. + +### Pipelines + +Pipelines are designed to be easy to use (therefore do not follow [*Simple over easy*](#simple-over-easy) 100%), are not feature complete, and should loosely be seen as examples of how to use [models](#models) and [schedulers](#schedulers) for inference. + +The following design principles are followed: +- Pipelines follow the single-file policy. All pipelines can be found in individual directories under src/diffusers/pipelines. One pipeline folder corresponds to one diffusion paper/project/release. Multiple pipeline files can be gathered in one pipeline folder, as it’s done for [`src/diffusers/pipelines/stable-diffusion`](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/stable_diffusion). If pipelines share similar functionality, one can make use of the [# Copied from mechanism](https://github.com/huggingface/diffusers/blob/125d783076e5bd9785beb05367a2d2566843a271/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L251). +- Pipelines all inherit from [`DiffusionPipeline`]. +- Every pipeline consists of different model and scheduler components, that are documented in the [`model_index.json` file](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/blob/main/model_index.json), are accessible under the same name as attributes of the pipeline and can be shared between pipelines with [`DiffusionPipeline.components`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.components) function. +- Every pipeline should be loadable via the [`DiffusionPipeline.from_pretrained`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained) function. +- Pipelines should be used **only** for inference. +- Pipelines should be very readable, self-explanatory, and easy to tweak. +- Pipelines should be designed to build on top of each other and be easy to integrate into higher-level APIs. +- Pipelines are **not** intended to be feature-complete user interfaces. For feature-complete user interfaces one should rather have a look at [InvokeAI](https://github.com/invoke-ai/InvokeAI), [Diffuzers](https://github.com/abhishekkrthakur/diffuzers), and [lama-cleaner](https://github.com/Sanster/lama-cleaner). +- Every pipeline should have one and only one way to run it via a `__call__` method. The naming of the `__call__` arguments should be shared across all pipelines. +- Pipelines should be named after the task they are intended to solve. +- In almost all cases, novel diffusion pipelines shall be implemented in a new pipeline folder/file. + +### Models + +Models are designed as configurable toolboxes that are natural extensions of [PyTorch's Module class](https://pytorch.org/docs/stable/generated/torch.nn.Module.html). They only partly follow the **single-file policy**. + +The following design principles are followed: +- Models correspond to **a type of model architecture**. *E.g.* the [`UNet2DConditionModel`] class is used for all UNet variations that expect 2D image inputs and are conditioned on some context. +- All models can be found in [`src/diffusers/models`](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models) and every model architecture shall be defined in its file, e.g. [`unets/unet_2d_condition.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_2d_condition.py), [`transformers/transformer_2d.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_2d.py), etc... +- Models **do not** follow the single-file policy and should make use of smaller model building blocks, such as [`attention.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention.py), [`resnet.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/resnet.py), [`embeddings.py`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/embeddings.py), etc... **Note**: This is in stark contrast to Transformers' modeling files and shows that models do not really follow the single-file policy. +- Models intend to expose complexity, just like PyTorch's `Module` class, and give clear error messages. +- Models all inherit from `ModelMixin` and `ConfigMixin`. +- Models can be optimized for performance when it doesn’t demand major code changes, keep backward compatibility, and give significant memory or compute gain. +- Models should by default have the highest precision and lowest performance setting. +- To integrate new model checkpoints whose general architecture can be classified as an architecture that already exists in Diffusers, the existing model architecture shall be adapted to make it work with the new checkpoint. One should only create a new file if the model architecture is fundamentally different. +- Models should be designed to be easily extendable to future changes. This can be achieved by limiting public function arguments, configuration arguments, and "foreseeing" future changes, *e.g.* it is usually better to add `string` "...type" arguments that can easily be extended to new future types instead of boolean `is_..._type` arguments. Only the minimum amount of changes shall be made to existing architectures to make a new model checkpoint work. +- The model design is a difficult trade-off between keeping code readable and concise and supporting many model checkpoints. For most parts of the modeling code, classes shall be adapted for new model checkpoints, while there are some exceptions where it is preferred to add new classes to make sure the code is kept concise and +readable long-term, such as [UNet blocks](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_2d_blocks.py) and [Attention processors](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py). + +### Schedulers + +Schedulers are responsible to guide the denoising process for inference as well as to define a noise schedule for training. They are designed as individual classes with loadable configuration files and strongly follow the **single-file policy**. + +The following design principles are followed: +- All schedulers are found in [`src/diffusers/schedulers`](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers). +- Schedulers are **not** allowed to import from large utils files and shall be kept very self-contained. +- One scheduler Python file corresponds to one scheduler algorithm (as might be defined in a paper). +- If schedulers share similar functionalities, we can make use of the `# Copied from` mechanism. +- Schedulers all inherit from `SchedulerMixin` and `ConfigMixin`. +- Schedulers can be easily swapped out with the [`ConfigMixin.from_config`](https://huggingface.co/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin.from_config) method as explained in detail [here](./docs/source/en/using-diffusers/schedulers.md). +- Every scheduler has to have a `set_num_inference_steps`, and a `step` function. `set_num_inference_steps(...)` has to be called before every denoising process, *i.e.* before `step(...)` is called. +- Every scheduler exposes the timesteps to be "looped over" via a `timesteps` attribute, which is an array of timesteps the model will be called upon. +- The `step(...)` function takes a predicted model output and the "current" sample (x_t) and returns the "previous", slightly more denoised sample (x_t-1). +- Given the complexity of diffusion schedulers, the `step` function does not expose all the complexity and can be a bit of a "black box". +- In almost all cases, novel schedulers shall be implemented in a new scheduling file. diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/README.md b/tasks/tasksmith-1c5704b1f07f/environment/source/README.md new file mode 100644 index 0000000000000000000000000000000000000000..07334416ed1be57f9175096b27cd2c6a551a9a10 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/README.md @@ -0,0 +1,231 @@ + + +

+
+ +
+

+

+ GitHub + GitHub release + GitHub release + Contributor Covenant + X account +

+ +🤗 Diffusers is the go-to library for state-of-the-art pretrained diffusion models for generating images, audio, and even 3D structures of molecules. Whether you're looking for a simple inference solution or training your own diffusion models, 🤗 Diffusers is a modular toolbox that supports both. Our library is designed with a focus on [usability over performance](https://huggingface.co/docs/diffusers/conceptual/philosophy#usability-over-performance), [simple over easy](https://huggingface.co/docs/diffusers/conceptual/philosophy#simple-over-easy), and [customizability over abstractions](https://huggingface.co/docs/diffusers/conceptual/philosophy#tweakable-contributorfriendly-over-abstraction). + +🤗 Diffusers offers three core components: + +- State-of-the-art [diffusion pipelines](https://huggingface.co/docs/diffusers/api/pipelines/overview) that can be run in inference with just a few lines of code. +- Interchangeable noise [schedulers](https://huggingface.co/docs/diffusers/api/schedulers/overview) for different diffusion speeds and output quality. +- Pretrained [models](https://huggingface.co/docs/diffusers/api/models/overview) that can be used as building blocks, and combined with schedulers, for creating your own end-to-end diffusion systems. + +## Installation + +We recommend installing 🤗 Diffusers in a virtual environment from PyPI or Conda. For more details about installing [PyTorch](https://pytorch.org/get-started/locally/), please refer to their official documentation. + +### PyTorch + +With `pip` (official package): + +```bash +pip install --upgrade diffusers[torch] +``` + +With `conda` (maintained by the community): + +```sh +conda install -c conda-forge diffusers +``` + +### Apple Silicon (M1/M2) support + +Please refer to the [How to use Stable Diffusion in Apple Silicon](https://huggingface.co/docs/diffusers/optimization/mps) guide. + +## Quickstart + +Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 30,000+ checkpoints): + +```python +from diffusers import DiffusionPipeline +import torch + +pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16) +pipeline.to("cuda") +pipeline("An image of a squirrel in Picasso style").images[0] +``` + +You can also dig into the models and schedulers toolbox to build your own diffusion system: + +```python +from diffusers import DDPMScheduler, UNet2DModel +from PIL import Image +import torch + +scheduler = DDPMScheduler.from_pretrained("google/ddpm-cat-256") +model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to("cuda") +scheduler.set_timesteps(50) + +sample_size = model.config.sample_size +noise = torch.randn((1, 3, sample_size, sample_size), device="cuda") +input = noise + +for t in scheduler.timesteps: + with torch.no_grad(): + noisy_residual = model(input, t).sample + prev_noisy_sample = scheduler.step(noisy_residual, t, input).prev_sample + input = prev_noisy_sample + +image = (input / 2 + 0.5).clamp(0, 1) +image = image.cpu().permute(0, 2, 3, 1).numpy()[0] +image = Image.fromarray((image * 255).round().astype("uint8")) +image +``` + +Check out the [Quickstart](https://huggingface.co/docs/diffusers/quicktour) to launch your diffusion journey today! + +## How to navigate the documentation + +| **Documentation** | **What can I learn?** | +|---------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [Tutorial](https://huggingface.co/docs/diffusers/tutorials/tutorial_overview) | A basic crash course for learning how to use the library's most important features like using models and schedulers to build your own diffusion system, and training your own diffusion model. | +| [Loading](https://huggingface.co/docs/diffusers/using-diffusers/loading) | Guides for how to load and configure all the components (pipelines, models, and schedulers) of the library, as well as how to use different schedulers. | +| [Pipelines for inference](https://huggingface.co/docs/diffusers/using-diffusers/overview_techniques) | Guides for how to use pipelines for different inference tasks, batched generation, controlling generated outputs and randomness, and how to contribute a pipeline to the library. | +| [Optimization](https://huggingface.co/docs/diffusers/optimization/fp16) | Guides for how to optimize your diffusion model to run faster and consume less memory. | +| [Training](https://huggingface.co/docs/diffusers/training/overview) | Guides for how to train a diffusion model for different tasks with different training techniques. | +## Contribution + +We ❤️ contributions from the open-source community! +If you want to contribute to this library, please check out our [Contribution guide](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md). +You can look out for [issues](https://github.com/huggingface/diffusers/issues) you'd like to tackle to contribute to the library. +- See [Good first issues](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) for general opportunities to contribute +- See [New model/pipeline](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22) to contribute exciting new diffusion models / diffusion pipelines +- See [New scheduler](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22) + +Also, say 👋 in our public Discord channel Join us on Discord. We discuss the hottest trends about diffusion models, help each other with contributions, personal projects or just hang out ☕. + + +## Popular Tasks & Pipelines + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TaskPipeline🤗 Hub
Unconditional Image Generation DDPM google/ddpm-ema-church-256
Text-to-ImageStable Diffusion Text-to-Image stable-diffusion-v1-5/stable-diffusion-v1-5
Text-to-ImageunCLIP kakaobrain/karlo-v1-alpha
Text-to-ImageDeepFloyd IF DeepFloyd/IF-I-XL-v1.0
Text-to-ImageKandinsky kandinsky-community/kandinsky-2-2-decoder
Text-guided Image-to-ImageControlNet lllyasviel/sd-controlnet-canny
Text-guided Image-to-ImageInstructPix2Pix timbrooks/instruct-pix2pix
Text-guided Image-to-ImageStable Diffusion Image-to-Image stable-diffusion-v1-5/stable-diffusion-v1-5
Text-guided Image InpaintingStable Diffusion Inpainting stable-diffusion-v1-5/stable-diffusion-inpainting
Image VariationStable Diffusion Image Variation lambdalabs/sd-image-variations-diffusers
Super ResolutionStable Diffusion Upscale stabilityai/stable-diffusion-x4-upscaler
Super ResolutionStable Diffusion Latent Upscale stabilityai/sd-x2-latent-upscaler
+ +## Popular libraries using 🧨 Diffusers + +- https://github.com/microsoft/TaskMatrix +- https://github.com/invoke-ai/InvokeAI +- https://github.com/InstantID/InstantID +- https://github.com/apple/ml-stable-diffusion +- https://github.com/Sanster/lama-cleaner +- https://github.com/IDEA-Research/Grounded-Segment-Anything +- https://github.com/ashawkey/stable-dreamfusion +- https://github.com/deep-floyd/IF +- https://github.com/bentoml/BentoML +- https://github.com/bmaltais/kohya_ss +- +14,000 other amazing GitHub repositories 💪 + +Thank you for using us ❤️. + +## Credits + +This library concretizes previous work by many different authors and would not have been possible without their great research and implementations. We'd like to thank, in particular, the following implementations which have helped us in our development and without which the API could not have been as polished today: + +- @CompVis' latent diffusion models library, available [here](https://github.com/CompVis/latent-diffusion) +- @hojonathanho original DDPM implementation, available [here](https://github.com/hojonathanho/diffusion) as well as the extremely useful translation into PyTorch by @pesser, available [here](https://github.com/pesser/pytorch_diffusion) +- @ermongroup's DDIM implementation, available [here](https://github.com/ermongroup/ddim) +- @yang-song's Score-VE and Score-VP implementations, available [here](https://github.com/yang-song/score_sde_pytorch) + +We also want to thank @heejkoo for the very helpful overview of papers, code and resources on diffusion models, available [here](https://github.com/heejkoo/Awesome-Diffusion-Models) as well as @crowsonkb and @rromb for useful discussions and insights. + +## Citation + +```bibtex +@misc{von-platen-etal-2022-diffusers, + author = {Patrick von Platen and Suraj Patil and Anton Lozhkov and Pedro Cuenca and Nathan Lambert and Kashif Rasul and Mishig Davaadorj and Dhruv Nair and Sayak Paul and William Berman and Yiyi Xu and Steven Liu and Thomas Wolf}, + title = {Diffusers: State-of-the-art diffusion models}, + year = {2022}, + publisher = {GitHub}, + journal = {GitHub repository}, + howpublished = {\url{https://github.com/huggingface/diffusers}} +} +``` diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/_typos.toml b/tasks/tasksmith-1c5704b1f07f/environment/source/_typos.toml new file mode 100644 index 0000000000000000000000000000000000000000..551099f981e7885fbda9ed28e297bace0e13407b --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/_typos.toml @@ -0,0 +1,13 @@ +# Files for typos +# Instruction: https://github.com/marketplace/actions/typos-action#getting-started + +[default.extend-identifiers] + +[default.extend-words] +NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py +nd="np" # nd may be np (numpy) +parms="parms" # parms is used in scripts/convert_original_stable_diffusion_to_diffusers.py + + +[files] +extend-exclude = ["_typos.toml"] diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/pyproject.toml b/tasks/tasksmith-1c5704b1f07f/environment/source/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..a864ea34b8887f0e9496a375eedf3161c79e7644 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/pyproject.toml @@ -0,0 +1,29 @@ +[tool.ruff] +line-length = 119 + +[tool.ruff.lint] +# Never enforce `E501` (line length violations). +ignore = ["C901", "E501", "E721", "E741", "F402", "F823"] +select = ["C", "E", "F", "I", "W"] + +# Ignore import violations in all `__init__.py` files. +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["E402", "F401", "F403", "F811"] +"src/diffusers/utils/dummy_*.py" = ["F401"] + +[tool.ruff.lint.isort] +lines-after-imports = 2 +known-first-party = ["diffusers"] + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/change_naming_configs_and_checkpoints.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/change_naming_configs_and_checkpoints.py new file mode 100644 index 0000000000000000000000000000000000000000..4220901c13bf7afe07915562f141525e369c0973 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/change_naming_configs_and_checkpoints.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the LDM checkpoints.""" + +import argparse +import json +import os + +import torch +from transformers.file_utils import has_file + +from diffusers import UNet2DConditionModel, UNet2DModel + + +do_only_config = False +do_only_weights = True +do_only_renaming = False + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--repo_path", + default=None, + type=str, + required=True, + help="The config json file corresponding to the architecture.", + ) + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + args = parser.parse_args() + + config_parameters_to_change = { + "image_size": "sample_size", + "num_res_blocks": "layers_per_block", + "block_channels": "block_out_channels", + "down_blocks": "down_block_types", + "up_blocks": "up_block_types", + "downscale_freq_shift": "freq_shift", + "resnet_num_groups": "norm_num_groups", + "resnet_act_fn": "act_fn", + "resnet_eps": "norm_eps", + "num_head_channels": "attention_head_dim", + } + + key_parameters_to_change = { + "time_steps": "time_proj", + "mid": "mid_block", + "downsample_blocks": "down_blocks", + "upsample_blocks": "up_blocks", + } + + subfolder = "" if has_file(args.repo_path, "config.json") else "unet" + + with open(os.path.join(args.repo_path, subfolder, "config.json"), "r", encoding="utf-8") as reader: + text = reader.read() + config = json.loads(text) + + if do_only_config: + for key in config_parameters_to_change.keys(): + config.pop(key, None) + + if has_file(args.repo_path, "config.json"): + model = UNet2DModel(**config) + else: + class_name = UNet2DConditionModel if "ldm-text2im-large-256" in args.repo_path else UNet2DModel + model = class_name(**config) + + if do_only_config: + model.save_config(os.path.join(args.repo_path, subfolder)) + + config = dict(model.config) + + if do_only_renaming: + for key, value in config_parameters_to_change.items(): + if key in config: + config[value] = config[key] + del config[key] + + config["down_block_types"] = [k.replace("UNetRes", "") for k in config["down_block_types"]] + config["up_block_types"] = [k.replace("UNetRes", "") for k in config["up_block_types"]] + + if do_only_weights: + state_dict = torch.load(os.path.join(args.repo_path, subfolder, "diffusion_pytorch_model.bin")) + + new_state_dict = {} + for param_key, param_value in state_dict.items(): + if param_key.endswith(".op.bias") or param_key.endswith(".op.weight"): + continue + has_changed = False + for key, new_key in key_parameters_to_change.items(): + if not has_changed and param_key.split(".")[0] == key: + new_state_dict[".".join([new_key] + param_key.split(".")[1:])] = param_value + has_changed = True + if not has_changed: + new_state_dict[param_key] = param_value + + model.load_state_dict(new_state_dict) + model.save_pretrained(os.path.join(args.repo_path, subfolder)) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/conversion_ldm_uncond.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/conversion_ldm_uncond.py new file mode 100644 index 0000000000000000000000000000000000000000..8c22cc1ce8f2da514c1f096afaf67f1650e4df8a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/conversion_ldm_uncond.py @@ -0,0 +1,56 @@ +import argparse + +import torch +import yaml + +from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel + + +def convert_ldm_original(checkpoint_path, config_path, output_path): + config = yaml.safe_load(config_path) + state_dict = torch.load(checkpoint_path, map_location="cpu")["model"] + keys = list(state_dict.keys()) + + # extract state_dict for VQVAE + first_stage_dict = {} + first_stage_key = "first_stage_model." + for key in keys: + if key.startswith(first_stage_key): + first_stage_dict[key.replace(first_stage_key, "")] = state_dict[key] + + # extract state_dict for UNetLDM + unet_state_dict = {} + unet_key = "model.diffusion_model." + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = state_dict[key] + + vqvae_init_args = config["model"]["params"]["first_stage_config"]["params"] + unet_init_args = config["model"]["params"]["unet_config"]["params"] + + vqvae = VQModel(**vqvae_init_args).eval() + vqvae.load_state_dict(first_stage_dict) + + unet = UNetLDMModel(**unet_init_args).eval() + unet.load_state_dict(unet_state_dict) + + noise_scheduler = DDIMScheduler( + timesteps=config["model"]["params"]["timesteps"], + beta_schedule="scaled_linear", + beta_start=config["model"]["params"]["linear_start"], + beta_end=config["model"]["params"]["linear_end"], + clip_sample=False, + ) + + pipeline = LDMPipeline(vqvae, unet, noise_scheduler) + pipeline.save_pretrained(output_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--checkpoint_path", type=str, required=True) + parser.add_argument("--config_path", type=str, required=True) + parser.add_argument("--output_path", type=str, required=True) + args = parser.parse_args() + + convert_ldm_original(args.checkpoint_path, args.config_path, args.output_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_amused.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_amused.py new file mode 100644 index 0000000000000000000000000000000000000000..ddd1bf508b6dfe643276dca64eec3a79b6bfe445 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_amused.py @@ -0,0 +1,523 @@ +import inspect +import os +from argparse import ArgumentParser + +import numpy as np +import torch +from muse import MaskGiTUViT, VQGANModel +from muse import PipelineMuse as OldPipelineMuse +from transformers import CLIPTextModelWithProjection, CLIPTokenizer + +from diffusers import VQModel +from diffusers.models.attention_processor import AttnProcessor +from diffusers.models.unets.uvit_2d import UVit2DModel +from diffusers.pipelines.amused.pipeline_amused import AmusedPipeline +from diffusers.schedulers import AmusedScheduler + + +torch.backends.cuda.enable_flash_sdp(False) +torch.backends.cuda.enable_mem_efficient_sdp(False) +torch.backends.cuda.enable_math_sdp(True) + +os.environ["CUDA_LAUNCH_BLOCKING"] = "1" +os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8" +torch.use_deterministic_algorithms(True) + +# Enable CUDNN deterministic mode +torch.backends.cudnn.deterministic = True +torch.backends.cudnn.benchmark = False +torch.backends.cuda.matmul.allow_tf32 = False + +device = "cuda" + + +def main(): + args = ArgumentParser() + args.add_argument("--model_256", action="store_true") + args.add_argument("--write_to", type=str, required=False, default=None) + args.add_argument("--transformer_path", type=str, required=False, default=None) + args = args.parse_args() + + transformer_path = args.transformer_path + subfolder = "transformer" + + if transformer_path is None: + if args.model_256: + transformer_path = "openMUSE/muse-256" + else: + transformer_path = ( + "../research-run-512-checkpoints/research-run-512-with-downsample-checkpoint-554000/unwrapped_model/" + ) + subfolder = None + + old_transformer = MaskGiTUViT.from_pretrained(transformer_path, subfolder=subfolder) + + old_transformer.to(device) + + old_vae = VQGANModel.from_pretrained("openMUSE/muse-512", subfolder="vae") + old_vae.to(device) + + vqvae = make_vqvae(old_vae) + + tokenizer = CLIPTokenizer.from_pretrained("openMUSE/muse-512", subfolder="text_encoder") + + text_encoder = CLIPTextModelWithProjection.from_pretrained("openMUSE/muse-512", subfolder="text_encoder") + text_encoder.to(device) + + transformer = make_transformer(old_transformer, args.model_256) + + scheduler = AmusedScheduler(mask_token_id=old_transformer.config.mask_token_id) + + new_pipe = AmusedPipeline( + vqvae=vqvae, tokenizer=tokenizer, text_encoder=text_encoder, transformer=transformer, scheduler=scheduler + ) + + old_pipe = OldPipelineMuse( + vae=old_vae, transformer=old_transformer, text_encoder=text_encoder, tokenizer=tokenizer + ) + old_pipe.to(device) + + if args.model_256: + transformer_seq_len = 256 + orig_size = (256, 256) + else: + transformer_seq_len = 1024 + orig_size = (512, 512) + + old_out = old_pipe( + "dog", + generator=torch.Generator(device).manual_seed(0), + transformer_seq_len=transformer_seq_len, + orig_size=orig_size, + timesteps=12, + )[0] + + new_out = new_pipe("dog", generator=torch.Generator(device).manual_seed(0)).images[0] + + old_out = np.array(old_out) + new_out = np.array(new_out) + + diff = np.abs(old_out.astype(np.float64) - new_out.astype(np.float64)) + + # assert diff diff.sum() == 0 + print("skipping pipeline full equivalence check") + + print(f"max diff: {diff.max()}, diff.sum() / diff.size {diff.sum() / diff.size}") + + if args.model_256: + assert diff.max() <= 3 + assert diff.sum() / diff.size < 0.7 + else: + assert diff.max() <= 1 + assert diff.sum() / diff.size < 0.4 + + if args.write_to is not None: + new_pipe.save_pretrained(args.write_to) + + +def make_transformer(old_transformer, model_256): + args = dict(old_transformer.config) + force_down_up_sample = args["force_down_up_sample"] + + signature = inspect.signature(UVit2DModel.__init__) + + args_ = { + "downsample": force_down_up_sample, + "upsample": force_down_up_sample, + "block_out_channels": args["block_out_channels"][0], + "sample_size": 16 if model_256 else 32, + } + + for s in list(signature.parameters.keys()): + if s in ["self", "downsample", "upsample", "sample_size", "block_out_channels"]: + continue + + args_[s] = args[s] + + new_transformer = UVit2DModel(**args_) + new_transformer.to(device) + + new_transformer.set_attn_processor(AttnProcessor()) + + state_dict = old_transformer.state_dict() + + state_dict["cond_embed.linear_1.weight"] = state_dict.pop("cond_embed.0.weight") + state_dict["cond_embed.linear_2.weight"] = state_dict.pop("cond_embed.2.weight") + + for i in range(22): + state_dict[f"transformer_layers.{i}.norm1.norm.weight"] = state_dict.pop( + f"transformer_layers.{i}.attn_layer_norm.weight" + ) + state_dict[f"transformer_layers.{i}.norm1.linear.weight"] = state_dict.pop( + f"transformer_layers.{i}.self_attn_adaLN_modulation.mapper.weight" + ) + + state_dict[f"transformer_layers.{i}.attn1.to_q.weight"] = state_dict.pop( + f"transformer_layers.{i}.attention.query.weight" + ) + state_dict[f"transformer_layers.{i}.attn1.to_k.weight"] = state_dict.pop( + f"transformer_layers.{i}.attention.key.weight" + ) + state_dict[f"transformer_layers.{i}.attn1.to_v.weight"] = state_dict.pop( + f"transformer_layers.{i}.attention.value.weight" + ) + state_dict[f"transformer_layers.{i}.attn1.to_out.0.weight"] = state_dict.pop( + f"transformer_layers.{i}.attention.out.weight" + ) + + state_dict[f"transformer_layers.{i}.norm2.norm.weight"] = state_dict.pop( + f"transformer_layers.{i}.crossattn_layer_norm.weight" + ) + state_dict[f"transformer_layers.{i}.norm2.linear.weight"] = state_dict.pop( + f"transformer_layers.{i}.cross_attn_adaLN_modulation.mapper.weight" + ) + + state_dict[f"transformer_layers.{i}.attn2.to_q.weight"] = state_dict.pop( + f"transformer_layers.{i}.crossattention.query.weight" + ) + state_dict[f"transformer_layers.{i}.attn2.to_k.weight"] = state_dict.pop( + f"transformer_layers.{i}.crossattention.key.weight" + ) + state_dict[f"transformer_layers.{i}.attn2.to_v.weight"] = state_dict.pop( + f"transformer_layers.{i}.crossattention.value.weight" + ) + state_dict[f"transformer_layers.{i}.attn2.to_out.0.weight"] = state_dict.pop( + f"transformer_layers.{i}.crossattention.out.weight" + ) + + state_dict[f"transformer_layers.{i}.norm3.norm.weight"] = state_dict.pop( + f"transformer_layers.{i}.ffn.pre_mlp_layer_norm.weight" + ) + state_dict[f"transformer_layers.{i}.norm3.linear.weight"] = state_dict.pop( + f"transformer_layers.{i}.ffn.adaLN_modulation.mapper.weight" + ) + + wi_0_weight = state_dict.pop(f"transformer_layers.{i}.ffn.wi_0.weight") + wi_1_weight = state_dict.pop(f"transformer_layers.{i}.ffn.wi_1.weight") + proj_weight = torch.concat([wi_1_weight, wi_0_weight], dim=0) + state_dict[f"transformer_layers.{i}.ff.net.0.proj.weight"] = proj_weight + + state_dict[f"transformer_layers.{i}.ff.net.2.weight"] = state_dict.pop(f"transformer_layers.{i}.ffn.wo.weight") + + if force_down_up_sample: + state_dict["down_block.downsample.norm.weight"] = state_dict.pop("down_blocks.0.downsample.0.norm.weight") + state_dict["down_block.downsample.conv.weight"] = state_dict.pop("down_blocks.0.downsample.1.weight") + + state_dict["up_block.upsample.norm.weight"] = state_dict.pop("up_blocks.0.upsample.0.norm.weight") + state_dict["up_block.upsample.conv.weight"] = state_dict.pop("up_blocks.0.upsample.1.weight") + + state_dict["mlm_layer.layer_norm.weight"] = state_dict.pop("mlm_layer.layer_norm.norm.weight") + + for i in range(3): + state_dict[f"down_block.res_blocks.{i}.norm.weight"] = state_dict.pop( + f"down_blocks.0.res_blocks.{i}.norm.norm.weight" + ) + state_dict[f"down_block.res_blocks.{i}.channelwise_linear_1.weight"] = state_dict.pop( + f"down_blocks.0.res_blocks.{i}.channelwise.0.weight" + ) + state_dict[f"down_block.res_blocks.{i}.channelwise_norm.gamma"] = state_dict.pop( + f"down_blocks.0.res_blocks.{i}.channelwise.2.gamma" + ) + state_dict[f"down_block.res_blocks.{i}.channelwise_norm.beta"] = state_dict.pop( + f"down_blocks.0.res_blocks.{i}.channelwise.2.beta" + ) + state_dict[f"down_block.res_blocks.{i}.channelwise_linear_2.weight"] = state_dict.pop( + f"down_blocks.0.res_blocks.{i}.channelwise.4.weight" + ) + state_dict[f"down_block.res_blocks.{i}.cond_embeds_mapper.weight"] = state_dict.pop( + f"down_blocks.0.res_blocks.{i}.adaLN_modulation.mapper.weight" + ) + + state_dict[f"down_block.attention_blocks.{i}.norm1.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.attn_layer_norm.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn1.to_q.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.attention.query.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn1.to_k.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.attention.key.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn1.to_v.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.attention.value.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn1.to_out.0.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.attention.out.weight" + ) + + state_dict[f"down_block.attention_blocks.{i}.norm2.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.crossattn_layer_norm.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn2.to_q.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.crossattention.query.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn2.to_k.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.crossattention.key.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn2.to_v.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.crossattention.value.weight" + ) + state_dict[f"down_block.attention_blocks.{i}.attn2.to_out.0.weight"] = state_dict.pop( + f"down_blocks.0.attention_blocks.{i}.crossattention.out.weight" + ) + + state_dict[f"up_block.res_blocks.{i}.norm.weight"] = state_dict.pop( + f"up_blocks.0.res_blocks.{i}.norm.norm.weight" + ) + state_dict[f"up_block.res_blocks.{i}.channelwise_linear_1.weight"] = state_dict.pop( + f"up_blocks.0.res_blocks.{i}.channelwise.0.weight" + ) + state_dict[f"up_block.res_blocks.{i}.channelwise_norm.gamma"] = state_dict.pop( + f"up_blocks.0.res_blocks.{i}.channelwise.2.gamma" + ) + state_dict[f"up_block.res_blocks.{i}.channelwise_norm.beta"] = state_dict.pop( + f"up_blocks.0.res_blocks.{i}.channelwise.2.beta" + ) + state_dict[f"up_block.res_blocks.{i}.channelwise_linear_2.weight"] = state_dict.pop( + f"up_blocks.0.res_blocks.{i}.channelwise.4.weight" + ) + state_dict[f"up_block.res_blocks.{i}.cond_embeds_mapper.weight"] = state_dict.pop( + f"up_blocks.0.res_blocks.{i}.adaLN_modulation.mapper.weight" + ) + + state_dict[f"up_block.attention_blocks.{i}.norm1.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.attn_layer_norm.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn1.to_q.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.attention.query.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn1.to_k.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.attention.key.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn1.to_v.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.attention.value.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn1.to_out.0.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.attention.out.weight" + ) + + state_dict[f"up_block.attention_blocks.{i}.norm2.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.crossattn_layer_norm.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn2.to_q.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.crossattention.query.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn2.to_k.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.crossattention.key.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn2.to_v.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.crossattention.value.weight" + ) + state_dict[f"up_block.attention_blocks.{i}.attn2.to_out.0.weight"] = state_dict.pop( + f"up_blocks.0.attention_blocks.{i}.crossattention.out.weight" + ) + + for key in list(state_dict.keys()): + if key.startswith("up_blocks.0"): + key_ = "up_block." + ".".join(key.split(".")[2:]) + state_dict[key_] = state_dict.pop(key) + + if key.startswith("down_blocks.0"): + key_ = "down_block." + ".".join(key.split(".")[2:]) + state_dict[key_] = state_dict.pop(key) + + new_transformer.load_state_dict(state_dict) + + input_ids = torch.randint(0, 10, (1, 32, 32), device=old_transformer.device) + encoder_hidden_states = torch.randn((1, 77, 768), device=old_transformer.device) + cond_embeds = torch.randn((1, 768), device=old_transformer.device) + micro_conds = torch.tensor([[512, 512, 0, 0, 6]], dtype=torch.float32, device=old_transformer.device) + + old_out = old_transformer(input_ids.reshape(1, -1), encoder_hidden_states, cond_embeds, micro_conds) + old_out = old_out.reshape(1, 32, 32, 8192).permute(0, 3, 1, 2) + + new_out = new_transformer(input_ids, encoder_hidden_states, cond_embeds, micro_conds) + + # NOTE: these differences are solely due to using the geglu block that has a single linear layer of + # double output dimension instead of two different linear layers + max_diff = (old_out - new_out).abs().max() + total_diff = (old_out - new_out).abs().sum() + print(f"Transformer max_diff: {max_diff} total_diff: {total_diff}") + assert max_diff < 0.01 + assert total_diff < 1500 + + return new_transformer + + +def make_vqvae(old_vae): + new_vae = VQModel( + act_fn="silu", + block_out_channels=[128, 256, 256, 512, 768], + down_block_types=[ + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + ], + in_channels=3, + latent_channels=64, + layers_per_block=2, + norm_num_groups=32, + num_vq_embeddings=8192, + out_channels=3, + sample_size=32, + up_block_types=[ + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + ], + mid_block_add_attention=False, + lookup_from_codebook=True, + ) + new_vae.to(device) + + # fmt: off + + new_state_dict = {} + + old_state_dict = old_vae.state_dict() + + new_state_dict["encoder.conv_in.weight"] = old_state_dict.pop("encoder.conv_in.weight") + new_state_dict["encoder.conv_in.bias"] = old_state_dict.pop("encoder.conv_in.bias") + + convert_vae_block_state_dict(old_state_dict, "encoder.down.0", new_state_dict, "encoder.down_blocks.0") + convert_vae_block_state_dict(old_state_dict, "encoder.down.1", new_state_dict, "encoder.down_blocks.1") + convert_vae_block_state_dict(old_state_dict, "encoder.down.2", new_state_dict, "encoder.down_blocks.2") + convert_vae_block_state_dict(old_state_dict, "encoder.down.3", new_state_dict, "encoder.down_blocks.3") + convert_vae_block_state_dict(old_state_dict, "encoder.down.4", new_state_dict, "encoder.down_blocks.4") + + new_state_dict["encoder.mid_block.resnets.0.norm1.weight"] = old_state_dict.pop("encoder.mid.block_1.norm1.weight") + new_state_dict["encoder.mid_block.resnets.0.norm1.bias"] = old_state_dict.pop("encoder.mid.block_1.norm1.bias") + new_state_dict["encoder.mid_block.resnets.0.conv1.weight"] = old_state_dict.pop("encoder.mid.block_1.conv1.weight") + new_state_dict["encoder.mid_block.resnets.0.conv1.bias"] = old_state_dict.pop("encoder.mid.block_1.conv1.bias") + new_state_dict["encoder.mid_block.resnets.0.norm2.weight"] = old_state_dict.pop("encoder.mid.block_1.norm2.weight") + new_state_dict["encoder.mid_block.resnets.0.norm2.bias"] = old_state_dict.pop("encoder.mid.block_1.norm2.bias") + new_state_dict["encoder.mid_block.resnets.0.conv2.weight"] = old_state_dict.pop("encoder.mid.block_1.conv2.weight") + new_state_dict["encoder.mid_block.resnets.0.conv2.bias"] = old_state_dict.pop("encoder.mid.block_1.conv2.bias") + new_state_dict["encoder.mid_block.resnets.1.norm1.weight"] = old_state_dict.pop("encoder.mid.block_2.norm1.weight") + new_state_dict["encoder.mid_block.resnets.1.norm1.bias"] = old_state_dict.pop("encoder.mid.block_2.norm1.bias") + new_state_dict["encoder.mid_block.resnets.1.conv1.weight"] = old_state_dict.pop("encoder.mid.block_2.conv1.weight") + new_state_dict["encoder.mid_block.resnets.1.conv1.bias"] = old_state_dict.pop("encoder.mid.block_2.conv1.bias") + new_state_dict["encoder.mid_block.resnets.1.norm2.weight"] = old_state_dict.pop("encoder.mid.block_2.norm2.weight") + new_state_dict["encoder.mid_block.resnets.1.norm2.bias"] = old_state_dict.pop("encoder.mid.block_2.norm2.bias") + new_state_dict["encoder.mid_block.resnets.1.conv2.weight"] = old_state_dict.pop("encoder.mid.block_2.conv2.weight") + new_state_dict["encoder.mid_block.resnets.1.conv2.bias"] = old_state_dict.pop("encoder.mid.block_2.conv2.bias") + new_state_dict["encoder.conv_norm_out.weight"] = old_state_dict.pop("encoder.norm_out.weight") + new_state_dict["encoder.conv_norm_out.bias"] = old_state_dict.pop("encoder.norm_out.bias") + new_state_dict["encoder.conv_out.weight"] = old_state_dict.pop("encoder.conv_out.weight") + new_state_dict["encoder.conv_out.bias"] = old_state_dict.pop("encoder.conv_out.bias") + new_state_dict["quant_conv.weight"] = old_state_dict.pop("quant_conv.weight") + new_state_dict["quant_conv.bias"] = old_state_dict.pop("quant_conv.bias") + new_state_dict["quantize.embedding.weight"] = old_state_dict.pop("quantize.embedding.weight") + new_state_dict["post_quant_conv.weight"] = old_state_dict.pop("post_quant_conv.weight") + new_state_dict["post_quant_conv.bias"] = old_state_dict.pop("post_quant_conv.bias") + new_state_dict["decoder.conv_in.weight"] = old_state_dict.pop("decoder.conv_in.weight") + new_state_dict["decoder.conv_in.bias"] = old_state_dict.pop("decoder.conv_in.bias") + new_state_dict["decoder.mid_block.resnets.0.norm1.weight"] = old_state_dict.pop("decoder.mid.block_1.norm1.weight") + new_state_dict["decoder.mid_block.resnets.0.norm1.bias"] = old_state_dict.pop("decoder.mid.block_1.norm1.bias") + new_state_dict["decoder.mid_block.resnets.0.conv1.weight"] = old_state_dict.pop("decoder.mid.block_1.conv1.weight") + new_state_dict["decoder.mid_block.resnets.0.conv1.bias"] = old_state_dict.pop("decoder.mid.block_1.conv1.bias") + new_state_dict["decoder.mid_block.resnets.0.norm2.weight"] = old_state_dict.pop("decoder.mid.block_1.norm2.weight") + new_state_dict["decoder.mid_block.resnets.0.norm2.bias"] = old_state_dict.pop("decoder.mid.block_1.norm2.bias") + new_state_dict["decoder.mid_block.resnets.0.conv2.weight"] = old_state_dict.pop("decoder.mid.block_1.conv2.weight") + new_state_dict["decoder.mid_block.resnets.0.conv2.bias"] = old_state_dict.pop("decoder.mid.block_1.conv2.bias") + new_state_dict["decoder.mid_block.resnets.1.norm1.weight"] = old_state_dict.pop("decoder.mid.block_2.norm1.weight") + new_state_dict["decoder.mid_block.resnets.1.norm1.bias"] = old_state_dict.pop("decoder.mid.block_2.norm1.bias") + new_state_dict["decoder.mid_block.resnets.1.conv1.weight"] = old_state_dict.pop("decoder.mid.block_2.conv1.weight") + new_state_dict["decoder.mid_block.resnets.1.conv1.bias"] = old_state_dict.pop("decoder.mid.block_2.conv1.bias") + new_state_dict["decoder.mid_block.resnets.1.norm2.weight"] = old_state_dict.pop("decoder.mid.block_2.norm2.weight") + new_state_dict["decoder.mid_block.resnets.1.norm2.bias"] = old_state_dict.pop("decoder.mid.block_2.norm2.bias") + new_state_dict["decoder.mid_block.resnets.1.conv2.weight"] = old_state_dict.pop("decoder.mid.block_2.conv2.weight") + new_state_dict["decoder.mid_block.resnets.1.conv2.bias"] = old_state_dict.pop("decoder.mid.block_2.conv2.bias") + + convert_vae_block_state_dict(old_state_dict, "decoder.up.0", new_state_dict, "decoder.up_blocks.4") + convert_vae_block_state_dict(old_state_dict, "decoder.up.1", new_state_dict, "decoder.up_blocks.3") + convert_vae_block_state_dict(old_state_dict, "decoder.up.2", new_state_dict, "decoder.up_blocks.2") + convert_vae_block_state_dict(old_state_dict, "decoder.up.3", new_state_dict, "decoder.up_blocks.1") + convert_vae_block_state_dict(old_state_dict, "decoder.up.4", new_state_dict, "decoder.up_blocks.0") + + new_state_dict["decoder.conv_norm_out.weight"] = old_state_dict.pop("decoder.norm_out.weight") + new_state_dict["decoder.conv_norm_out.bias"] = old_state_dict.pop("decoder.norm_out.bias") + new_state_dict["decoder.conv_out.weight"] = old_state_dict.pop("decoder.conv_out.weight") + new_state_dict["decoder.conv_out.bias"] = old_state_dict.pop("decoder.conv_out.bias") + + # fmt: on + + assert len(old_state_dict.keys()) == 0 + + new_vae.load_state_dict(new_state_dict) + + input = torch.randn((1, 3, 512, 512), device=device) + input = input.clamp(-1, 1) + + old_encoder_output = old_vae.quant_conv(old_vae.encoder(input)) + new_encoder_output = new_vae.quant_conv(new_vae.encoder(input)) + assert (old_encoder_output == new_encoder_output).all() + + old_decoder_output = old_vae.decoder(old_vae.post_quant_conv(old_encoder_output)) + new_decoder_output = new_vae.decoder(new_vae.post_quant_conv(new_encoder_output)) + + # assert (old_decoder_output == new_decoder_output).all() + print("kipping vae decoder equivalence check") + print(f"vae decoder diff {(old_decoder_output - new_decoder_output).float().abs().sum()}") + + old_output = old_vae(input)[0] + new_output = new_vae(input)[0] + + # assert (old_output == new_output).all() + print("skipping full vae equivalence check") + print(f"vae full diff {(old_output - new_output).float().abs().sum()}") + + return new_vae + + +def convert_vae_block_state_dict(old_state_dict, prefix_from, new_state_dict, prefix_to): + # fmt: off + + new_state_dict[f"{prefix_to}.resnets.0.norm1.weight"] = old_state_dict.pop(f"{prefix_from}.block.0.norm1.weight") + new_state_dict[f"{prefix_to}.resnets.0.norm1.bias"] = old_state_dict.pop(f"{prefix_from}.block.0.norm1.bias") + new_state_dict[f"{prefix_to}.resnets.0.conv1.weight"] = old_state_dict.pop(f"{prefix_from}.block.0.conv1.weight") + new_state_dict[f"{prefix_to}.resnets.0.conv1.bias"] = old_state_dict.pop(f"{prefix_from}.block.0.conv1.bias") + new_state_dict[f"{prefix_to}.resnets.0.norm2.weight"] = old_state_dict.pop(f"{prefix_from}.block.0.norm2.weight") + new_state_dict[f"{prefix_to}.resnets.0.norm2.bias"] = old_state_dict.pop(f"{prefix_from}.block.0.norm2.bias") + new_state_dict[f"{prefix_to}.resnets.0.conv2.weight"] = old_state_dict.pop(f"{prefix_from}.block.0.conv2.weight") + new_state_dict[f"{prefix_to}.resnets.0.conv2.bias"] = old_state_dict.pop(f"{prefix_from}.block.0.conv2.bias") + + if f"{prefix_from}.block.0.nin_shortcut.weight" in old_state_dict: + new_state_dict[f"{prefix_to}.resnets.0.conv_shortcut.weight"] = old_state_dict.pop(f"{prefix_from}.block.0.nin_shortcut.weight") + new_state_dict[f"{prefix_to}.resnets.0.conv_shortcut.bias"] = old_state_dict.pop(f"{prefix_from}.block.0.nin_shortcut.bias") + + new_state_dict[f"{prefix_to}.resnets.1.norm1.weight"] = old_state_dict.pop(f"{prefix_from}.block.1.norm1.weight") + new_state_dict[f"{prefix_to}.resnets.1.norm1.bias"] = old_state_dict.pop(f"{prefix_from}.block.1.norm1.bias") + new_state_dict[f"{prefix_to}.resnets.1.conv1.weight"] = old_state_dict.pop(f"{prefix_from}.block.1.conv1.weight") + new_state_dict[f"{prefix_to}.resnets.1.conv1.bias"] = old_state_dict.pop(f"{prefix_from}.block.1.conv1.bias") + new_state_dict[f"{prefix_to}.resnets.1.norm2.weight"] = old_state_dict.pop(f"{prefix_from}.block.1.norm2.weight") + new_state_dict[f"{prefix_to}.resnets.1.norm2.bias"] = old_state_dict.pop(f"{prefix_from}.block.1.norm2.bias") + new_state_dict[f"{prefix_to}.resnets.1.conv2.weight"] = old_state_dict.pop(f"{prefix_from}.block.1.conv2.weight") + new_state_dict[f"{prefix_to}.resnets.1.conv2.bias"] = old_state_dict.pop(f"{prefix_from}.block.1.conv2.bias") + + if f"{prefix_from}.downsample.conv.weight" in old_state_dict: + new_state_dict[f"{prefix_to}.downsamplers.0.conv.weight"] = old_state_dict.pop(f"{prefix_from}.downsample.conv.weight") + new_state_dict[f"{prefix_to}.downsamplers.0.conv.bias"] = old_state_dict.pop(f"{prefix_from}.downsample.conv.bias") + + if f"{prefix_from}.upsample.conv.weight" in old_state_dict: + new_state_dict[f"{prefix_to}.upsamplers.0.conv.weight"] = old_state_dict.pop(f"{prefix_from}.upsample.conv.weight") + new_state_dict[f"{prefix_to}.upsamplers.0.conv.bias"] = old_state_dict.pop(f"{prefix_from}.upsample.conv.bias") + + if f"{prefix_from}.block.2.norm1.weight" in old_state_dict: + new_state_dict[f"{prefix_to}.resnets.2.norm1.weight"] = old_state_dict.pop(f"{prefix_from}.block.2.norm1.weight") + new_state_dict[f"{prefix_to}.resnets.2.norm1.bias"] = old_state_dict.pop(f"{prefix_from}.block.2.norm1.bias") + new_state_dict[f"{prefix_to}.resnets.2.conv1.weight"] = old_state_dict.pop(f"{prefix_from}.block.2.conv1.weight") + new_state_dict[f"{prefix_to}.resnets.2.conv1.bias"] = old_state_dict.pop(f"{prefix_from}.block.2.conv1.bias") + new_state_dict[f"{prefix_to}.resnets.2.norm2.weight"] = old_state_dict.pop(f"{prefix_from}.block.2.norm2.weight") + new_state_dict[f"{prefix_to}.resnets.2.norm2.bias"] = old_state_dict.pop(f"{prefix_from}.block.2.norm2.bias") + new_state_dict[f"{prefix_to}.resnets.2.conv2.weight"] = old_state_dict.pop(f"{prefix_from}.block.2.conv2.weight") + new_state_dict[f"{prefix_to}.resnets.2.conv2.bias"] = old_state_dict.pop(f"{prefix_from}.block.2.conv2.bias") + + # fmt: on + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_motion_lora_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_motion_lora_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..21567ffa9e7a95abd86c573761ca90d1648b8002 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_motion_lora_to_diffusers.py @@ -0,0 +1,69 @@ +import argparse +import os + +import torch +from huggingface_hub import create_repo, upload_folder +from safetensors.torch import load_file, save_file + + +def convert_motion_module(original_state_dict): + converted_state_dict = {} + for k, v in original_state_dict.items(): + if "pos_encoder" in k: + continue + + else: + converted_state_dict[ + k.replace(".norms.0", ".norm1") + .replace(".norms.1", ".norm2") + .replace(".ff_norm", ".norm3") + .replace(".attention_blocks.0", ".attn1") + .replace(".attention_blocks.1", ".attn2") + .replace(".temporal_transformer", "") + ] = v + + return converted_state_dict + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--ckpt_path", type=str, required=True, help="Path to checkpoint") + parser.add_argument("--output_path", type=str, required=True, help="Path to output directory") + parser.add_argument( + "--push_to_hub", + action="store_true", + default=False, + help="Whether to push the converted model to the HF or not", + ) + + return parser.parse_args() + + +if __name__ == "__main__": + args = get_args() + + if args.ckpt_path.endswith(".safetensors"): + state_dict = load_file(args.ckpt_path) + else: + state_dict = torch.load(args.ckpt_path, map_location="cpu") + + if "state_dict" in state_dict.keys(): + state_dict = state_dict["state_dict"] + + conv_state_dict = convert_motion_module(state_dict) + + # convert to new format + output_dict = {} + for module_name, params in conv_state_dict.items(): + if type(params) is not torch.Tensor: + continue + output_dict.update({f"unet.{module_name}": params}) + + os.makedirs(args.output_path, exist_ok=True) + + filepath = os.path.join(args.output_path, "diffusion_pytorch_model.safetensors") + save_file(output_dict, filepath) + + if args.push_to_hub: + repo_id = create_repo(args.output_path, exist_ok=True).repo_id + upload_folder(repo_id=repo_id, folder_path=args.output_path, repo_type="model") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_motion_module_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_motion_module_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..e188a6a533e86a837b58b61ba68905d5ab24a008 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_motion_module_to_diffusers.py @@ -0,0 +1,62 @@ +import argparse + +import torch +from safetensors.torch import load_file + +from diffusers import MotionAdapter + + +def convert_motion_module(original_state_dict): + converted_state_dict = {} + for k, v in original_state_dict.items(): + if "pos_encoder" in k: + continue + + else: + converted_state_dict[ + k.replace(".norms.0", ".norm1") + .replace(".norms.1", ".norm2") + .replace(".ff_norm", ".norm3") + .replace(".attention_blocks.0", ".attn1") + .replace(".attention_blocks.1", ".attn2") + .replace(".temporal_transformer", "") + ] = v + + return converted_state_dict + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--ckpt_path", type=str, required=True) + parser.add_argument("--output_path", type=str, required=True) + parser.add_argument("--use_motion_mid_block", action="store_true") + parser.add_argument("--motion_max_seq_length", type=int, default=32) + parser.add_argument("--block_out_channels", nargs="+", default=[320, 640, 1280, 1280], type=int) + parser.add_argument("--save_fp16", action="store_true") + + return parser.parse_args() + + +if __name__ == "__main__": + args = get_args() + + if args.ckpt_path.endswith(".safetensors"): + state_dict = load_file(args.ckpt_path) + else: + state_dict = torch.load(args.ckpt_path, map_location="cpu") + + if "state_dict" in state_dict.keys(): + state_dict = state_dict["state_dict"] + + conv_state_dict = convert_motion_module(state_dict) + adapter = MotionAdapter( + block_out_channels=args.block_out_channels, + use_motion_mid_block=args.use_motion_mid_block, + motion_max_seq_length=args.motion_max_seq_length, + ) + # skip loading position embeddings + adapter.load_state_dict(conv_state_dict, strict=False) + adapter.save_pretrained(args.output_path) + + if args.save_fp16: + adapter.to(dtype=torch.float16).save_pretrained(args.output_path, variant="fp16") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_sparsectrl_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_sparsectrl_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..f246dceb97f841273d0904248e4bfd8c341fda53 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_animatediff_sparsectrl_to_diffusers.py @@ -0,0 +1,83 @@ +import argparse +from typing import Dict + +import torch +import torch.nn as nn + +from diffusers import SparseControlNetModel + + +KEYS_RENAME_MAPPING = { + ".attention_blocks.0": ".attn1", + ".attention_blocks.1": ".attn2", + ".attn1.pos_encoder": ".pos_embed", + ".ff_norm": ".norm3", + ".norms.0": ".norm1", + ".norms.1": ".norm2", + ".temporal_transformer": "", +} + + +def convert(original_state_dict: Dict[str, nn.Module]) -> Dict[str, nn.Module]: + converted_state_dict = {} + + for key in list(original_state_dict.keys()): + renamed_key = key + for new_name, old_name in KEYS_RENAME_MAPPING.items(): + renamed_key = renamed_key.replace(new_name, old_name) + converted_state_dict[renamed_key] = original_state_dict.pop(key) + + return converted_state_dict + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--ckpt_path", type=str, required=True, help="Path to checkpoint") + parser.add_argument("--output_path", type=str, required=True, help="Path to output directory") + parser.add_argument( + "--max_motion_seq_length", + type=int, + default=32, + help="Max motion sequence length supported by the motion adapter", + ) + parser.add_argument( + "--conditioning_channels", type=int, default=4, help="Number of channels in conditioning input to controlnet" + ) + parser.add_argument( + "--use_simplified_condition_embedding", + action="store_true", + default=False, + help="Whether or not to use simplified condition embedding. When `conditioning_channels==4` i.e. latent inputs, set this to `True`. When `conditioning_channels==3` i.e. image inputs, set this to `False`", + ) + parser.add_argument( + "--save_fp16", + action="store_true", + default=False, + help="Whether or not to save model in fp16 precision along with fp32", + ) + parser.add_argument( + "--push_to_hub", action="store_true", default=False, help="Whether or not to push saved model to the HF hub" + ) + return parser.parse_args() + + +if __name__ == "__main__": + args = get_args() + + state_dict = torch.load(args.ckpt_path, map_location="cpu") + if "state_dict" in state_dict.keys(): + state_dict: dict = state_dict["state_dict"] + + controlnet = SparseControlNetModel( + conditioning_channels=args.conditioning_channels, + motion_max_seq_length=args.max_motion_seq_length, + use_simplified_condition_embedding=args.use_simplified_condition_embedding, + ) + + state_dict = convert(state_dict) + controlnet.load_state_dict(state_dict, strict=True) + + controlnet.save_pretrained(args.output_path, push_to_hub=args.push_to_hub) + if args.save_fp16: + controlnet = controlnet.to(dtype=torch.float16) + controlnet.save_pretrained(args.output_path, variant="fp16", push_to_hub=args.push_to_hub) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_asymmetric_vqgan_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_asymmetric_vqgan_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..ffb735e18224a7ef48503367112f5ce8142bdf9c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_asymmetric_vqgan_to_diffusers.py @@ -0,0 +1,184 @@ +import argparse +import time +from pathlib import Path +from typing import Any, Dict, Literal + +import torch + +from diffusers import AsymmetricAutoencoderKL + + +ASYMMETRIC_AUTOENCODER_KL_x_1_5_CONFIG = { + "in_channels": 3, + "out_channels": 3, + "down_block_types": [ + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + ], + "down_block_out_channels": [128, 256, 512, 512], + "layers_per_down_block": 2, + "up_block_types": [ + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + ], + "up_block_out_channels": [192, 384, 768, 768], + "layers_per_up_block": 3, + "act_fn": "silu", + "latent_channels": 4, + "norm_num_groups": 32, + "sample_size": 256, + "scaling_factor": 0.18215, +} + +ASYMMETRIC_AUTOENCODER_KL_x_2_CONFIG = { + "in_channels": 3, + "out_channels": 3, + "down_block_types": [ + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + "DownEncoderBlock2D", + ], + "down_block_out_channels": [128, 256, 512, 512], + "layers_per_down_block": 2, + "up_block_types": [ + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + "UpDecoderBlock2D", + ], + "up_block_out_channels": [256, 512, 1024, 1024], + "layers_per_up_block": 5, + "act_fn": "silu", + "latent_channels": 4, + "norm_num_groups": 32, + "sample_size": 256, + "scaling_factor": 0.18215, +} + + +def convert_asymmetric_autoencoder_kl_state_dict(original_state_dict: Dict[str, Any]) -> Dict[str, Any]: + converted_state_dict = {} + for k, v in original_state_dict.items(): + if k.startswith("encoder."): + converted_state_dict[ + k.replace("encoder.down.", "encoder.down_blocks.") + .replace("encoder.mid.", "encoder.mid_block.") + .replace("encoder.norm_out.", "encoder.conv_norm_out.") + .replace(".downsample.", ".downsamplers.0.") + .replace(".nin_shortcut.", ".conv_shortcut.") + .replace(".block.", ".resnets.") + .replace(".block_1.", ".resnets.0.") + .replace(".block_2.", ".resnets.1.") + .replace(".attn_1.k.", ".attentions.0.to_k.") + .replace(".attn_1.q.", ".attentions.0.to_q.") + .replace(".attn_1.v.", ".attentions.0.to_v.") + .replace(".attn_1.proj_out.", ".attentions.0.to_out.0.") + .replace(".attn_1.norm.", ".attentions.0.group_norm.") + ] = v + elif k.startswith("decoder.") and "up_layers" not in k: + converted_state_dict[ + k.replace("decoder.encoder.", "decoder.condition_encoder.") + .replace(".norm_out.", ".conv_norm_out.") + .replace(".up.0.", ".up_blocks.3.") + .replace(".up.1.", ".up_blocks.2.") + .replace(".up.2.", ".up_blocks.1.") + .replace(".up.3.", ".up_blocks.0.") + .replace(".block.", ".resnets.") + .replace("mid", "mid_block") + .replace(".0.upsample.", ".0.upsamplers.0.") + .replace(".1.upsample.", ".1.upsamplers.0.") + .replace(".2.upsample.", ".2.upsamplers.0.") + .replace(".nin_shortcut.", ".conv_shortcut.") + .replace(".block_1.", ".resnets.0.") + .replace(".block_2.", ".resnets.1.") + .replace(".attn_1.k.", ".attentions.0.to_k.") + .replace(".attn_1.q.", ".attentions.0.to_q.") + .replace(".attn_1.v.", ".attentions.0.to_v.") + .replace(".attn_1.proj_out.", ".attentions.0.to_out.0.") + .replace(".attn_1.norm.", ".attentions.0.group_norm.") + ] = v + elif k.startswith("quant_conv."): + converted_state_dict[k] = v + elif k.startswith("post_quant_conv."): + converted_state_dict[k] = v + else: + print(f" skipping key `{k}`") + # fix weights shape + for k, v in converted_state_dict.items(): + if ( + (k.startswith("encoder.mid_block.attentions.0") or k.startswith("decoder.mid_block.attentions.0")) + and k.endswith("weight") + and ("to_q" in k or "to_k" in k or "to_v" in k or "to_out" in k) + ): + converted_state_dict[k] = converted_state_dict[k][:, :, 0, 0] + + return converted_state_dict + + +def get_asymmetric_autoencoder_kl_from_original_checkpoint( + scale: Literal["1.5", "2"], original_checkpoint_path: str, map_location: torch.device +) -> AsymmetricAutoencoderKL: + print("Loading original state_dict") + original_state_dict = torch.load(original_checkpoint_path, map_location=map_location) + original_state_dict = original_state_dict["state_dict"] + print("Converting state_dict") + converted_state_dict = convert_asymmetric_autoencoder_kl_state_dict(original_state_dict) + kwargs = ASYMMETRIC_AUTOENCODER_KL_x_1_5_CONFIG if scale == "1.5" else ASYMMETRIC_AUTOENCODER_KL_x_2_CONFIG + print("Initializing AsymmetricAutoencoderKL model") + asymmetric_autoencoder_kl = AsymmetricAutoencoderKL(**kwargs) + print("Loading weight from converted state_dict") + asymmetric_autoencoder_kl.load_state_dict(converted_state_dict) + asymmetric_autoencoder_kl.eval() + print("AsymmetricAutoencoderKL successfully initialized") + return asymmetric_autoencoder_kl + + +if __name__ == "__main__": + start = time.time() + parser = argparse.ArgumentParser() + parser.add_argument( + "--scale", + default=None, + type=str, + required=True, + help="Asymmetric VQGAN scale: `1.5` or `2`", + ) + parser.add_argument( + "--original_checkpoint_path", + default=None, + type=str, + required=True, + help="Path to the original Asymmetric VQGAN checkpoint", + ) + parser.add_argument( + "--output_path", + default=None, + type=str, + required=True, + help="Path to save pretrained AsymmetricAutoencoderKL model", + ) + parser.add_argument( + "--map_location", + default="cpu", + type=str, + required=False, + help="The device passed to `map_location` when loading the checkpoint", + ) + args = parser.parse_args() + + assert args.scale in ["1.5", "2"], f"{args.scale} should be `1.5` of `2`" + assert Path(args.original_checkpoint_path).is_file() + + asymmetric_autoencoder_kl = get_asymmetric_autoencoder_kl_from_original_checkpoint( + scale=args.scale, + original_checkpoint_path=args.original_checkpoint_path, + map_location=torch.device(args.map_location), + ) + print("Saving pretrained AsymmetricAutoencoderKL") + asymmetric_autoencoder_kl.save_pretrained(args.output_path) + print(f"Done in {time.time() - start:.2f} seconds") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_aura_flow_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_aura_flow_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..74c34f4851ff203422275b237cb03423a17d54a1 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_aura_flow_to_diffusers.py @@ -0,0 +1,131 @@ +import argparse + +import torch +from huggingface_hub import hf_hub_download + +from diffusers.models.transformers.auraflow_transformer_2d import AuraFlowTransformer2DModel + + +def load_original_state_dict(args): + model_pt = hf_hub_download(repo_id=args.original_state_dict_repo_id, filename="aura_diffusion_pytorch_model.bin") + state_dict = torch.load(model_pt, map_location="cpu") + return state_dict + + +def calculate_layers(state_dict_keys, key_prefix): + dit_layers = set() + for k in state_dict_keys: + if key_prefix in k: + dit_layers.add(int(k.split(".")[2])) + print(f"{key_prefix}: {len(dit_layers)}") + return len(dit_layers) + + +# similar to SD3 but only for the last norm layer +def swap_scale_shift(weight, dim): + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + return new_weight + + +def convert_transformer(state_dict): + converted_state_dict = {} + state_dict_keys = list(state_dict.keys()) + + converted_state_dict["register_tokens"] = state_dict.pop("model.register_tokens") + converted_state_dict["pos_embed.pos_embed"] = state_dict.pop("model.positional_encoding") + converted_state_dict["pos_embed.proj.weight"] = state_dict.pop("model.init_x_linear.weight") + converted_state_dict["pos_embed.proj.bias"] = state_dict.pop("model.init_x_linear.bias") + + converted_state_dict["time_step_proj.linear_1.weight"] = state_dict.pop("model.t_embedder.mlp.0.weight") + converted_state_dict["time_step_proj.linear_1.bias"] = state_dict.pop("model.t_embedder.mlp.0.bias") + converted_state_dict["time_step_proj.linear_2.weight"] = state_dict.pop("model.t_embedder.mlp.2.weight") + converted_state_dict["time_step_proj.linear_2.bias"] = state_dict.pop("model.t_embedder.mlp.2.bias") + + converted_state_dict["context_embedder.weight"] = state_dict.pop("model.cond_seq_linear.weight") + + mmdit_layers = calculate_layers(state_dict_keys, key_prefix="double_layers") + single_dit_layers = calculate_layers(state_dict_keys, key_prefix="single_layers") + + # MMDiT blocks 🎸. + for i in range(mmdit_layers): + # feed-forward + path_mapping = {"mlpX": "ff", "mlpC": "ff_context"} + weight_mapping = {"c_fc1": "linear_1", "c_fc2": "linear_2", "c_proj": "out_projection"} + for orig_k, diffuser_k in path_mapping.items(): + for k, v in weight_mapping.items(): + converted_state_dict[f"joint_transformer_blocks.{i}.{diffuser_k}.{v}.weight"] = state_dict.pop( + f"model.double_layers.{i}.{orig_k}.{k}.weight" + ) + + # norms + path_mapping = {"modX": "norm1", "modC": "norm1_context"} + for orig_k, diffuser_k in path_mapping.items(): + converted_state_dict[f"joint_transformer_blocks.{i}.{diffuser_k}.linear.weight"] = state_dict.pop( + f"model.double_layers.{i}.{orig_k}.1.weight" + ) + + # attns + x_attn_mapping = {"w2q": "to_q", "w2k": "to_k", "w2v": "to_v", "w2o": "to_out.0"} + context_attn_mapping = {"w1q": "add_q_proj", "w1k": "add_k_proj", "w1v": "add_v_proj", "w1o": "to_add_out"} + for attn_mapping in [x_attn_mapping, context_attn_mapping]: + for k, v in attn_mapping.items(): + converted_state_dict[f"joint_transformer_blocks.{i}.attn.{v}.weight"] = state_dict.pop( + f"model.double_layers.{i}.attn.{k}.weight" + ) + + # Single-DiT blocks. + for i in range(single_dit_layers): + # feed-forward + mapping = {"c_fc1": "linear_1", "c_fc2": "linear_2", "c_proj": "out_projection"} + for k, v in mapping.items(): + converted_state_dict[f"single_transformer_blocks.{i}.ff.{v}.weight"] = state_dict.pop( + f"model.single_layers.{i}.mlp.{k}.weight" + ) + + # norms + converted_state_dict[f"single_transformer_blocks.{i}.norm1.linear.weight"] = state_dict.pop( + f"model.single_layers.{i}.modCX.1.weight" + ) + + # attns + x_attn_mapping = {"w1q": "to_q", "w1k": "to_k", "w1v": "to_v", "w1o": "to_out.0"} + for k, v in x_attn_mapping.items(): + converted_state_dict[f"single_transformer_blocks.{i}.attn.{v}.weight"] = state_dict.pop( + f"model.single_layers.{i}.attn.{k}.weight" + ) + + # Final blocks. + converted_state_dict["proj_out.weight"] = state_dict.pop("model.final_linear.weight") + converted_state_dict["norm_out.linear.weight"] = swap_scale_shift(state_dict.pop("model.modF.1.weight"), dim=None) + + return converted_state_dict + + +@torch.no_grad() +def populate_state_dict(args): + original_state_dict = load_original_state_dict(args) + state_dict_keys = list(original_state_dict.keys()) + mmdit_layers = calculate_layers(state_dict_keys, key_prefix="double_layers") + single_dit_layers = calculate_layers(state_dict_keys, key_prefix="single_layers") + + converted_state_dict = convert_transformer(original_state_dict) + model_diffusers = AuraFlowTransformer2DModel( + num_mmdit_layers=mmdit_layers, num_single_dit_layers=single_dit_layers + ) + model_diffusers.load_state_dict(converted_state_dict, strict=True) + + return model_diffusers + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--original_state_dict_repo_id", default="AuraDiffusion/auradiffusion-v0.1a0", type=str) + parser.add_argument("--dump_path", default="aura-flow", type=str) + parser.add_argument("--hub_id", default=None, type=str) + args = parser.parse_args() + + model_diffusers = populate_state_dict(args) + model_diffusers.save_pretrained(args.dump_path) + if args.hub_id is not None: + model_diffusers.push_to_hub(args.hub_id) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_blipdiffusion_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_blipdiffusion_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..2c286ea0fdc7add5a007a5399ff34b68fc30d803 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_blipdiffusion_to_diffusers.py @@ -0,0 +1,344 @@ +""" +This script requires you to build `LAVIS` from source, since the pip version doesn't have BLIP Diffusion. Follow instructions here: https://github.com/salesforce/LAVIS/tree/main. +""" + +import argparse +import os +import tempfile + +import torch +from lavis.models import load_model_and_preprocess +from transformers import CLIPTokenizer +from transformers.models.blip_2.configuration_blip_2 import Blip2Config + +from diffusers import ( + AutoencoderKL, + PNDMScheduler, + UNet2DConditionModel, +) +from diffusers.pipelines import BlipDiffusionPipeline +from diffusers.pipelines.blip_diffusion.blip_image_processing import BlipImageProcessor +from diffusers.pipelines.blip_diffusion.modeling_blip2 import Blip2QFormerModel +from diffusers.pipelines.blip_diffusion.modeling_ctx_clip import ContextCLIPTextModel + + +BLIP2_CONFIG = { + "vision_config": { + "hidden_size": 1024, + "num_hidden_layers": 23, + "num_attention_heads": 16, + "image_size": 224, + "patch_size": 14, + "intermediate_size": 4096, + "hidden_act": "quick_gelu", + }, + "qformer_config": { + "cross_attention_frequency": 1, + "encoder_hidden_size": 1024, + "vocab_size": 30523, + }, + "num_query_tokens": 16, +} +blip2config = Blip2Config(**BLIP2_CONFIG) + + +def qformer_model_from_original_config(): + qformer = Blip2QFormerModel(blip2config) + return qformer + + +def embeddings_from_original_checkpoint(model, diffuser_embeddings_prefix, original_embeddings_prefix): + embeddings = {} + embeddings.update( + { + f"{diffuser_embeddings_prefix}.word_embeddings.weight": model[ + f"{original_embeddings_prefix}.word_embeddings.weight" + ] + } + ) + embeddings.update( + { + f"{diffuser_embeddings_prefix}.position_embeddings.weight": model[ + f"{original_embeddings_prefix}.position_embeddings.weight" + ] + } + ) + embeddings.update( + {f"{diffuser_embeddings_prefix}.LayerNorm.weight": model[f"{original_embeddings_prefix}.LayerNorm.weight"]} + ) + embeddings.update( + {f"{diffuser_embeddings_prefix}.LayerNorm.bias": model[f"{original_embeddings_prefix}.LayerNorm.bias"]} + ) + return embeddings + + +def proj_layer_from_original_checkpoint(model, diffuser_proj_prefix, original_proj_prefix): + proj_layer = {} + proj_layer.update({f"{diffuser_proj_prefix}.dense1.weight": model[f"{original_proj_prefix}.dense1.weight"]}) + proj_layer.update({f"{diffuser_proj_prefix}.dense1.bias": model[f"{original_proj_prefix}.dense1.bias"]}) + proj_layer.update({f"{diffuser_proj_prefix}.dense2.weight": model[f"{original_proj_prefix}.dense2.weight"]}) + proj_layer.update({f"{diffuser_proj_prefix}.dense2.bias": model[f"{original_proj_prefix}.dense2.bias"]}) + proj_layer.update({f"{diffuser_proj_prefix}.LayerNorm.weight": model[f"{original_proj_prefix}.LayerNorm.weight"]}) + proj_layer.update({f"{diffuser_proj_prefix}.LayerNorm.bias": model[f"{original_proj_prefix}.LayerNorm.bias"]}) + return proj_layer + + +def attention_from_original_checkpoint(model, diffuser_attention_prefix, original_attention_prefix): + attention = {} + attention.update( + { + f"{diffuser_attention_prefix}.attention.query.weight": model[ + f"{original_attention_prefix}.self.query.weight" + ] + } + ) + attention.update( + {f"{diffuser_attention_prefix}.attention.query.bias": model[f"{original_attention_prefix}.self.query.bias"]} + ) + attention.update( + {f"{diffuser_attention_prefix}.attention.key.weight": model[f"{original_attention_prefix}.self.key.weight"]} + ) + attention.update( + {f"{diffuser_attention_prefix}.attention.key.bias": model[f"{original_attention_prefix}.self.key.bias"]} + ) + attention.update( + { + f"{diffuser_attention_prefix}.attention.value.weight": model[ + f"{original_attention_prefix}.self.value.weight" + ] + } + ) + attention.update( + {f"{diffuser_attention_prefix}.attention.value.bias": model[f"{original_attention_prefix}.self.value.bias"]} + ) + attention.update( + {f"{diffuser_attention_prefix}.output.dense.weight": model[f"{original_attention_prefix}.output.dense.weight"]} + ) + attention.update( + {f"{diffuser_attention_prefix}.output.dense.bias": model[f"{original_attention_prefix}.output.dense.bias"]} + ) + attention.update( + { + f"{diffuser_attention_prefix}.output.LayerNorm.weight": model[ + f"{original_attention_prefix}.output.LayerNorm.weight" + ] + } + ) + attention.update( + { + f"{diffuser_attention_prefix}.output.LayerNorm.bias": model[ + f"{original_attention_prefix}.output.LayerNorm.bias" + ] + } + ) + return attention + + +def output_layers_from_original_checkpoint(model, diffuser_output_prefix, original_output_prefix): + output_layers = {} + output_layers.update({f"{diffuser_output_prefix}.dense.weight": model[f"{original_output_prefix}.dense.weight"]}) + output_layers.update({f"{diffuser_output_prefix}.dense.bias": model[f"{original_output_prefix}.dense.bias"]}) + output_layers.update( + {f"{diffuser_output_prefix}.LayerNorm.weight": model[f"{original_output_prefix}.LayerNorm.weight"]} + ) + output_layers.update( + {f"{diffuser_output_prefix}.LayerNorm.bias": model[f"{original_output_prefix}.LayerNorm.bias"]} + ) + return output_layers + + +def encoder_from_original_checkpoint(model, diffuser_encoder_prefix, original_encoder_prefix): + encoder = {} + for i in range(blip2config.qformer_config.num_hidden_layers): + encoder.update( + attention_from_original_checkpoint( + model, f"{diffuser_encoder_prefix}.{i}.attention", f"{original_encoder_prefix}.{i}.attention" + ) + ) + encoder.update( + attention_from_original_checkpoint( + model, f"{diffuser_encoder_prefix}.{i}.crossattention", f"{original_encoder_prefix}.{i}.crossattention" + ) + ) + + encoder.update( + { + f"{diffuser_encoder_prefix}.{i}.intermediate.dense.weight": model[ + f"{original_encoder_prefix}.{i}.intermediate.dense.weight" + ] + } + ) + encoder.update( + { + f"{diffuser_encoder_prefix}.{i}.intermediate.dense.bias": model[ + f"{original_encoder_prefix}.{i}.intermediate.dense.bias" + ] + } + ) + encoder.update( + { + f"{diffuser_encoder_prefix}.{i}.intermediate_query.dense.weight": model[ + f"{original_encoder_prefix}.{i}.intermediate_query.dense.weight" + ] + } + ) + encoder.update( + { + f"{diffuser_encoder_prefix}.{i}.intermediate_query.dense.bias": model[ + f"{original_encoder_prefix}.{i}.intermediate_query.dense.bias" + ] + } + ) + + encoder.update( + output_layers_from_original_checkpoint( + model, f"{diffuser_encoder_prefix}.{i}.output", f"{original_encoder_prefix}.{i}.output" + ) + ) + encoder.update( + output_layers_from_original_checkpoint( + model, f"{diffuser_encoder_prefix}.{i}.output_query", f"{original_encoder_prefix}.{i}.output_query" + ) + ) + return encoder + + +def visual_encoder_layer_from_original_checkpoint(model, diffuser_prefix, original_prefix): + visual_encoder_layer = {} + + visual_encoder_layer.update({f"{diffuser_prefix}.layer_norm1.weight": model[f"{original_prefix}.ln_1.weight"]}) + visual_encoder_layer.update({f"{diffuser_prefix}.layer_norm1.bias": model[f"{original_prefix}.ln_1.bias"]}) + visual_encoder_layer.update({f"{diffuser_prefix}.layer_norm2.weight": model[f"{original_prefix}.ln_2.weight"]}) + visual_encoder_layer.update({f"{diffuser_prefix}.layer_norm2.bias": model[f"{original_prefix}.ln_2.bias"]}) + visual_encoder_layer.update( + {f"{diffuser_prefix}.self_attn.qkv.weight": model[f"{original_prefix}.attn.in_proj_weight"]} + ) + visual_encoder_layer.update( + {f"{diffuser_prefix}.self_attn.qkv.bias": model[f"{original_prefix}.attn.in_proj_bias"]} + ) + visual_encoder_layer.update( + {f"{diffuser_prefix}.self_attn.projection.weight": model[f"{original_prefix}.attn.out_proj.weight"]} + ) + visual_encoder_layer.update( + {f"{diffuser_prefix}.self_attn.projection.bias": model[f"{original_prefix}.attn.out_proj.bias"]} + ) + visual_encoder_layer.update({f"{diffuser_prefix}.mlp.fc1.weight": model[f"{original_prefix}.mlp.c_fc.weight"]}) + visual_encoder_layer.update({f"{diffuser_prefix}.mlp.fc1.bias": model[f"{original_prefix}.mlp.c_fc.bias"]}) + visual_encoder_layer.update({f"{diffuser_prefix}.mlp.fc2.weight": model[f"{original_prefix}.mlp.c_proj.weight"]}) + visual_encoder_layer.update({f"{diffuser_prefix}.mlp.fc2.bias": model[f"{original_prefix}.mlp.c_proj.bias"]}) + + return visual_encoder_layer + + +def visual_encoder_from_original_checkpoint(model, diffuser_prefix, original_prefix): + visual_encoder = {} + + visual_encoder.update( + { + f"{diffuser_prefix}.embeddings.class_embedding": model[f"{original_prefix}.class_embedding"] + .unsqueeze(0) + .unsqueeze(0) + } + ) + visual_encoder.update( + { + f"{diffuser_prefix}.embeddings.position_embedding": model[ + f"{original_prefix}.positional_embedding" + ].unsqueeze(0) + } + ) + visual_encoder.update( + {f"{diffuser_prefix}.embeddings.patch_embedding.weight": model[f"{original_prefix}.conv1.weight"]} + ) + visual_encoder.update({f"{diffuser_prefix}.pre_layernorm.weight": model[f"{original_prefix}.ln_pre.weight"]}) + visual_encoder.update({f"{diffuser_prefix}.pre_layernorm.bias": model[f"{original_prefix}.ln_pre.bias"]}) + + for i in range(blip2config.vision_config.num_hidden_layers): + visual_encoder.update( + visual_encoder_layer_from_original_checkpoint( + model, f"{diffuser_prefix}.encoder.layers.{i}", f"{original_prefix}.transformer.resblocks.{i}" + ) + ) + + visual_encoder.update({f"{diffuser_prefix}.post_layernorm.weight": model["blip.ln_vision.weight"]}) + visual_encoder.update({f"{diffuser_prefix}.post_layernorm.bias": model["blip.ln_vision.bias"]}) + + return visual_encoder + + +def qformer_original_checkpoint_to_diffusers_checkpoint(model): + qformer_checkpoint = {} + qformer_checkpoint.update(embeddings_from_original_checkpoint(model, "embeddings", "blip.Qformer.bert.embeddings")) + qformer_checkpoint.update({"query_tokens": model["blip.query_tokens"]}) + qformer_checkpoint.update(proj_layer_from_original_checkpoint(model, "proj_layer", "proj_layer")) + qformer_checkpoint.update( + encoder_from_original_checkpoint(model, "encoder.layer", "blip.Qformer.bert.encoder.layer") + ) + qformer_checkpoint.update(visual_encoder_from_original_checkpoint(model, "visual_encoder", "blip.visual_encoder")) + return qformer_checkpoint + + +def get_qformer(model): + print("loading qformer") + + qformer = qformer_model_from_original_config() + qformer_diffusers_checkpoint = qformer_original_checkpoint_to_diffusers_checkpoint(model) + + load_checkpoint_to_model(qformer_diffusers_checkpoint, qformer) + + print("done loading qformer") + return qformer + + +def load_checkpoint_to_model(checkpoint, model): + with tempfile.NamedTemporaryFile(delete=False) as file: + torch.save(checkpoint, file.name) + del checkpoint + model.load_state_dict(torch.load(file.name), strict=False) + + os.remove(file.name) + + +def save_blip_diffusion_model(model, args): + qformer = get_qformer(model) + qformer.eval() + + text_encoder = ContextCLIPTextModel.from_pretrained( + "stable-diffusion-v1-5/stable-diffusion-v1-5", subfolder="text_encoder" + ) + vae = AutoencoderKL.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", subfolder="vae") + unet = UNet2DConditionModel.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", subfolder="unet") + vae.eval() + text_encoder.eval() + scheduler = PNDMScheduler( + beta_start=0.00085, + beta_end=0.012, + beta_schedule="scaled_linear", + set_alpha_to_one=False, + skip_prk_steps=True, + ) + tokenizer = CLIPTokenizer.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", subfolder="tokenizer") + image_processor = BlipImageProcessor() + blip_diffusion = BlipDiffusionPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + vae=vae, + unet=unet, + scheduler=scheduler, + qformer=qformer, + image_processor=image_processor, + ) + blip_diffusion.save_pretrained(args.checkpoint_path) + + +def main(args): + model, _, _ = load_model_and_preprocess("blip_diffusion", "base", device="cpu", is_eval=True) + save_blip_diffusion_model(model.state_dict(), args) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--checkpoint_path", default=None, type=str, required=True, help="Path to the output model.") + args = parser.parse_args() + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogvideox_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogvideox_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..7eeed240c4de9c41cff826795b8d0a760953d2a0 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogvideox_to_diffusers.py @@ -0,0 +1,346 @@ +import argparse +from typing import Any, Dict + +import torch +from transformers import T5EncoderModel, T5Tokenizer + +from diffusers import ( + AutoencoderKLCogVideoX, + CogVideoXDDIMScheduler, + CogVideoXImageToVideoPipeline, + CogVideoXPipeline, + CogVideoXTransformer3DModel, +) + + +def reassign_query_key_value_inplace(key: str, state_dict: Dict[str, Any]): + to_q_key = key.replace("query_key_value", "to_q") + to_k_key = key.replace("query_key_value", "to_k") + to_v_key = key.replace("query_key_value", "to_v") + to_q, to_k, to_v = torch.chunk(state_dict[key], chunks=3, dim=0) + state_dict[to_q_key] = to_q + state_dict[to_k_key] = to_k + state_dict[to_v_key] = to_v + state_dict.pop(key) + + +def reassign_query_key_layernorm_inplace(key: str, state_dict: Dict[str, Any]): + layer_id, weight_or_bias = key.split(".")[-2:] + + if "query" in key: + new_key = f"transformer_blocks.{layer_id}.attn1.norm_q.{weight_or_bias}" + elif "key" in key: + new_key = f"transformer_blocks.{layer_id}.attn1.norm_k.{weight_or_bias}" + + state_dict[new_key] = state_dict.pop(key) + + +def reassign_adaln_norm_inplace(key: str, state_dict: Dict[str, Any]): + layer_id, _, weight_or_bias = key.split(".")[-3:] + + weights_or_biases = state_dict[key].chunk(12, dim=0) + norm1_weights_or_biases = torch.cat(weights_or_biases[0:3] + weights_or_biases[6:9]) + norm2_weights_or_biases = torch.cat(weights_or_biases[3:6] + weights_or_biases[9:12]) + + norm1_key = f"transformer_blocks.{layer_id}.norm1.linear.{weight_or_bias}" + state_dict[norm1_key] = norm1_weights_or_biases + + norm2_key = f"transformer_blocks.{layer_id}.norm2.linear.{weight_or_bias}" + state_dict[norm2_key] = norm2_weights_or_biases + + state_dict.pop(key) + + +def remove_keys_inplace(key: str, state_dict: Dict[str, Any]): + state_dict.pop(key) + + +def replace_up_keys_inplace(key: str, state_dict: Dict[str, Any]): + key_split = key.split(".") + layer_index = int(key_split[2]) + replace_layer_index = 4 - 1 - layer_index + + key_split[1] = "up_blocks" + key_split[2] = str(replace_layer_index) + new_key = ".".join(key_split) + + state_dict[new_key] = state_dict.pop(key) + + +TRANSFORMER_KEYS_RENAME_DICT = { + "transformer.final_layernorm": "norm_final", + "transformer": "transformer_blocks", + "attention": "attn1", + "mlp": "ff.net", + "dense_h_to_4h": "0.proj", + "dense_4h_to_h": "2", + ".layers": "", + "dense": "to_out.0", + "input_layernorm": "norm1.norm", + "post_attn1_layernorm": "norm2.norm", + "time_embed.0": "time_embedding.linear_1", + "time_embed.2": "time_embedding.linear_2", + "ofs_embed.0": "ofs_embedding.linear_1", + "ofs_embed.2": "ofs_embedding.linear_2", + "mixins.patch_embed": "patch_embed", + "mixins.final_layer.norm_final": "norm_out.norm", + "mixins.final_layer.linear": "proj_out", + "mixins.final_layer.adaLN_modulation.1": "norm_out.linear", + "mixins.pos_embed.pos_embedding": "patch_embed.pos_embedding", # Specific to CogVideoX-5b-I2V +} + +TRANSFORMER_SPECIAL_KEYS_REMAP = { + "query_key_value": reassign_query_key_value_inplace, + "query_layernorm_list": reassign_query_key_layernorm_inplace, + "key_layernorm_list": reassign_query_key_layernorm_inplace, + "adaln_layer.adaLN_modulations": reassign_adaln_norm_inplace, + "embed_tokens": remove_keys_inplace, + "freqs_sin": remove_keys_inplace, + "freqs_cos": remove_keys_inplace, + "position_embedding": remove_keys_inplace, +} + +VAE_KEYS_RENAME_DICT = { + "block.": "resnets.", + "down.": "down_blocks.", + "downsample": "downsamplers.0", + "upsample": "upsamplers.0", + "nin_shortcut": "conv_shortcut", + "encoder.mid.block_1": "encoder.mid_block.resnets.0", + "encoder.mid.block_2": "encoder.mid_block.resnets.1", + "decoder.mid.block_1": "decoder.mid_block.resnets.0", + "decoder.mid.block_2": "decoder.mid_block.resnets.1", +} + +VAE_SPECIAL_KEYS_REMAP = { + "loss": remove_keys_inplace, + "up.": replace_up_keys_inplace, +} + +TOKENIZER_MAX_LENGTH = 226 + + +def get_state_dict(saved_dict: Dict[str, Any]) -> Dict[str, Any]: + state_dict = saved_dict + if "model" in saved_dict.keys(): + state_dict = state_dict["model"] + if "module" in saved_dict.keys(): + state_dict = state_dict["module"] + if "state_dict" in saved_dict.keys(): + state_dict = state_dict["state_dict"] + return state_dict + + +def update_state_dict_inplace(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def convert_transformer( + ckpt_path: str, + num_layers: int, + num_attention_heads: int, + use_rotary_positional_embeddings: bool, + i2v: bool, + dtype: torch.dtype, + init_kwargs: Dict[str, Any], +): + PREFIX_KEY = "model.diffusion_model." + + original_state_dict = get_state_dict(torch.load(ckpt_path, map_location="cpu", mmap=True)) + transformer = CogVideoXTransformer3DModel( + in_channels=32 if i2v else 16, + num_layers=num_layers, + num_attention_heads=num_attention_heads, + use_rotary_positional_embeddings=use_rotary_positional_embeddings, + ofs_embed_dim=512 if (i2v and init_kwargs["patch_size_t"] is not None) else None, # CogVideoX1.5-5B-I2V + use_learned_positional_embeddings=i2v and init_kwargs["patch_size_t"] is None, # CogVideoX-5B-I2V + **init_kwargs, + ).to(dtype=dtype) + + for key in list(original_state_dict.keys()): + new_key = key[len(PREFIX_KEY) :] + for replace_key, rename_key in TRANSFORMER_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_inplace(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in TRANSFORMER_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + transformer.load_state_dict(original_state_dict, strict=True) + return transformer + + +def convert_vae(ckpt_path: str, scaling_factor: float, version: str, dtype: torch.dtype): + init_kwargs = {"scaling_factor": scaling_factor} + if version == "1.5": + init_kwargs.update({"invert_scale_latents": True}) + + original_state_dict = get_state_dict(torch.load(ckpt_path, map_location="cpu", mmap=True)) + vae = AutoencoderKLCogVideoX(**init_kwargs).to(dtype=dtype) + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in VAE_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_inplace(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in VAE_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + vae.load_state_dict(original_state_dict, strict=True) + return vae + + +def get_transformer_init_kwargs(version: str): + if version == "1.0": + vae_scale_factor_spatial = 8 + init_kwargs = { + "patch_size": 2, + "patch_size_t": None, + "patch_bias": True, + "sample_height": 480 // vae_scale_factor_spatial, + "sample_width": 720 // vae_scale_factor_spatial, + "sample_frames": 49, + } + + elif version == "1.5": + vae_scale_factor_spatial = 8 + init_kwargs = { + "patch_size": 2, + "patch_size_t": 2, + "patch_bias": False, + "sample_height": 300, + "sample_width": 300, + "sample_frames": 81, + } + else: + raise ValueError("Unsupported version of CogVideoX.") + + return init_kwargs + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--transformer_ckpt_path", type=str, default=None, help="Path to original transformer checkpoint" + ) + parser.add_argument("--vae_ckpt_path", type=str, default=None, help="Path to original vae checkpoint") + parser.add_argument("--output_path", type=str, required=True, help="Path where converted model should be saved") + parser.add_argument("--fp16", action="store_true", default=False, help="Whether to save the model weights in fp16") + parser.add_argument("--bf16", action="store_true", default=False, help="Whether to save the model weights in bf16") + parser.add_argument( + "--push_to_hub", action="store_true", default=False, help="Whether to push to HF Hub after saving" + ) + parser.add_argument( + "--text_encoder_cache_dir", type=str, default=None, help="Path to text encoder cache directory" + ) + parser.add_argument( + "--typecast_text_encoder", + action="store_true", + default=False, + help="Whether or not to apply fp16/bf16 precision to text_encoder", + ) + # For CogVideoX-2B, num_layers is 30. For 5B, it is 42 + parser.add_argument("--num_layers", type=int, default=30, help="Number of transformer blocks") + # For CogVideoX-2B, num_attention_heads is 30. For 5B, it is 48 + parser.add_argument("--num_attention_heads", type=int, default=30, help="Number of attention heads") + # For CogVideoX-2B, use_rotary_positional_embeddings is False. For 5B, it is True + parser.add_argument( + "--use_rotary_positional_embeddings", action="store_true", default=False, help="Whether to use RoPE or not" + ) + # For CogVideoX-2B, scaling_factor is 1.15258426. For 5B, it is 0.7 + parser.add_argument("--scaling_factor", type=float, default=1.15258426, help="Scaling factor in the VAE") + # For CogVideoX-2B, snr_shift_scale is 3.0. For 5B, it is 1.0 + parser.add_argument("--snr_shift_scale", type=float, default=3.0, help="Scaling factor in the VAE") + parser.add_argument( + "--i2v", + action="store_true", + default=False, + help="Whether the model to be converted is the Image-to-Video version of CogVideoX.", + ) + parser.add_argument( + "--version", + choices=["1.0", "1.5"], + default="1.0", + help="Which version of CogVideoX to use for initializing default modeling parameters.", + ) + return parser.parse_args() + + +if __name__ == "__main__": + args = get_args() + + transformer = None + vae = None + + if args.fp16 and args.bf16: + raise ValueError("You cannot pass both --fp16 and --bf16 at the same time.") + + dtype = torch.float16 if args.fp16 else torch.bfloat16 if args.bf16 else torch.float32 + + if args.transformer_ckpt_path is not None: + init_kwargs = get_transformer_init_kwargs(args.version) + transformer = convert_transformer( + args.transformer_ckpt_path, + args.num_layers, + args.num_attention_heads, + args.use_rotary_positional_embeddings, + args.i2v, + dtype, + init_kwargs, + ) + if args.vae_ckpt_path is not None: + # Keep VAE in float32 for better quality + vae = convert_vae(args.vae_ckpt_path, args.scaling_factor, args.version, torch.float32) + + text_encoder_id = "google/t5-v1_1-xxl" + tokenizer = T5Tokenizer.from_pretrained(text_encoder_id, model_max_length=TOKENIZER_MAX_LENGTH) + text_encoder = T5EncoderModel.from_pretrained(text_encoder_id, cache_dir=args.text_encoder_cache_dir) + + if args.typecast_text_encoder: + text_encoder = text_encoder.to(dtype=dtype) + + # Apparently, the conversion does not work anymore without this :shrug: + for param in text_encoder.parameters(): + param.data = param.data.contiguous() + + scheduler = CogVideoXDDIMScheduler.from_config( + { + "snr_shift_scale": args.snr_shift_scale, + "beta_end": 0.012, + "beta_schedule": "scaled_linear", + "beta_start": 0.00085, + "clip_sample": False, + "num_train_timesteps": 1000, + "prediction_type": "v_prediction", + "rescale_betas_zero_snr": True, + "set_alpha_to_one": True, + "timestep_spacing": "trailing", + } + ) + if args.i2v: + pipeline_cls = CogVideoXImageToVideoPipeline + else: + pipeline_cls = CogVideoXPipeline + + pipe = pipeline_cls( + tokenizer=tokenizer, + text_encoder=text_encoder, + vae=vae, + transformer=transformer, + scheduler=scheduler, + ) + + # We don't use variant here because the model must be run in fp16 (2B) or bf16 (5B). It would be weird + # for users to specify variant when the default is not fp32 and they want to run with the correct default (which + # is either fp16/bf16 here). + + # This is necessary This is necessary for users with insufficient memory, + # such as those using Colab and notebooks, as it can save some memory used for model loading. + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB", push_to_hub=args.push_to_hub) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview3_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview3_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..605555ebdbeff9a517a65fdfaa9cbccb9a5092c0 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview3_to_diffusers.py @@ -0,0 +1,242 @@ +""" +Convert a CogView3 checkpoint to the Diffusers format. + +This script converts a CogView3 checkpoint to the Diffusers format, which can then be used +with the Diffusers library. + +Example usage: + python scripts/convert_cogview3_to_diffusers.py \ + --transformer_checkpoint_path 'your path/cogview3plus_3b/1/mp_rank_00_model_states.pt' \ + --vae_checkpoint_path 'your path/3plus_ae/imagekl_ch16.pt' \ + --output_path "/raid/yiyi/cogview3_diffusers" \ + --dtype "bf16" + +Arguments: + --transformer_checkpoint_path: Path to Transformer state dict. + --vae_checkpoint_path: Path to VAE state dict. + --output_path: The path to save the converted model. + --push_to_hub: Whether to push the converted checkpoint to the HF Hub or not. Defaults to `False`. + --text_encoder_cache_dir: Cache directory where text encoder is located. Defaults to None, which means HF_HOME will be used + --dtype: The dtype to save the model in (default: "bf16", options: "fp16", "bf16", "fp32"). If None, the dtype of the state dict is considered. + + Default is "bf16" because CogView3 uses bfloat16 for Training. + +Note: You must provide either --original_state_dict_repo_id or --checkpoint_path. +""" + +import argparse +from contextlib import nullcontext + +import torch +from accelerate import init_empty_weights +from transformers import T5EncoderModel, T5Tokenizer + +from diffusers import AutoencoderKL, CogVideoXDDIMScheduler, CogView3PlusPipeline, CogView3PlusTransformer2DModel +from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available() else nullcontext + +TOKENIZER_MAX_LENGTH = 224 + +parser = argparse.ArgumentParser() +parser.add_argument("--transformer_checkpoint_path", default=None, type=str) +parser.add_argument("--vae_checkpoint_path", default=None, type=str) +parser.add_argument("--output_path", required=True, type=str) +parser.add_argument("--push_to_hub", action="store_true", default=False, help="Whether to push to HF Hub after saving") +parser.add_argument("--text_encoder_cache_dir", type=str, default=None, help="Path to text encoder cache directory") +parser.add_argument("--dtype", type=str, default="bf16") + +args = parser.parse_args() + + +# this is specific to `AdaLayerNormContinuous`: +# diffusers implementation split the linear projection into the scale, shift while CogView3 split it tino shift, scale +def swap_scale_shift(weight, dim): + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + return new_weight + + +def convert_cogview3_transformer_checkpoint_to_diffusers(ckpt_path): + original_state_dict = torch.load(ckpt_path, map_location="cpu") + original_state_dict = original_state_dict["module"] + original_state_dict = {k.replace("model.diffusion_model.", ""): v for k, v in original_state_dict.items()} + + new_state_dict = {} + + # Convert patch_embed + new_state_dict["patch_embed.proj.weight"] = original_state_dict.pop("mixins.patch_embed.proj.weight") + new_state_dict["patch_embed.proj.bias"] = original_state_dict.pop("mixins.patch_embed.proj.bias") + new_state_dict["patch_embed.text_proj.weight"] = original_state_dict.pop("mixins.patch_embed.text_proj.weight") + new_state_dict["patch_embed.text_proj.bias"] = original_state_dict.pop("mixins.patch_embed.text_proj.bias") + + # Convert time_condition_embed + new_state_dict["time_condition_embed.timestep_embedder.linear_1.weight"] = original_state_dict.pop( + "time_embed.0.weight" + ) + new_state_dict["time_condition_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop( + "time_embed.0.bias" + ) + new_state_dict["time_condition_embed.timestep_embedder.linear_2.weight"] = original_state_dict.pop( + "time_embed.2.weight" + ) + new_state_dict["time_condition_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop( + "time_embed.2.bias" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_1.weight"] = original_state_dict.pop( + "label_emb.0.0.weight" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_1.bias"] = original_state_dict.pop( + "label_emb.0.0.bias" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_2.weight"] = original_state_dict.pop( + "label_emb.0.2.weight" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_2.bias"] = original_state_dict.pop( + "label_emb.0.2.bias" + ) + + # Convert transformer blocks + for i in range(30): + block_prefix = f"transformer_blocks.{i}." + old_prefix = f"transformer.layers.{i}." + adaln_prefix = f"mixins.adaln.adaln_modules.{i}." + + new_state_dict[block_prefix + "norm1.linear.weight"] = original_state_dict.pop(adaln_prefix + "1.weight") + new_state_dict[block_prefix + "norm1.linear.bias"] = original_state_dict.pop(adaln_prefix + "1.bias") + + qkv_weight = original_state_dict.pop(old_prefix + "attention.query_key_value.weight") + qkv_bias = original_state_dict.pop(old_prefix + "attention.query_key_value.bias") + q, k, v = qkv_weight.chunk(3, dim=0) + q_bias, k_bias, v_bias = qkv_bias.chunk(3, dim=0) + + new_state_dict[block_prefix + "attn1.to_q.weight"] = q + new_state_dict[block_prefix + "attn1.to_q.bias"] = q_bias + new_state_dict[block_prefix + "attn1.to_k.weight"] = k + new_state_dict[block_prefix + "attn1.to_k.bias"] = k_bias + new_state_dict[block_prefix + "attn1.to_v.weight"] = v + new_state_dict[block_prefix + "attn1.to_v.bias"] = v_bias + + new_state_dict[block_prefix + "attn1.to_out.0.weight"] = original_state_dict.pop( + old_prefix + "attention.dense.weight" + ) + new_state_dict[block_prefix + "attn1.to_out.0.bias"] = original_state_dict.pop( + old_prefix + "attention.dense.bias" + ) + + new_state_dict[block_prefix + "ff.net.0.proj.weight"] = original_state_dict.pop( + old_prefix + "mlp.dense_h_to_4h.weight" + ) + new_state_dict[block_prefix + "ff.net.0.proj.bias"] = original_state_dict.pop( + old_prefix + "mlp.dense_h_to_4h.bias" + ) + new_state_dict[block_prefix + "ff.net.2.weight"] = original_state_dict.pop( + old_prefix + "mlp.dense_4h_to_h.weight" + ) + new_state_dict[block_prefix + "ff.net.2.bias"] = original_state_dict.pop(old_prefix + "mlp.dense_4h_to_h.bias") + + # Convert final norm and projection + new_state_dict["norm_out.linear.weight"] = swap_scale_shift( + original_state_dict.pop("mixins.final_layer.adaln.1.weight"), dim=0 + ) + new_state_dict["norm_out.linear.bias"] = swap_scale_shift( + original_state_dict.pop("mixins.final_layer.adaln.1.bias"), dim=0 + ) + new_state_dict["proj_out.weight"] = original_state_dict.pop("mixins.final_layer.linear.weight") + new_state_dict["proj_out.bias"] = original_state_dict.pop("mixins.final_layer.linear.bias") + + return new_state_dict + + +def convert_cogview3_vae_checkpoint_to_diffusers(ckpt_path, vae_config): + original_state_dict = torch.load(ckpt_path, map_location="cpu")["state_dict"] + return convert_ldm_vae_checkpoint(original_state_dict, vae_config) + + +def main(args): + if args.dtype == "fp16": + dtype = torch.float16 + elif args.dtype == "bf16": + dtype = torch.bfloat16 + elif args.dtype == "fp32": + dtype = torch.float32 + else: + raise ValueError(f"Unsupported dtype: {args.dtype}") + + transformer = None + vae = None + + if args.transformer_checkpoint_path is not None: + converted_transformer_state_dict = convert_cogview3_transformer_checkpoint_to_diffusers( + args.transformer_checkpoint_path + ) + transformer = CogView3PlusTransformer2DModel() + transformer.load_state_dict(converted_transformer_state_dict, strict=True) + if dtype is not None: + # Original checkpoint data type will be preserved + transformer = transformer.to(dtype=dtype) + + if args.vae_checkpoint_path is not None: + vae_config = { + "in_channels": 3, + "out_channels": 3, + "down_block_types": ("DownEncoderBlock2D",) * 4, + "up_block_types": ("UpDecoderBlock2D",) * 4, + "block_out_channels": (128, 512, 1024, 1024), + "layers_per_block": 3, + "act_fn": "silu", + "latent_channels": 16, + "norm_num_groups": 32, + "sample_size": 1024, + "scaling_factor": 1.0, + "force_upcast": True, + "use_quant_conv": False, + "use_post_quant_conv": False, + "mid_block_add_attention": False, + } + converted_vae_state_dict = convert_cogview3_vae_checkpoint_to_diffusers(args.vae_checkpoint_path, vae_config) + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_state_dict, strict=True) + if dtype is not None: + vae = vae.to(dtype=dtype) + + text_encoder_id = "google/t5-v1_1-xxl" + tokenizer = T5Tokenizer.from_pretrained(text_encoder_id, model_max_length=TOKENIZER_MAX_LENGTH) + text_encoder = T5EncoderModel.from_pretrained(text_encoder_id, cache_dir=args.text_encoder_cache_dir) + + # Apparently, the conversion does not work anymore without this :shrug: + for param in text_encoder.parameters(): + param.data = param.data.contiguous() + + scheduler = CogVideoXDDIMScheduler.from_config( + { + "snr_shift_scale": 4.0, + "beta_end": 0.012, + "beta_schedule": "scaled_linear", + "beta_start": 0.00085, + "clip_sample": False, + "num_train_timesteps": 1000, + "prediction_type": "v_prediction", + "rescale_betas_zero_snr": True, + "set_alpha_to_one": True, + "timestep_spacing": "trailing", + } + ) + + pipe = CogView3PlusPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + vae=vae, + transformer=transformer, + scheduler=scheduler, + ) + + # This is necessary for users with insufficient memory, such as those using Colab and notebooks, as it can + # save some memory used for model loading. + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB", push_to_hub=args.push_to_hub) + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview4_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview4_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..b6d01c797aeb3f98f1b2053c7d4d60fe02faed17 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview4_to_diffusers.py @@ -0,0 +1,254 @@ +""" +Convert a CogView4 checkpoint from SAT(https://github.com/THUDM/SwissArmyTransformer) to the Diffusers format. +(deprecated Since 2025-02-07 and will remove it in later CogView4 version) + +This script converts a CogView4 checkpoint to the Diffusers format, which can then be used +with the Diffusers library. + +Example usage: + python scripts/convert_cogview4_to_diffusers.py \ + --transformer_checkpoint_path 'your path/cogview4_6b/1/mp_rank_00_model_states.pt' \ + --vae_checkpoint_path 'your path/cogview4_6b/imagekl_ch16.pt' \ + --output_path "THUDM/CogView4-6B" \ + --dtype "bf16" + +Arguments: + --transformer_checkpoint_path: Path to Transformer state dict. + --vae_checkpoint_path: Path to VAE state dict. + --output_path: The path to save the converted model. + --push_to_hub: Whether to push the converted checkpoint to the HF Hub or not. Defaults to `False`. + --text_encoder_cache_dir: Cache directory where text encoder is located. Defaults to None, which means HF_HOME will be used + --dtype: The dtype to save the model in (default: "bf16", options: "fp16", "bf16", "fp32"). If None, the dtype of the state dict is considered. + + Default is "bf16" because CogView4 uses bfloat16 for Training. + +Note: You must provide either --original_state_dict_repo_id or --checkpoint_path. +""" + +import argparse +from contextlib import nullcontext + +import torch +from accelerate import init_empty_weights +from transformers import GlmForCausalLM, PreTrainedTokenizerFast + +from diffusers import AutoencoderKL, CogView4Pipeline, CogView4Transformer2DModel, FlowMatchEulerDiscreteScheduler +from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available() else nullcontext + +parser = argparse.ArgumentParser() +parser.add_argument("--transformer_checkpoint_path", default=None, type=str) +parser.add_argument("--vae_checkpoint_path", default=None, type=str) +parser.add_argument("--output_path", required=True, type=str) +parser.add_argument("--push_to_hub", action="store_true", default=False, help="Whether to push to HF Hub after saving") +parser.add_argument("--text_encoder_cache_dir", type=str, default=None, help="Path to text encoder cache directory") +parser.add_argument("--dtype", type=str, default="bf16") + +args = parser.parse_args() + + +# this is specific to `AdaLayerNormContinuous`: +# diffusers implementation split the linear projection into the scale, shift while CogView4 split it tino shift, scale +def swap_scale_shift(weight, dim): + """ + Swap the scale and shift components in the weight tensor. + + Args: + weight (torch.Tensor): The original weight tensor. + dim (int): The dimension along which to split. + + Returns: + torch.Tensor: The modified weight tensor with scale and shift swapped. + """ + shift, scale = weight.chunk(2, dim=dim) + new_weight = torch.cat([scale, shift], dim=dim) + return new_weight + + +def convert_cogview4_transformer_checkpoint_to_diffusers(ckpt_path): + original_state_dict = torch.load(ckpt_path, map_location="cpu") + original_state_dict = original_state_dict["module"] + original_state_dict = {k.replace("model.diffusion_model.", ""): v for k, v in original_state_dict.items()} + + new_state_dict = {} + + # Convert patch_embed + new_state_dict["patch_embed.proj.weight"] = original_state_dict.pop("mixins.patch_embed.proj.weight") + new_state_dict["patch_embed.proj.bias"] = original_state_dict.pop("mixins.patch_embed.proj.bias") + new_state_dict["patch_embed.text_proj.weight"] = original_state_dict.pop("mixins.patch_embed.text_proj.weight") + new_state_dict["patch_embed.text_proj.bias"] = original_state_dict.pop("mixins.patch_embed.text_proj.bias") + + # Convert time_condition_embed + new_state_dict["time_condition_embed.timestep_embedder.linear_1.weight"] = original_state_dict.pop( + "time_embed.0.weight" + ) + new_state_dict["time_condition_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop( + "time_embed.0.bias" + ) + new_state_dict["time_condition_embed.timestep_embedder.linear_2.weight"] = original_state_dict.pop( + "time_embed.2.weight" + ) + new_state_dict["time_condition_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop( + "time_embed.2.bias" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_1.weight"] = original_state_dict.pop( + "label_emb.0.0.weight" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_1.bias"] = original_state_dict.pop( + "label_emb.0.0.bias" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_2.weight"] = original_state_dict.pop( + "label_emb.0.2.weight" + ) + new_state_dict["time_condition_embed.condition_embedder.linear_2.bias"] = original_state_dict.pop( + "label_emb.0.2.bias" + ) + + # Convert transformer blocks, for cogview4 is 28 blocks + for i in range(28): + block_prefix = f"transformer_blocks.{i}." + old_prefix = f"transformer.layers.{i}." + adaln_prefix = f"mixins.adaln.adaln_modules.{i}." + new_state_dict[block_prefix + "norm1.linear.weight"] = original_state_dict.pop(adaln_prefix + "1.weight") + new_state_dict[block_prefix + "norm1.linear.bias"] = original_state_dict.pop(adaln_prefix + "1.bias") + + qkv_weight = original_state_dict.pop(old_prefix + "attention.query_key_value.weight") + qkv_bias = original_state_dict.pop(old_prefix + "attention.query_key_value.bias") + q, k, v = qkv_weight.chunk(3, dim=0) + q_bias, k_bias, v_bias = qkv_bias.chunk(3, dim=0) + + new_state_dict[block_prefix + "attn1.to_q.weight"] = q + new_state_dict[block_prefix + "attn1.to_q.bias"] = q_bias + new_state_dict[block_prefix + "attn1.to_k.weight"] = k + new_state_dict[block_prefix + "attn1.to_k.bias"] = k_bias + new_state_dict[block_prefix + "attn1.to_v.weight"] = v + new_state_dict[block_prefix + "attn1.to_v.bias"] = v_bias + + new_state_dict[block_prefix + "attn1.to_out.0.weight"] = original_state_dict.pop( + old_prefix + "attention.dense.weight" + ) + new_state_dict[block_prefix + "attn1.to_out.0.bias"] = original_state_dict.pop( + old_prefix + "attention.dense.bias" + ) + + new_state_dict[block_prefix + "ff.net.0.proj.weight"] = original_state_dict.pop( + old_prefix + "mlp.dense_h_to_4h.weight" + ) + new_state_dict[block_prefix + "ff.net.0.proj.bias"] = original_state_dict.pop( + old_prefix + "mlp.dense_h_to_4h.bias" + ) + new_state_dict[block_prefix + "ff.net.2.weight"] = original_state_dict.pop( + old_prefix + "mlp.dense_4h_to_h.weight" + ) + new_state_dict[block_prefix + "ff.net.2.bias"] = original_state_dict.pop(old_prefix + "mlp.dense_4h_to_h.bias") + + # Convert final norm and projection + new_state_dict["norm_out.linear.weight"] = swap_scale_shift( + original_state_dict.pop("mixins.final_layer.adaln.1.weight"), dim=0 + ) + new_state_dict["norm_out.linear.bias"] = swap_scale_shift( + original_state_dict.pop("mixins.final_layer.adaln.1.bias"), dim=0 + ) + new_state_dict["proj_out.weight"] = original_state_dict.pop("mixins.final_layer.linear.weight") + new_state_dict["proj_out.bias"] = original_state_dict.pop("mixins.final_layer.linear.bias") + + return new_state_dict + + +def convert_cogview4_vae_checkpoint_to_diffusers(ckpt_path, vae_config): + original_state_dict = torch.load(ckpt_path, map_location="cpu")["state_dict"] + return convert_ldm_vae_checkpoint(original_state_dict, vae_config) + + +def main(args): + if args.dtype == "fp16": + dtype = torch.float16 + elif args.dtype == "bf16": + dtype = torch.bfloat16 + elif args.dtype == "fp32": + dtype = torch.float32 + else: + raise ValueError(f"Unsupported dtype: {args.dtype}") + + transformer = None + vae = None + + if args.transformer_checkpoint_path is not None: + converted_transformer_state_dict = convert_cogview4_transformer_checkpoint_to_diffusers( + args.transformer_checkpoint_path + ) + transformer = CogView4Transformer2DModel( + patch_size=2, + in_channels=16, + num_layers=28, + attention_head_dim=128, + num_attention_heads=32, + out_channels=16, + text_embed_dim=4096, + time_embed_dim=512, + condition_dim=256, + pos_embed_max_size=128, + ) + transformer.load_state_dict(converted_transformer_state_dict, strict=True) + if dtype is not None: + # Original checkpoint data type will be preserved + transformer = transformer.to(dtype=dtype) + + if args.vae_checkpoint_path is not None: + vae_config = { + "in_channels": 3, + "out_channels": 3, + "down_block_types": ("DownEncoderBlock2D",) * 4, + "up_block_types": ("UpDecoderBlock2D",) * 4, + "block_out_channels": (128, 512, 1024, 1024), + "layers_per_block": 3, + "act_fn": "silu", + "latent_channels": 16, + "norm_num_groups": 32, + "sample_size": 1024, + "scaling_factor": 1.0, + "shift_factor": 0.0, + "force_upcast": True, + "use_quant_conv": False, + "use_post_quant_conv": False, + "mid_block_add_attention": False, + } + converted_vae_state_dict = convert_cogview4_vae_checkpoint_to_diffusers(args.vae_checkpoint_path, vae_config) + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_state_dict, strict=True) + if dtype is not None: + vae = vae.to(dtype=dtype) + + text_encoder_id = "THUDM/glm-4-9b-hf" + tokenizer = PreTrainedTokenizerFast.from_pretrained(text_encoder_id) + text_encoder = GlmForCausalLM.from_pretrained( + text_encoder_id, + cache_dir=args.text_encoder_cache_dir, + torch_dtype=torch.bfloat16 if args.dtype == "bf16" else torch.float32, + ) + + for param in text_encoder.parameters(): + param.data = param.data.contiguous() + + scheduler = FlowMatchEulerDiscreteScheduler( + base_shift=0.25, max_shift=0.75, base_image_seq_len=256, use_dynamic_shifting=True, time_shift_type="linear" + ) + + pipe = CogView4Pipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + vae=vae, + transformer=transformer, + scheduler=scheduler, + ) + + # This is necessary for users with insufficient memory, such as those using Colab and notebooks, as it can + # save some memory used for model loading. + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB", push_to_hub=args.push_to_hub) + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview4_to_diffusers_megatron.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview4_to_diffusers_megatron.py new file mode 100644 index 0000000000000000000000000000000000000000..8faeccb13888f8fd14f2d5fe4ee0dd51174343b4 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cogview4_to_diffusers_megatron.py @@ -0,0 +1,384 @@ +""" +Convert a CogView4 checkpoint from Megatron to the Diffusers format. + +Example usage: + python scripts/convert_cogview4_to_diffusers.py \ + --transformer_checkpoint_path 'your path/cogview4_6b/mp_rank_00/model_optim_rng.pt' \ + --vae_checkpoint_path 'your path/cogview4_6b/imagekl_ch16.pt' \ + --output_path "THUDM/CogView4-6B" \ + --dtype "bf16" + +Arguments: + --transformer_checkpoint_path: Path to Transformer state dict. + --vae_checkpoint_path: Path to VAE state dict. + --output_path: The path to save the converted model. + --push_to_hub: Whether to push the converted checkpoint to the HF Hub or not. Defaults to `False`. + --text_encoder_cache_dir: Cache directory where text encoder is located. Defaults to None, which means HF_HOME will be used. + --dtype: The dtype to save the model in (default: "bf16", options: "fp16", "bf16", "fp32"). If None, the dtype of the state dict is considered. + + Default is "bf16" because CogView4 uses bfloat16 for training. + +Note: You must provide either --transformer_checkpoint_path or --vae_checkpoint_path. +""" + +import argparse + +import torch +from tqdm import tqdm +from transformers import GlmModel, PreTrainedTokenizerFast + +from diffusers import ( + AutoencoderKL, + CogView4ControlPipeline, + CogView4Pipeline, + CogView4Transformer2DModel, + FlowMatchEulerDiscreteScheduler, +) +from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint + + +parser = argparse.ArgumentParser() +parser.add_argument( + "--transformer_checkpoint_path", + default=None, + type=str, + help="Path to Megatron (not SAT) Transformer checkpoint, e.g., 'model_optim_rng.pt'.", +) +parser.add_argument( + "--vae_checkpoint_path", + default=None, + type=str, + help="(Optional) Path to VAE checkpoint, e.g., 'imagekl_ch16.pt'.", +) +parser.add_argument( + "--output_path", + required=True, + type=str, + help="Directory to save the final Diffusers format pipeline.", +) +parser.add_argument( + "--push_to_hub", + action="store_true", + default=False, + help="Whether to push the converted model to the HuggingFace Hub.", +) +parser.add_argument( + "--text_encoder_cache_dir", + type=str, + default=None, + help="Specify the cache directory for the text encoder.", +) +parser.add_argument( + "--dtype", + type=str, + default="bf16", + choices=["fp16", "bf16", "fp32"], + help="Data type to save the model in.", +) + +parser.add_argument( + "--num_layers", + type=int, + default=28, + help="Number of Transformer layers (e.g., 28, 48...).", +) +parser.add_argument( + "--num_heads", + type=int, + default=32, + help="Number of attention heads.", +) +parser.add_argument( + "--hidden_size", + type=int, + default=4096, + help="Transformer hidden dimension size.", +) +parser.add_argument( + "--attention_head_dim", + type=int, + default=128, + help="Dimension of each attention head.", +) +parser.add_argument( + "--time_embed_dim", + type=int, + default=512, + help="Dimension of time embeddings.", +) +parser.add_argument( + "--condition_dim", + type=int, + default=256, + help="Dimension of condition embeddings.", +) +parser.add_argument( + "--pos_embed_max_size", + type=int, + default=128, + help="Maximum size for positional embeddings.", +) +parser.add_argument( + "--control", + action="store_true", + default=False, + help="Whether to use control model.", +) + +args = parser.parse_args() + + +def swap_scale_shift(weight, dim): + """ + Swap the scale and shift components in the weight tensor. + + Args: + weight (torch.Tensor): The original weight tensor. + dim (int): The dimension along which to split. + + Returns: + torch.Tensor: The modified weight tensor with scale and shift swapped. + """ + shift, scale = weight.chunk(2, dim=dim) + new_weight = torch.cat([scale, shift], dim=dim) + return new_weight + + +def convert_megatron_transformer_checkpoint_to_diffusers( + ckpt_path: str, + num_layers: int, + num_heads: int, + hidden_size: int, +): + """ + Convert a Megatron Transformer checkpoint to Diffusers format. + + Args: + ckpt_path (str): Path to the Megatron Transformer checkpoint. + num_layers (int): Number of Transformer layers. + num_heads (int): Number of attention heads. + hidden_size (int): Hidden size of the Transformer. + + Returns: + dict: The converted state dictionary compatible with Diffusers. + """ + ckpt = torch.load(ckpt_path, map_location="cpu", weights_only=False) + mega = ckpt["model"] + + new_state_dict = {} + + # Patch Embedding + new_state_dict["patch_embed.proj.weight"] = mega["encoder_expand_linear.weight"].reshape( + hidden_size, 128 if args.control else 64 + ) + new_state_dict["patch_embed.proj.bias"] = mega["encoder_expand_linear.bias"] + new_state_dict["patch_embed.text_proj.weight"] = mega["text_projector.weight"] + new_state_dict["patch_embed.text_proj.bias"] = mega["text_projector.bias"] + + # Time Condition Embedding + new_state_dict["time_condition_embed.timestep_embedder.linear_1.weight"] = mega[ + "time_embedding.time_embed.0.weight" + ] + new_state_dict["time_condition_embed.timestep_embedder.linear_1.bias"] = mega["time_embedding.time_embed.0.bias"] + new_state_dict["time_condition_embed.timestep_embedder.linear_2.weight"] = mega[ + "time_embedding.time_embed.2.weight" + ] + new_state_dict["time_condition_embed.timestep_embedder.linear_2.bias"] = mega["time_embedding.time_embed.2.bias"] + + new_state_dict["time_condition_embed.condition_embedder.linear_1.weight"] = mega[ + "label_embedding.label_embed.0.weight" + ] + new_state_dict["time_condition_embed.condition_embedder.linear_1.bias"] = mega[ + "label_embedding.label_embed.0.bias" + ] + new_state_dict["time_condition_embed.condition_embedder.linear_2.weight"] = mega[ + "label_embedding.label_embed.2.weight" + ] + new_state_dict["time_condition_embed.condition_embedder.linear_2.bias"] = mega[ + "label_embedding.label_embed.2.bias" + ] + + # Convert each Transformer layer + for i in tqdm(range(num_layers), desc="Converting layers (Megatron->Diffusers)"): + block_prefix = f"transformer_blocks.{i}." + + # AdaLayerNorm + new_state_dict[block_prefix + "norm1.linear.weight"] = mega[f"decoder.layers.{i}.adaln.weight"] + new_state_dict[block_prefix + "norm1.linear.bias"] = mega[f"decoder.layers.{i}.adaln.bias"] + qkv_weight = mega[f"decoder.layers.{i}.self_attention.linear_qkv.weight"] + qkv_bias = mega[f"decoder.layers.{i}.self_attention.linear_qkv.bias"] + + # Reshape to match SAT logic + qkv_weight = qkv_weight.view(num_heads, 3, hidden_size // num_heads, hidden_size) + qkv_weight = qkv_weight.permute(1, 0, 2, 3).reshape(3 * hidden_size, hidden_size) + + qkv_bias = qkv_bias.view(num_heads, 3, hidden_size // num_heads) + qkv_bias = qkv_bias.permute(1, 0, 2).reshape(3 * hidden_size) + + # Assign to Diffusers keys + q, k, v = torch.chunk(qkv_weight, 3, dim=0) + qb, kb, vb = torch.chunk(qkv_bias, 3, dim=0) + + new_state_dict[block_prefix + "attn1.to_q.weight"] = q + new_state_dict[block_prefix + "attn1.to_q.bias"] = qb + new_state_dict[block_prefix + "attn1.to_k.weight"] = k + new_state_dict[block_prefix + "attn1.to_k.bias"] = kb + new_state_dict[block_prefix + "attn1.to_v.weight"] = v + new_state_dict[block_prefix + "attn1.to_v.bias"] = vb + + # Attention Output + new_state_dict[block_prefix + "attn1.to_out.0.weight"] = mega[ + f"decoder.layers.{i}.self_attention.linear_proj.weight" + ] + new_state_dict[block_prefix + "attn1.to_out.0.bias"] = mega[ + f"decoder.layers.{i}.self_attention.linear_proj.bias" + ] + + # MLP + new_state_dict[block_prefix + "ff.net.0.proj.weight"] = mega[f"decoder.layers.{i}.mlp.linear_fc1.weight"] + new_state_dict[block_prefix + "ff.net.0.proj.bias"] = mega[f"decoder.layers.{i}.mlp.linear_fc1.bias"] + new_state_dict[block_prefix + "ff.net.2.weight"] = mega[f"decoder.layers.{i}.mlp.linear_fc2.weight"] + new_state_dict[block_prefix + "ff.net.2.bias"] = mega[f"decoder.layers.{i}.mlp.linear_fc2.bias"] + + # Final Layers + new_state_dict["norm_out.linear.weight"] = swap_scale_shift(mega["adaln_final.weight"], dim=0) + new_state_dict["norm_out.linear.bias"] = swap_scale_shift(mega["adaln_final.bias"], dim=0) + new_state_dict["proj_out.weight"] = mega["output_projector.weight"] + new_state_dict["proj_out.bias"] = mega["output_projector.bias"] + + return new_state_dict + + +def convert_cogview4_vae_checkpoint_to_diffusers(ckpt_path, vae_config): + """ + Convert a CogView4 VAE checkpoint to Diffusers format. + + Args: + ckpt_path (str): Path to the VAE checkpoint. + vae_config (dict): Configuration dictionary for the VAE. + + Returns: + dict: The converted VAE state dictionary compatible with Diffusers. + """ + original_state_dict = torch.load(ckpt_path, map_location="cpu", weights_only=False)["state_dict"] + return convert_ldm_vae_checkpoint(original_state_dict, vae_config) + + +def main(args): + """ + Main function to convert CogView4 checkpoints to Diffusers format. + + Args: + args (argparse.Namespace): Parsed command-line arguments. + """ + # Determine the desired data type + if args.dtype == "fp16": + dtype = torch.float16 + elif args.dtype == "bf16": + dtype = torch.bfloat16 + elif args.dtype == "fp32": + dtype = torch.float32 + else: + raise ValueError(f"Unsupported dtype: {args.dtype}") + + transformer = None + vae = None + + # Convert Transformer checkpoint if provided + if args.transformer_checkpoint_path is not None: + converted_transformer_state_dict = convert_megatron_transformer_checkpoint_to_diffusers( + ckpt_path=args.transformer_checkpoint_path, + num_layers=args.num_layers, + num_heads=args.num_heads, + hidden_size=args.hidden_size, + ) + transformer = CogView4Transformer2DModel( + patch_size=2, + in_channels=32 if args.control else 16, + num_layers=args.num_layers, + attention_head_dim=args.attention_head_dim, + num_attention_heads=args.num_heads, + out_channels=16, + text_embed_dim=args.hidden_size, + time_embed_dim=args.time_embed_dim, + condition_dim=args.condition_dim, + pos_embed_max_size=args.pos_embed_max_size, + ) + + transformer.load_state_dict(converted_transformer_state_dict, strict=True) + + # Convert to the specified dtype + if dtype is not None: + transformer = transformer.to(dtype=dtype) + + # Convert VAE checkpoint if provided + if args.vae_checkpoint_path is not None: + vae_config = { + "in_channels": 3, + "out_channels": 3, + "down_block_types": ("DownEncoderBlock2D",) * 4, + "up_block_types": ("UpDecoderBlock2D",) * 4, + "block_out_channels": (128, 512, 1024, 1024), + "layers_per_block": 3, + "act_fn": "silu", + "latent_channels": 16, + "norm_num_groups": 32, + "sample_size": 1024, + "scaling_factor": 1.0, + "shift_factor": 0.0, + "force_upcast": True, + "use_quant_conv": False, + "use_post_quant_conv": False, + "mid_block_add_attention": False, + } + converted_vae_state_dict = convert_cogview4_vae_checkpoint_to_diffusers(args.vae_checkpoint_path, vae_config) + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_state_dict, strict=True) + if dtype is not None: + vae = vae.to(dtype=dtype) + + # Load the text encoder and tokenizer + text_encoder_id = "THUDM/glm-4-9b-hf" + tokenizer = PreTrainedTokenizerFast.from_pretrained(text_encoder_id) + text_encoder = GlmModel.from_pretrained( + text_encoder_id, + cache_dir=args.text_encoder_cache_dir, + torch_dtype=torch.bfloat16 if args.dtype == "bf16" else torch.float32, + ) + for param in text_encoder.parameters(): + param.data = param.data.contiguous() + + # Initialize the scheduler + scheduler = FlowMatchEulerDiscreteScheduler( + base_shift=0.25, max_shift=0.75, base_image_seq_len=256, use_dynamic_shifting=True, time_shift_type="linear" + ) + + # Create the pipeline + if args.control: + pipe = CogView4ControlPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + vae=vae, + transformer=transformer, + scheduler=scheduler, + ) + else: + pipe = CogView4Pipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + vae=vae, + transformer=transformer, + scheduler=scheduler, + ) + + # Save the converted pipeline + pipe.save_pretrained( + args.output_path, + safe_serialization=True, + max_shard_size="5GB", + push_to_hub=args.push_to_hub, + ) + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_consistency_decoder.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_consistency_decoder.py new file mode 100644 index 0000000000000000000000000000000000000000..9e289457752b31ba1eca7059243ce32356a4298d --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_consistency_decoder.py @@ -0,0 +1,1131 @@ +import math +import os +import urllib +import warnings +from argparse import ArgumentParser + +import torch +import torch.nn as nn +import torch.nn.functional as F +from huggingface_hub.utils import insecure_hashlib +from safetensors.torch import load_file as stl +from tqdm import tqdm + +from diffusers import AutoencoderKL, ConsistencyDecoderVAE, DiffusionPipeline, StableDiffusionPipeline, UNet2DModel +from diffusers.models.autoencoders.vae import Encoder +from diffusers.models.embeddings import TimestepEmbedding +from diffusers.models.unets.unet_2d_blocks import ResnetDownsampleBlock2D, ResnetUpsampleBlock2D, UNetMidBlock2D + + +args = ArgumentParser() +args.add_argument("--save_pretrained", required=False, default=None, type=str) +args.add_argument("--test_image", required=True, type=str) +args = args.parse_args() + + +def _extract_into_tensor(arr, timesteps, broadcast_shape): + # from: https://github.com/openai/guided-diffusion/blob/22e0df8183507e13a7813f8d38d51b072ca1e67c/guided_diffusion/gaussian_diffusion.py#L895 + # """ + res = arr[timesteps].float() + dims_to_append = len(broadcast_shape) - len(res.shape) + return res[(...,) + (None,) * dims_to_append] + + +def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.999): + # from: https://github.com/openai/guided-diffusion/blob/22e0df8183507e13a7813f8d38d51b072ca1e67c/guided_diffusion/gaussian_diffusion.py#L45 + betas = [] + for i in range(num_diffusion_timesteps): + t1 = i / num_diffusion_timesteps + t2 = (i + 1) / num_diffusion_timesteps + betas.append(min(1 - alpha_bar(t2) / alpha_bar(t1), max_beta)) + return torch.tensor(betas) + + +def _download(url: str, root: str): + os.makedirs(root, exist_ok=True) + filename = os.path.basename(url) + + expected_sha256 = url.split("/")[-2] + download_target = os.path.join(root, filename) + + if os.path.exists(download_target) and not os.path.isfile(download_target): + raise RuntimeError(f"{download_target} exists and is not a regular file") + + if os.path.isfile(download_target): + if insecure_hashlib.sha256(open(download_target, "rb").read()).hexdigest() == expected_sha256: + return download_target + else: + warnings.warn(f"{download_target} exists, but the SHA256 checksum does not match; re-downloading the file") + + with urllib.request.urlopen(url) as source, open(download_target, "wb") as output: + with tqdm( + total=int(source.info().get("Content-Length")), + ncols=80, + unit="iB", + unit_scale=True, + unit_divisor=1024, + ) as loop: + while True: + buffer = source.read(8192) + if not buffer: + break + + output.write(buffer) + loop.update(len(buffer)) + + if insecure_hashlib.sha256(open(download_target, "rb").read()).hexdigest() != expected_sha256: + raise RuntimeError("Model has been downloaded but the SHA256 checksum does not match") + + return download_target + + +class ConsistencyDecoder: + def __init__(self, device="cuda:0", download_root=os.path.expanduser("~/.cache/clip")): + self.n_distilled_steps = 64 + download_target = _download( + "https://openaipublic.azureedge.net/diff-vae/c9cebd3132dd9c42936d803e33424145a748843c8f716c0814838bdc8a2fe7cb/decoder.pt", + download_root, + ) + self.ckpt = torch.jit.load(download_target).to(device) + self.device = device + sigma_data = 0.5 + betas = betas_for_alpha_bar(1024, lambda t: math.cos((t + 0.008) / 1.008 * math.pi / 2) ** 2).to(device) + alphas = 1.0 - betas + alphas_cumprod = torch.cumprod(alphas, dim=0) + self.sqrt_alphas_cumprod = torch.sqrt(alphas_cumprod) + self.sqrt_one_minus_alphas_cumprod = torch.sqrt(1.0 - alphas_cumprod) + sqrt_recip_alphas_cumprod = torch.sqrt(1.0 / alphas_cumprod) + sigmas = torch.sqrt(1.0 / alphas_cumprod - 1) + self.c_skip = sqrt_recip_alphas_cumprod * sigma_data**2 / (sigmas**2 + sigma_data**2) + self.c_out = sigmas * sigma_data / (sigmas**2 + sigma_data**2) ** 0.5 + self.c_in = sqrt_recip_alphas_cumprod / (sigmas**2 + sigma_data**2) ** 0.5 + + @staticmethod + def round_timesteps(timesteps, total_timesteps, n_distilled_steps, truncate_start=True): + with torch.no_grad(): + space = torch.div(total_timesteps, n_distilled_steps, rounding_mode="floor") + rounded_timesteps = (torch.div(timesteps, space, rounding_mode="floor") + 1) * space + if truncate_start: + rounded_timesteps[rounded_timesteps == total_timesteps] -= space + else: + rounded_timesteps[rounded_timesteps == total_timesteps] -= space + rounded_timesteps[rounded_timesteps == 0] += space + return rounded_timesteps + + @staticmethod + def ldm_transform_latent(z, extra_scale_factor=1): + channel_means = [0.38862467, 0.02253063, 0.07381133, -0.0171294] + channel_stds = [0.9654121, 1.0440036, 0.76147926, 0.77022034] + + if len(z.shape) != 4: + raise ValueError() + + z = z * 0.18215 + channels = [z[:, i] for i in range(z.shape[1])] + + channels = [extra_scale_factor * (c - channel_means[i]) / channel_stds[i] for i, c in enumerate(channels)] + return torch.stack(channels, dim=1) + + @torch.no_grad() + def __call__( + self, + features: torch.Tensor, + schedule=[1.0, 0.5], + generator=None, + ): + features = self.ldm_transform_latent(features) + ts = self.round_timesteps( + torch.arange(0, 1024), + 1024, + self.n_distilled_steps, + truncate_start=False, + ) + shape = ( + features.size(0), + 3, + 8 * features.size(2), + 8 * features.size(3), + ) + x_start = torch.zeros(shape, device=features.device, dtype=features.dtype) + schedule_timesteps = [int((1024 - 1) * s) for s in schedule] + for i in schedule_timesteps: + t = ts[i].item() + t_ = torch.tensor([t] * features.shape[0]).to(self.device) + # noise = torch.randn_like(x_start) + noise = torch.randn(x_start.shape, dtype=x_start.dtype, generator=generator).to(device=x_start.device) + x_start = ( + _extract_into_tensor(self.sqrt_alphas_cumprod, t_, x_start.shape) * x_start + + _extract_into_tensor(self.sqrt_one_minus_alphas_cumprod, t_, x_start.shape) * noise + ) + c_in = _extract_into_tensor(self.c_in, t_, x_start.shape) + + import torch.nn.functional as F + + from diffusers import UNet2DModel + + if isinstance(self.ckpt, UNet2DModel): + input = torch.concat([c_in * x_start, F.upsample_nearest(features, scale_factor=8)], dim=1) + model_output = self.ckpt(input, t_).sample + else: + model_output = self.ckpt(c_in * x_start, t_, features=features) + + B, C = x_start.shape[:2] + model_output, _ = torch.split(model_output, C, dim=1) + pred_xstart = ( + _extract_into_tensor(self.c_out, t_, x_start.shape) * model_output + + _extract_into_tensor(self.c_skip, t_, x_start.shape) * x_start + ).clamp(-1, 1) + x_start = pred_xstart + return x_start + + +def save_image(image, name): + import numpy as np + from PIL import Image + + image = image[0].cpu().numpy() + image = (image + 1.0) * 127.5 + image = image.clip(0, 255).astype(np.uint8) + image = Image.fromarray(image.transpose(1, 2, 0)) + image.save(name) + + +def load_image(uri, size=None, center_crop=False): + import numpy as np + from PIL import Image + + image = Image.open(uri) + if center_crop: + image = image.crop( + ( + (image.width - min(image.width, image.height)) // 2, + (image.height - min(image.width, image.height)) // 2, + (image.width + min(image.width, image.height)) // 2, + (image.height + min(image.width, image.height)) // 2, + ) + ) + if size is not None: + image = image.resize(size) + image = torch.tensor(np.array(image).transpose(2, 0, 1)).unsqueeze(0).float() + image = image / 127.5 - 1.0 + return image + + +class TimestepEmbedding_(nn.Module): + def __init__(self, n_time=1024, n_emb=320, n_out=1280) -> None: + super().__init__() + self.emb = nn.Embedding(n_time, n_emb) + self.f_1 = nn.Linear(n_emb, n_out) + self.f_2 = nn.Linear(n_out, n_out) + + def forward(self, x) -> torch.Tensor: + x = self.emb(x) + x = self.f_1(x) + x = F.silu(x) + return self.f_2(x) + + +class ImageEmbedding(nn.Module): + def __init__(self, in_channels=7, out_channels=320) -> None: + super().__init__() + self.f = nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1) + + def forward(self, x) -> torch.Tensor: + return self.f(x) + + +class ImageUnembedding(nn.Module): + def __init__(self, in_channels=320, out_channels=6) -> None: + super().__init__() + self.gn = nn.GroupNorm(32, in_channels) + self.f = nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1) + + def forward(self, x) -> torch.Tensor: + return self.f(F.silu(self.gn(x))) + + +class ConvResblock(nn.Module): + def __init__(self, in_features=320, out_features=320) -> None: + super().__init__() + self.f_t = nn.Linear(1280, out_features * 2) + + self.gn_1 = nn.GroupNorm(32, in_features) + self.f_1 = nn.Conv2d(in_features, out_features, kernel_size=3, padding=1) + + self.gn_2 = nn.GroupNorm(32, out_features) + self.f_2 = nn.Conv2d(out_features, out_features, kernel_size=3, padding=1) + + skip_conv = in_features != out_features + self.f_s = nn.Conv2d(in_features, out_features, kernel_size=1, padding=0) if skip_conv else nn.Identity() + + def forward(self, x, t): + x_skip = x + t = self.f_t(F.silu(t)) + t = t.chunk(2, dim=1) + t_1 = t[0].unsqueeze(dim=2).unsqueeze(dim=3) + 1 + t_2 = t[1].unsqueeze(dim=2).unsqueeze(dim=3) + + gn_1 = F.silu(self.gn_1(x)) + f_1 = self.f_1(gn_1) + + gn_2 = self.gn_2(f_1) + + return self.f_s(x_skip) + self.f_2(F.silu(gn_2 * t_1 + t_2)) + + +# Also ConvResblock +class Downsample(nn.Module): + def __init__(self, in_channels=320) -> None: + super().__init__() + self.f_t = nn.Linear(1280, in_channels * 2) + + self.gn_1 = nn.GroupNorm(32, in_channels) + self.f_1 = nn.Conv2d(in_channels, in_channels, kernel_size=3, padding=1) + self.gn_2 = nn.GroupNorm(32, in_channels) + + self.f_2 = nn.Conv2d(in_channels, in_channels, kernel_size=3, padding=1) + + def forward(self, x, t) -> torch.Tensor: + x_skip = x + + t = self.f_t(F.silu(t)) + t_1, t_2 = t.chunk(2, dim=1) + t_1 = t_1.unsqueeze(2).unsqueeze(3) + 1 + t_2 = t_2.unsqueeze(2).unsqueeze(3) + + gn_1 = F.silu(self.gn_1(x)) + avg_pool2d = F.avg_pool2d(gn_1, kernel_size=(2, 2), stride=None) + + f_1 = self.f_1(avg_pool2d) + gn_2 = self.gn_2(f_1) + + f_2 = self.f_2(F.silu(t_2 + (t_1 * gn_2))) + + return f_2 + F.avg_pool2d(x_skip, kernel_size=(2, 2), stride=None) + + +# Also ConvResblock +class Upsample(nn.Module): + def __init__(self, in_channels=1024) -> None: + super().__init__() + self.f_t = nn.Linear(1280, in_channels * 2) + + self.gn_1 = nn.GroupNorm(32, in_channels) + self.f_1 = nn.Conv2d(in_channels, in_channels, kernel_size=3, padding=1) + self.gn_2 = nn.GroupNorm(32, in_channels) + + self.f_2 = nn.Conv2d(in_channels, in_channels, kernel_size=3, padding=1) + + def forward(self, x, t) -> torch.Tensor: + x_skip = x + + t = self.f_t(F.silu(t)) + t_1, t_2 = t.chunk(2, dim=1) + t_1 = t_1.unsqueeze(2).unsqueeze(3) + 1 + t_2 = t_2.unsqueeze(2).unsqueeze(3) + + gn_1 = F.silu(self.gn_1(x)) + upsample = F.upsample_nearest(gn_1, scale_factor=2) + f_1 = self.f_1(upsample) + gn_2 = self.gn_2(f_1) + + f_2 = self.f_2(F.silu(t_2 + (t_1 * gn_2))) + + return f_2 + F.upsample_nearest(x_skip, scale_factor=2) + + +class ConvUNetVAE(nn.Module): + def __init__(self) -> None: + super().__init__() + self.embed_image = ImageEmbedding() + self.embed_time = TimestepEmbedding_() + + down_0 = nn.ModuleList( + [ + ConvResblock(320, 320), + ConvResblock(320, 320), + ConvResblock(320, 320), + Downsample(320), + ] + ) + down_1 = nn.ModuleList( + [ + ConvResblock(320, 640), + ConvResblock(640, 640), + ConvResblock(640, 640), + Downsample(640), + ] + ) + down_2 = nn.ModuleList( + [ + ConvResblock(640, 1024), + ConvResblock(1024, 1024), + ConvResblock(1024, 1024), + Downsample(1024), + ] + ) + down_3 = nn.ModuleList( + [ + ConvResblock(1024, 1024), + ConvResblock(1024, 1024), + ConvResblock(1024, 1024), + ] + ) + self.down = nn.ModuleList( + [ + down_0, + down_1, + down_2, + down_3, + ] + ) + + self.mid = nn.ModuleList( + [ + ConvResblock(1024, 1024), + ConvResblock(1024, 1024), + ] + ) + + up_3 = nn.ModuleList( + [ + ConvResblock(1024 * 2, 1024), + ConvResblock(1024 * 2, 1024), + ConvResblock(1024 * 2, 1024), + ConvResblock(1024 * 2, 1024), + Upsample(1024), + ] + ) + up_2 = nn.ModuleList( + [ + ConvResblock(1024 * 2, 1024), + ConvResblock(1024 * 2, 1024), + ConvResblock(1024 * 2, 1024), + ConvResblock(1024 + 640, 1024), + Upsample(1024), + ] + ) + up_1 = nn.ModuleList( + [ + ConvResblock(1024 + 640, 640), + ConvResblock(640 * 2, 640), + ConvResblock(640 * 2, 640), + ConvResblock(320 + 640, 640), + Upsample(640), + ] + ) + up_0 = nn.ModuleList( + [ + ConvResblock(320 + 640, 320), + ConvResblock(320 * 2, 320), + ConvResblock(320 * 2, 320), + ConvResblock(320 * 2, 320), + ] + ) + self.up = nn.ModuleList( + [ + up_0, + up_1, + up_2, + up_3, + ] + ) + + self.output = ImageUnembedding() + + def forward(self, x, t, features) -> torch.Tensor: + converted = hasattr(self, "converted") and self.converted + + x = torch.cat([x, F.upsample_nearest(features, scale_factor=8)], dim=1) + + if converted: + t = self.time_embedding(self.time_proj(t)) + else: + t = self.embed_time(t) + + x = self.embed_image(x) + + skips = [x] + for i, down in enumerate(self.down): + if converted and i in [0, 1, 2, 3]: + x, skips_ = down(x, t) + for skip in skips_: + skips.append(skip) + else: + for block in down: + x = block(x, t) + skips.append(x) + print(x.float().abs().sum()) + + if converted: + x = self.mid(x, t) + else: + for i in range(2): + x = self.mid[i](x, t) + print(x.float().abs().sum()) + + for i, up in enumerate(self.up[::-1]): + if converted and i in [0, 1, 2, 3]: + skip_4 = skips.pop() + skip_3 = skips.pop() + skip_2 = skips.pop() + skip_1 = skips.pop() + skips_ = (skip_1, skip_2, skip_3, skip_4) + x = up(x, skips_, t) + else: + for block in up: + if isinstance(block, ConvResblock): + x = torch.concat([x, skips.pop()], dim=1) + x = block(x, t) + + return self.output(x) + + +def rename_state_dict_key(k): + k = k.replace("blocks.", "") + for i in range(5): + k = k.replace(f"down_{i}_", f"down.{i}.") + k = k.replace(f"conv_{i}.", f"{i}.") + k = k.replace(f"up_{i}_", f"up.{i}.") + k = k.replace(f"mid_{i}", f"mid.{i}") + k = k.replace("upsamp.", "4.") + k = k.replace("downsamp.", "3.") + k = k.replace("f_t.w", "f_t.weight").replace("f_t.b", "f_t.bias") + k = k.replace("f_1.w", "f_1.weight").replace("f_1.b", "f_1.bias") + k = k.replace("f_2.w", "f_2.weight").replace("f_2.b", "f_2.bias") + k = k.replace("f_s.w", "f_s.weight").replace("f_s.b", "f_s.bias") + k = k.replace("f.w", "f.weight").replace("f.b", "f.bias") + k = k.replace("gn_1.g", "gn_1.weight").replace("gn_1.b", "gn_1.bias") + k = k.replace("gn_2.g", "gn_2.weight").replace("gn_2.b", "gn_2.bias") + k = k.replace("gn.g", "gn.weight").replace("gn.b", "gn.bias") + return k + + +def rename_state_dict(sd, embedding): + sd = {rename_state_dict_key(k): v for k, v in sd.items()} + sd["embed_time.emb.weight"] = embedding["weight"] + return sd + + +# encode with stable diffusion vae +pipe = StableDiffusionPipeline.from_pretrained( + "stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16 +) +pipe.vae.cuda() + +# construct original decoder with jitted model +decoder_consistency = ConsistencyDecoder(device="cuda:0") + +# construct UNet code, overwrite the decoder with conv_unet_vae +model = ConvUNetVAE() +model.load_state_dict( + rename_state_dict( + stl("consistency_decoder.safetensors"), + stl("embedding.safetensors"), + ) +) +model = model.cuda() + +decoder_consistency.ckpt = model + +image = load_image(args.test_image, size=(256, 256), center_crop=True) +latent = pipe.vae.encode(image.half().cuda()).latent_dist.sample() + +# decode with gan +sample_gan = pipe.vae.decode(latent).sample.detach() +save_image(sample_gan, "gan.png") + +# decode with conv_unet_vae +sample_consistency_orig = decoder_consistency(latent, generator=torch.Generator("cpu").manual_seed(0)) +save_image(sample_consistency_orig, "con_orig.png") + + +########### conversion + +print("CONVERSION") + +print("DOWN BLOCK ONE") + +block_one_sd_orig = model.down[0].state_dict() +block_one_sd_new = {} + +for i in range(3): + block_one_sd_new[f"resnets.{i}.norm1.weight"] = block_one_sd_orig.pop(f"{i}.gn_1.weight") + block_one_sd_new[f"resnets.{i}.norm1.bias"] = block_one_sd_orig.pop(f"{i}.gn_1.bias") + block_one_sd_new[f"resnets.{i}.conv1.weight"] = block_one_sd_orig.pop(f"{i}.f_1.weight") + block_one_sd_new[f"resnets.{i}.conv1.bias"] = block_one_sd_orig.pop(f"{i}.f_1.bias") + block_one_sd_new[f"resnets.{i}.time_emb_proj.weight"] = block_one_sd_orig.pop(f"{i}.f_t.weight") + block_one_sd_new[f"resnets.{i}.time_emb_proj.bias"] = block_one_sd_orig.pop(f"{i}.f_t.bias") + block_one_sd_new[f"resnets.{i}.norm2.weight"] = block_one_sd_orig.pop(f"{i}.gn_2.weight") + block_one_sd_new[f"resnets.{i}.norm2.bias"] = block_one_sd_orig.pop(f"{i}.gn_2.bias") + block_one_sd_new[f"resnets.{i}.conv2.weight"] = block_one_sd_orig.pop(f"{i}.f_2.weight") + block_one_sd_new[f"resnets.{i}.conv2.bias"] = block_one_sd_orig.pop(f"{i}.f_2.bias") + +block_one_sd_new["downsamplers.0.norm1.weight"] = block_one_sd_orig.pop("3.gn_1.weight") +block_one_sd_new["downsamplers.0.norm1.bias"] = block_one_sd_orig.pop("3.gn_1.bias") +block_one_sd_new["downsamplers.0.conv1.weight"] = block_one_sd_orig.pop("3.f_1.weight") +block_one_sd_new["downsamplers.0.conv1.bias"] = block_one_sd_orig.pop("3.f_1.bias") +block_one_sd_new["downsamplers.0.time_emb_proj.weight"] = block_one_sd_orig.pop("3.f_t.weight") +block_one_sd_new["downsamplers.0.time_emb_proj.bias"] = block_one_sd_orig.pop("3.f_t.bias") +block_one_sd_new["downsamplers.0.norm2.weight"] = block_one_sd_orig.pop("3.gn_2.weight") +block_one_sd_new["downsamplers.0.norm2.bias"] = block_one_sd_orig.pop("3.gn_2.bias") +block_one_sd_new["downsamplers.0.conv2.weight"] = block_one_sd_orig.pop("3.f_2.weight") +block_one_sd_new["downsamplers.0.conv2.bias"] = block_one_sd_orig.pop("3.f_2.bias") + +assert len(block_one_sd_orig) == 0 + +block_one = ResnetDownsampleBlock2D( + in_channels=320, + out_channels=320, + temb_channels=1280, + num_layers=3, + add_downsample=True, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +block_one.load_state_dict(block_one_sd_new) + +print("DOWN BLOCK TWO") + +block_two_sd_orig = model.down[1].state_dict() +block_two_sd_new = {} + +for i in range(3): + block_two_sd_new[f"resnets.{i}.norm1.weight"] = block_two_sd_orig.pop(f"{i}.gn_1.weight") + block_two_sd_new[f"resnets.{i}.norm1.bias"] = block_two_sd_orig.pop(f"{i}.gn_1.bias") + block_two_sd_new[f"resnets.{i}.conv1.weight"] = block_two_sd_orig.pop(f"{i}.f_1.weight") + block_two_sd_new[f"resnets.{i}.conv1.bias"] = block_two_sd_orig.pop(f"{i}.f_1.bias") + block_two_sd_new[f"resnets.{i}.time_emb_proj.weight"] = block_two_sd_orig.pop(f"{i}.f_t.weight") + block_two_sd_new[f"resnets.{i}.time_emb_proj.bias"] = block_two_sd_orig.pop(f"{i}.f_t.bias") + block_two_sd_new[f"resnets.{i}.norm2.weight"] = block_two_sd_orig.pop(f"{i}.gn_2.weight") + block_two_sd_new[f"resnets.{i}.norm2.bias"] = block_two_sd_orig.pop(f"{i}.gn_2.bias") + block_two_sd_new[f"resnets.{i}.conv2.weight"] = block_two_sd_orig.pop(f"{i}.f_2.weight") + block_two_sd_new[f"resnets.{i}.conv2.bias"] = block_two_sd_orig.pop(f"{i}.f_2.bias") + + if i == 0: + block_two_sd_new[f"resnets.{i}.conv_shortcut.weight"] = block_two_sd_orig.pop(f"{i}.f_s.weight") + block_two_sd_new[f"resnets.{i}.conv_shortcut.bias"] = block_two_sd_orig.pop(f"{i}.f_s.bias") + +block_two_sd_new["downsamplers.0.norm1.weight"] = block_two_sd_orig.pop("3.gn_1.weight") +block_two_sd_new["downsamplers.0.norm1.bias"] = block_two_sd_orig.pop("3.gn_1.bias") +block_two_sd_new["downsamplers.0.conv1.weight"] = block_two_sd_orig.pop("3.f_1.weight") +block_two_sd_new["downsamplers.0.conv1.bias"] = block_two_sd_orig.pop("3.f_1.bias") +block_two_sd_new["downsamplers.0.time_emb_proj.weight"] = block_two_sd_orig.pop("3.f_t.weight") +block_two_sd_new["downsamplers.0.time_emb_proj.bias"] = block_two_sd_orig.pop("3.f_t.bias") +block_two_sd_new["downsamplers.0.norm2.weight"] = block_two_sd_orig.pop("3.gn_2.weight") +block_two_sd_new["downsamplers.0.norm2.bias"] = block_two_sd_orig.pop("3.gn_2.bias") +block_two_sd_new["downsamplers.0.conv2.weight"] = block_two_sd_orig.pop("3.f_2.weight") +block_two_sd_new["downsamplers.0.conv2.bias"] = block_two_sd_orig.pop("3.f_2.bias") + +assert len(block_two_sd_orig) == 0 + +block_two = ResnetDownsampleBlock2D( + in_channels=320, + out_channels=640, + temb_channels=1280, + num_layers=3, + add_downsample=True, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +block_two.load_state_dict(block_two_sd_new) + +print("DOWN BLOCK THREE") + +block_three_sd_orig = model.down[2].state_dict() +block_three_sd_new = {} + +for i in range(3): + block_three_sd_new[f"resnets.{i}.norm1.weight"] = block_three_sd_orig.pop(f"{i}.gn_1.weight") + block_three_sd_new[f"resnets.{i}.norm1.bias"] = block_three_sd_orig.pop(f"{i}.gn_1.bias") + block_three_sd_new[f"resnets.{i}.conv1.weight"] = block_three_sd_orig.pop(f"{i}.f_1.weight") + block_three_sd_new[f"resnets.{i}.conv1.bias"] = block_three_sd_orig.pop(f"{i}.f_1.bias") + block_three_sd_new[f"resnets.{i}.time_emb_proj.weight"] = block_three_sd_orig.pop(f"{i}.f_t.weight") + block_three_sd_new[f"resnets.{i}.time_emb_proj.bias"] = block_three_sd_orig.pop(f"{i}.f_t.bias") + block_three_sd_new[f"resnets.{i}.norm2.weight"] = block_three_sd_orig.pop(f"{i}.gn_2.weight") + block_three_sd_new[f"resnets.{i}.norm2.bias"] = block_three_sd_orig.pop(f"{i}.gn_2.bias") + block_three_sd_new[f"resnets.{i}.conv2.weight"] = block_three_sd_orig.pop(f"{i}.f_2.weight") + block_three_sd_new[f"resnets.{i}.conv2.bias"] = block_three_sd_orig.pop(f"{i}.f_2.bias") + + if i == 0: + block_three_sd_new[f"resnets.{i}.conv_shortcut.weight"] = block_three_sd_orig.pop(f"{i}.f_s.weight") + block_three_sd_new[f"resnets.{i}.conv_shortcut.bias"] = block_three_sd_orig.pop(f"{i}.f_s.bias") + +block_three_sd_new["downsamplers.0.norm1.weight"] = block_three_sd_orig.pop("3.gn_1.weight") +block_three_sd_new["downsamplers.0.norm1.bias"] = block_three_sd_orig.pop("3.gn_1.bias") +block_three_sd_new["downsamplers.0.conv1.weight"] = block_three_sd_orig.pop("3.f_1.weight") +block_three_sd_new["downsamplers.0.conv1.bias"] = block_three_sd_orig.pop("3.f_1.bias") +block_three_sd_new["downsamplers.0.time_emb_proj.weight"] = block_three_sd_orig.pop("3.f_t.weight") +block_three_sd_new["downsamplers.0.time_emb_proj.bias"] = block_three_sd_orig.pop("3.f_t.bias") +block_three_sd_new["downsamplers.0.norm2.weight"] = block_three_sd_orig.pop("3.gn_2.weight") +block_three_sd_new["downsamplers.0.norm2.bias"] = block_three_sd_orig.pop("3.gn_2.bias") +block_three_sd_new["downsamplers.0.conv2.weight"] = block_three_sd_orig.pop("3.f_2.weight") +block_three_sd_new["downsamplers.0.conv2.bias"] = block_three_sd_orig.pop("3.f_2.bias") + +assert len(block_three_sd_orig) == 0 + +block_three = ResnetDownsampleBlock2D( + in_channels=640, + out_channels=1024, + temb_channels=1280, + num_layers=3, + add_downsample=True, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +block_three.load_state_dict(block_three_sd_new) + +print("DOWN BLOCK FOUR") + +block_four_sd_orig = model.down[3].state_dict() +block_four_sd_new = {} + +for i in range(3): + block_four_sd_new[f"resnets.{i}.norm1.weight"] = block_four_sd_orig.pop(f"{i}.gn_1.weight") + block_four_sd_new[f"resnets.{i}.norm1.bias"] = block_four_sd_orig.pop(f"{i}.gn_1.bias") + block_four_sd_new[f"resnets.{i}.conv1.weight"] = block_four_sd_orig.pop(f"{i}.f_1.weight") + block_four_sd_new[f"resnets.{i}.conv1.bias"] = block_four_sd_orig.pop(f"{i}.f_1.bias") + block_four_sd_new[f"resnets.{i}.time_emb_proj.weight"] = block_four_sd_orig.pop(f"{i}.f_t.weight") + block_four_sd_new[f"resnets.{i}.time_emb_proj.bias"] = block_four_sd_orig.pop(f"{i}.f_t.bias") + block_four_sd_new[f"resnets.{i}.norm2.weight"] = block_four_sd_orig.pop(f"{i}.gn_2.weight") + block_four_sd_new[f"resnets.{i}.norm2.bias"] = block_four_sd_orig.pop(f"{i}.gn_2.bias") + block_four_sd_new[f"resnets.{i}.conv2.weight"] = block_four_sd_orig.pop(f"{i}.f_2.weight") + block_four_sd_new[f"resnets.{i}.conv2.bias"] = block_four_sd_orig.pop(f"{i}.f_2.bias") + +assert len(block_four_sd_orig) == 0 + +block_four = ResnetDownsampleBlock2D( + in_channels=1024, + out_channels=1024, + temb_channels=1280, + num_layers=3, + add_downsample=False, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +block_four.load_state_dict(block_four_sd_new) + + +print("MID BLOCK 1") + +mid_block_one_sd_orig = model.mid.state_dict() +mid_block_one_sd_new = {} + +for i in range(2): + mid_block_one_sd_new[f"resnets.{i}.norm1.weight"] = mid_block_one_sd_orig.pop(f"{i}.gn_1.weight") + mid_block_one_sd_new[f"resnets.{i}.norm1.bias"] = mid_block_one_sd_orig.pop(f"{i}.gn_1.bias") + mid_block_one_sd_new[f"resnets.{i}.conv1.weight"] = mid_block_one_sd_orig.pop(f"{i}.f_1.weight") + mid_block_one_sd_new[f"resnets.{i}.conv1.bias"] = mid_block_one_sd_orig.pop(f"{i}.f_1.bias") + mid_block_one_sd_new[f"resnets.{i}.time_emb_proj.weight"] = mid_block_one_sd_orig.pop(f"{i}.f_t.weight") + mid_block_one_sd_new[f"resnets.{i}.time_emb_proj.bias"] = mid_block_one_sd_orig.pop(f"{i}.f_t.bias") + mid_block_one_sd_new[f"resnets.{i}.norm2.weight"] = mid_block_one_sd_orig.pop(f"{i}.gn_2.weight") + mid_block_one_sd_new[f"resnets.{i}.norm2.bias"] = mid_block_one_sd_orig.pop(f"{i}.gn_2.bias") + mid_block_one_sd_new[f"resnets.{i}.conv2.weight"] = mid_block_one_sd_orig.pop(f"{i}.f_2.weight") + mid_block_one_sd_new[f"resnets.{i}.conv2.bias"] = mid_block_one_sd_orig.pop(f"{i}.f_2.bias") + +assert len(mid_block_one_sd_orig) == 0 + +mid_block_one = UNetMidBlock2D( + in_channels=1024, + temb_channels=1280, + num_layers=1, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, + add_attention=False, +) + +mid_block_one.load_state_dict(mid_block_one_sd_new) + +print("UP BLOCK ONE") + +up_block_one_sd_orig = model.up[-1].state_dict() +up_block_one_sd_new = {} + +for i in range(4): + up_block_one_sd_new[f"resnets.{i}.norm1.weight"] = up_block_one_sd_orig.pop(f"{i}.gn_1.weight") + up_block_one_sd_new[f"resnets.{i}.norm1.bias"] = up_block_one_sd_orig.pop(f"{i}.gn_1.bias") + up_block_one_sd_new[f"resnets.{i}.conv1.weight"] = up_block_one_sd_orig.pop(f"{i}.f_1.weight") + up_block_one_sd_new[f"resnets.{i}.conv1.bias"] = up_block_one_sd_orig.pop(f"{i}.f_1.bias") + up_block_one_sd_new[f"resnets.{i}.time_emb_proj.weight"] = up_block_one_sd_orig.pop(f"{i}.f_t.weight") + up_block_one_sd_new[f"resnets.{i}.time_emb_proj.bias"] = up_block_one_sd_orig.pop(f"{i}.f_t.bias") + up_block_one_sd_new[f"resnets.{i}.norm2.weight"] = up_block_one_sd_orig.pop(f"{i}.gn_2.weight") + up_block_one_sd_new[f"resnets.{i}.norm2.bias"] = up_block_one_sd_orig.pop(f"{i}.gn_2.bias") + up_block_one_sd_new[f"resnets.{i}.conv2.weight"] = up_block_one_sd_orig.pop(f"{i}.f_2.weight") + up_block_one_sd_new[f"resnets.{i}.conv2.bias"] = up_block_one_sd_orig.pop(f"{i}.f_2.bias") + up_block_one_sd_new[f"resnets.{i}.conv_shortcut.weight"] = up_block_one_sd_orig.pop(f"{i}.f_s.weight") + up_block_one_sd_new[f"resnets.{i}.conv_shortcut.bias"] = up_block_one_sd_orig.pop(f"{i}.f_s.bias") + +up_block_one_sd_new["upsamplers.0.norm1.weight"] = up_block_one_sd_orig.pop("4.gn_1.weight") +up_block_one_sd_new["upsamplers.0.norm1.bias"] = up_block_one_sd_orig.pop("4.gn_1.bias") +up_block_one_sd_new["upsamplers.0.conv1.weight"] = up_block_one_sd_orig.pop("4.f_1.weight") +up_block_one_sd_new["upsamplers.0.conv1.bias"] = up_block_one_sd_orig.pop("4.f_1.bias") +up_block_one_sd_new["upsamplers.0.time_emb_proj.weight"] = up_block_one_sd_orig.pop("4.f_t.weight") +up_block_one_sd_new["upsamplers.0.time_emb_proj.bias"] = up_block_one_sd_orig.pop("4.f_t.bias") +up_block_one_sd_new["upsamplers.0.norm2.weight"] = up_block_one_sd_orig.pop("4.gn_2.weight") +up_block_one_sd_new["upsamplers.0.norm2.bias"] = up_block_one_sd_orig.pop("4.gn_2.bias") +up_block_one_sd_new["upsamplers.0.conv2.weight"] = up_block_one_sd_orig.pop("4.f_2.weight") +up_block_one_sd_new["upsamplers.0.conv2.bias"] = up_block_one_sd_orig.pop("4.f_2.bias") + +assert len(up_block_one_sd_orig) == 0 + +up_block_one = ResnetUpsampleBlock2D( + in_channels=1024, + prev_output_channel=1024, + out_channels=1024, + temb_channels=1280, + num_layers=4, + add_upsample=True, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +up_block_one.load_state_dict(up_block_one_sd_new) + +print("UP BLOCK TWO") + +up_block_two_sd_orig = model.up[-2].state_dict() +up_block_two_sd_new = {} + +for i in range(4): + up_block_two_sd_new[f"resnets.{i}.norm1.weight"] = up_block_two_sd_orig.pop(f"{i}.gn_1.weight") + up_block_two_sd_new[f"resnets.{i}.norm1.bias"] = up_block_two_sd_orig.pop(f"{i}.gn_1.bias") + up_block_two_sd_new[f"resnets.{i}.conv1.weight"] = up_block_two_sd_orig.pop(f"{i}.f_1.weight") + up_block_two_sd_new[f"resnets.{i}.conv1.bias"] = up_block_two_sd_orig.pop(f"{i}.f_1.bias") + up_block_two_sd_new[f"resnets.{i}.time_emb_proj.weight"] = up_block_two_sd_orig.pop(f"{i}.f_t.weight") + up_block_two_sd_new[f"resnets.{i}.time_emb_proj.bias"] = up_block_two_sd_orig.pop(f"{i}.f_t.bias") + up_block_two_sd_new[f"resnets.{i}.norm2.weight"] = up_block_two_sd_orig.pop(f"{i}.gn_2.weight") + up_block_two_sd_new[f"resnets.{i}.norm2.bias"] = up_block_two_sd_orig.pop(f"{i}.gn_2.bias") + up_block_two_sd_new[f"resnets.{i}.conv2.weight"] = up_block_two_sd_orig.pop(f"{i}.f_2.weight") + up_block_two_sd_new[f"resnets.{i}.conv2.bias"] = up_block_two_sd_orig.pop(f"{i}.f_2.bias") + up_block_two_sd_new[f"resnets.{i}.conv_shortcut.weight"] = up_block_two_sd_orig.pop(f"{i}.f_s.weight") + up_block_two_sd_new[f"resnets.{i}.conv_shortcut.bias"] = up_block_two_sd_orig.pop(f"{i}.f_s.bias") + +up_block_two_sd_new["upsamplers.0.norm1.weight"] = up_block_two_sd_orig.pop("4.gn_1.weight") +up_block_two_sd_new["upsamplers.0.norm1.bias"] = up_block_two_sd_orig.pop("4.gn_1.bias") +up_block_two_sd_new["upsamplers.0.conv1.weight"] = up_block_two_sd_orig.pop("4.f_1.weight") +up_block_two_sd_new["upsamplers.0.conv1.bias"] = up_block_two_sd_orig.pop("4.f_1.bias") +up_block_two_sd_new["upsamplers.0.time_emb_proj.weight"] = up_block_two_sd_orig.pop("4.f_t.weight") +up_block_two_sd_new["upsamplers.0.time_emb_proj.bias"] = up_block_two_sd_orig.pop("4.f_t.bias") +up_block_two_sd_new["upsamplers.0.norm2.weight"] = up_block_two_sd_orig.pop("4.gn_2.weight") +up_block_two_sd_new["upsamplers.0.norm2.bias"] = up_block_two_sd_orig.pop("4.gn_2.bias") +up_block_two_sd_new["upsamplers.0.conv2.weight"] = up_block_two_sd_orig.pop("4.f_2.weight") +up_block_two_sd_new["upsamplers.0.conv2.bias"] = up_block_two_sd_orig.pop("4.f_2.bias") + +assert len(up_block_two_sd_orig) == 0 + +up_block_two = ResnetUpsampleBlock2D( + in_channels=640, + prev_output_channel=1024, + out_channels=1024, + temb_channels=1280, + num_layers=4, + add_upsample=True, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +up_block_two.load_state_dict(up_block_two_sd_new) + +print("UP BLOCK THREE") + +up_block_three_sd_orig = model.up[-3].state_dict() +up_block_three_sd_new = {} + +for i in range(4): + up_block_three_sd_new[f"resnets.{i}.norm1.weight"] = up_block_three_sd_orig.pop(f"{i}.gn_1.weight") + up_block_three_sd_new[f"resnets.{i}.norm1.bias"] = up_block_three_sd_orig.pop(f"{i}.gn_1.bias") + up_block_three_sd_new[f"resnets.{i}.conv1.weight"] = up_block_three_sd_orig.pop(f"{i}.f_1.weight") + up_block_three_sd_new[f"resnets.{i}.conv1.bias"] = up_block_three_sd_orig.pop(f"{i}.f_1.bias") + up_block_three_sd_new[f"resnets.{i}.time_emb_proj.weight"] = up_block_three_sd_orig.pop(f"{i}.f_t.weight") + up_block_three_sd_new[f"resnets.{i}.time_emb_proj.bias"] = up_block_three_sd_orig.pop(f"{i}.f_t.bias") + up_block_three_sd_new[f"resnets.{i}.norm2.weight"] = up_block_three_sd_orig.pop(f"{i}.gn_2.weight") + up_block_three_sd_new[f"resnets.{i}.norm2.bias"] = up_block_three_sd_orig.pop(f"{i}.gn_2.bias") + up_block_three_sd_new[f"resnets.{i}.conv2.weight"] = up_block_three_sd_orig.pop(f"{i}.f_2.weight") + up_block_three_sd_new[f"resnets.{i}.conv2.bias"] = up_block_three_sd_orig.pop(f"{i}.f_2.bias") + up_block_three_sd_new[f"resnets.{i}.conv_shortcut.weight"] = up_block_three_sd_orig.pop(f"{i}.f_s.weight") + up_block_three_sd_new[f"resnets.{i}.conv_shortcut.bias"] = up_block_three_sd_orig.pop(f"{i}.f_s.bias") + +up_block_three_sd_new["upsamplers.0.norm1.weight"] = up_block_three_sd_orig.pop("4.gn_1.weight") +up_block_three_sd_new["upsamplers.0.norm1.bias"] = up_block_three_sd_orig.pop("4.gn_1.bias") +up_block_three_sd_new["upsamplers.0.conv1.weight"] = up_block_three_sd_orig.pop("4.f_1.weight") +up_block_three_sd_new["upsamplers.0.conv1.bias"] = up_block_three_sd_orig.pop("4.f_1.bias") +up_block_three_sd_new["upsamplers.0.time_emb_proj.weight"] = up_block_three_sd_orig.pop("4.f_t.weight") +up_block_three_sd_new["upsamplers.0.time_emb_proj.bias"] = up_block_three_sd_orig.pop("4.f_t.bias") +up_block_three_sd_new["upsamplers.0.norm2.weight"] = up_block_three_sd_orig.pop("4.gn_2.weight") +up_block_three_sd_new["upsamplers.0.norm2.bias"] = up_block_three_sd_orig.pop("4.gn_2.bias") +up_block_three_sd_new["upsamplers.0.conv2.weight"] = up_block_three_sd_orig.pop("4.f_2.weight") +up_block_three_sd_new["upsamplers.0.conv2.bias"] = up_block_three_sd_orig.pop("4.f_2.bias") + +assert len(up_block_three_sd_orig) == 0 + +up_block_three = ResnetUpsampleBlock2D( + in_channels=320, + prev_output_channel=1024, + out_channels=640, + temb_channels=1280, + num_layers=4, + add_upsample=True, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +up_block_three.load_state_dict(up_block_three_sd_new) + +print("UP BLOCK FOUR") + +up_block_four_sd_orig = model.up[-4].state_dict() +up_block_four_sd_new = {} + +for i in range(4): + up_block_four_sd_new[f"resnets.{i}.norm1.weight"] = up_block_four_sd_orig.pop(f"{i}.gn_1.weight") + up_block_four_sd_new[f"resnets.{i}.norm1.bias"] = up_block_four_sd_orig.pop(f"{i}.gn_1.bias") + up_block_four_sd_new[f"resnets.{i}.conv1.weight"] = up_block_four_sd_orig.pop(f"{i}.f_1.weight") + up_block_four_sd_new[f"resnets.{i}.conv1.bias"] = up_block_four_sd_orig.pop(f"{i}.f_1.bias") + up_block_four_sd_new[f"resnets.{i}.time_emb_proj.weight"] = up_block_four_sd_orig.pop(f"{i}.f_t.weight") + up_block_four_sd_new[f"resnets.{i}.time_emb_proj.bias"] = up_block_four_sd_orig.pop(f"{i}.f_t.bias") + up_block_four_sd_new[f"resnets.{i}.norm2.weight"] = up_block_four_sd_orig.pop(f"{i}.gn_2.weight") + up_block_four_sd_new[f"resnets.{i}.norm2.bias"] = up_block_four_sd_orig.pop(f"{i}.gn_2.bias") + up_block_four_sd_new[f"resnets.{i}.conv2.weight"] = up_block_four_sd_orig.pop(f"{i}.f_2.weight") + up_block_four_sd_new[f"resnets.{i}.conv2.bias"] = up_block_four_sd_orig.pop(f"{i}.f_2.bias") + up_block_four_sd_new[f"resnets.{i}.conv_shortcut.weight"] = up_block_four_sd_orig.pop(f"{i}.f_s.weight") + up_block_four_sd_new[f"resnets.{i}.conv_shortcut.bias"] = up_block_four_sd_orig.pop(f"{i}.f_s.bias") + +assert len(up_block_four_sd_orig) == 0 + +up_block_four = ResnetUpsampleBlock2D( + in_channels=320, + prev_output_channel=640, + out_channels=320, + temb_channels=1280, + num_layers=4, + add_upsample=False, + resnet_time_scale_shift="scale_shift", + resnet_eps=1e-5, +) + +up_block_four.load_state_dict(up_block_four_sd_new) + +print("initial projection (conv_in)") + +conv_in_sd_orig = model.embed_image.state_dict() +conv_in_sd_new = {} + +conv_in_sd_new["weight"] = conv_in_sd_orig.pop("f.weight") +conv_in_sd_new["bias"] = conv_in_sd_orig.pop("f.bias") + +assert len(conv_in_sd_orig) == 0 + +block_out_channels = [320, 640, 1024, 1024] + +in_channels = 7 +conv_in_kernel = 3 +conv_in_padding = (conv_in_kernel - 1) // 2 +conv_in = nn.Conv2d(in_channels, block_out_channels[0], kernel_size=conv_in_kernel, padding=conv_in_padding) + +conv_in.load_state_dict(conv_in_sd_new) + +print("out projection (conv_out) (conv_norm_out)") +out_channels = 6 +norm_num_groups = 32 +norm_eps = 1e-5 +act_fn = "silu" +conv_out_kernel = 3 +conv_out_padding = (conv_out_kernel - 1) // 2 +conv_norm_out = nn.GroupNorm(num_channels=block_out_channels[0], num_groups=norm_num_groups, eps=norm_eps) +# uses torch.functional in orig +# conv_act = get_activation(act_fn) +conv_out = nn.Conv2d(block_out_channels[0], out_channels, kernel_size=conv_out_kernel, padding=conv_out_padding) + +conv_norm_out.load_state_dict(model.output.gn.state_dict()) +conv_out.load_state_dict(model.output.f.state_dict()) + +print("timestep projection (time_proj) (time_embedding)") + +f1_sd = model.embed_time.f_1.state_dict() +f2_sd = model.embed_time.f_2.state_dict() + +time_embedding_sd = { + "linear_1.weight": f1_sd.pop("weight"), + "linear_1.bias": f1_sd.pop("bias"), + "linear_2.weight": f2_sd.pop("weight"), + "linear_2.bias": f2_sd.pop("bias"), +} + +assert len(f1_sd) == 0 +assert len(f2_sd) == 0 + +time_embedding_type = "learned" +num_train_timesteps = 1024 +time_embedding_dim = 1280 + +time_proj = nn.Embedding(num_train_timesteps, block_out_channels[0]) +timestep_input_dim = block_out_channels[0] + +time_embedding = TimestepEmbedding(timestep_input_dim, time_embedding_dim) + +time_proj.load_state_dict(model.embed_time.emb.state_dict()) +time_embedding.load_state_dict(time_embedding_sd) + +print("CONVERT") + +time_embedding.to("cuda") +time_proj.to("cuda") +conv_in.to("cuda") + +block_one.to("cuda") +block_two.to("cuda") +block_three.to("cuda") +block_four.to("cuda") + +mid_block_one.to("cuda") + +up_block_one.to("cuda") +up_block_two.to("cuda") +up_block_three.to("cuda") +up_block_four.to("cuda") + +conv_norm_out.to("cuda") +conv_out.to("cuda") + +model.time_proj = time_proj +model.time_embedding = time_embedding +model.embed_image = conv_in + +model.down[0] = block_one +model.down[1] = block_two +model.down[2] = block_three +model.down[3] = block_four + +model.mid = mid_block_one + +model.up[-1] = up_block_one +model.up[-2] = up_block_two +model.up[-3] = up_block_three +model.up[-4] = up_block_four + +model.output.gn = conv_norm_out +model.output.f = conv_out + +model.converted = True + +sample_consistency_new = decoder_consistency(latent, generator=torch.Generator("cpu").manual_seed(0)) +save_image(sample_consistency_new, "con_new.png") + +assert (sample_consistency_orig == sample_consistency_new).all() + +print("making unet") + +unet = UNet2DModel( + in_channels=in_channels, + out_channels=out_channels, + down_block_types=( + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + ), + up_block_types=( + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + ), + block_out_channels=block_out_channels, + layers_per_block=3, + norm_num_groups=norm_num_groups, + norm_eps=norm_eps, + resnet_time_scale_shift="scale_shift", + time_embedding_type="learned", + num_train_timesteps=num_train_timesteps, + add_attention=False, +) + +unet_state_dict = {} + + +def add_state_dict(prefix, mod): + for k, v in mod.state_dict().items(): + unet_state_dict[f"{prefix}.{k}"] = v + + +add_state_dict("conv_in", conv_in) +add_state_dict("time_proj", time_proj) +add_state_dict("time_embedding", time_embedding) +add_state_dict("down_blocks.0", block_one) +add_state_dict("down_blocks.1", block_two) +add_state_dict("down_blocks.2", block_three) +add_state_dict("down_blocks.3", block_four) +add_state_dict("mid_block", mid_block_one) +add_state_dict("up_blocks.0", up_block_one) +add_state_dict("up_blocks.1", up_block_two) +add_state_dict("up_blocks.2", up_block_three) +add_state_dict("up_blocks.3", up_block_four) +add_state_dict("conv_norm_out", conv_norm_out) +add_state_dict("conv_out", conv_out) + +unet.load_state_dict(unet_state_dict) + +print("running with diffusers unet") + +unet.to("cuda") + +decoder_consistency.ckpt = unet + +sample_consistency_new_2 = decoder_consistency(latent, generator=torch.Generator("cpu").manual_seed(0)) +save_image(sample_consistency_new_2, "con_new_2.png") + +assert (sample_consistency_orig == sample_consistency_new_2).all() + +print("running with diffusers model") + +Encoder.old_constructor = Encoder.__init__ + + +def new_constructor(self, **kwargs): + self.old_constructor(**kwargs) + self.constructor_arguments = kwargs + + +Encoder.__init__ = new_constructor + + +vae = AutoencoderKL.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", subfolder="vae") +consistency_vae = ConsistencyDecoderVAE( + encoder_args=vae.encoder.constructor_arguments, + decoder_args=unet.config, + scaling_factor=vae.config.scaling_factor, + block_out_channels=vae.config.block_out_channels, + latent_channels=vae.config.latent_channels, +) +consistency_vae.encoder.load_state_dict(vae.encoder.state_dict()) +consistency_vae.quant_conv.load_state_dict(vae.quant_conv.state_dict()) +consistency_vae.decoder_unet.load_state_dict(unet.state_dict()) + +consistency_vae.to(dtype=torch.float16, device="cuda") + +sample_consistency_new_3 = consistency_vae.decode( + 0.18215 * latent, generator=torch.Generator("cpu").manual_seed(0) +).sample + +print("max difference") +print((sample_consistency_orig - sample_consistency_new_3).abs().max()) +print("total difference") +print((sample_consistency_orig - sample_consistency_new_3).abs().sum()) +# assert (sample_consistency_orig == sample_consistency_new_3).all() + +print("running with diffusers pipeline") + +pipe = DiffusionPipeline.from_pretrained( + "stable-diffusion-v1-5/stable-diffusion-v1-5", vae=consistency_vae, torch_dtype=torch.float16 +) +pipe.to("cuda") + +pipe("horse", generator=torch.Generator("cpu").manual_seed(0)).images[0].save("horse.png") + + +if args.save_pretrained is not None: + consistency_vae.save_pretrained(args.save_pretrained) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_consistency_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_consistency_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..2b918280ca055d0d89a15273ff69872f75c3d730 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_consistency_to_diffusers.py @@ -0,0 +1,315 @@ +import argparse +import os + +import torch + +from diffusers import ( + CMStochasticIterativeScheduler, + ConsistencyModelPipeline, + UNet2DModel, +) + + +TEST_UNET_CONFIG = { + "sample_size": 32, + "in_channels": 3, + "out_channels": 3, + "layers_per_block": 2, + "num_class_embeds": 1000, + "block_out_channels": [32, 64], + "attention_head_dim": 8, + "down_block_types": [ + "ResnetDownsampleBlock2D", + "AttnDownBlock2D", + ], + "up_block_types": [ + "AttnUpBlock2D", + "ResnetUpsampleBlock2D", + ], + "resnet_time_scale_shift": "scale_shift", + "attn_norm_num_groups": 32, + "upsample_type": "resnet", + "downsample_type": "resnet", +} + +IMAGENET_64_UNET_CONFIG = { + "sample_size": 64, + "in_channels": 3, + "out_channels": 3, + "layers_per_block": 3, + "num_class_embeds": 1000, + "block_out_channels": [192, 192 * 2, 192 * 3, 192 * 4], + "attention_head_dim": 64, + "down_block_types": [ + "ResnetDownsampleBlock2D", + "AttnDownBlock2D", + "AttnDownBlock2D", + "AttnDownBlock2D", + ], + "up_block_types": [ + "AttnUpBlock2D", + "AttnUpBlock2D", + "AttnUpBlock2D", + "ResnetUpsampleBlock2D", + ], + "resnet_time_scale_shift": "scale_shift", + "attn_norm_num_groups": 32, + "upsample_type": "resnet", + "downsample_type": "resnet", +} + +LSUN_256_UNET_CONFIG = { + "sample_size": 256, + "in_channels": 3, + "out_channels": 3, + "layers_per_block": 2, + "num_class_embeds": None, + "block_out_channels": [256, 256, 256 * 2, 256 * 2, 256 * 4, 256 * 4], + "attention_head_dim": 64, + "down_block_types": [ + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "AttnDownBlock2D", + "AttnDownBlock2D", + "AttnDownBlock2D", + ], + "up_block_types": [ + "AttnUpBlock2D", + "AttnUpBlock2D", + "AttnUpBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + ], + "resnet_time_scale_shift": "default", + "upsample_type": "resnet", + "downsample_type": "resnet", +} + +CD_SCHEDULER_CONFIG = { + "num_train_timesteps": 40, + "sigma_min": 0.002, + "sigma_max": 80.0, +} + +CT_IMAGENET_64_SCHEDULER_CONFIG = { + "num_train_timesteps": 201, + "sigma_min": 0.002, + "sigma_max": 80.0, +} + +CT_LSUN_256_SCHEDULER_CONFIG = { + "num_train_timesteps": 151, + "sigma_min": 0.002, + "sigma_max": 80.0, +} + + +def str2bool(v): + """ + https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse + """ + if isinstance(v, bool): + return v + if v.lower() in ("yes", "true", "t", "y", "1"): + return True + elif v.lower() in ("no", "false", "f", "n", "0"): + return False + else: + raise argparse.ArgumentTypeError("boolean value expected") + + +def convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=False): + new_checkpoint[f"{new_prefix}.norm1.weight"] = checkpoint[f"{old_prefix}.in_layers.0.weight"] + new_checkpoint[f"{new_prefix}.norm1.bias"] = checkpoint[f"{old_prefix}.in_layers.0.bias"] + new_checkpoint[f"{new_prefix}.conv1.weight"] = checkpoint[f"{old_prefix}.in_layers.2.weight"] + new_checkpoint[f"{new_prefix}.conv1.bias"] = checkpoint[f"{old_prefix}.in_layers.2.bias"] + new_checkpoint[f"{new_prefix}.time_emb_proj.weight"] = checkpoint[f"{old_prefix}.emb_layers.1.weight"] + new_checkpoint[f"{new_prefix}.time_emb_proj.bias"] = checkpoint[f"{old_prefix}.emb_layers.1.bias"] + new_checkpoint[f"{new_prefix}.norm2.weight"] = checkpoint[f"{old_prefix}.out_layers.0.weight"] + new_checkpoint[f"{new_prefix}.norm2.bias"] = checkpoint[f"{old_prefix}.out_layers.0.bias"] + new_checkpoint[f"{new_prefix}.conv2.weight"] = checkpoint[f"{old_prefix}.out_layers.3.weight"] + new_checkpoint[f"{new_prefix}.conv2.bias"] = checkpoint[f"{old_prefix}.out_layers.3.bias"] + + if has_skip: + new_checkpoint[f"{new_prefix}.conv_shortcut.weight"] = checkpoint[f"{old_prefix}.skip_connection.weight"] + new_checkpoint[f"{new_prefix}.conv_shortcut.bias"] = checkpoint[f"{old_prefix}.skip_connection.bias"] + + return new_checkpoint + + +def convert_attention(checkpoint, new_checkpoint, old_prefix, new_prefix, attention_dim=None): + weight_q, weight_k, weight_v = checkpoint[f"{old_prefix}.qkv.weight"].chunk(3, dim=0) + bias_q, bias_k, bias_v = checkpoint[f"{old_prefix}.qkv.bias"].chunk(3, dim=0) + + new_checkpoint[f"{new_prefix}.group_norm.weight"] = checkpoint[f"{old_prefix}.norm.weight"] + new_checkpoint[f"{new_prefix}.group_norm.bias"] = checkpoint[f"{old_prefix}.norm.bias"] + + new_checkpoint[f"{new_prefix}.to_q.weight"] = weight_q.squeeze(-1).squeeze(-1) + new_checkpoint[f"{new_prefix}.to_q.bias"] = bias_q.squeeze(-1).squeeze(-1) + new_checkpoint[f"{new_prefix}.to_k.weight"] = weight_k.squeeze(-1).squeeze(-1) + new_checkpoint[f"{new_prefix}.to_k.bias"] = bias_k.squeeze(-1).squeeze(-1) + new_checkpoint[f"{new_prefix}.to_v.weight"] = weight_v.squeeze(-1).squeeze(-1) + new_checkpoint[f"{new_prefix}.to_v.bias"] = bias_v.squeeze(-1).squeeze(-1) + + new_checkpoint[f"{new_prefix}.to_out.0.weight"] = ( + checkpoint[f"{old_prefix}.proj_out.weight"].squeeze(-1).squeeze(-1) + ) + new_checkpoint[f"{new_prefix}.to_out.0.bias"] = checkpoint[f"{old_prefix}.proj_out.bias"].squeeze(-1).squeeze(-1) + + return new_checkpoint + + +def con_pt_to_diffuser(checkpoint_path: str, unet_config): + checkpoint = torch.load(checkpoint_path, map_location="cpu") + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = checkpoint["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = checkpoint["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = checkpoint["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = checkpoint["time_embed.2.bias"] + + if unet_config["num_class_embeds"] is not None: + new_checkpoint["class_embedding.weight"] = checkpoint["label_emb.weight"] + + new_checkpoint["conv_in.weight"] = checkpoint["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = checkpoint["input_blocks.0.0.bias"] + + down_block_types = unet_config["down_block_types"] + layers_per_block = unet_config["layers_per_block"] + attention_head_dim = unet_config["attention_head_dim"] + channels_list = unet_config["block_out_channels"] + current_layer = 1 + prev_channels = channels_list[0] + + for i, layer_type in enumerate(down_block_types): + current_channels = channels_list[i] + downsample_block_has_skip = current_channels != prev_channels + if layer_type == "ResnetDownsampleBlock2D": + for j in range(layers_per_block): + new_prefix = f"down_blocks.{i}.resnets.{j}" + old_prefix = f"input_blocks.{current_layer}.0" + has_skip = True if j == 0 and downsample_block_has_skip else False + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=has_skip) + current_layer += 1 + + elif layer_type == "AttnDownBlock2D": + for j in range(layers_per_block): + new_prefix = f"down_blocks.{i}.resnets.{j}" + old_prefix = f"input_blocks.{current_layer}.0" + has_skip = True if j == 0 and downsample_block_has_skip else False + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=has_skip) + new_prefix = f"down_blocks.{i}.attentions.{j}" + old_prefix = f"input_blocks.{current_layer}.1" + new_checkpoint = convert_attention( + checkpoint, new_checkpoint, old_prefix, new_prefix, attention_head_dim + ) + current_layer += 1 + + if i != len(down_block_types) - 1: + new_prefix = f"down_blocks.{i}.downsamplers.0" + old_prefix = f"input_blocks.{current_layer}.0" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix) + current_layer += 1 + + prev_channels = current_channels + + # hardcoded the mid-block for now + new_prefix = "mid_block.resnets.0" + old_prefix = "middle_block.0" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix) + new_prefix = "mid_block.attentions.0" + old_prefix = "middle_block.1" + new_checkpoint = convert_attention(checkpoint, new_checkpoint, old_prefix, new_prefix, attention_head_dim) + new_prefix = "mid_block.resnets.1" + old_prefix = "middle_block.2" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix) + + current_layer = 0 + up_block_types = unet_config["up_block_types"] + + for i, layer_type in enumerate(up_block_types): + if layer_type == "ResnetUpsampleBlock2D": + for j in range(layers_per_block + 1): + new_prefix = f"up_blocks.{i}.resnets.{j}" + old_prefix = f"output_blocks.{current_layer}.0" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=True) + current_layer += 1 + + if i != len(up_block_types) - 1: + new_prefix = f"up_blocks.{i}.upsamplers.0" + old_prefix = f"output_blocks.{current_layer - 1}.1" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix) + elif layer_type == "AttnUpBlock2D": + for j in range(layers_per_block + 1): + new_prefix = f"up_blocks.{i}.resnets.{j}" + old_prefix = f"output_blocks.{current_layer}.0" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=True) + new_prefix = f"up_blocks.{i}.attentions.{j}" + old_prefix = f"output_blocks.{current_layer}.1" + new_checkpoint = convert_attention( + checkpoint, new_checkpoint, old_prefix, new_prefix, attention_head_dim + ) + current_layer += 1 + + if i != len(up_block_types) - 1: + new_prefix = f"up_blocks.{i}.upsamplers.0" + old_prefix = f"output_blocks.{current_layer - 1}.2" + new_checkpoint = convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix) + + new_checkpoint["conv_norm_out.weight"] = checkpoint["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = checkpoint["out.0.bias"] + new_checkpoint["conv_out.weight"] = checkpoint["out.2.weight"] + new_checkpoint["conv_out.bias"] = checkpoint["out.2.bias"] + + return new_checkpoint + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--unet_path", default=None, type=str, required=True, help="Path to the unet.pt to convert.") + parser.add_argument( + "--dump_path", default=None, type=str, required=True, help="Path to output the converted UNet model." + ) + parser.add_argument("--class_cond", default=True, type=str, help="Whether the model is class-conditional.") + + args = parser.parse_args() + args.class_cond = str2bool(args.class_cond) + + ckpt_name = os.path.basename(args.unet_path) + print(f"Checkpoint: {ckpt_name}") + + # Get U-Net config + if "imagenet64" in ckpt_name: + unet_config = IMAGENET_64_UNET_CONFIG + elif "256" in ckpt_name and (("bedroom" in ckpt_name) or ("cat" in ckpt_name)): + unet_config = LSUN_256_UNET_CONFIG + elif "test" in ckpt_name: + unet_config = TEST_UNET_CONFIG + else: + raise ValueError(f"Checkpoint type {ckpt_name} is not currently supported.") + + if not args.class_cond: + unet_config["num_class_embeds"] = None + + converted_unet_ckpt = con_pt_to_diffuser(args.unet_path, unet_config) + + image_unet = UNet2DModel(**unet_config) + image_unet.load_state_dict(converted_unet_ckpt) + + # Get scheduler config + if "cd" in ckpt_name or "test" in ckpt_name: + scheduler_config = CD_SCHEDULER_CONFIG + elif "ct" in ckpt_name and "imagenet64" in ckpt_name: + scheduler_config = CT_IMAGENET_64_SCHEDULER_CONFIG + elif "ct" in ckpt_name and "256" in ckpt_name and (("bedroom" in ckpt_name) or ("cat" in ckpt_name)): + scheduler_config = CT_LSUN_256_SCHEDULER_CONFIG + else: + raise ValueError(f"Checkpoint type {ckpt_name} is not currently supported.") + + cm_scheduler = CMStochasticIterativeScheduler(**scheduler_config) + + consistency_model = ConsistencyModelPipeline(unet=image_unet, scheduler=cm_scheduler) + consistency_model.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cosmos_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cosmos_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..6f6563ad641bc6fbc744833e451d420cb850efe8 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_cosmos_to_diffusers.py @@ -0,0 +1,506 @@ +import argparse +import pathlib +from typing import Any, Dict + +import torch +from accelerate import init_empty_weights +from huggingface_hub import snapshot_download +from transformers import T5EncoderModel, T5TokenizerFast + +from diffusers import ( + AutoencoderKLCosmos, + AutoencoderKLWan, + Cosmos2TextToImagePipeline, + Cosmos2VideoToWorldPipeline, + CosmosTextToWorldPipeline, + CosmosTransformer3DModel, + CosmosVideoToWorldPipeline, + EDMEulerScheduler, + FlowMatchEulerDiscreteScheduler, +) + + +def remove_keys_(key: str, state_dict: Dict[str, Any]): + state_dict.pop(key) + + +def update_state_dict_(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def rename_transformer_blocks_(key: str, state_dict: Dict[str, Any]): + block_index = int(key.split(".")[1].removeprefix("block")) + new_key = key + + old_prefix = f"blocks.block{block_index}" + new_prefix = f"transformer_blocks.{block_index}" + new_key = new_prefix + new_key.removeprefix(old_prefix) + + state_dict[new_key] = state_dict.pop(key) + + +TRANSFORMER_KEYS_RENAME_DICT_COSMOS_1_0 = { + "t_embedder.1": "time_embed.t_embedder", + "affline_norm": "time_embed.norm", + ".blocks.0.block.attn": ".attn1", + ".blocks.1.block.attn": ".attn2", + ".blocks.2.block": ".ff", + ".blocks.0.adaLN_modulation.1": ".norm1.linear_1", + ".blocks.0.adaLN_modulation.2": ".norm1.linear_2", + ".blocks.1.adaLN_modulation.1": ".norm2.linear_1", + ".blocks.1.adaLN_modulation.2": ".norm2.linear_2", + ".blocks.2.adaLN_modulation.1": ".norm3.linear_1", + ".blocks.2.adaLN_modulation.2": ".norm3.linear_2", + "to_q.0": "to_q", + "to_q.1": "norm_q", + "to_k.0": "to_k", + "to_k.1": "norm_k", + "to_v.0": "to_v", + "layer1": "net.0.proj", + "layer2": "net.2", + "proj.1": "proj", + "x_embedder": "patch_embed", + "extra_pos_embedder": "learnable_pos_embed", + "final_layer.adaLN_modulation.1": "norm_out.linear_1", + "final_layer.adaLN_modulation.2": "norm_out.linear_2", + "final_layer.linear": "proj_out", +} + +TRANSFORMER_SPECIAL_KEYS_REMAP_COSMOS_1_0 = { + "blocks.block": rename_transformer_blocks_, + "logvar.0.freqs": remove_keys_, + "logvar.0.phases": remove_keys_, + "logvar.1.weight": remove_keys_, + "pos_embedder.seq": remove_keys_, +} + +TRANSFORMER_KEYS_RENAME_DICT_COSMOS_2_0 = { + "t_embedder.1": "time_embed.t_embedder", + "t_embedding_norm": "time_embed.norm", + "blocks": "transformer_blocks", + "adaln_modulation_self_attn.1": "norm1.linear_1", + "adaln_modulation_self_attn.2": "norm1.linear_2", + "adaln_modulation_cross_attn.1": "norm2.linear_1", + "adaln_modulation_cross_attn.2": "norm2.linear_2", + "adaln_modulation_mlp.1": "norm3.linear_1", + "adaln_modulation_mlp.2": "norm3.linear_2", + "self_attn": "attn1", + "cross_attn": "attn2", + "q_proj": "to_q", + "k_proj": "to_k", + "v_proj": "to_v", + "output_proj": "to_out.0", + "q_norm": "norm_q", + "k_norm": "norm_k", + "mlp.layer1": "ff.net.0.proj", + "mlp.layer2": "ff.net.2", + "x_embedder.proj.1": "patch_embed.proj", + "final_layer.adaln_modulation.1": "norm_out.linear_1", + "final_layer.adaln_modulation.2": "norm_out.linear_2", + "final_layer.linear": "proj_out", +} + +TRANSFORMER_SPECIAL_KEYS_REMAP_COSMOS_2_0 = { + "accum_video_sample_counter": remove_keys_, + "accum_image_sample_counter": remove_keys_, + "accum_iteration": remove_keys_, + "accum_train_in_hours": remove_keys_, + "pos_embedder.seq": remove_keys_, + "pos_embedder.dim_spatial_range": remove_keys_, + "pos_embedder.dim_temporal_range": remove_keys_, + "_extra_state": remove_keys_, +} + + +TRANSFORMER_CONFIGS = { + "Cosmos-1.0-Diffusion-7B-Text2World": { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 32, + "attention_head_dim": 128, + "num_layers": 28, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (2.0, 1.0, 1.0), + "concat_padding_mask": True, + "extra_pos_embed_type": "learnable", + }, + "Cosmos-1.0-Diffusion-7B-Video2World": { + "in_channels": 16 + 1, + "out_channels": 16, + "num_attention_heads": 32, + "attention_head_dim": 128, + "num_layers": 28, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (2.0, 1.0, 1.0), + "concat_padding_mask": True, + "extra_pos_embed_type": "learnable", + }, + "Cosmos-1.0-Diffusion-14B-Text2World": { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 40, + "attention_head_dim": 128, + "num_layers": 36, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (2.0, 2.0, 2.0), + "concat_padding_mask": True, + "extra_pos_embed_type": "learnable", + }, + "Cosmos-1.0-Diffusion-14B-Video2World": { + "in_channels": 16 + 1, + "out_channels": 16, + "num_attention_heads": 40, + "attention_head_dim": 128, + "num_layers": 36, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (2.0, 2.0, 2.0), + "concat_padding_mask": True, + "extra_pos_embed_type": "learnable", + }, + "Cosmos-2.0-Diffusion-2B-Text2Image": { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 16, + "attention_head_dim": 128, + "num_layers": 28, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (1.0, 4.0, 4.0), + "concat_padding_mask": True, + "extra_pos_embed_type": None, + }, + "Cosmos-2.0-Diffusion-14B-Text2Image": { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 40, + "attention_head_dim": 128, + "num_layers": 36, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (1.0, 4.0, 4.0), + "concat_padding_mask": True, + "extra_pos_embed_type": None, + }, + "Cosmos-2.0-Diffusion-2B-Video2World": { + "in_channels": 16 + 1, + "out_channels": 16, + "num_attention_heads": 16, + "attention_head_dim": 128, + "num_layers": 28, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (1.0, 3.0, 3.0), + "concat_padding_mask": True, + "extra_pos_embed_type": None, + }, + "Cosmos-2.0-Diffusion-14B-Video2World": { + "in_channels": 16 + 1, + "out_channels": 16, + "num_attention_heads": 40, + "attention_head_dim": 128, + "num_layers": 36, + "mlp_ratio": 4.0, + "text_embed_dim": 1024, + "adaln_lora_dim": 256, + "max_size": (128, 240, 240), + "patch_size": (1, 2, 2), + "rope_scale": (20 / 24, 2.0, 2.0), + "concat_padding_mask": True, + "extra_pos_embed_type": None, + }, +} + +VAE_KEYS_RENAME_DICT = { + "down.0": "down_blocks.0", + "down.1": "down_blocks.1", + "down.2": "down_blocks.2", + "up.0": "up_blocks.2", + "up.1": "up_blocks.1", + "up.2": "up_blocks.0", + ".block.": ".resnets.", + "downsample": "downsamplers.0", + "upsample": "upsamplers.0", + "mid.block_1": "mid_block.resnets.0", + "mid.attn_1.0": "mid_block.attentions.0", + "mid.attn_1.1": "mid_block.temp_attentions.0", + "mid.block_2": "mid_block.resnets.1", + ".q.conv3d": ".to_q", + ".k.conv3d": ".to_k", + ".v.conv3d": ".to_v", + ".proj_out.conv3d": ".to_out.0", + ".0.conv3d": ".conv_s", + ".1.conv3d": ".conv_t", + "conv1.conv3d": "conv1", + "conv2.conv3d": "conv2", + "conv3.conv3d": "conv3", + "nin_shortcut.conv3d": "conv_shortcut", + "quant_conv.conv3d": "quant_conv", + "post_quant_conv.conv3d": "post_quant_conv", +} + +VAE_SPECIAL_KEYS_REMAP = { + "wavelets": remove_keys_, + "_arange": remove_keys_, + "patch_size_buffer": remove_keys_, +} + +VAE_CONFIGS = { + "CV8x8x8-0.1": { + "name": "nvidia/Cosmos-0.1-Tokenizer-CV8x8x8", + "diffusers_config": { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 16, + "encoder_block_out_channels": (128, 256, 512, 512), + "decode_block_out_channels": (256, 512, 512, 512), + "attention_resolutions": (32,), + "resolution": 1024, + "num_layers": 2, + "patch_size": 4, + "patch_type": "haar", + "scaling_factor": 1.0, + "spatial_compression_ratio": 8, + "temporal_compression_ratio": 8, + "latents_mean": None, + "latents_std": None, + }, + }, + "CV8x8x8-1.0": { + "name": "nvidia/Cosmos-1.0-Tokenizer-CV8x8x8", + "diffusers_config": { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 16, + "encoder_block_out_channels": (128, 256, 512, 512), + "decode_block_out_channels": (256, 512, 512, 512), + "attention_resolutions": (32,), + "resolution": 1024, + "num_layers": 2, + "patch_size": 4, + "patch_type": "haar", + "scaling_factor": 1.0, + "spatial_compression_ratio": 8, + "temporal_compression_ratio": 8, + "latents_mean": None, + "latents_std": None, + }, + }, +} + + +def get_state_dict(saved_dict: Dict[str, Any]) -> Dict[str, Any]: + state_dict = saved_dict + if "model" in saved_dict.keys(): + state_dict = state_dict["model"] + if "module" in saved_dict.keys(): + state_dict = state_dict["module"] + if "state_dict" in saved_dict.keys(): + state_dict = state_dict["state_dict"] + return state_dict + + +def convert_transformer(transformer_type: str, ckpt_path: str, weights_only: bool = True): + PREFIX_KEY = "net." + original_state_dict = get_state_dict(torch.load(ckpt_path, map_location="cpu", weights_only=weights_only)) + + if "Cosmos-1.0" in transformer_type: + TRANSFORMER_KEYS_RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT_COSMOS_1_0 + TRANSFORMER_SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP_COSMOS_1_0 + elif "Cosmos-2.0" in transformer_type: + TRANSFORMER_KEYS_RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT_COSMOS_2_0 + TRANSFORMER_SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP_COSMOS_2_0 + else: + assert False + + with init_empty_weights(): + config = TRANSFORMER_CONFIGS[transformer_type] + transformer = CosmosTransformer3DModel(**config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + if new_key.startswith(PREFIX_KEY): + new_key = new_key.removeprefix(PREFIX_KEY) + for replace_key, rename_key in TRANSFORMER_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in TRANSFORMER_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + transformer.load_state_dict(original_state_dict, strict=True, assign=True) + return transformer + + +def convert_vae(vae_type: str): + model_name = VAE_CONFIGS[vae_type]["name"] + snapshot_directory = snapshot_download(model_name, repo_type="model") + directory = pathlib.Path(snapshot_directory) + + autoencoder_file = directory / "autoencoder.jit" + mean_std_file = directory / "mean_std.pt" + + original_state_dict = torch.jit.load(autoencoder_file.as_posix()).state_dict() + if mean_std_file.exists(): + mean_std = torch.load(mean_std_file, map_location="cpu", weights_only=True) + else: + mean_std = (None, None) + + config = VAE_CONFIGS[vae_type]["diffusers_config"] + config.update( + { + "latents_mean": mean_std[0].detach().cpu().numpy().tolist(), + "latents_std": mean_std[1].detach().cpu().numpy().tolist(), + } + ) + vae = AutoencoderKLCosmos(**config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in VAE_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in VAE_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + vae.load_state_dict(original_state_dict, strict=True, assign=True) + return vae + + +def save_pipeline_cosmos_1_0(args, transformer, vae): + text_encoder = T5EncoderModel.from_pretrained(args.text_encoder_path, torch_dtype=torch.bfloat16) + tokenizer = T5TokenizerFast.from_pretrained(args.tokenizer_path) + # The original code initializes EDM config with sigma_min=0.0002, but does not make use of it anywhere directly. + # So, the sigma_min values that is used is the default value of 0.002. + scheduler = EDMEulerScheduler( + sigma_min=0.002, + sigma_max=80, + sigma_data=0.5, + sigma_schedule="karras", + num_train_timesteps=1000, + prediction_type="epsilon", + rho=7.0, + final_sigmas_type="sigma_min", + ) + + pipe_cls = CosmosTextToWorldPipeline if "Text2World" in args.transformer_type else CosmosVideoToWorldPipeline + pipe = pipe_cls( + text_encoder=text_encoder, + tokenizer=tokenizer, + transformer=transformer, + vae=vae, + scheduler=scheduler, + safety_checker=lambda *args, **kwargs: None, + ) + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + + +def save_pipeline_cosmos_2_0(args, transformer, vae): + text_encoder = T5EncoderModel.from_pretrained(args.text_encoder_path, torch_dtype=torch.bfloat16) + tokenizer = T5TokenizerFast.from_pretrained(args.tokenizer_path) + + scheduler = FlowMatchEulerDiscreteScheduler(use_karras_sigmas=True) + + pipe_cls = Cosmos2TextToImagePipeline if "Text2Image" in args.transformer_type else Cosmos2VideoToWorldPipeline + pipe = pipe_cls( + text_encoder=text_encoder, + tokenizer=tokenizer, + transformer=transformer, + vae=vae, + scheduler=scheduler, + safety_checker=lambda *args, **kwargs: None, + ) + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--transformer_type", type=str, default=None, choices=list(TRANSFORMER_CONFIGS.keys())) + parser.add_argument( + "--transformer_ckpt_path", type=str, default=None, help="Path to original transformer checkpoint" + ) + parser.add_argument( + "--vae_type", type=str, default=None, choices=["none", *list(VAE_CONFIGS.keys())], help="Type of VAE" + ) + parser.add_argument("--text_encoder_path", type=str, default="google-t5/t5-11b") + parser.add_argument("--tokenizer_path", type=str, default="google-t5/t5-11b") + parser.add_argument("--save_pipeline", action="store_true") + parser.add_argument("--output_path", type=str, required=True, help="Path where converted model should be saved") + parser.add_argument("--dtype", default="bf16", help="Torch dtype to save the transformer in.") + return parser.parse_args() + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + + +if __name__ == "__main__": + args = get_args() + + transformer = None + dtype = DTYPE_MAPPING[args.dtype] + + if args.save_pipeline: + assert args.transformer_ckpt_path is not None + assert args.vae_type is not None + assert args.text_encoder_path is not None + assert args.tokenizer_path is not None + + if args.transformer_ckpt_path is not None: + weights_only = "Cosmos-1.0" in args.transformer_type + transformer = convert_transformer(args.transformer_type, args.transformer_ckpt_path, weights_only) + transformer = transformer.to(dtype=dtype) + if not args.save_pipeline: + transformer.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + + if args.vae_type is not None: + if "Cosmos-1.0" in args.transformer_type: + vae = convert_vae(args.vae_type) + else: + vae = AutoencoderKLWan.from_pretrained( + "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", subfolder="vae", torch_dtype=torch.float32 + ) + if not args.save_pipeline: + vae.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + + if args.save_pipeline: + if "Cosmos-1.0" in args.transformer_type: + save_pipeline_cosmos_1_0(args, transformer, vae) + elif "Cosmos-2.0" in args.transformer_type: + save_pipeline_cosmos_2_0(args, transformer, vae) + else: + assert False diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dance_diffusion_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dance_diffusion_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..e269a49070cc00c1ff3f71bb2c21e57b0a5d5e70 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dance_diffusion_to_diffusers.py @@ -0,0 +1,346 @@ +#!/usr/bin/env python3 +import argparse +import math +import os +from copy import deepcopy + +import requests +import torch +from audio_diffusion.models import DiffusionAttnUnet1D +from diffusion import sampling +from torch import nn + +from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNet1DModel +from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT + + +MODELS_MAP = { + "gwf-440k": { + "url": "https://model-server.zqevans2.workers.dev/gwf-440k.ckpt", + "sample_rate": 48000, + "sample_size": 65536, + }, + "jmann-small-190k": { + "url": "https://model-server.zqevans2.workers.dev/jmann-small-190k.ckpt", + "sample_rate": 48000, + "sample_size": 65536, + }, + "jmann-large-580k": { + "url": "https://model-server.zqevans2.workers.dev/jmann-large-580k.ckpt", + "sample_rate": 48000, + "sample_size": 131072, + }, + "maestro-uncond-150k": { + "url": "https://model-server.zqevans2.workers.dev/maestro-uncond-150k.ckpt", + "sample_rate": 16000, + "sample_size": 65536, + }, + "unlocked-uncond-250k": { + "url": "https://model-server.zqevans2.workers.dev/unlocked-uncond-250k.ckpt", + "sample_rate": 16000, + "sample_size": 65536, + }, + "honk-140k": { + "url": "https://model-server.zqevans2.workers.dev/honk-140k.ckpt", + "sample_rate": 16000, + "sample_size": 65536, + }, +} + + +def alpha_sigma_to_t(alpha, sigma): + """Returns a timestep, given the scaling factors for the clean image and for + the noise.""" + return torch.atan2(sigma, alpha) / math.pi * 2 + + +def get_crash_schedule(t): + sigma = torch.sin(t * math.pi / 2) ** 2 + alpha = (1 - sigma**2) ** 0.5 + return alpha_sigma_to_t(alpha, sigma) + + +class Object(object): + pass + + +class DiffusionUncond(nn.Module): + def __init__(self, global_args): + super().__init__() + + self.diffusion = DiffusionAttnUnet1D(global_args, n_attn_layers=4) + self.diffusion_ema = deepcopy(self.diffusion) + self.rng = torch.quasirandom.SobolEngine(1, scramble=True) + + +def download(model_name): + url = MODELS_MAP[model_name]["url"] + r = requests.get(url, stream=True, timeout=DIFFUSERS_REQUEST_TIMEOUT) + + local_filename = f"./{model_name}.ckpt" + with open(local_filename, "wb") as fp: + for chunk in r.iter_content(chunk_size=8192): + fp.write(chunk) + + return local_filename + + +DOWN_NUM_TO_LAYER = { + "1": "resnets.0", + "2": "attentions.0", + "3": "resnets.1", + "4": "attentions.1", + "5": "resnets.2", + "6": "attentions.2", +} +UP_NUM_TO_LAYER = { + "8": "resnets.0", + "9": "attentions.0", + "10": "resnets.1", + "11": "attentions.1", + "12": "resnets.2", + "13": "attentions.2", +} +MID_NUM_TO_LAYER = { + "1": "resnets.0", + "2": "attentions.0", + "3": "resnets.1", + "4": "attentions.1", + "5": "resnets.2", + "6": "attentions.2", + "8": "resnets.3", + "9": "attentions.3", + "10": "resnets.4", + "11": "attentions.4", + "12": "resnets.5", + "13": "attentions.5", +} +DEPTH_0_TO_LAYER = { + "0": "resnets.0", + "1": "resnets.1", + "2": "resnets.2", + "4": "resnets.0", + "5": "resnets.1", + "6": "resnets.2", +} + +RES_CONV_MAP = { + "skip": "conv_skip", + "main.0": "conv_1", + "main.1": "group_norm_1", + "main.3": "conv_2", + "main.4": "group_norm_2", +} + +ATTN_MAP = { + "norm": "group_norm", + "qkv_proj": ["query", "key", "value"], + "out_proj": ["proj_attn"], +} + + +def convert_resconv_naming(name): + if name.startswith("skip"): + return name.replace("skip", RES_CONV_MAP["skip"]) + + # name has to be of format main.{digit} + if not name.startswith("main."): + raise ValueError(f"ResConvBlock error with {name}") + + return name.replace(name[:6], RES_CONV_MAP[name[:6]]) + + +def convert_attn_naming(name): + for key, value in ATTN_MAP.items(): + if name.startswith(key) and not isinstance(value, list): + return name.replace(key, value) + elif name.startswith(key): + return [name.replace(key, v) for v in value] + raise ValueError(f"Attn error with {name}") + + +def rename(input_string, max_depth=13): + string = input_string + + if string.split(".")[0] == "timestep_embed": + return string.replace("timestep_embed", "time_proj") + + depth = 0 + if string.startswith("net.3."): + depth += 1 + string = string[6:] + elif string.startswith("net."): + string = string[4:] + + while string.startswith("main.7."): + depth += 1 + string = string[7:] + + if string.startswith("main."): + string = string[5:] + + # mid block + if string[:2].isdigit(): + layer_num = string[:2] + string_left = string[2:] + else: + layer_num = string[0] + string_left = string[1:] + + if depth == max_depth: + new_layer = MID_NUM_TO_LAYER[layer_num] + prefix = "mid_block" + elif depth > 0 and int(layer_num) < 7: + new_layer = DOWN_NUM_TO_LAYER[layer_num] + prefix = f"down_blocks.{depth}" + elif depth > 0 and int(layer_num) > 7: + new_layer = UP_NUM_TO_LAYER[layer_num] + prefix = f"up_blocks.{max_depth - depth - 1}" + elif depth == 0: + new_layer = DEPTH_0_TO_LAYER[layer_num] + prefix = f"up_blocks.{max_depth - 1}" if int(layer_num) > 3 else "down_blocks.0" + + if not string_left.startswith("."): + raise ValueError(f"Naming error with {input_string} and string_left: {string_left}.") + + string_left = string_left[1:] + + if "resnets" in new_layer: + string_left = convert_resconv_naming(string_left) + elif "attentions" in new_layer: + new_string_left = convert_attn_naming(string_left) + string_left = new_string_left + + if not isinstance(string_left, list): + new_string = prefix + "." + new_layer + "." + string_left + else: + new_string = [prefix + "." + new_layer + "." + s for s in string_left] + return new_string + + +def rename_orig_weights(state_dict): + new_state_dict = {} + for k, v in state_dict.items(): + if k.endswith("kernel"): + # up- and downsample layers, don't have trainable weights + continue + + new_k = rename(k) + + # check if we need to transform from Conv => Linear for attention + if isinstance(new_k, list): + new_state_dict = transform_conv_attns(new_state_dict, new_k, v) + else: + new_state_dict[new_k] = v + + return new_state_dict + + +def transform_conv_attns(new_state_dict, new_k, v): + if len(new_k) == 1: + if len(v.shape) == 3: + # weight + new_state_dict[new_k[0]] = v[:, :, 0] + else: + # bias + new_state_dict[new_k[0]] = v + else: + # qkv matrices + trippled_shape = v.shape[0] + single_shape = trippled_shape // 3 + for i in range(3): + if len(v.shape) == 3: + new_state_dict[new_k[i]] = v[i * single_shape : (i + 1) * single_shape, :, 0] + else: + new_state_dict[new_k[i]] = v[i * single_shape : (i + 1) * single_shape] + return new_state_dict + + +def main(args): + device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + + model_name = args.model_path.split("/")[-1].split(".")[0] + if not os.path.isfile(args.model_path): + assert model_name == args.model_path, ( + f"Make sure to provide one of the official model names {MODELS_MAP.keys()}" + ) + args.model_path = download(model_name) + + sample_rate = MODELS_MAP[model_name]["sample_rate"] + sample_size = MODELS_MAP[model_name]["sample_size"] + + config = Object() + config.sample_size = sample_size + config.sample_rate = sample_rate + config.latent_dim = 0 + + diffusers_model = UNet1DModel(sample_size=sample_size, sample_rate=sample_rate) + diffusers_state_dict = diffusers_model.state_dict() + + orig_model = DiffusionUncond(config) + orig_model.load_state_dict(torch.load(args.model_path, map_location=device)["state_dict"]) + orig_model = orig_model.diffusion_ema.eval() + orig_model_state_dict = orig_model.state_dict() + renamed_state_dict = rename_orig_weights(orig_model_state_dict) + + renamed_minus_diffusers = set(renamed_state_dict.keys()) - set(diffusers_state_dict.keys()) + diffusers_minus_renamed = set(diffusers_state_dict.keys()) - set(renamed_state_dict.keys()) + + assert len(renamed_minus_diffusers) == 0, f"Problem with {renamed_minus_diffusers}" + assert all(k.endswith("kernel") for k in list(diffusers_minus_renamed)), f"Problem with {diffusers_minus_renamed}" + + for key, value in renamed_state_dict.items(): + assert diffusers_state_dict[key].squeeze().shape == value.squeeze().shape, ( + f"Shape for {key} doesn't match. Diffusers: {diffusers_state_dict[key].shape} vs. {value.shape}" + ) + if key == "time_proj.weight": + value = value.squeeze() + + diffusers_state_dict[key] = value + + diffusers_model.load_state_dict(diffusers_state_dict) + + steps = 100 + seed = 33 + + diffusers_scheduler = IPNDMScheduler(num_train_timesteps=steps) + + generator = torch.manual_seed(seed) + noise = torch.randn([1, 2, config.sample_size], generator=generator).to(device) + + t = torch.linspace(1, 0, steps + 1, device=device)[:-1] + step_list = get_crash_schedule(t) + + pipe = DanceDiffusionPipeline(unet=diffusers_model, scheduler=diffusers_scheduler) + + generator = torch.manual_seed(33) + audio = pipe(num_inference_steps=steps, generator=generator).audios + + generated = sampling.iplms_sample(orig_model, noise, step_list, {}) + generated = generated.clamp(-1, 1) + + diff_sum = (generated - audio).abs().sum() + diff_max = (generated - audio).abs().max() + + if args.save: + pipe.save_pretrained(args.checkpoint_path) + + print("Diff sum", diff_sum) + print("Diff max", diff_max) + + assert diff_max < 1e-3, f"Diff max: {diff_max} is too much :-/" + + print(f"Conversion for {model_name} successful!") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--model_path", default=None, type=str, required=True, help="Path to the model to convert.") + parser.add_argument( + "--save", default=True, type=bool, required=False, help="Whether to save the converted model or not." + ) + parser.add_argument("--checkpoint_path", default=None, type=str, required=True, help="Path to the output model.") + args = parser.parse_args() + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dcae_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dcae_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..15f79a8154e6dc3eb010f69cba630da32b98dc22 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dcae_to_diffusers.py @@ -0,0 +1,323 @@ +import argparse +from typing import Any, Dict + +import torch +from huggingface_hub import hf_hub_download +from safetensors.torch import load_file + +from diffusers import AutoencoderDC + + +def remap_qkv_(key: str, state_dict: Dict[str, Any]): + qkv = state_dict.pop(key) + q, k, v = torch.chunk(qkv, 3, dim=0) + parent_module, _, _ = key.rpartition(".qkv.conv.weight") + state_dict[f"{parent_module}.to_q.weight"] = q.squeeze() + state_dict[f"{parent_module}.to_k.weight"] = k.squeeze() + state_dict[f"{parent_module}.to_v.weight"] = v.squeeze() + + +def remap_proj_conv_(key: str, state_dict: Dict[str, Any]): + parent_module, _, _ = key.rpartition(".proj.conv.weight") + state_dict[f"{parent_module}.to_out.weight"] = state_dict.pop(key).squeeze() + + +AE_KEYS_RENAME_DICT = { + # common + "main.": "", + "op_list.": "", + "context_module": "attn", + "local_module": "conv_out", + # NOTE: The below two lines work because scales in the available configs only have a tuple length of 1 + # If there were more scales, there would be more layers, so a loop would be better to handle this + "aggreg.0.0": "to_qkv_multiscale.0.proj_in", + "aggreg.0.1": "to_qkv_multiscale.0.proj_out", + "depth_conv.conv": "conv_depth", + "inverted_conv.conv": "conv_inverted", + "point_conv.conv": "conv_point", + "point_conv.norm": "norm", + "conv.conv.": "conv.", + "conv1.conv": "conv1", + "conv2.conv": "conv2", + "conv2.norm": "norm", + "proj.norm": "norm_out", + # encoder + "encoder.project_in.conv": "encoder.conv_in", + "encoder.project_out.0.conv": "encoder.conv_out", + "encoder.stages": "encoder.down_blocks", + # decoder + "decoder.project_in.conv": "decoder.conv_in", + "decoder.project_out.0": "decoder.norm_out", + "decoder.project_out.2.conv": "decoder.conv_out", + "decoder.stages": "decoder.up_blocks", +} + +AE_F32C32_KEYS = { + # encoder + "encoder.project_in.conv": "encoder.conv_in.conv", + # decoder + "decoder.project_out.2.conv": "decoder.conv_out.conv", +} + +AE_F64C128_KEYS = { + # encoder + "encoder.project_in.conv": "encoder.conv_in.conv", + # decoder + "decoder.project_out.2.conv": "decoder.conv_out.conv", +} + +AE_F128C512_KEYS = { + # encoder + "encoder.project_in.conv": "encoder.conv_in.conv", + # decoder + "decoder.project_out.2.conv": "decoder.conv_out.conv", +} + +AE_SPECIAL_KEYS_REMAP = { + "qkv.conv.weight": remap_qkv_, + "proj.conv.weight": remap_proj_conv_, +} + + +def get_state_dict(saved_dict: Dict[str, Any]) -> Dict[str, Any]: + state_dict = saved_dict + if "model" in saved_dict.keys(): + state_dict = state_dict["model"] + if "module" in saved_dict.keys(): + state_dict = state_dict["module"] + if "state_dict" in saved_dict.keys(): + state_dict = state_dict["state_dict"] + return state_dict + + +def update_state_dict_(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def convert_ae(config_name: str, dtype: torch.dtype): + config = get_ae_config(config_name) + hub_id = f"mit-han-lab/{config_name}" + ckpt_path = hf_hub_download(hub_id, "model.safetensors") + original_state_dict = get_state_dict(load_file(ckpt_path)) + + ae = AutoencoderDC(**config).to(dtype=dtype) + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in AE_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in AE_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + ae.load_state_dict(original_state_dict, strict=True) + return ae + + +def get_ae_config(name: str): + if name in ["dc-ae-f32c32-sana-1.0"]: + config = { + "latent_channels": 32, + "encoder_block_types": ( + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ), + "decoder_block_types": ( + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ), + "encoder_block_out_channels": (128, 256, 512, 512, 1024, 1024), + "decoder_block_out_channels": (128, 256, 512, 512, 1024, 1024), + "encoder_qkv_multiscales": ((), (), (), (5,), (5,), (5,)), + "decoder_qkv_multiscales": ((), (), (), (5,), (5,), (5,)), + "encoder_layers_per_block": (2, 2, 2, 3, 3, 3), + "decoder_layers_per_block": [3, 3, 3, 3, 3, 3], + "downsample_block_type": "conv", + "upsample_block_type": "interpolate", + "decoder_norm_types": "rms_norm", + "decoder_act_fns": "silu", + "scaling_factor": 0.41407, + } + elif name in ["dc-ae-f32c32-in-1.0", "dc-ae-f32c32-mix-1.0"]: + AE_KEYS_RENAME_DICT.update(AE_F32C32_KEYS) + config = { + "latent_channels": 32, + "encoder_block_types": [ + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ], + "decoder_block_types": [ + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ], + "encoder_block_out_channels": [128, 256, 512, 512, 1024, 1024], + "decoder_block_out_channels": [128, 256, 512, 512, 1024, 1024], + "encoder_layers_per_block": [0, 4, 8, 2, 2, 2], + "decoder_layers_per_block": [0, 5, 10, 2, 2, 2], + "encoder_qkv_multiscales": ((), (), (), (), (), ()), + "decoder_qkv_multiscales": ((), (), (), (), (), ()), + "decoder_norm_types": ["batch_norm", "batch_norm", "batch_norm", "rms_norm", "rms_norm", "rms_norm"], + "decoder_act_fns": ["relu", "relu", "relu", "silu", "silu", "silu"], + } + if name == "dc-ae-f32c32-in-1.0": + config["scaling_factor"] = 0.3189 + elif name == "dc-ae-f32c32-mix-1.0": + config["scaling_factor"] = 0.4552 + elif name in ["dc-ae-f64c128-in-1.0", "dc-ae-f64c128-mix-1.0"]: + AE_KEYS_RENAME_DICT.update(AE_F64C128_KEYS) + config = { + "latent_channels": 128, + "encoder_block_types": [ + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ], + "decoder_block_types": [ + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ], + "encoder_block_out_channels": [128, 256, 512, 512, 1024, 1024, 2048], + "decoder_block_out_channels": [128, 256, 512, 512, 1024, 1024, 2048], + "encoder_layers_per_block": [0, 4, 8, 2, 2, 2, 2], + "decoder_layers_per_block": [0, 5, 10, 2, 2, 2, 2], + "encoder_qkv_multiscales": ((), (), (), (), (), (), ()), + "decoder_qkv_multiscales": ((), (), (), (), (), (), ()), + "decoder_norm_types": [ + "batch_norm", + "batch_norm", + "batch_norm", + "rms_norm", + "rms_norm", + "rms_norm", + "rms_norm", + ], + "decoder_act_fns": ["relu", "relu", "relu", "silu", "silu", "silu", "silu"], + } + if name == "dc-ae-f64c128-in-1.0": + config["scaling_factor"] = 0.2889 + elif name == "dc-ae-f64c128-mix-1.0": + config["scaling_factor"] = 0.4538 + elif name in ["dc-ae-f128c512-in-1.0", "dc-ae-f128c512-mix-1.0"]: + AE_KEYS_RENAME_DICT.update(AE_F128C512_KEYS) + config = { + "latent_channels": 512, + "encoder_block_types": [ + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ], + "decoder_block_types": [ + "ResBlock", + "ResBlock", + "ResBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + "EfficientViTBlock", + ], + "encoder_block_out_channels": [128, 256, 512, 512, 1024, 1024, 2048, 2048], + "decoder_block_out_channels": [128, 256, 512, 512, 1024, 1024, 2048, 2048], + "encoder_layers_per_block": [0, 4, 8, 2, 2, 2, 2, 2], + "decoder_layers_per_block": [0, 5, 10, 2, 2, 2, 2, 2], + "encoder_qkv_multiscales": ((), (), (), (), (), (), (), ()), + "decoder_qkv_multiscales": ((), (), (), (), (), (), (), ()), + "decoder_norm_types": [ + "batch_norm", + "batch_norm", + "batch_norm", + "rms_norm", + "rms_norm", + "rms_norm", + "rms_norm", + "rms_norm", + ], + "decoder_act_fns": ["relu", "relu", "relu", "silu", "silu", "silu", "silu", "silu"], + } + if name == "dc-ae-f128c512-in-1.0": + config["scaling_factor"] = 0.4883 + elif name == "dc-ae-f128c512-mix-1.0": + config["scaling_factor"] = 0.3620 + else: + raise ValueError("Invalid config name provided.") + + return config + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--config_name", + type=str, + default="dc-ae-f32c32-sana-1.0", + choices=[ + "dc-ae-f32c32-sana-1.0", + "dc-ae-f32c32-in-1.0", + "dc-ae-f32c32-mix-1.0", + "dc-ae-f64c128-in-1.0", + "dc-ae-f64c128-mix-1.0", + "dc-ae-f128c512-in-1.0", + "dc-ae-f128c512-mix-1.0", + ], + help="The DCAE checkpoint to convert", + ) + parser.add_argument("--output_path", type=str, required=True, help="Path where converted model should be saved") + parser.add_argument("--dtype", default="fp32", help="Torch dtype to save the model in.") + return parser.parse_args() + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + +VARIANT_MAPPING = { + "fp32": None, + "fp16": "fp16", + "bf16": "bf16", +} + + +if __name__ == "__main__": + args = get_args() + + dtype = DTYPE_MAPPING[args.dtype] + variant = VARIANT_MAPPING[args.dtype] + + ae = convert_ae(args.config_name, dtype) + ae.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB", variant=variant) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ddpm_original_checkpoint_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ddpm_original_checkpoint_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..46595784b0bac0016b623b7122082275248363e9 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ddpm_original_checkpoint_to_diffusers.py @@ -0,0 +1,431 @@ +import argparse +import json + +import torch + +from diffusers import AutoencoderKL, DDPMPipeline, DDPMScheduler, UNet2DModel, VQModel + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + mapping = [] + for old_item in old_list: + new_item = old_item + new_item = new_item.replace("block.", "resnets.") + new_item = new_item.replace("conv_shorcut", "conv1") + new_item = new_item.replace("in_shortcut", "conv_shortcut") + new_item = new_item.replace("temb_proj", "time_emb_proj") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0, in_mid=False): + mapping = [] + for old_item in old_list: + new_item = old_item + + # In `model.mid`, the layer is called `attn`. + if not in_mid: + new_item = new_item.replace("attn", "attentions") + new_item = new_item.replace(".k.", ".key.") + new_item = new_item.replace(".v.", ".value.") + new_item = new_item.replace(".q.", ".query.") + + new_item = new_item.replace("proj_out", "proj_attn") + new_item = new_item.replace("norm", "group_norm") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + if attention_paths_to_split is not None: + if config is None: + raise ValueError("Please specify the config if setting 'attention_paths_to_split' to 'True'.") + + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config.get("num_head_channels", 1) // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape).squeeze() + checkpoint[path_map["key"]] = key.reshape(target_shape).squeeze() + checkpoint[path_map["value"]] = value.reshape(target_shape).squeeze() + + for path in paths: + new_path = path["new"] + + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + new_path = new_path.replace("down.", "down_blocks.") + new_path = new_path.replace("up.", "up_blocks.") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + if "attentions" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]].squeeze() + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def convert_ddpm_checkpoint(checkpoint, config): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = checkpoint["temb.dense.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = checkpoint["temb.dense.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = checkpoint["temb.dense.1.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = checkpoint["temb.dense.1.bias"] + + new_checkpoint["conv_norm_out.weight"] = checkpoint["norm_out.weight"] + new_checkpoint["conv_norm_out.bias"] = checkpoint["norm_out.bias"] + + new_checkpoint["conv_in.weight"] = checkpoint["conv_in.weight"] + new_checkpoint["conv_in.bias"] = checkpoint["conv_in.bias"] + new_checkpoint["conv_out.weight"] = checkpoint["conv_out.weight"] + new_checkpoint["conv_out.bias"] = checkpoint["conv_out.bias"] + + num_down_blocks = len({".".join(layer.split(".")[:2]) for layer in checkpoint if "down" in layer}) + down_blocks = { + layer_id: [key for key in checkpoint if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + num_up_blocks = len({".".join(layer.split(".")[:2]) for layer in checkpoint if "up" in layer}) + up_blocks = {layer_id: [key for key in checkpoint if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks)} + + for i in range(num_down_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + + if any("downsample" in layer for layer in down_blocks[i]): + new_checkpoint[f"down_blocks.{i}.downsamplers.0.conv.weight"] = checkpoint[ + f"down.{i}.downsample.op.weight" + ] + new_checkpoint[f"down_blocks.{i}.downsamplers.0.conv.bias"] = checkpoint[f"down.{i}.downsample.op.bias"] + # new_checkpoint[f'down_blocks.{i}.downsamplers.0.op.weight'] = checkpoint[f'down.{i}.downsample.conv.weight'] + # new_checkpoint[f'down_blocks.{i}.downsamplers.0.op.bias'] = checkpoint[f'down.{i}.downsample.conv.bias'] + + if any("block" in layer for layer in down_blocks[i]): + num_blocks = len( + {".".join(shave_segments(layer, 2).split(".")[:2]) for layer in down_blocks[i] if "block" in layer} + ) + blocks = { + layer_id: [key for key in down_blocks[i] if f"block.{layer_id}" in key] + for layer_id in range(num_blocks) + } + + if num_blocks > 0: + for j in range(config["layers_per_block"]): + paths = renew_resnet_paths(blocks[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint) + + if any("attn" in layer for layer in down_blocks[i]): + num_attn = len( + {".".join(shave_segments(layer, 2).split(".")[:2]) for layer in down_blocks[i] if "attn" in layer} + ) + attns = { + layer_id: [key for key in down_blocks[i] if f"attn.{layer_id}" in key] + for layer_id in range(num_blocks) + } + + if num_attn > 0: + for j in range(config["layers_per_block"]): + paths = renew_attention_paths(attns[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint, config=config) + + mid_block_1_layers = [key for key in checkpoint if "mid.block_1" in key] + mid_block_2_layers = [key for key in checkpoint if "mid.block_2" in key] + mid_attn_1_layers = [key for key in checkpoint if "mid.attn_1" in key] + + # Mid new 2 + paths = renew_resnet_paths(mid_block_1_layers) + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[{"old": "mid.", "new": "mid_new_2."}, {"old": "block_1", "new": "resnets.0"}], + ) + + paths = renew_resnet_paths(mid_block_2_layers) + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[{"old": "mid.", "new": "mid_new_2."}, {"old": "block_2", "new": "resnets.1"}], + ) + + paths = renew_attention_paths(mid_attn_1_layers, in_mid=True) + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[{"old": "mid.", "new": "mid_new_2."}, {"old": "attn_1", "new": "attentions.0"}], + ) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + + if any("upsample" in layer for layer in up_blocks[i]): + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = checkpoint[ + f"up.{i}.upsample.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = checkpoint[f"up.{i}.upsample.conv.bias"] + + if any("block" in layer for layer in up_blocks[i]): + num_blocks = len( + {".".join(shave_segments(layer, 2).split(".")[:2]) for layer in up_blocks[i] if "block" in layer} + ) + blocks = { + layer_id: [key for key in up_blocks[i] if f"block.{layer_id}" in key] for layer_id in range(num_blocks) + } + + if num_blocks > 0: + for j in range(config["layers_per_block"] + 1): + replace_indices = {"old": f"up_blocks.{i}", "new": f"up_blocks.{block_id}"} + paths = renew_resnet_paths(blocks[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint, additional_replacements=[replace_indices]) + + if any("attn" in layer for layer in up_blocks[i]): + num_attn = len( + {".".join(shave_segments(layer, 2).split(".")[:2]) for layer in up_blocks[i] if "attn" in layer} + ) + attns = { + layer_id: [key for key in up_blocks[i] if f"attn.{layer_id}" in key] for layer_id in range(num_blocks) + } + + if num_attn > 0: + for j in range(config["layers_per_block"] + 1): + replace_indices = {"old": f"up_blocks.{i}", "new": f"up_blocks.{block_id}"} + paths = renew_attention_paths(attns[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint, additional_replacements=[replace_indices]) + + new_checkpoint = {k.replace("mid_new_2", "mid_block"): v for k, v in new_checkpoint.items()} + return new_checkpoint + + +def convert_vq_autoenc_checkpoint(checkpoint, config): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + new_checkpoint = {} + + new_checkpoint["encoder.conv_norm_out.weight"] = checkpoint["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = checkpoint["encoder.norm_out.bias"] + + new_checkpoint["encoder.conv_in.weight"] = checkpoint["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = checkpoint["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = checkpoint["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = checkpoint["encoder.conv_out.bias"] + + new_checkpoint["decoder.conv_norm_out.weight"] = checkpoint["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = checkpoint["decoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = checkpoint["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = checkpoint["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = checkpoint["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = checkpoint["decoder.conv_out.bias"] + + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in checkpoint if "down" in layer}) + down_blocks = { + layer_id: [key for key in checkpoint if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in checkpoint if "up" in layer}) + up_blocks = {layer_id: [key for key in checkpoint if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks)} + + for i in range(num_down_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + + if any("downsample" in layer for layer in down_blocks[i]): + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = checkpoint[ + f"encoder.down.{i}.downsample.conv.weight" + ] + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = checkpoint[ + f"encoder.down.{i}.downsample.conv.bias" + ] + + if any("block" in layer for layer in down_blocks[i]): + num_blocks = len( + {".".join(shave_segments(layer, 3).split(".")[:3]) for layer in down_blocks[i] if "block" in layer} + ) + blocks = { + layer_id: [key for key in down_blocks[i] if f"block.{layer_id}" in key] + for layer_id in range(num_blocks) + } + + if num_blocks > 0: + for j in range(config["layers_per_block"]): + paths = renew_resnet_paths(blocks[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint) + + if any("attn" in layer for layer in down_blocks[i]): + num_attn = len( + {".".join(shave_segments(layer, 3).split(".")[:3]) for layer in down_blocks[i] if "attn" in layer} + ) + attns = { + layer_id: [key for key in down_blocks[i] if f"attn.{layer_id}" in key] + for layer_id in range(num_blocks) + } + + if num_attn > 0: + for j in range(config["layers_per_block"]): + paths = renew_attention_paths(attns[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint, config=config) + + mid_block_1_layers = [key for key in checkpoint if "mid.block_1" in key] + mid_block_2_layers = [key for key in checkpoint if "mid.block_2" in key] + mid_attn_1_layers = [key for key in checkpoint if "mid.attn_1" in key] + + # Mid new 2 + paths = renew_resnet_paths(mid_block_1_layers) + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[{"old": "mid.", "new": "mid_new_2."}, {"old": "block_1", "new": "resnets.0"}], + ) + + paths = renew_resnet_paths(mid_block_2_layers) + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[{"old": "mid.", "new": "mid_new_2."}, {"old": "block_2", "new": "resnets.1"}], + ) + + paths = renew_attention_paths(mid_attn_1_layers, in_mid=True) + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[{"old": "mid.", "new": "mid_new_2."}, {"old": "attn_1", "new": "attentions.0"}], + ) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + + if any("upsample" in layer for layer in up_blocks[i]): + new_checkpoint[f"decoder.up_blocks.{block_id}.upsamplers.0.conv.weight"] = checkpoint[ + f"decoder.up.{i}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{block_id}.upsamplers.0.conv.bias"] = checkpoint[ + f"decoder.up.{i}.upsample.conv.bias" + ] + + if any("block" in layer for layer in up_blocks[i]): + num_blocks = len( + {".".join(shave_segments(layer, 3).split(".")[:3]) for layer in up_blocks[i] if "block" in layer} + ) + blocks = { + layer_id: [key for key in up_blocks[i] if f"block.{layer_id}" in key] for layer_id in range(num_blocks) + } + + if num_blocks > 0: + for j in range(config["layers_per_block"] + 1): + replace_indices = {"old": f"up_blocks.{i}", "new": f"up_blocks.{block_id}"} + paths = renew_resnet_paths(blocks[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint, additional_replacements=[replace_indices]) + + if any("attn" in layer for layer in up_blocks[i]): + num_attn = len( + {".".join(shave_segments(layer, 3).split(".")[:3]) for layer in up_blocks[i] if "attn" in layer} + ) + attns = { + layer_id: [key for key in up_blocks[i] if f"attn.{layer_id}" in key] for layer_id in range(num_blocks) + } + + if num_attn > 0: + for j in range(config["layers_per_block"] + 1): + replace_indices = {"old": f"up_blocks.{i}", "new": f"up_blocks.{block_id}"} + paths = renew_attention_paths(attns[j]) + assign_to_checkpoint(paths, new_checkpoint, checkpoint, additional_replacements=[replace_indices]) + + new_checkpoint = {k.replace("mid_new_2", "mid_block"): v for k, v in new_checkpoint.items()} + new_checkpoint["quant_conv.weight"] = checkpoint["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = checkpoint["quant_conv.bias"] + if "quantize.embedding.weight" in checkpoint: + new_checkpoint["quantize.embedding.weight"] = checkpoint["quantize.embedding.weight"] + new_checkpoint["post_quant_conv.weight"] = checkpoint["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = checkpoint["post_quant_conv.bias"] + + return new_checkpoint + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + + parser.add_argument( + "--config_file", + default=None, + type=str, + required=True, + help="The config json file corresponding to the architecture.", + ) + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + args = parser.parse_args() + checkpoint = torch.load(args.checkpoint_path) + + with open(args.config_file) as f: + config = json.loads(f.read()) + + # unet case + key_prefix_set = {key.split(".")[0] for key in checkpoint.keys()} + if "encoder" in key_prefix_set and "decoder" in key_prefix_set: + converted_checkpoint = convert_vq_autoenc_checkpoint(checkpoint, config) + else: + converted_checkpoint = convert_ddpm_checkpoint(checkpoint, config) + + if "ddpm" in config: + del config["ddpm"] + + if config["_class_name"] == "VQModel": + model = VQModel(**config) + model.load_state_dict(converted_checkpoint) + model.save_pretrained(args.dump_path) + elif config["_class_name"] == "AutoencoderKL": + model = AutoencoderKL(**config) + model.load_state_dict(converted_checkpoint) + model.save_pretrained(args.dump_path) + else: + model = UNet2DModel(**config) + model.load_state_dict(converted_checkpoint) + + scheduler = DDPMScheduler.from_config("/".join(args.checkpoint_path.split("/")[:-1])) + + pipe = DDPMPipeline(unet=model, scheduler=scheduler) + pipe.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_sdxl_lora_to_webui.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_sdxl_lora_to_webui.py new file mode 100644 index 0000000000000000000000000000000000000000..dfb3871275cbc68809379596a9209e08f377936c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_sdxl_lora_to_webui.py @@ -0,0 +1,56 @@ +# Script for converting a Hugging Face Diffusers trained SDXL LoRAs to Kohya format +# This means that you can input your diffusers-trained LoRAs and +# Get the output to work with WebUIs such as AUTOMATIC1111, ComfyUI, SD.Next and others. + +# To get started you can find some cool `diffusers` trained LoRAs such as this cute Corgy +# https://huggingface.co/ignasbud/corgy_dog_LoRA/, download its `pytorch_lora_weights.safetensors` file +# and run the script: +# python convert_diffusers_sdxl_lora_to_webui.py --input_lora pytorch_lora_weights.safetensors --output_lora corgy.safetensors +# now you can use corgy.safetensors in your WebUI of choice! + +# To train your own, here are some diffusers training scripts and utils that you can use and then convert: +# LoRA Ease - no code SDXL Dreambooth LoRA trainer: https://huggingface.co/spaces/multimodalart/lora-ease +# Dreambooth Advanced Training Script - state of the art techniques such as pivotal tuning and prodigy optimizer: +# - Script: https://github.com/huggingface/diffusers/blob/main/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py +# - Colab (only on Pro): https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/SDXL_Dreambooth_LoRA_advanced_example.ipynb +# Canonical diffusers training scripts: +# - Script: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora_sdxl.py +# - Colab (runs on free tier): https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/SDXL_DreamBooth_LoRA_.ipynb + +import argparse +import os + +from safetensors.torch import load_file, save_file + +from diffusers.utils import convert_all_state_dict_to_peft, convert_state_dict_to_kohya + + +def convert_and_save(input_lora, output_lora=None): + if output_lora is None: + base_name = os.path.splitext(input_lora)[0] + output_lora = f"{base_name}_webui.safetensors" + + diffusers_state_dict = load_file(input_lora) + peft_state_dict = convert_all_state_dict_to_peft(diffusers_state_dict) + kohya_state_dict = convert_state_dict_to_kohya(peft_state_dict) + save_file(kohya_state_dict, output_lora) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Convert LoRA model to PEFT and then to Kohya format.") + parser.add_argument( + "--input_lora", + type=str, + required=True, + help="Path to the input LoRA model file in the diffusers format.", + ) + parser.add_argument( + "--output_lora", + type=str, + required=False, + help="Path for the converted LoRA (safetensors format for AUTOMATIC1111, ComfyUI, etc.). Optional, defaults to input name with a _webui suffix.", + ) + + args = parser.parse_args() + + convert_and_save(args.input_lora, args.output_lora) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_to_original_sdxl.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_to_original_sdxl.py new file mode 100644 index 0000000000000000000000000000000000000000..1aa792b3f06ac7db88078024da241e0aa97b7925 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_to_original_sdxl.py @@ -0,0 +1,350 @@ +# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint. +# *Only* converts the UNet, VAE, and Text Encoder. +# Does not convert optimizer state or any other thing. + +import argparse +import os.path as osp +import re + +import torch +from safetensors.torch import load_file, save_file + + +# =================# +# UNet Conversion # +# =================# + +unet_conversion_map = [ + # (stable-diffusion, HF Diffusers) + ("time_embed.0.weight", "time_embedding.linear_1.weight"), + ("time_embed.0.bias", "time_embedding.linear_1.bias"), + ("time_embed.2.weight", "time_embedding.linear_2.weight"), + ("time_embed.2.bias", "time_embedding.linear_2.bias"), + ("input_blocks.0.0.weight", "conv_in.weight"), + ("input_blocks.0.0.bias", "conv_in.bias"), + ("out.0.weight", "conv_norm_out.weight"), + ("out.0.bias", "conv_norm_out.bias"), + ("out.2.weight", "conv_out.weight"), + ("out.2.bias", "conv_out.bias"), + # the following are for sdxl + ("label_emb.0.0.weight", "add_embedding.linear_1.weight"), + ("label_emb.0.0.bias", "add_embedding.linear_1.bias"), + ("label_emb.0.2.weight", "add_embedding.linear_2.weight"), + ("label_emb.0.2.bias", "add_embedding.linear_2.bias"), +] + +unet_conversion_map_resnet = [ + # (stable-diffusion, HF Diffusers) + ("in_layers.0", "norm1"), + ("in_layers.2", "conv1"), + ("out_layers.0", "norm2"), + ("out_layers.3", "conv2"), + ("emb_layers.1", "time_emb_proj"), + ("skip_connection", "conv_shortcut"), +] + +unet_conversion_map_layer = [] +# hardcoded number of downblocks and resnets/attentions... +# would need smarter logic for other networks. +for i in range(3): + # loop over downblocks/upblocks + + for j in range(2): + # loop over resnets/attentions for downblocks + hf_down_res_prefix = f"down_blocks.{i}.resnets.{j}." + sd_down_res_prefix = f"input_blocks.{3 * i + j + 1}.0." + unet_conversion_map_layer.append((sd_down_res_prefix, hf_down_res_prefix)) + + if i > 0: + hf_down_atn_prefix = f"down_blocks.{i}.attentions.{j}." + sd_down_atn_prefix = f"input_blocks.{3 * i + j + 1}.1." + unet_conversion_map_layer.append((sd_down_atn_prefix, hf_down_atn_prefix)) + + for j in range(4): + # loop over resnets/attentions for upblocks + hf_up_res_prefix = f"up_blocks.{i}.resnets.{j}." + sd_up_res_prefix = f"output_blocks.{3 * i + j}.0." + unet_conversion_map_layer.append((sd_up_res_prefix, hf_up_res_prefix)) + + if i < 2: + # no attention layers in up_blocks.0 + hf_up_atn_prefix = f"up_blocks.{i}.attentions.{j}." + sd_up_atn_prefix = f"output_blocks.{3 * i + j}.1." + unet_conversion_map_layer.append((sd_up_atn_prefix, hf_up_atn_prefix)) + + if i < 3: + # no downsample in down_blocks.3 + hf_downsample_prefix = f"down_blocks.{i}.downsamplers.0.conv." + sd_downsample_prefix = f"input_blocks.{3 * (i + 1)}.0.op." + unet_conversion_map_layer.append((sd_downsample_prefix, hf_downsample_prefix)) + + # no upsample in up_blocks.3 + hf_upsample_prefix = f"up_blocks.{i}.upsamplers.0." + sd_upsample_prefix = f"output_blocks.{3 * i + 2}.{1 if i == 0 else 2}." + unet_conversion_map_layer.append((sd_upsample_prefix, hf_upsample_prefix)) +unet_conversion_map_layer.append(("output_blocks.2.2.conv.", "output_blocks.2.1.conv.")) + +hf_mid_atn_prefix = "mid_block.attentions.0." +sd_mid_atn_prefix = "middle_block.1." +unet_conversion_map_layer.append((sd_mid_atn_prefix, hf_mid_atn_prefix)) +for j in range(2): + hf_mid_res_prefix = f"mid_block.resnets.{j}." + sd_mid_res_prefix = f"middle_block.{2 * j}." + unet_conversion_map_layer.append((sd_mid_res_prefix, hf_mid_res_prefix)) + + +def convert_unet_state_dict(unet_state_dict): + # buyer beware: this is a *brittle* function, + # and correct output requires that all of these pieces interact in + # the exact order in which I have arranged them. + mapping = {k: k for k in unet_state_dict.keys()} + for sd_name, hf_name in unet_conversion_map: + mapping[hf_name] = sd_name + for k, v in mapping.items(): + if "resnets" in k: + for sd_part, hf_part in unet_conversion_map_resnet: + v = v.replace(hf_part, sd_part) + mapping[k] = v + for k, v in mapping.items(): + for sd_part, hf_part in unet_conversion_map_layer: + v = v.replace(hf_part, sd_part) + mapping[k] = v + new_state_dict = {sd_name: unet_state_dict[hf_name] for hf_name, sd_name in mapping.items()} + return new_state_dict + + +# ================# +# VAE Conversion # +# ================# + +vae_conversion_map = [ + # (stable-diffusion, HF Diffusers) + ("nin_shortcut", "conv_shortcut"), + ("norm_out", "conv_norm_out"), + ("mid.attn_1.", "mid_block.attentions.0."), +] + +for i in range(4): + # down_blocks have two resnets + for j in range(2): + hf_down_prefix = f"encoder.down_blocks.{i}.resnets.{j}." + sd_down_prefix = f"encoder.down.{i}.block.{j}." + vae_conversion_map.append((sd_down_prefix, hf_down_prefix)) + + if i < 3: + hf_downsample_prefix = f"down_blocks.{i}.downsamplers.0." + sd_downsample_prefix = f"down.{i}.downsample." + vae_conversion_map.append((sd_downsample_prefix, hf_downsample_prefix)) + + hf_upsample_prefix = f"up_blocks.{i}.upsamplers.0." + sd_upsample_prefix = f"up.{3 - i}.upsample." + vae_conversion_map.append((sd_upsample_prefix, hf_upsample_prefix)) + + # up_blocks have three resnets + # also, up blocks in hf are numbered in reverse from sd + for j in range(3): + hf_up_prefix = f"decoder.up_blocks.{i}.resnets.{j}." + sd_up_prefix = f"decoder.up.{3 - i}.block.{j}." + vae_conversion_map.append((sd_up_prefix, hf_up_prefix)) + +# this part accounts for mid blocks in both the encoder and the decoder +for i in range(2): + hf_mid_res_prefix = f"mid_block.resnets.{i}." + sd_mid_res_prefix = f"mid.block_{i + 1}." + vae_conversion_map.append((sd_mid_res_prefix, hf_mid_res_prefix)) + + +vae_conversion_map_attn = [ + # (stable-diffusion, HF Diffusers) + ("norm.", "group_norm."), + # the following are for SDXL + ("q.", "to_q."), + ("k.", "to_k."), + ("v.", "to_v."), + ("proj_out.", "to_out.0."), +] + + +def reshape_weight_for_sd(w): + # convert HF linear weights to SD conv2d weights + if not w.ndim == 1: + return w.reshape(*w.shape, 1, 1) + else: + return w + + +def convert_vae_state_dict(vae_state_dict): + mapping = {k: k for k in vae_state_dict.keys()} + for k, v in mapping.items(): + for sd_part, hf_part in vae_conversion_map: + v = v.replace(hf_part, sd_part) + mapping[k] = v + for k, v in mapping.items(): + if "attentions" in k: + for sd_part, hf_part in vae_conversion_map_attn: + v = v.replace(hf_part, sd_part) + mapping[k] = v + new_state_dict = {v: vae_state_dict[k] for k, v in mapping.items()} + weights_to_convert = ["q", "k", "v", "proj_out"] + for k, v in new_state_dict.items(): + for weight_name in weights_to_convert: + if f"mid.attn_1.{weight_name}.weight" in k: + print(f"Reshaping {k} for SD format") + new_state_dict[k] = reshape_weight_for_sd(v) + return new_state_dict + + +# =========================# +# Text Encoder Conversion # +# =========================# + + +textenc_conversion_lst = [ + # (stable-diffusion, HF Diffusers) + ("transformer.resblocks.", "text_model.encoder.layers."), + ("ln_1", "layer_norm1"), + ("ln_2", "layer_norm2"), + (".c_fc.", ".fc1."), + (".c_proj.", ".fc2."), + (".attn", ".self_attn"), + ("ln_final.", "text_model.final_layer_norm."), + ("token_embedding.weight", "text_model.embeddings.token_embedding.weight"), + ("positional_embedding", "text_model.embeddings.position_embedding.weight"), +] +protected = {re.escape(x[1]): x[0] for x in textenc_conversion_lst} +textenc_pattern = re.compile("|".join(protected.keys())) + +# Ordering is from https://github.com/pytorch/pytorch/blob/master/test/cpp/api/modules.cpp +code2idx = {"q": 0, "k": 1, "v": 2} + + +def convert_openclip_text_enc_state_dict(text_enc_dict): + new_state_dict = {} + capture_qkv_weight = {} + capture_qkv_bias = {} + for k, v in text_enc_dict.items(): + if ( + k.endswith(".self_attn.q_proj.weight") + or k.endswith(".self_attn.k_proj.weight") + or k.endswith(".self_attn.v_proj.weight") + ): + k_pre = k[: -len(".q_proj.weight")] + k_code = k[-len("q_proj.weight")] + if k_pre not in capture_qkv_weight: + capture_qkv_weight[k_pre] = [None, None, None] + capture_qkv_weight[k_pre][code2idx[k_code]] = v + continue + + if ( + k.endswith(".self_attn.q_proj.bias") + or k.endswith(".self_attn.k_proj.bias") + or k.endswith(".self_attn.v_proj.bias") + ): + k_pre = k[: -len(".q_proj.bias")] + k_code = k[-len("q_proj.bias")] + if k_pre not in capture_qkv_bias: + capture_qkv_bias[k_pre] = [None, None, None] + capture_qkv_bias[k_pre][code2idx[k_code]] = v + continue + + relabelled_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], k) + new_state_dict[relabelled_key] = v + + for k_pre, tensors in capture_qkv_weight.items(): + if None in tensors: + raise Exception("CORRUPTED MODEL: one of the q-k-v values for the text encoder was missing") + relabelled_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], k_pre) + new_state_dict[relabelled_key + ".in_proj_weight"] = torch.cat(tensors) + + for k_pre, tensors in capture_qkv_bias.items(): + if None in tensors: + raise Exception("CORRUPTED MODEL: one of the q-k-v values for the text encoder was missing") + relabelled_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], k_pre) + new_state_dict[relabelled_key + ".in_proj_bias"] = torch.cat(tensors) + + return new_state_dict + + +def convert_openai_text_enc_state_dict(text_enc_dict): + return text_enc_dict + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--model_path", default=None, type=str, required=True, help="Path to the model to convert.") + parser.add_argument("--checkpoint_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--half", action="store_true", help="Save weights in half precision.") + parser.add_argument( + "--use_safetensors", action="store_true", help="Save weights use safetensors, default is ckpt." + ) + + args = parser.parse_args() + + assert args.model_path is not None, "Must provide a model path!" + + assert args.checkpoint_path is not None, "Must provide a checkpoint path!" + + # Path for safetensors + unet_path = osp.join(args.model_path, "unet", "diffusion_pytorch_model.safetensors") + vae_path = osp.join(args.model_path, "vae", "diffusion_pytorch_model.safetensors") + text_enc_path = osp.join(args.model_path, "text_encoder", "model.safetensors") + text_enc_2_path = osp.join(args.model_path, "text_encoder_2", "model.safetensors") + + # Load models from safetensors if it exists, if it doesn't pytorch + if osp.exists(unet_path): + unet_state_dict = load_file(unet_path, device="cpu") + else: + unet_path = osp.join(args.model_path, "unet", "diffusion_pytorch_model.bin") + unet_state_dict = torch.load(unet_path, map_location="cpu") + + if osp.exists(vae_path): + vae_state_dict = load_file(vae_path, device="cpu") + else: + vae_path = osp.join(args.model_path, "vae", "diffusion_pytorch_model.bin") + vae_state_dict = torch.load(vae_path, map_location="cpu") + + if osp.exists(text_enc_path): + text_enc_dict = load_file(text_enc_path, device="cpu") + else: + text_enc_path = osp.join(args.model_path, "text_encoder", "pytorch_model.bin") + text_enc_dict = torch.load(text_enc_path, map_location="cpu") + + if osp.exists(text_enc_2_path): + text_enc_2_dict = load_file(text_enc_2_path, device="cpu") + else: + text_enc_2_path = osp.join(args.model_path, "text_encoder_2", "pytorch_model.bin") + text_enc_2_dict = torch.load(text_enc_2_path, map_location="cpu") + + # Convert the UNet model + unet_state_dict = convert_unet_state_dict(unet_state_dict) + unet_state_dict = {"model.diffusion_model." + k: v for k, v in unet_state_dict.items()} + + # Convert the VAE model + vae_state_dict = convert_vae_state_dict(vae_state_dict) + vae_state_dict = {"first_stage_model." + k: v for k, v in vae_state_dict.items()} + + # Convert text encoder 1 + text_enc_dict = convert_openai_text_enc_state_dict(text_enc_dict) + text_enc_dict = {"conditioner.embedders.0.transformer." + k: v for k, v in text_enc_dict.items()} + + # Convert text encoder 2 + text_enc_2_dict = convert_openclip_text_enc_state_dict(text_enc_2_dict) + text_enc_2_dict = {"conditioner.embedders.1.model." + k: v for k, v in text_enc_2_dict.items()} + # We call the `.T.contiguous()` to match what's done in + # https://github.com/huggingface/diffusers/blob/84905ca7287876b925b6bf8e9bb92fec21c78764/src/diffusers/loaders/single_file_utils.py#L1085 + text_enc_2_dict["conditioner.embedders.1.model.text_projection"] = text_enc_2_dict.pop( + "conditioner.embedders.1.model.text_projection.weight" + ).T.contiguous() + + # Put together new checkpoint + state_dict = {**unet_state_dict, **vae_state_dict, **text_enc_dict, **text_enc_2_dict} + + if args.half: + state_dict = {k: v.half() for k, v in state_dict.items()} + + if args.use_safetensors: + save_file(state_dict, args.checkpoint_path) + else: + state_dict = {"state_dict": state_dict} + torch.save(state_dict, args.checkpoint_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_to_original_stable_diffusion.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_to_original_stable_diffusion.py new file mode 100644 index 0000000000000000000000000000000000000000..049dda7d42a748d487f708f9595e196b49d39840 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_diffusers_to_original_stable_diffusion.py @@ -0,0 +1,353 @@ +# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint. +# *Only* converts the UNet, VAE, and Text Encoder. +# Does not convert optimizer state or any other thing. + +import argparse +import os.path as osp +import re + +import torch +from safetensors.torch import load_file, save_file + + +# =================# +# UNet Conversion # +# =================# + +unet_conversion_map = [ + # (stable-diffusion, HF Diffusers) + ("time_embed.0.weight", "time_embedding.linear_1.weight"), + ("time_embed.0.bias", "time_embedding.linear_1.bias"), + ("time_embed.2.weight", "time_embedding.linear_2.weight"), + ("time_embed.2.bias", "time_embedding.linear_2.bias"), + ("input_blocks.0.0.weight", "conv_in.weight"), + ("input_blocks.0.0.bias", "conv_in.bias"), + ("out.0.weight", "conv_norm_out.weight"), + ("out.0.bias", "conv_norm_out.bias"), + ("out.2.weight", "conv_out.weight"), + ("out.2.bias", "conv_out.bias"), +] + +unet_conversion_map_resnet = [ + # (stable-diffusion, HF Diffusers) + ("in_layers.0", "norm1"), + ("in_layers.2", "conv1"), + ("out_layers.0", "norm2"), + ("out_layers.3", "conv2"), + ("emb_layers.1", "time_emb_proj"), + ("skip_connection", "conv_shortcut"), +] + +unet_conversion_map_layer = [] +# hardcoded number of downblocks and resnets/attentions... +# would need smarter logic for other networks. +for i in range(4): + # loop over downblocks/upblocks + + for j in range(2): + # loop over resnets/attentions for downblocks + hf_down_res_prefix = f"down_blocks.{i}.resnets.{j}." + sd_down_res_prefix = f"input_blocks.{3 * i + j + 1}.0." + unet_conversion_map_layer.append((sd_down_res_prefix, hf_down_res_prefix)) + + if i < 3: + # no attention layers in down_blocks.3 + hf_down_atn_prefix = f"down_blocks.{i}.attentions.{j}." + sd_down_atn_prefix = f"input_blocks.{3 * i + j + 1}.1." + unet_conversion_map_layer.append((sd_down_atn_prefix, hf_down_atn_prefix)) + + for j in range(3): + # loop over resnets/attentions for upblocks + hf_up_res_prefix = f"up_blocks.{i}.resnets.{j}." + sd_up_res_prefix = f"output_blocks.{3 * i + j}.0." + unet_conversion_map_layer.append((sd_up_res_prefix, hf_up_res_prefix)) + + if i > 0: + # no attention layers in up_blocks.0 + hf_up_atn_prefix = f"up_blocks.{i}.attentions.{j}." + sd_up_atn_prefix = f"output_blocks.{3 * i + j}.1." + unet_conversion_map_layer.append((sd_up_atn_prefix, hf_up_atn_prefix)) + + if i < 3: + # no downsample in down_blocks.3 + hf_downsample_prefix = f"down_blocks.{i}.downsamplers.0.conv." + sd_downsample_prefix = f"input_blocks.{3 * (i + 1)}.0.op." + unet_conversion_map_layer.append((sd_downsample_prefix, hf_downsample_prefix)) + + # no upsample in up_blocks.3 + hf_upsample_prefix = f"up_blocks.{i}.upsamplers.0." + sd_upsample_prefix = f"output_blocks.{3 * i + 2}.{1 if i == 0 else 2}." + unet_conversion_map_layer.append((sd_upsample_prefix, hf_upsample_prefix)) + +hf_mid_atn_prefix = "mid_block.attentions.0." +sd_mid_atn_prefix = "middle_block.1." +unet_conversion_map_layer.append((sd_mid_atn_prefix, hf_mid_atn_prefix)) + +for j in range(2): + hf_mid_res_prefix = f"mid_block.resnets.{j}." + sd_mid_res_prefix = f"middle_block.{2 * j}." + unet_conversion_map_layer.append((sd_mid_res_prefix, hf_mid_res_prefix)) + + +def convert_unet_state_dict(unet_state_dict): + # buyer beware: this is a *brittle* function, + # and correct output requires that all of these pieces interact in + # the exact order in which I have arranged them. + mapping = {k: k for k in unet_state_dict.keys()} + for sd_name, hf_name in unet_conversion_map: + mapping[hf_name] = sd_name + for k, v in mapping.items(): + if "resnets" in k: + for sd_part, hf_part in unet_conversion_map_resnet: + v = v.replace(hf_part, sd_part) + mapping[k] = v + for k, v in mapping.items(): + for sd_part, hf_part in unet_conversion_map_layer: + v = v.replace(hf_part, sd_part) + mapping[k] = v + new_state_dict = {v: unet_state_dict[k] for k, v in mapping.items()} + return new_state_dict + + +# ================# +# VAE Conversion # +# ================# + +vae_conversion_map = [ + # (stable-diffusion, HF Diffusers) + ("nin_shortcut", "conv_shortcut"), + ("norm_out", "conv_norm_out"), + ("mid.attn_1.", "mid_block.attentions.0."), +] + +for i in range(4): + # down_blocks have two resnets + for j in range(2): + hf_down_prefix = f"encoder.down_blocks.{i}.resnets.{j}." + sd_down_prefix = f"encoder.down.{i}.block.{j}." + vae_conversion_map.append((sd_down_prefix, hf_down_prefix)) + + if i < 3: + hf_downsample_prefix = f"down_blocks.{i}.downsamplers.0." + sd_downsample_prefix = f"down.{i}.downsample." + vae_conversion_map.append((sd_downsample_prefix, hf_downsample_prefix)) + + hf_upsample_prefix = f"up_blocks.{i}.upsamplers.0." + sd_upsample_prefix = f"up.{3 - i}.upsample." + vae_conversion_map.append((sd_upsample_prefix, hf_upsample_prefix)) + + # up_blocks have three resnets + # also, up blocks in hf are numbered in reverse from sd + for j in range(3): + hf_up_prefix = f"decoder.up_blocks.{i}.resnets.{j}." + sd_up_prefix = f"decoder.up.{3 - i}.block.{j}." + vae_conversion_map.append((sd_up_prefix, hf_up_prefix)) + +# this part accounts for mid blocks in both the encoder and the decoder +for i in range(2): + hf_mid_res_prefix = f"mid_block.resnets.{i}." + sd_mid_res_prefix = f"mid.block_{i + 1}." + vae_conversion_map.append((sd_mid_res_prefix, hf_mid_res_prefix)) + + +vae_conversion_map_attn = [ + # (stable-diffusion, HF Diffusers) + ("norm.", "group_norm."), + ("q.", "query."), + ("k.", "key."), + ("v.", "value."), + ("proj_out.", "proj_attn."), +] + +# This is probably not the most ideal solution, but it does work. +vae_extra_conversion_map = [ + ("to_q", "q"), + ("to_k", "k"), + ("to_v", "v"), + ("to_out.0", "proj_out"), +] + + +def reshape_weight_for_sd(w): + # convert HF linear weights to SD conv2d weights + if not w.ndim == 1: + return w.reshape(*w.shape, 1, 1) + else: + return w + + +def convert_vae_state_dict(vae_state_dict): + mapping = {k: k for k in vae_state_dict.keys()} + for k, v in mapping.items(): + for sd_part, hf_part in vae_conversion_map: + v = v.replace(hf_part, sd_part) + mapping[k] = v + for k, v in mapping.items(): + if "attentions" in k: + for sd_part, hf_part in vae_conversion_map_attn: + v = v.replace(hf_part, sd_part) + mapping[k] = v + new_state_dict = {v: vae_state_dict[k] for k, v in mapping.items()} + weights_to_convert = ["q", "k", "v", "proj_out"] + keys_to_rename = {} + for k, v in new_state_dict.items(): + for weight_name in weights_to_convert: + if f"mid.attn_1.{weight_name}.weight" in k: + print(f"Reshaping {k} for SD format") + new_state_dict[k] = reshape_weight_for_sd(v) + for weight_name, real_weight_name in vae_extra_conversion_map: + if f"mid.attn_1.{weight_name}.weight" in k or f"mid.attn_1.{weight_name}.bias" in k: + keys_to_rename[k] = k.replace(weight_name, real_weight_name) + for k, v in keys_to_rename.items(): + if k in new_state_dict: + print(f"Renaming {k} to {v}") + new_state_dict[v] = reshape_weight_for_sd(new_state_dict[k]) + del new_state_dict[k] + return new_state_dict + + +# =========================# +# Text Encoder Conversion # +# =========================# + + +textenc_conversion_lst = [ + # (stable-diffusion, HF Diffusers) + ("resblocks.", "text_model.encoder.layers."), + ("ln_1", "layer_norm1"), + ("ln_2", "layer_norm2"), + (".c_fc.", ".fc1."), + (".c_proj.", ".fc2."), + (".attn", ".self_attn"), + ("ln_final.", "transformer.text_model.final_layer_norm."), + ("token_embedding.weight", "transformer.text_model.embeddings.token_embedding.weight"), + ("positional_embedding", "transformer.text_model.embeddings.position_embedding.weight"), +] +protected = {re.escape(x[1]): x[0] for x in textenc_conversion_lst} +textenc_pattern = re.compile("|".join(protected.keys())) + +# Ordering is from https://github.com/pytorch/pytorch/blob/master/test/cpp/api/modules.cpp +code2idx = {"q": 0, "k": 1, "v": 2} + + +def convert_text_enc_state_dict_v20(text_enc_dict): + new_state_dict = {} + capture_qkv_weight = {} + capture_qkv_bias = {} + for k, v in text_enc_dict.items(): + if ( + k.endswith(".self_attn.q_proj.weight") + or k.endswith(".self_attn.k_proj.weight") + or k.endswith(".self_attn.v_proj.weight") + ): + k_pre = k[: -len(".q_proj.weight")] + k_code = k[-len("q_proj.weight")] + if k_pre not in capture_qkv_weight: + capture_qkv_weight[k_pre] = [None, None, None] + capture_qkv_weight[k_pre][code2idx[k_code]] = v + continue + + if ( + k.endswith(".self_attn.q_proj.bias") + or k.endswith(".self_attn.k_proj.bias") + or k.endswith(".self_attn.v_proj.bias") + ): + k_pre = k[: -len(".q_proj.bias")] + k_code = k[-len("q_proj.bias")] + if k_pre not in capture_qkv_bias: + capture_qkv_bias[k_pre] = [None, None, None] + capture_qkv_bias[k_pre][code2idx[k_code]] = v + continue + + relabelled_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], k) + new_state_dict[relabelled_key] = v + + for k_pre, tensors in capture_qkv_weight.items(): + if None in tensors: + raise Exception("CORRUPTED MODEL: one of the q-k-v values for the text encoder was missing") + relabelled_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], k_pre) + new_state_dict[relabelled_key + ".in_proj_weight"] = torch.cat(tensors) + + for k_pre, tensors in capture_qkv_bias.items(): + if None in tensors: + raise Exception("CORRUPTED MODEL: one of the q-k-v values for the text encoder was missing") + relabelled_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], k_pre) + new_state_dict[relabelled_key + ".in_proj_bias"] = torch.cat(tensors) + + return new_state_dict + + +def convert_text_enc_state_dict(text_enc_dict): + return text_enc_dict + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--model_path", default=None, type=str, required=True, help="Path to the model to convert.") + parser.add_argument("--checkpoint_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--half", action="store_true", help="Save weights in half precision.") + parser.add_argument( + "--use_safetensors", action="store_true", help="Save weights use safetensors, default is ckpt." + ) + + args = parser.parse_args() + + assert args.model_path is not None, "Must provide a model path!" + + assert args.checkpoint_path is not None, "Must provide a checkpoint path!" + + # Path for safetensors + unet_path = osp.join(args.model_path, "unet", "diffusion_pytorch_model.safetensors") + vae_path = osp.join(args.model_path, "vae", "diffusion_pytorch_model.safetensors") + text_enc_path = osp.join(args.model_path, "text_encoder", "model.safetensors") + + # Load models from safetensors if it exists, if it doesn't pytorch + if osp.exists(unet_path): + unet_state_dict = load_file(unet_path, device="cpu") + else: + unet_path = osp.join(args.model_path, "unet", "diffusion_pytorch_model.bin") + unet_state_dict = torch.load(unet_path, map_location="cpu") + + if osp.exists(vae_path): + vae_state_dict = load_file(vae_path, device="cpu") + else: + vae_path = osp.join(args.model_path, "vae", "diffusion_pytorch_model.bin") + vae_state_dict = torch.load(vae_path, map_location="cpu") + + if osp.exists(text_enc_path): + text_enc_dict = load_file(text_enc_path, device="cpu") + else: + text_enc_path = osp.join(args.model_path, "text_encoder", "pytorch_model.bin") + text_enc_dict = torch.load(text_enc_path, map_location="cpu") + + # Convert the UNet model + unet_state_dict = convert_unet_state_dict(unet_state_dict) + unet_state_dict = {"model.diffusion_model." + k: v for k, v in unet_state_dict.items()} + + # Convert the VAE model + vae_state_dict = convert_vae_state_dict(vae_state_dict) + vae_state_dict = {"first_stage_model." + k: v for k, v in vae_state_dict.items()} + + # Easiest way to identify v2.0 model seems to be that the text encoder (OpenCLIP) is deeper + is_v20_model = "text_model.encoder.layers.22.layer_norm2.bias" in text_enc_dict + + if is_v20_model: + # Need to add the tag 'transformer' in advance so we can knock it out from the final layer-norm + text_enc_dict = {"transformer." + k: v for k, v in text_enc_dict.items()} + text_enc_dict = convert_text_enc_state_dict_v20(text_enc_dict) + text_enc_dict = {"cond_stage_model.model." + k: v for k, v in text_enc_dict.items()} + else: + text_enc_dict = convert_text_enc_state_dict(text_enc_dict) + text_enc_dict = {"cond_stage_model.transformer." + k: v for k, v in text_enc_dict.items()} + + # Put together new checkpoint + state_dict = {**unet_state_dict, **vae_state_dict, **text_enc_dict} + if args.half: + state_dict = {k: v.half() for k, v in state_dict.items()} + + if args.use_safetensors: + save_file(state_dict, args.checkpoint_path) + else: + state_dict = {"state_dict": state_dict} + torch.save(state_dict, args.checkpoint_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dit_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dit_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..dc127f69555c260f594e70444b1540faa196e3fb --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_dit_to_diffusers.py @@ -0,0 +1,162 @@ +import argparse +import os + +import torch +from torchvision.datasets.utils import download_url + +from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, Transformer2DModel + + +pretrained_models = {512: "DiT-XL-2-512x512.pt", 256: "DiT-XL-2-256x256.pt"} + + +def download_model(model_name): + """ + Downloads a pre-trained DiT model from the web. + """ + local_path = f"pretrained_models/{model_name}" + if not os.path.isfile(local_path): + os.makedirs("pretrained_models", exist_ok=True) + web_path = f"https://dl.fbaipublicfiles.com/DiT/models/{model_name}" + download_url(web_path, "pretrained_models") + model = torch.load(local_path, map_location=lambda storage, loc: storage) + return model + + +def main(args): + state_dict = download_model(pretrained_models[args.image_size]) + + state_dict["pos_embed.proj.weight"] = state_dict["x_embedder.proj.weight"] + state_dict["pos_embed.proj.bias"] = state_dict["x_embedder.proj.bias"] + state_dict.pop("x_embedder.proj.weight") + state_dict.pop("x_embedder.proj.bias") + + for depth in range(28): + state_dict[f"transformer_blocks.{depth}.norm1.emb.timestep_embedder.linear_1.weight"] = state_dict[ + "t_embedder.mlp.0.weight" + ] + state_dict[f"transformer_blocks.{depth}.norm1.emb.timestep_embedder.linear_1.bias"] = state_dict[ + "t_embedder.mlp.0.bias" + ] + state_dict[f"transformer_blocks.{depth}.norm1.emb.timestep_embedder.linear_2.weight"] = state_dict[ + "t_embedder.mlp.2.weight" + ] + state_dict[f"transformer_blocks.{depth}.norm1.emb.timestep_embedder.linear_2.bias"] = state_dict[ + "t_embedder.mlp.2.bias" + ] + state_dict[f"transformer_blocks.{depth}.norm1.emb.class_embedder.embedding_table.weight"] = state_dict[ + "y_embedder.embedding_table.weight" + ] + + state_dict[f"transformer_blocks.{depth}.norm1.linear.weight"] = state_dict[ + f"blocks.{depth}.adaLN_modulation.1.weight" + ] + state_dict[f"transformer_blocks.{depth}.norm1.linear.bias"] = state_dict[ + f"blocks.{depth}.adaLN_modulation.1.bias" + ] + + q, k, v = torch.chunk(state_dict[f"blocks.{depth}.attn.qkv.weight"], 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(state_dict[f"blocks.{depth}.attn.qkv.bias"], 3, dim=0) + + state_dict[f"transformer_blocks.{depth}.attn1.to_q.weight"] = q + state_dict[f"transformer_blocks.{depth}.attn1.to_q.bias"] = q_bias + state_dict[f"transformer_blocks.{depth}.attn1.to_k.weight"] = k + state_dict[f"transformer_blocks.{depth}.attn1.to_k.bias"] = k_bias + state_dict[f"transformer_blocks.{depth}.attn1.to_v.weight"] = v + state_dict[f"transformer_blocks.{depth}.attn1.to_v.bias"] = v_bias + + state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.weight"] = state_dict[ + f"blocks.{depth}.attn.proj.weight" + ] + state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.bias"] = state_dict[f"blocks.{depth}.attn.proj.bias"] + + state_dict[f"transformer_blocks.{depth}.ff.net.0.proj.weight"] = state_dict[f"blocks.{depth}.mlp.fc1.weight"] + state_dict[f"transformer_blocks.{depth}.ff.net.0.proj.bias"] = state_dict[f"blocks.{depth}.mlp.fc1.bias"] + state_dict[f"transformer_blocks.{depth}.ff.net.2.weight"] = state_dict[f"blocks.{depth}.mlp.fc2.weight"] + state_dict[f"transformer_blocks.{depth}.ff.net.2.bias"] = state_dict[f"blocks.{depth}.mlp.fc2.bias"] + + state_dict.pop(f"blocks.{depth}.attn.qkv.weight") + state_dict.pop(f"blocks.{depth}.attn.qkv.bias") + state_dict.pop(f"blocks.{depth}.attn.proj.weight") + state_dict.pop(f"blocks.{depth}.attn.proj.bias") + state_dict.pop(f"blocks.{depth}.mlp.fc1.weight") + state_dict.pop(f"blocks.{depth}.mlp.fc1.bias") + state_dict.pop(f"blocks.{depth}.mlp.fc2.weight") + state_dict.pop(f"blocks.{depth}.mlp.fc2.bias") + state_dict.pop(f"blocks.{depth}.adaLN_modulation.1.weight") + state_dict.pop(f"blocks.{depth}.adaLN_modulation.1.bias") + + state_dict.pop("t_embedder.mlp.0.weight") + state_dict.pop("t_embedder.mlp.0.bias") + state_dict.pop("t_embedder.mlp.2.weight") + state_dict.pop("t_embedder.mlp.2.bias") + state_dict.pop("y_embedder.embedding_table.weight") + + state_dict["proj_out_1.weight"] = state_dict["final_layer.adaLN_modulation.1.weight"] + state_dict["proj_out_1.bias"] = state_dict["final_layer.adaLN_modulation.1.bias"] + state_dict["proj_out_2.weight"] = state_dict["final_layer.linear.weight"] + state_dict["proj_out_2.bias"] = state_dict["final_layer.linear.bias"] + + state_dict.pop("final_layer.linear.weight") + state_dict.pop("final_layer.linear.bias") + state_dict.pop("final_layer.adaLN_modulation.1.weight") + state_dict.pop("final_layer.adaLN_modulation.1.bias") + + # DiT XL/2 + transformer = Transformer2DModel( + sample_size=args.image_size // 8, + num_layers=28, + attention_head_dim=72, + in_channels=4, + out_channels=8, + patch_size=2, + attention_bias=True, + num_attention_heads=16, + activation_fn="gelu-approximate", + num_embeds_ada_norm=1000, + norm_type="ada_norm_zero", + norm_elementwise_affine=False, + ) + transformer.load_state_dict(state_dict, strict=True) + + scheduler = DDIMScheduler( + num_train_timesteps=1000, + beta_schedule="linear", + prediction_type="epsilon", + clip_sample=False, + ) + + vae = AutoencoderKL.from_pretrained(args.vae_model) + + pipeline = DiTPipeline(transformer=transformer, vae=vae, scheduler=scheduler) + + if args.save: + pipeline.save_pretrained(args.checkpoint_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--image_size", + default=256, + type=int, + required=False, + help="Image size of pretrained model, either 256 or 512.", + ) + parser.add_argument( + "--vae_model", + default="stabilityai/sd-vae-ft-ema", + type=str, + required=False, + help="Path to pretrained VAE model, either stabilityai/sd-vae-ft-mse or stabilityai/sd-vae-ft-ema.", + ) + parser.add_argument( + "--save", default=True, type=bool, required=False, help="Whether to save the converted pipeline or not." + ) + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the output pipeline." + ) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_flux_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_flux_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..ec31d842d4db14949a846b20daeebcefbdd580ec --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_flux_to_diffusers.py @@ -0,0 +1,308 @@ +import argparse +from contextlib import nullcontext + +import safetensors.torch +import torch +from accelerate import init_empty_weights +from huggingface_hub import hf_hub_download + +from diffusers import AutoencoderKL, FluxTransformer2DModel +from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint +from diffusers.utils.import_utils import is_accelerate_available + + +""" +# Transformer + +python scripts/convert_flux_to_diffusers.py \ +--original_state_dict_repo_id "black-forest-labs/FLUX.1-schnell" \ +--filename "flux1-schnell.sft" +--output_path "flux-schnell" \ +--transformer +""" + +""" +# VAE + +python scripts/convert_flux_to_diffusers.py \ +--original_state_dict_repo_id "black-forest-labs/FLUX.1-schnell" \ +--filename "ae.sft" +--output_path "flux-schnell" \ +--vae +""" + +CTX = init_empty_weights if is_accelerate_available() else nullcontext + +parser = argparse.ArgumentParser() +parser.add_argument("--original_state_dict_repo_id", default=None, type=str) +parser.add_argument("--filename", default="flux.safetensors", type=str) +parser.add_argument("--checkpoint_path", default=None, type=str) +parser.add_argument("--in_channels", type=int, default=64) +parser.add_argument("--out_channels", type=int, default=None) +parser.add_argument("--vae", action="store_true") +parser.add_argument("--transformer", action="store_true") +parser.add_argument("--output_path", type=str) +parser.add_argument("--dtype", type=str, default="bf16") + +args = parser.parse_args() +dtype = torch.bfloat16 if args.dtype == "bf16" else torch.float32 + + +def load_original_checkpoint(args): + if args.original_state_dict_repo_id is not None: + ckpt_path = hf_hub_download(repo_id=args.original_state_dict_repo_id, filename=args.filename) + elif args.checkpoint_path is not None: + ckpt_path = args.checkpoint_path + else: + raise ValueError(" please provide either `original_state_dict_repo_id` or a local `checkpoint_path`") + + original_state_dict = safetensors.torch.load_file(ckpt_path) + return original_state_dict + + +# in SD3 original implementation of AdaLayerNormContinuous, it split linear projection output into shift, scale; +# while in diffusers it split into scale, shift. Here we swap the linear projection weights in order to be able to use diffusers implementation +def swap_scale_shift(weight): + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + return new_weight + + +def convert_flux_transformer_checkpoint_to_diffusers( + original_state_dict, num_layers, num_single_layers, inner_dim, mlp_ratio=4.0 +): + converted_state_dict = {} + + ## time_text_embed.timestep_embedder <- time_in + converted_state_dict["time_text_embed.timestep_embedder.linear_1.weight"] = original_state_dict.pop( + "time_in.in_layer.weight" + ) + converted_state_dict["time_text_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop( + "time_in.in_layer.bias" + ) + converted_state_dict["time_text_embed.timestep_embedder.linear_2.weight"] = original_state_dict.pop( + "time_in.out_layer.weight" + ) + converted_state_dict["time_text_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop( + "time_in.out_layer.bias" + ) + + ## time_text_embed.text_embedder <- vector_in + converted_state_dict["time_text_embed.text_embedder.linear_1.weight"] = original_state_dict.pop( + "vector_in.in_layer.weight" + ) + converted_state_dict["time_text_embed.text_embedder.linear_1.bias"] = original_state_dict.pop( + "vector_in.in_layer.bias" + ) + converted_state_dict["time_text_embed.text_embedder.linear_2.weight"] = original_state_dict.pop( + "vector_in.out_layer.weight" + ) + converted_state_dict["time_text_embed.text_embedder.linear_2.bias"] = original_state_dict.pop( + "vector_in.out_layer.bias" + ) + + # guidance + has_guidance = any("guidance" in k for k in original_state_dict) + if has_guidance: + converted_state_dict["time_text_embed.guidance_embedder.linear_1.weight"] = original_state_dict.pop( + "guidance_in.in_layer.weight" + ) + converted_state_dict["time_text_embed.guidance_embedder.linear_1.bias"] = original_state_dict.pop( + "guidance_in.in_layer.bias" + ) + converted_state_dict["time_text_embed.guidance_embedder.linear_2.weight"] = original_state_dict.pop( + "guidance_in.out_layer.weight" + ) + converted_state_dict["time_text_embed.guidance_embedder.linear_2.bias"] = original_state_dict.pop( + "guidance_in.out_layer.bias" + ) + + # context_embedder + converted_state_dict["context_embedder.weight"] = original_state_dict.pop("txt_in.weight") + converted_state_dict["context_embedder.bias"] = original_state_dict.pop("txt_in.bias") + + # x_embedder + converted_state_dict["x_embedder.weight"] = original_state_dict.pop("img_in.weight") + converted_state_dict["x_embedder.bias"] = original_state_dict.pop("img_in.bias") + + # double transformer blocks + for i in range(num_layers): + block_prefix = f"transformer_blocks.{i}." + # norms. + ## norm1 + converted_state_dict[f"{block_prefix}norm1.linear.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_mod.lin.weight" + ) + converted_state_dict[f"{block_prefix}norm1.linear.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_mod.lin.bias" + ) + ## norm1_context + converted_state_dict[f"{block_prefix}norm1_context.linear.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mod.lin.weight" + ) + converted_state_dict[f"{block_prefix}norm1_context.linear.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mod.lin.bias" + ) + # Q, K, V + sample_q, sample_k, sample_v = torch.chunk( + original_state_dict.pop(f"double_blocks.{i}.img_attn.qkv.weight"), 3, dim=0 + ) + context_q, context_k, context_v = torch.chunk( + original_state_dict.pop(f"double_blocks.{i}.txt_attn.qkv.weight"), 3, dim=0 + ) + sample_q_bias, sample_k_bias, sample_v_bias = torch.chunk( + original_state_dict.pop(f"double_blocks.{i}.img_attn.qkv.bias"), 3, dim=0 + ) + context_q_bias, context_k_bias, context_v_bias = torch.chunk( + original_state_dict.pop(f"double_blocks.{i}.txt_attn.qkv.bias"), 3, dim=0 + ) + converted_state_dict[f"{block_prefix}attn.to_q.weight"] = torch.cat([sample_q]) + converted_state_dict[f"{block_prefix}attn.to_q.bias"] = torch.cat([sample_q_bias]) + converted_state_dict[f"{block_prefix}attn.to_k.weight"] = torch.cat([sample_k]) + converted_state_dict[f"{block_prefix}attn.to_k.bias"] = torch.cat([sample_k_bias]) + converted_state_dict[f"{block_prefix}attn.to_v.weight"] = torch.cat([sample_v]) + converted_state_dict[f"{block_prefix}attn.to_v.bias"] = torch.cat([sample_v_bias]) + converted_state_dict[f"{block_prefix}attn.add_q_proj.weight"] = torch.cat([context_q]) + converted_state_dict[f"{block_prefix}attn.add_q_proj.bias"] = torch.cat([context_q_bias]) + converted_state_dict[f"{block_prefix}attn.add_k_proj.weight"] = torch.cat([context_k]) + converted_state_dict[f"{block_prefix}attn.add_k_proj.bias"] = torch.cat([context_k_bias]) + converted_state_dict[f"{block_prefix}attn.add_v_proj.weight"] = torch.cat([context_v]) + converted_state_dict[f"{block_prefix}attn.add_v_proj.bias"] = torch.cat([context_v_bias]) + # qk_norm + converted_state_dict[f"{block_prefix}attn.norm_q.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn.norm.query_norm.scale" + ) + converted_state_dict[f"{block_prefix}attn.norm_k.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn.norm.key_norm.scale" + ) + converted_state_dict[f"{block_prefix}attn.norm_added_q.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn.norm.query_norm.scale" + ) + converted_state_dict[f"{block_prefix}attn.norm_added_k.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn.norm.key_norm.scale" + ) + # ff img_mlp + converted_state_dict[f"{block_prefix}ff.net.0.proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.0.weight" + ) + converted_state_dict[f"{block_prefix}ff.net.0.proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.0.bias" + ) + converted_state_dict[f"{block_prefix}ff.net.2.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.2.weight" + ) + converted_state_dict[f"{block_prefix}ff.net.2.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.2.bias" + ) + converted_state_dict[f"{block_prefix}ff_context.net.0.proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.0.weight" + ) + converted_state_dict[f"{block_prefix}ff_context.net.0.proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.0.bias" + ) + converted_state_dict[f"{block_prefix}ff_context.net.2.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.2.weight" + ) + converted_state_dict[f"{block_prefix}ff_context.net.2.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.2.bias" + ) + # output projections. + converted_state_dict[f"{block_prefix}attn.to_out.0.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn.proj.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_out.0.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn.proj.bias" + ) + converted_state_dict[f"{block_prefix}attn.to_add_out.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn.proj.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_add_out.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn.proj.bias" + ) + + # single transformer blocks + for i in range(num_single_layers): + block_prefix = f"single_transformer_blocks.{i}." + # norm.linear <- single_blocks.0.modulation.lin + converted_state_dict[f"{block_prefix}norm.linear.weight"] = original_state_dict.pop( + f"single_blocks.{i}.modulation.lin.weight" + ) + converted_state_dict[f"{block_prefix}norm.linear.bias"] = original_state_dict.pop( + f"single_blocks.{i}.modulation.lin.bias" + ) + # Q, K, V, mlp + mlp_hidden_dim = int(inner_dim * mlp_ratio) + split_size = (inner_dim, inner_dim, inner_dim, mlp_hidden_dim) + q, k, v, mlp = torch.split(original_state_dict.pop(f"single_blocks.{i}.linear1.weight"), split_size, dim=0) + q_bias, k_bias, v_bias, mlp_bias = torch.split( + original_state_dict.pop(f"single_blocks.{i}.linear1.bias"), split_size, dim=0 + ) + converted_state_dict[f"{block_prefix}attn.to_q.weight"] = torch.cat([q]) + converted_state_dict[f"{block_prefix}attn.to_q.bias"] = torch.cat([q_bias]) + converted_state_dict[f"{block_prefix}attn.to_k.weight"] = torch.cat([k]) + converted_state_dict[f"{block_prefix}attn.to_k.bias"] = torch.cat([k_bias]) + converted_state_dict[f"{block_prefix}attn.to_v.weight"] = torch.cat([v]) + converted_state_dict[f"{block_prefix}attn.to_v.bias"] = torch.cat([v_bias]) + converted_state_dict[f"{block_prefix}proj_mlp.weight"] = torch.cat([mlp]) + converted_state_dict[f"{block_prefix}proj_mlp.bias"] = torch.cat([mlp_bias]) + # qk norm + converted_state_dict[f"{block_prefix}attn.norm_q.weight"] = original_state_dict.pop( + f"single_blocks.{i}.norm.query_norm.scale" + ) + converted_state_dict[f"{block_prefix}attn.norm_k.weight"] = original_state_dict.pop( + f"single_blocks.{i}.norm.key_norm.scale" + ) + # output projections. + converted_state_dict[f"{block_prefix}proj_out.weight"] = original_state_dict.pop( + f"single_blocks.{i}.linear2.weight" + ) + converted_state_dict[f"{block_prefix}proj_out.bias"] = original_state_dict.pop( + f"single_blocks.{i}.linear2.bias" + ) + + converted_state_dict["proj_out.weight"] = original_state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = original_state_dict.pop("final_layer.linear.bias") + converted_state_dict["norm_out.linear.weight"] = swap_scale_shift( + original_state_dict.pop("final_layer.adaLN_modulation.1.weight") + ) + converted_state_dict["norm_out.linear.bias"] = swap_scale_shift( + original_state_dict.pop("final_layer.adaLN_modulation.1.bias") + ) + + return converted_state_dict + + +def main(args): + original_ckpt = load_original_checkpoint(args) + has_guidance = any("guidance" in k for k in original_ckpt) + + if args.transformer: + num_layers = 19 + num_single_layers = 38 + inner_dim = 3072 + mlp_ratio = 4.0 + + converted_transformer_state_dict = convert_flux_transformer_checkpoint_to_diffusers( + original_ckpt, num_layers, num_single_layers, inner_dim, mlp_ratio=mlp_ratio + ) + transformer = FluxTransformer2DModel( + in_channels=args.in_channels, out_channels=args.out_channels, guidance_embeds=has_guidance + ) + transformer.load_state_dict(converted_transformer_state_dict, strict=True) + + print( + f"Saving Flux Transformer in Diffusers format. Variant: {'guidance-distilled' if has_guidance else 'timestep-distilled'}" + ) + transformer.to(dtype).save_pretrained(f"{args.output_path}/transformer") + + if args.vae: + config = AutoencoderKL.load_config("stabilityai/stable-diffusion-3-medium-diffusers", subfolder="vae") + vae = AutoencoderKL.from_config(config, scaling_factor=0.3611, shift_factor=0.1159).to(torch.bfloat16) + + converted_vae_state_dict = convert_ldm_vae_checkpoint(original_ckpt, vae.config) + vae.load_state_dict(converted_vae_state_dict, strict=True) + vae.to(dtype).save_pretrained(f"{args.output_path}/vae") + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_flux_xlabs_ipadapter_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_flux_xlabs_ipadapter_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..b701b7fb40b1b9f115ece6bf0dddee6d4ca7052a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_flux_xlabs_ipadapter_to_diffusers.py @@ -0,0 +1,97 @@ +import argparse +from contextlib import nullcontext + +import safetensors.torch +from accelerate import init_empty_weights +from huggingface_hub import hf_hub_download + +from diffusers.utils.import_utils import is_accelerate_available, is_transformers_available + + +if is_transformers_available(): + from transformers import CLIPVisionModelWithProjection + + vision = True +else: + vision = False + +""" +python scripts/convert_flux_xlabs_ipadapter_to_diffusers.py \ +--original_state_dict_repo_id "XLabs-AI/flux-ip-adapter" \ +--filename "flux-ip-adapter.safetensors" +--output_path "flux-ip-adapter-hf/" +""" + + +CTX = init_empty_weights if is_accelerate_available else nullcontext + +parser = argparse.ArgumentParser() +parser.add_argument("--original_state_dict_repo_id", default=None, type=str) +parser.add_argument("--filename", default="flux.safetensors", type=str) +parser.add_argument("--checkpoint_path", default=None, type=str) +parser.add_argument("--output_path", type=str) +parser.add_argument("--vision_pretrained_or_path", default="openai/clip-vit-large-patch14", type=str) + +args = parser.parse_args() + + +def load_original_checkpoint(args): + if args.original_state_dict_repo_id is not None: + ckpt_path = hf_hub_download(repo_id=args.original_state_dict_repo_id, filename=args.filename) + elif args.checkpoint_path is not None: + ckpt_path = args.checkpoint_path + else: + raise ValueError(" please provide either `original_state_dict_repo_id` or a local `checkpoint_path`") + + original_state_dict = safetensors.torch.load_file(ckpt_path) + return original_state_dict + + +def convert_flux_ipadapter_checkpoint_to_diffusers(original_state_dict, num_layers): + converted_state_dict = {} + + # image_proj + ## norm + converted_state_dict["image_proj.norm.weight"] = original_state_dict.pop("ip_adapter_proj_model.norm.weight") + converted_state_dict["image_proj.norm.bias"] = original_state_dict.pop("ip_adapter_proj_model.norm.bias") + ## proj + converted_state_dict["image_proj.proj.weight"] = original_state_dict.pop("ip_adapter_proj_model.norm.weight") + converted_state_dict["image_proj.proj.bias"] = original_state_dict.pop("ip_adapter_proj_model.norm.bias") + + # double transformer blocks + for i in range(num_layers): + block_prefix = f"ip_adapter.{i}." + # to_k_ip + converted_state_dict[f"{block_prefix}to_k_ip.bias"] = original_state_dict.pop( + f"double_blocks.{i}.processor.ip_adapter_double_stream_k_proj.bias" + ) + converted_state_dict[f"{block_prefix}to_k_ip.weight"] = original_state_dict.pop( + f"double_blocks.{i}.processor.ip_adapter_double_stream_k_proj.weight" + ) + # to_v_ip + converted_state_dict[f"{block_prefix}to_v_ip.bias"] = original_state_dict.pop( + f"double_blocks.{i}.processor.ip_adapter_double_stream_v_proj.bias" + ) + converted_state_dict[f"{block_prefix}to_k_ip.weight"] = original_state_dict.pop( + f"double_blocks.{i}.processor.ip_adapter_double_stream_v_proj.weight" + ) + + return converted_state_dict + + +def main(args): + original_ckpt = load_original_checkpoint(args) + + num_layers = 19 + converted_ip_adapter_state_dict = convert_flux_ipadapter_checkpoint_to_diffusers(original_ckpt, num_layers) + + print("Saving Flux IP-Adapter in Diffusers format.") + safetensors.torch.save_file(converted_ip_adapter_state_dict, f"{args.output_path}/model.safetensors") + + if vision: + model = CLIPVisionModelWithProjection.from_pretrained(args.vision_pretrained_or_path) + model.save_pretrained(f"{args.output_path}/image_encoder") + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_gligen_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_gligen_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..83c1f928e407f9a9cc93a07a609ae2472c2a7b18 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_gligen_to_diffusers.py @@ -0,0 +1,581 @@ +import argparse +import re + +import torch +import yaml +from transformers import ( + CLIPProcessor, + CLIPTextModel, + CLIPTokenizer, + CLIPVisionModelWithProjection, +) + +from diffusers import ( + AutoencoderKL, + DDIMScheduler, + StableDiffusionGLIGENPipeline, + StableDiffusionGLIGENTextImagePipeline, + UNet2DConditionModel, +) +from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( + assign_to_checkpoint, + conv_attn_to_linear, + protected, + renew_attention_paths, + renew_resnet_paths, + renew_vae_attention_paths, + renew_vae_resnet_paths, + shave_segments, + textenc_conversion_map, + textenc_pattern, +) + + +def convert_open_clip_checkpoint(checkpoint): + checkpoint = checkpoint["text_encoder"] + text_model = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14") + + keys = list(checkpoint.keys()) + + text_model_dict = {} + + if "cond_stage_model.model.text_projection" in checkpoint: + d_model = int(checkpoint["cond_stage_model.model.text_projection"].shape[0]) + else: + d_model = 1024 + + for key in keys: + if "resblocks.23" in key: # Diffusers drops the final layer and only uses the penultimate layer + continue + if key in textenc_conversion_map: + text_model_dict[textenc_conversion_map[key]] = checkpoint[key] + # if key.startswith("cond_stage_model.model.transformer."): + new_key = key[len("transformer.") :] + if new_key.endswith(".in_proj_weight"): + new_key = new_key[: -len(".in_proj_weight")] + new_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], new_key) + text_model_dict[new_key + ".q_proj.weight"] = checkpoint[key][:d_model, :] + text_model_dict[new_key + ".k_proj.weight"] = checkpoint[key][d_model : d_model * 2, :] + text_model_dict[new_key + ".v_proj.weight"] = checkpoint[key][d_model * 2 :, :] + elif new_key.endswith(".in_proj_bias"): + new_key = new_key[: -len(".in_proj_bias")] + new_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], new_key) + text_model_dict[new_key + ".q_proj.bias"] = checkpoint[key][:d_model] + text_model_dict[new_key + ".k_proj.bias"] = checkpoint[key][d_model : d_model * 2] + text_model_dict[new_key + ".v_proj.bias"] = checkpoint[key][d_model * 2 :] + else: + if key != "transformer.text_model.embeddings.position_ids": + new_key = textenc_pattern.sub(lambda m: protected[re.escape(m.group(0))], new_key) + + text_model_dict[new_key] = checkpoint[key] + + if key == "transformer.text_model.embeddings.token_embedding.weight": + text_model_dict["text_model.embeddings.token_embedding.weight"] = checkpoint[key] + + text_model_dict.pop("text_model.embeddings.transformer.text_model.embeddings.token_embedding.weight") + + text_model.load_state_dict(text_model_dict) + + return text_model + + +def convert_gligen_vae_checkpoint(checkpoint, config): + checkpoint = checkpoint["autoencoder"] + vae_state_dict = {} + vae_key = "first_stage_model." + keys = list(checkpoint.keys()) + for key in keys: + vae_state_dict[key.replace(vae_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for key in new_checkpoint.keys(): + if "encoder.mid_block.attentions.0" in key or "decoder.mid_block.attentions.0" in key: + if "query" in key: + new_checkpoint[key.replace("query", "to_q")] = new_checkpoint.pop(key) + if "value" in key: + new_checkpoint[key.replace("value", "to_v")] = new_checkpoint.pop(key) + if "key" in key: + new_checkpoint[key.replace("key", "to_k")] = new_checkpoint.pop(key) + if "proj_attn" in key: + new_checkpoint[key.replace("proj_attn", "to_out.0")] = new_checkpoint.pop(key) + + return new_checkpoint + + +def convert_gligen_unet_checkpoint(checkpoint, config, path=None, extract_ema=False): + unet_state_dict = {} + checkpoint = checkpoint["model"] + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + print(f"Checkpoint {path} has bot EMA and non-EMA weights.") + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + for key in keys: + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + for key in keys: + if "position_net" in key: + new_checkpoint[key] = unet_state_dict[key] + + return new_checkpoint + + +def create_vae_config(original_config, image_size: int): + vae_params = original_config["autoencoder"]["params"]["ddconfig"] + _ = original_config["autoencoder"]["params"]["embed_dim"] + + block_out_channels = [vae_params["ch"] * mult for mult in vae_params["ch_mult"]] + down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) + up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) + + config = { + "sample_size": image_size, + "in_channels": vae_params["in_channels"], + "out_channels": vae_params["out_ch"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "latent_channels": vae_params["z_channels"], + "layers_per_block": vae_params["num_res_blocks"], + } + + return config + + +def create_unet_config(original_config, image_size: int, attention_type): + unet_params = original_config["model"]["params"] + vae_params = original_config["autoencoder"]["params"]["ddconfig"] + + block_out_channels = [unet_params["model_channels"] * mult for mult in unet_params["channel_mult"]] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlock2D" if resolution in unet_params["attention_resolutions"] else "DownBlock2D" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlock2D" if resolution in unet_params["attention_resolutions"] else "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + vae_scale_factor = 2 ** (len(vae_params["ch_mult"]) - 1) + + head_dim = unet_params["num_heads"] if "num_heads" in unet_params else None + use_linear_projection = ( + unet_params["use_linear_in_transformer"] if "use_linear_in_transformer" in unet_params else False + ) + if use_linear_projection: + if head_dim is None: + head_dim = [5, 10, 20, 20] + + config = { + "sample_size": image_size // vae_scale_factor, + "in_channels": unet_params["in_channels"], + "down_block_types": tuple(down_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params["num_res_blocks"], + "cross_attention_dim": unet_params["context_dim"], + "attention_head_dim": head_dim, + "use_linear_projection": use_linear_projection, + "attention_type": attention_type, + } + + return config + + +def convert_gligen_to_diffusers( + checkpoint_path: str, + original_config_file: str, + attention_type: str, + image_size: int = 512, + extract_ema: bool = False, + num_in_channels: int = None, + device: str = None, +): + if device is None: + device = "cuda" if torch.cuda.is_available() else "cpu" + checkpoint = torch.load(checkpoint_path, map_location=device) + else: + checkpoint = torch.load(checkpoint_path, map_location=device) + + if "global_step" in checkpoint: + checkpoint["global_step"] + else: + print("global_step key not found in model") + + original_config = yaml.safe_load(original_config_file) + + if num_in_channels is not None: + original_config["model"]["params"]["in_channels"] = num_in_channels + + num_train_timesteps = original_config["diffusion"]["params"]["timesteps"] + beta_start = original_config["diffusion"]["params"]["linear_start"] + beta_end = original_config["diffusion"]["params"]["linear_end"] + + scheduler = DDIMScheduler( + beta_end=beta_end, + beta_schedule="scaled_linear", + beta_start=beta_start, + num_train_timesteps=num_train_timesteps, + steps_offset=1, + clip_sample=False, + set_alpha_to_one=False, + prediction_type="epsilon", + ) + + # Convert the UNet2DConditionalModel model + unet_config = create_unet_config(original_config, image_size, attention_type) + unet = UNet2DConditionModel(**unet_config) + + converted_unet_checkpoint = convert_gligen_unet_checkpoint( + checkpoint, unet_config, path=checkpoint_path, extract_ema=extract_ema + ) + + unet.load_state_dict(converted_unet_checkpoint) + + # Convert the VAE model + vae_config = create_vae_config(original_config, image_size) + converted_vae_checkpoint = convert_gligen_vae_checkpoint(checkpoint, vae_config) + + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_checkpoint) + + # Convert the text model + text_encoder = convert_open_clip_checkpoint(checkpoint) + tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14") + + if attention_type == "gated-text-image": + image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") + processor = CLIPProcessor.from_pretrained("openai/clip-vit-large-patch14") + + pipe = StableDiffusionGLIGENTextImagePipeline( + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + image_encoder=image_encoder, + processor=processor, + unet=unet, + scheduler=scheduler, + safety_checker=None, + feature_extractor=None, + ) + elif attention_type == "gated": + pipe = StableDiffusionGLIGENPipeline( + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + unet=unet, + scheduler=scheduler, + safety_checker=None, + feature_extractor=None, + ) + + return pipe + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--original_config_file", + default=None, + type=str, + required=True, + help="The YAML config file corresponding to the gligen architecture.", + ) + parser.add_argument( + "--num_in_channels", + default=None, + type=int, + help="The number of input channels. If `None` number of input channels will be automatically inferred.", + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--attention_type", + default=None, + type=str, + required=True, + help="Type of attention ex: gated or gated-text-image", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use.") + parser.add_argument("--half", action="store_true", help="Save weights in half precision.") + + args = parser.parse_args() + + pipe = convert_gligen_to_diffusers( + checkpoint_path=args.checkpoint_path, + original_config_file=args.original_config_file, + attention_type=args.attention_type, + extract_ema=args.extract_ema, + num_in_channels=args.num_in_channels, + device=args.device, + ) + + if args.half: + pipe.to(dtype=torch.float16) + + pipe.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuan_image_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuan_image_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..c41e934cc3d430a09a81bc68b815d6d5a60d3fc7 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuan_image_to_diffusers.py @@ -0,0 +1,1044 @@ +import argparse +import logging + +import torch +from safetensors import safe_open + +from diffusers import AutoencoderKLHunyuanImage, AutoencoderKLHunyuanImageRefiner, HunyuanImageTransformer2DModel + + +logger = logging.getLogger(__name__) # pylint: disable=invalid-name + + +""" +Usage examples +============== + +python scripts/convert_hunyuan_image_to_diffusers.py \ + --model_type hunyuanimage2.1 \ + --transformer_checkpoint_path "/raid/yiyi/HunyuanImage-2.1/ckpts/dit/hunyuanimage2.1.safetensors" \ + --vae_checkpoint_path "HunyuanImage-2.1/ckpts/vae/vae_2_1/pytorch_model.ckpt" \ + --output_path "/raid/yiyi/test-hy21-diffusers" \ + --dtype fp32 + +python scripts/convert_hunyuan_image_to_diffusers.py \ + --model_type hunyuanimage2.1-distilled \ + --transformer_checkpoint_path "/raid/yiyi/HunyuanImage-2.1/ckpts/dit/hunyuanimage2.1-distilled.safetensors" \ + --vae_checkpoint_path "/raid/yiyi/HunyuanImage-2.1/ckpts/vae/vae_2_1/pytorch_model.ckpt" \ + --output_path "/raid/yiyi/test-hy21-distilled-diffusers" \ + --dtype fp32 + + +python scripts/convert_hunyuan_image_to_diffusers.py \ + --model_type hunyuanimage-refiner \ + --transformer_checkpoint_path "/raid/yiyi/HunyuanImage-2.1/ckpts/dit/hunyuanimage-refiner.safetensors" \ + --vae_checkpoint_path "/raid/yiyi/HunyuanImage-2.1/ckpts/vae/vae_refiner/pytorch_model.pt" \ + --output_path "/raid/yiyi/test-hy2-refiner-diffusers" \ + --dtype fp32 +""" + +parser = argparse.ArgumentParser() +parser.add_argument( + "--model_type", type=str, default=None +) # hunyuanimage2.1, hunyuanimage2.1-distilled, hunyuanimage-refiner +parser.add_argument("--transformer_checkpoint_path", default=None, type=str) # ckpts/dit/hunyuanimage2.1.safetensors +parser.add_argument("--vae_checkpoint_path", default=None, type=str) # ckpts/vae/vae_2_1/pytorch_model.ckpt +parser.add_argument("--output_path", type=str) +parser.add_argument("--dtype", type=str, default="fp32") + +args = parser.parse_args() +dtype = torch.bfloat16 if args.dtype == "bf16" else torch.float32 + + +# copied from https://github.com/Tencent-Hunyuan/HunyuanImage-2.1/hyimage/models/hunyuan/modules/hunyuanimage_dit.py#L21 +def convert_hunyuan_dict_for_tensor_parallel(state_dict): + """ + Convert a Hunyuan model state dict to be compatible with tensor parallel architectures. + + Args: + state_dict: Original state dict + + Returns: + new_dict: Converted state dict + """ + new_dict = {} + for k, w in state_dict.items(): + if k.startswith("double_blocks") and "attn_qkv.weight" in k: + hidden_size = w.shape[1] + k1 = k.replace("attn_qkv.weight", "attn_q.weight") + w1 = w[:hidden_size, :] + new_dict[k1] = w1 + k2 = k.replace("attn_qkv.weight", "attn_k.weight") + w2 = w[hidden_size : 2 * hidden_size, :] + new_dict[k2] = w2 + k3 = k.replace("attn_qkv.weight", "attn_v.weight") + w3 = w[-hidden_size:, :] + new_dict[k3] = w3 + elif k.startswith("double_blocks") and "attn_qkv.bias" in k: + hidden_size = w.shape[0] // 3 + k1 = k.replace("attn_qkv.bias", "attn_q.bias") + w1 = w[:hidden_size] + new_dict[k1] = w1 + k2 = k.replace("attn_qkv.bias", "attn_k.bias") + w2 = w[hidden_size : 2 * hidden_size] + new_dict[k2] = w2 + k3 = k.replace("attn_qkv.bias", "attn_v.bias") + w3 = w[-hidden_size:] + new_dict[k3] = w3 + elif k.startswith("single_blocks") and "linear1" in k: + hidden_size = state_dict[k.replace("linear1", "linear2")].shape[0] + k1 = k.replace("linear1", "linear1_q") + w1 = w[:hidden_size] + new_dict[k1] = w1 + k2 = k.replace("linear1", "linear1_k") + w2 = w[hidden_size : 2 * hidden_size] + new_dict[k2] = w2 + k3 = k.replace("linear1", "linear1_v") + w3 = w[2 * hidden_size : 3 * hidden_size] + new_dict[k3] = w3 + k4 = k.replace("linear1", "linear1_mlp") + w4 = w[3 * hidden_size :] + new_dict[k4] = w4 + elif k.startswith("single_blocks") and "linear2" in k: + k1 = k.replace("linear2", "linear2.fc") + new_dict[k1] = w + else: + new_dict[k] = w + return new_dict + + +def load_original_vae_checkpoint(args): + # "ckpts/vae/vae_2_1/pytorch_model.ckpt" + state_dict = torch.load(args.vae_checkpoint_path) + + if "state_dict" in state_dict: + state_dict = state_dict["state_dict"] + vae_state_dict = {} + for k, v in state_dict.items(): + if k.startswith("vae."): + vae_state_dict[k.replace("vae.", "")] = v + + for k, v in vae_state_dict.items(): + if "weight" in k: + if len(v.shape) == 5 and v.shape[2] == 1: + vae_state_dict[k] = v.squeeze(2) + else: + vae_state_dict[k] = v + else: + vae_state_dict[k] = v + return vae_state_dict + + +def load_original_refiner_vae_checkpoint(args): + # "ckpts/vae/vae_refiner/pytorch_model.pt" + state_dict = torch.load(args.vae_checkpoint_path) + + if "state_dict" in state_dict: + state_dict = state_dict["state_dict"] + vae_state_dict = {} + for k, v in state_dict.items(): + if k.startswith("vae."): + vae_state_dict[k.replace("vae.", "")] = v + return vae_state_dict + + +def load_original_transformer_checkpoint(args): + # ckpts/dit/hunyuanimage-refiner.safetensors" + # ckpts/dit/hunyuanimage2.1.safetensors" + state_dict = {} + with safe_open(args.transformer_checkpoint_path, framework="pt", device="cpu") as f: + for key in f.keys(): + state_dict[key] = f.get_tensor(key) + if args.model_type == "hunyuanimage-2.1": + state_dict = convert_hunyuan_dict_for_tensor_parallel(state_dict) + return state_dict + + +def convert_hunyuan_image_transformer_checkpoint_to_diffusers( + original_state_dict, use_byt5=True, guidance_distilled=False, use_meanflow=False +): + converted_state_dict = {} + + # 1. byt5_in -> context_embedder_2 + if use_byt5: + converted_state_dict["context_embedder_2.norm.weight"] = original_state_dict.pop("byt5_in.layernorm.weight") + converted_state_dict["context_embedder_2.norm.bias"] = original_state_dict.pop("byt5_in.layernorm.bias") + converted_state_dict["context_embedder_2.linear_1.weight"] = original_state_dict.pop("byt5_in.fc1.weight") + converted_state_dict["context_embedder_2.linear_1.bias"] = original_state_dict.pop("byt5_in.fc1.bias") + converted_state_dict["context_embedder_2.linear_2.weight"] = original_state_dict.pop("byt5_in.fc2.weight") + converted_state_dict["context_embedder_2.linear_2.bias"] = original_state_dict.pop("byt5_in.fc2.bias") + converted_state_dict["context_embedder_2.linear_3.weight"] = original_state_dict.pop("byt5_in.fc3.weight") + converted_state_dict["context_embedder_2.linear_3.bias"] = original_state_dict.pop("byt5_in.fc3.bias") + + # 2. img_in -> x_embedder + converted_state_dict["x_embedder.proj.weight"] = original_state_dict.pop("img_in.proj.weight") + converted_state_dict["x_embedder.proj.bias"] = original_state_dict.pop("img_in.proj.bias") + + # 3. txt_in -> context_embedder (complex mapping) + # txt_in.input_embedder -> context_embedder.proj_in + converted_state_dict["context_embedder.proj_in.weight"] = original_state_dict.pop("txt_in.input_embedder.weight") + converted_state_dict["context_embedder.proj_in.bias"] = original_state_dict.pop("txt_in.input_embedder.bias") + + # txt_in.t_embedder -> context_embedder.time_text_embed.timestep_embedder + converted_state_dict["context_embedder.time_text_embed.timestep_embedder.linear_1.weight"] = ( + original_state_dict.pop("txt_in.t_embedder.mlp.0.weight") + ) + converted_state_dict["context_embedder.time_text_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop( + "txt_in.t_embedder.mlp.0.bias" + ) + converted_state_dict["context_embedder.time_text_embed.timestep_embedder.linear_2.weight"] = ( + original_state_dict.pop("txt_in.t_embedder.mlp.2.weight") + ) + converted_state_dict["context_embedder.time_text_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop( + "txt_in.t_embedder.mlp.2.bias" + ) + + # txt_in.c_embedder -> context_embedder.time_text_embed.text_embedder + converted_state_dict["context_embedder.time_text_embed.text_embedder.linear_1.weight"] = original_state_dict.pop( + "txt_in.c_embedder.linear_1.weight" + ) + converted_state_dict["context_embedder.time_text_embed.text_embedder.linear_1.bias"] = original_state_dict.pop( + "txt_in.c_embedder.linear_1.bias" + ) + converted_state_dict["context_embedder.time_text_embed.text_embedder.linear_2.weight"] = original_state_dict.pop( + "txt_in.c_embedder.linear_2.weight" + ) + converted_state_dict["context_embedder.time_text_embed.text_embedder.linear_2.bias"] = original_state_dict.pop( + "txt_in.c_embedder.linear_2.bias" + ) + + # txt_in.individual_token_refiner -> context_embedder.token_refiner + for i in range(2): # 2 refiner blocks + block_prefix = f"context_embedder.token_refiner.refiner_blocks.{i}." + # norm1 + converted_state_dict[f"{block_prefix}norm1.weight"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.norm1.weight" + ) + converted_state_dict[f"{block_prefix}norm1.bias"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.norm1.bias" + ) + # norm2 + converted_state_dict[f"{block_prefix}norm2.weight"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.norm2.weight" + ) + converted_state_dict[f"{block_prefix}norm2.bias"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.norm2.bias" + ) + + # Split QKV + qkv_weight = original_state_dict.pop(f"txt_in.individual_token_refiner.blocks.{i}.self_attn_qkv.weight") + qkv_bias = original_state_dict.pop(f"txt_in.individual_token_refiner.blocks.{i}.self_attn_qkv.bias") + q_weight, k_weight, v_weight = torch.chunk(qkv_weight, 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(qkv_bias, 3, dim=0) + + converted_state_dict[f"{block_prefix}attn.to_q.weight"] = q_weight + converted_state_dict[f"{block_prefix}attn.to_q.bias"] = q_bias + converted_state_dict[f"{block_prefix}attn.to_k.weight"] = k_weight + converted_state_dict[f"{block_prefix}attn.to_k.bias"] = k_bias + converted_state_dict[f"{block_prefix}attn.to_v.weight"] = v_weight + converted_state_dict[f"{block_prefix}attn.to_v.bias"] = v_bias + + # attn projection + converted_state_dict[f"{block_prefix}attn.to_out.0.weight"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.self_attn_proj.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_out.0.bias"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.self_attn_proj.bias" + ) + + # MLP + converted_state_dict[f"{block_prefix}ff.net.0.proj.weight"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.mlp.fc1.weight" + ) + converted_state_dict[f"{block_prefix}ff.net.0.proj.bias"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.mlp.fc1.bias" + ) + converted_state_dict[f"{block_prefix}ff.net.2.weight"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.mlp.fc2.weight" + ) + converted_state_dict[f"{block_prefix}ff.net.2.bias"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.mlp.fc2.bias" + ) + + # norm_out + converted_state_dict[f"{block_prefix}norm_out.linear.weight"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.adaLN_modulation.1.weight" + ) + converted_state_dict[f"{block_prefix}norm_out.linear.bias"] = original_state_dict.pop( + f"txt_in.individual_token_refiner.blocks.{i}.adaLN_modulation.1.bias" + ) + + # 4. time_in -> time_text_embed.timestep_embedder + converted_state_dict["time_guidance_embed.timestep_embedder.linear_1.weight"] = original_state_dict.pop( + "time_in.mlp.0.weight" + ) + converted_state_dict["time_guidance_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop( + "time_in.mlp.0.bias" + ) + converted_state_dict["time_guidance_embed.timestep_embedder.linear_2.weight"] = original_state_dict.pop( + "time_in.mlp.2.weight" + ) + converted_state_dict["time_guidance_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop( + "time_in.mlp.2.bias" + ) + + # time_r_in -> time_guidance_embed.timestep_r_embedder + if use_meanflow: + converted_state_dict["time_guidance_embed.timestep_embedder_r.linear_1.weight"] = original_state_dict.pop( + "time_r_in.mlp.0.weight" + ) + converted_state_dict["time_guidance_embed.timestep_embedder_r.linear_1.bias"] = original_state_dict.pop( + "time_r_in.mlp.0.bias" + ) + converted_state_dict["time_guidance_embed.timestep_embedder_r.linear_2.weight"] = original_state_dict.pop( + "time_r_in.mlp.2.weight" + ) + converted_state_dict["time_guidance_embed.timestep_embedder_r.linear_2.bias"] = original_state_dict.pop( + "time_r_in.mlp.2.bias" + ) + + # guidance_in -> time_guidance_embed.guidance_embedder + if guidance_distilled: + converted_state_dict["time_guidance_embed.guidance_embedder.linear_1.weight"] = original_state_dict.pop( + "guidance_in.mlp.0.weight" + ) + converted_state_dict["time_guidance_embed.guidance_embedder.linear_1.bias"] = original_state_dict.pop( + "guidance_in.mlp.0.bias" + ) + converted_state_dict["time_guidance_embed.guidance_embedder.linear_2.weight"] = original_state_dict.pop( + "guidance_in.mlp.2.weight" + ) + converted_state_dict["time_guidance_embed.guidance_embedder.linear_2.bias"] = original_state_dict.pop( + "guidance_in.mlp.2.bias" + ) + + # 5. double_blocks -> transformer_blocks + for i in range(20): # 20 double blocks + block_prefix = f"transformer_blocks.{i}." + + # norm1 (img_mod) + converted_state_dict[f"{block_prefix}norm1.linear.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_mod.linear.weight" + ) + converted_state_dict[f"{block_prefix}norm1.linear.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_mod.linear.bias" + ) + + # norm1_context (txt_mod) + converted_state_dict[f"{block_prefix}norm1_context.linear.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mod.linear.weight" + ) + converted_state_dict[f"{block_prefix}norm1_context.linear.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mod.linear.bias" + ) + + # img attention + converted_state_dict[f"{block_prefix}attn.to_q.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_q.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_q.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_q.bias" + ) + converted_state_dict[f"{block_prefix}attn.to_k.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_k.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_k.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_k.bias" + ) + converted_state_dict[f"{block_prefix}attn.to_v.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_v.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_v.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_v.bias" + ) + + # img attention norms + converted_state_dict[f"{block_prefix}attn.norm_q.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_q_norm.weight" + ) + converted_state_dict[f"{block_prefix}attn.norm_k.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_k_norm.weight" + ) + + # img attention projection + converted_state_dict[f"{block_prefix}attn.to_out.0.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_proj.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_out.0.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_attn_proj.bias" + ) + + # img MLP + converted_state_dict[f"{block_prefix}ff.net.0.proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.fc1.weight" + ) + converted_state_dict[f"{block_prefix}ff.net.0.proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.fc1.bias" + ) + converted_state_dict[f"{block_prefix}ff.net.2.weight"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.fc2.weight" + ) + converted_state_dict[f"{block_prefix}ff.net.2.bias"] = original_state_dict.pop( + f"double_blocks.{i}.img_mlp.fc2.bias" + ) + + # txt attention (additional projections) + converted_state_dict[f"{block_prefix}attn.add_q_proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_q.weight" + ) + converted_state_dict[f"{block_prefix}attn.add_q_proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_q.bias" + ) + converted_state_dict[f"{block_prefix}attn.add_k_proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_k.weight" + ) + converted_state_dict[f"{block_prefix}attn.add_k_proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_k.bias" + ) + converted_state_dict[f"{block_prefix}attn.add_v_proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_v.weight" + ) + converted_state_dict[f"{block_prefix}attn.add_v_proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_v.bias" + ) + + # txt attention norms + converted_state_dict[f"{block_prefix}attn.norm_added_q.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_q_norm.weight" + ) + converted_state_dict[f"{block_prefix}attn.norm_added_k.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_k_norm.weight" + ) + + # txt attention projection + converted_state_dict[f"{block_prefix}attn.to_add_out.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_proj.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_add_out.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_attn_proj.bias" + ) + + # txt MLP (ff_context) + converted_state_dict[f"{block_prefix}ff_context.net.0.proj.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.fc1.weight" + ) + converted_state_dict[f"{block_prefix}ff_context.net.0.proj.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.fc1.bias" + ) + converted_state_dict[f"{block_prefix}ff_context.net.2.weight"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.fc2.weight" + ) + converted_state_dict[f"{block_prefix}ff_context.net.2.bias"] = original_state_dict.pop( + f"double_blocks.{i}.txt_mlp.fc2.bias" + ) + + # 6. single_blocks -> single_transformer_blocks + for i in range(40): # 40 single blocks + block_prefix = f"single_transformer_blocks.{i}." + + # norm + converted_state_dict[f"{block_prefix}norm.linear.weight"] = original_state_dict.pop( + f"single_blocks.{i}.modulation.linear.weight" + ) + converted_state_dict[f"{block_prefix}norm.linear.bias"] = original_state_dict.pop( + f"single_blocks.{i}.modulation.linear.bias" + ) + + # attention Q, K, V + converted_state_dict[f"{block_prefix}attn.to_q.weight"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_q.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_q.bias"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_q.bias" + ) + converted_state_dict[f"{block_prefix}attn.to_k.weight"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_k.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_k.bias"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_k.bias" + ) + converted_state_dict[f"{block_prefix}attn.to_v.weight"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_v.weight" + ) + converted_state_dict[f"{block_prefix}attn.to_v.bias"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_v.bias" + ) + + # attention norms + converted_state_dict[f"{block_prefix}attn.norm_q.weight"] = original_state_dict.pop( + f"single_blocks.{i}.q_norm.weight" + ) + converted_state_dict[f"{block_prefix}attn.norm_k.weight"] = original_state_dict.pop( + f"single_blocks.{i}.k_norm.weight" + ) + + # MLP projection + converted_state_dict[f"{block_prefix}proj_mlp.weight"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_mlp.weight" + ) + converted_state_dict[f"{block_prefix}proj_mlp.bias"] = original_state_dict.pop( + f"single_blocks.{i}.linear1_mlp.bias" + ) + + # output projection + converted_state_dict[f"{block_prefix}proj_out.weight"] = original_state_dict.pop( + f"single_blocks.{i}.linear2.fc.weight" + ) + converted_state_dict[f"{block_prefix}proj_out.bias"] = original_state_dict.pop( + f"single_blocks.{i}.linear2.fc.bias" + ) + + # 7. final_layer -> norm_out + proj_out + converted_state_dict["proj_out.weight"] = original_state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = original_state_dict.pop("final_layer.linear.bias") + shift_w, scale_w = original_state_dict.pop("final_layer.adaLN_modulation.1.weight").chunk(2, dim=0) + shift_b, scale_b = original_state_dict.pop("final_layer.adaLN_modulation.1.bias").chunk(2, dim=0) + converted_state_dict["norm_out.linear.weight"] = torch.cat([scale_w, shift_w], dim=0) + converted_state_dict["norm_out.linear.bias"] = torch.cat([scale_b, shift_b], dim=0) + + return converted_state_dict, original_state_dict + + +def convert_hunyuan_image_vae_checkpoint_to_diffusers( + original_state_dict, block_out_channels=[128, 256, 512, 512, 1024, 1024], layers_per_block=2 +): + """Convert original VAE state dict to Diffusers format.""" + converted = {} + + # 1. Encoder + # 1.1 conv_in + converted["encoder.conv_in.weight"] = original_state_dict.pop("encoder.conv_in.weight") + converted["encoder.conv_in.bias"] = original_state_dict.pop("encoder.conv_in.bias") + + # 1.2 down blocks + diffusers_block_idx = 0 + + for block_index in range(len(block_out_channels)): + for resnet_block_index in range(layers_per_block): + orig_prefix = f"encoder.down.{block_index}.block.{resnet_block_index}" + diff_prefix = f"encoder.down_blocks.{diffusers_block_idx}" + + # resnet blocks + converted[f"{diff_prefix}.norm1.weight"] = original_state_dict.pop(f"{orig_prefix}.norm1.weight") + converted[f"{diff_prefix}.norm1.bias"] = original_state_dict.pop(f"{orig_prefix}.norm1.bias") + converted[f"{diff_prefix}.conv1.weight"] = original_state_dict.pop(f"{orig_prefix}.conv1.weight") + converted[f"{diff_prefix}.conv1.bias"] = original_state_dict.pop(f"{orig_prefix}.conv1.bias") + converted[f"{diff_prefix}.norm2.weight"] = original_state_dict.pop(f"{orig_prefix}.norm2.weight") + converted[f"{diff_prefix}.norm2.bias"] = original_state_dict.pop(f"{orig_prefix}.norm2.bias") + converted[f"{diff_prefix}.conv2.weight"] = original_state_dict.pop(f"{orig_prefix}.conv2.weight") + converted[f"{diff_prefix}.conv2.bias"] = original_state_dict.pop(f"{orig_prefix}.conv2.bias") + + diffusers_block_idx += 1 + + # downsample blocks + if f"encoder.down.{block_index}.downsample.conv.weight" in original_state_dict: + converted[f"encoder.down_blocks.{diffusers_block_idx}.conv.weight"] = original_state_dict.pop( + f"encoder.down.{block_index}.downsample.conv.weight" + ) + converted[f"encoder.down_blocks.{diffusers_block_idx}.conv.bias"] = original_state_dict.pop( + f"encoder.down.{block_index}.downsample.conv.bias" + ) + diffusers_block_idx += 1 + + # 1.3 mid block + converted["encoder.mid_block.resnets.0.norm1.weight"] = original_state_dict.pop("encoder.mid.block_1.norm1.weight") + converted["encoder.mid_block.resnets.0.norm1.bias"] = original_state_dict.pop("encoder.mid.block_1.norm1.bias") + converted["encoder.mid_block.resnets.0.conv1.weight"] = original_state_dict.pop("encoder.mid.block_1.conv1.weight") + converted["encoder.mid_block.resnets.0.conv1.bias"] = original_state_dict.pop("encoder.mid.block_1.conv1.bias") + converted["encoder.mid_block.resnets.0.norm2.weight"] = original_state_dict.pop("encoder.mid.block_1.norm2.weight") + converted["encoder.mid_block.resnets.0.norm2.bias"] = original_state_dict.pop("encoder.mid.block_1.norm2.bias") + converted["encoder.mid_block.resnets.0.conv2.weight"] = original_state_dict.pop("encoder.mid.block_1.conv2.weight") + converted["encoder.mid_block.resnets.0.conv2.bias"] = original_state_dict.pop("encoder.mid.block_1.conv2.bias") + + converted["encoder.mid_block.resnets.1.norm1.weight"] = original_state_dict.pop("encoder.mid.block_2.norm1.weight") + converted["encoder.mid_block.resnets.1.norm1.bias"] = original_state_dict.pop("encoder.mid.block_2.norm1.bias") + converted["encoder.mid_block.resnets.1.conv1.weight"] = original_state_dict.pop("encoder.mid.block_2.conv1.weight") + converted["encoder.mid_block.resnets.1.conv1.bias"] = original_state_dict.pop("encoder.mid.block_2.conv1.bias") + converted["encoder.mid_block.resnets.1.norm2.weight"] = original_state_dict.pop("encoder.mid.block_2.norm2.weight") + converted["encoder.mid_block.resnets.1.norm2.bias"] = original_state_dict.pop("encoder.mid.block_2.norm2.bias") + converted["encoder.mid_block.resnets.1.conv2.weight"] = original_state_dict.pop("encoder.mid.block_2.conv2.weight") + converted["encoder.mid_block.resnets.1.conv2.bias"] = original_state_dict.pop("encoder.mid.block_2.conv2.bias") + + converted["encoder.mid_block.attentions.0.norm.weight"] = original_state_dict.pop("encoder.mid.attn_1.norm.weight") + converted["encoder.mid_block.attentions.0.norm.bias"] = original_state_dict.pop("encoder.mid.attn_1.norm.bias") + converted["encoder.mid_block.attentions.0.to_q.weight"] = original_state_dict.pop("encoder.mid.attn_1.q.weight") + converted["encoder.mid_block.attentions.0.to_q.bias"] = original_state_dict.pop("encoder.mid.attn_1.q.bias") + converted["encoder.mid_block.attentions.0.to_k.weight"] = original_state_dict.pop("encoder.mid.attn_1.k.weight") + converted["encoder.mid_block.attentions.0.to_k.bias"] = original_state_dict.pop("encoder.mid.attn_1.k.bias") + converted["encoder.mid_block.attentions.0.to_v.weight"] = original_state_dict.pop("encoder.mid.attn_1.v.weight") + converted["encoder.mid_block.attentions.0.to_v.bias"] = original_state_dict.pop("encoder.mid.attn_1.v.bias") + converted["encoder.mid_block.attentions.0.proj.weight"] = original_state_dict.pop( + "encoder.mid.attn_1.proj_out.weight" + ) + converted["encoder.mid_block.attentions.0.proj.bias"] = original_state_dict.pop("encoder.mid.attn_1.proj_out.bias") + + # 1.4 encoder output + converted["encoder.norm_out.weight"] = original_state_dict.pop("encoder.norm_out.weight") + converted["encoder.norm_out.bias"] = original_state_dict.pop("encoder.norm_out.bias") + converted["encoder.conv_out.weight"] = original_state_dict.pop("encoder.conv_out.weight") + converted["encoder.conv_out.bias"] = original_state_dict.pop("encoder.conv_out.bias") + + # 2. Decoder + # 2.1 conv_in + converted["decoder.conv_in.weight"] = original_state_dict.pop("decoder.conv_in.weight") + converted["decoder.conv_in.bias"] = original_state_dict.pop("decoder.conv_in.bias") + + # 2.2 mid block + converted["decoder.mid_block.resnets.0.norm1.weight"] = original_state_dict.pop("decoder.mid.block_1.norm1.weight") + converted["decoder.mid_block.resnets.0.norm1.bias"] = original_state_dict.pop("decoder.mid.block_1.norm1.bias") + converted["decoder.mid_block.resnets.0.conv1.weight"] = original_state_dict.pop("decoder.mid.block_1.conv1.weight") + converted["decoder.mid_block.resnets.0.conv1.bias"] = original_state_dict.pop("decoder.mid.block_1.conv1.bias") + converted["decoder.mid_block.resnets.0.norm2.weight"] = original_state_dict.pop("decoder.mid.block_1.norm2.weight") + converted["decoder.mid_block.resnets.0.norm2.bias"] = original_state_dict.pop("decoder.mid.block_1.norm2.bias") + converted["decoder.mid_block.resnets.0.conv2.weight"] = original_state_dict.pop("decoder.mid.block_1.conv2.weight") + converted["decoder.mid_block.resnets.0.conv2.bias"] = original_state_dict.pop("decoder.mid.block_1.conv2.bias") + + converted["decoder.mid_block.resnets.1.norm1.weight"] = original_state_dict.pop("decoder.mid.block_2.norm1.weight") + converted["decoder.mid_block.resnets.1.norm1.bias"] = original_state_dict.pop("decoder.mid.block_2.norm1.bias") + converted["decoder.mid_block.resnets.1.conv1.weight"] = original_state_dict.pop("decoder.mid.block_2.conv1.weight") + converted["decoder.mid_block.resnets.1.conv1.bias"] = original_state_dict.pop("decoder.mid.block_2.conv1.bias") + converted["decoder.mid_block.resnets.1.norm2.weight"] = original_state_dict.pop("decoder.mid.block_2.norm2.weight") + converted["decoder.mid_block.resnets.1.norm2.bias"] = original_state_dict.pop("decoder.mid.block_2.norm2.bias") + converted["decoder.mid_block.resnets.1.conv2.weight"] = original_state_dict.pop("decoder.mid.block_2.conv2.weight") + converted["decoder.mid_block.resnets.1.conv2.bias"] = original_state_dict.pop("decoder.mid.block_2.conv2.bias") + + converted["decoder.mid_block.attentions.0.norm.weight"] = original_state_dict.pop("decoder.mid.attn_1.norm.weight") + converted["decoder.mid_block.attentions.0.norm.bias"] = original_state_dict.pop("decoder.mid.attn_1.norm.bias") + converted["decoder.mid_block.attentions.0.to_q.weight"] = original_state_dict.pop("decoder.mid.attn_1.q.weight") + converted["decoder.mid_block.attentions.0.to_q.bias"] = original_state_dict.pop("decoder.mid.attn_1.q.bias") + converted["decoder.mid_block.attentions.0.to_k.weight"] = original_state_dict.pop("decoder.mid.attn_1.k.weight") + converted["decoder.mid_block.attentions.0.to_k.bias"] = original_state_dict.pop("decoder.mid.attn_1.k.bias") + converted["decoder.mid_block.attentions.0.to_v.weight"] = original_state_dict.pop("decoder.mid.attn_1.v.weight") + converted["decoder.mid_block.attentions.0.to_v.bias"] = original_state_dict.pop("decoder.mid.attn_1.v.bias") + converted["decoder.mid_block.attentions.0.proj.weight"] = original_state_dict.pop( + "decoder.mid.attn_1.proj_out.weight" + ) + converted["decoder.mid_block.attentions.0.proj.bias"] = original_state_dict.pop("decoder.mid.attn_1.proj_out.bias") + + # 2.3 up blocks + diffusers_block_idx = 0 + for up_block_index in range(len(block_out_channels)): + # resnet blocks + for resnet_block_index in range(layers_per_block + 1): + orig_prefix = f"decoder.up.{up_block_index}.block.{resnet_block_index}" + diff_prefix = f"decoder.up_blocks.{diffusers_block_idx}" + + converted[f"{diff_prefix}.norm1.weight"] = original_state_dict.pop(f"{orig_prefix}.norm1.weight") + converted[f"{diff_prefix}.norm1.bias"] = original_state_dict.pop(f"{orig_prefix}.norm1.bias") + converted[f"{diff_prefix}.conv1.weight"] = original_state_dict.pop(f"{orig_prefix}.conv1.weight") + converted[f"{diff_prefix}.conv1.bias"] = original_state_dict.pop(f"{orig_prefix}.conv1.bias") + converted[f"{diff_prefix}.norm2.weight"] = original_state_dict.pop(f"{orig_prefix}.norm2.weight") + converted[f"{diff_prefix}.norm2.bias"] = original_state_dict.pop(f"{orig_prefix}.norm2.bias") + converted[f"{diff_prefix}.conv2.weight"] = original_state_dict.pop(f"{orig_prefix}.conv2.weight") + converted[f"{diff_prefix}.conv2.bias"] = original_state_dict.pop(f"{orig_prefix}.conv2.bias") + + diffusers_block_idx += 1 + + # upsample blocks + if f"decoder.up.{up_block_index}.upsample.conv.weight" in original_state_dict: + converted[f"decoder.up_blocks.{diffusers_block_idx}.conv.weight"] = original_state_dict.pop( + f"decoder.up.{up_block_index}.upsample.conv.weight" + ) + converted[f"decoder.up_blocks.{diffusers_block_idx}.conv.bias"] = original_state_dict.pop( + f"decoder.up.{up_block_index}.upsample.conv.bias" + ) + diffusers_block_idx += 1 + + # 2.4 decoder output + converted["decoder.norm_out.weight"] = original_state_dict.pop("decoder.norm_out.weight") + converted["decoder.norm_out.bias"] = original_state_dict.pop("decoder.norm_out.bias") + converted["decoder.conv_out.weight"] = original_state_dict.pop("decoder.conv_out.weight") + converted["decoder.conv_out.bias"] = original_state_dict.pop("decoder.conv_out.bias") + + return converted, original_state_dict + + +def convert_hunyuan_image_refiner_vae_checkpoint_to_diffusers( + original_state_dict, block_out_channels=[128, 256, 512, 1024, 1024], layers_per_block=2 +): + converted = {} + + # 1. Encoder + # 1.1 conv_in + converted["encoder.conv_in.conv.weight"] = original_state_dict.pop("encoder.conv_in.conv.weight") + converted["encoder.conv_in.conv.bias"] = original_state_dict.pop("encoder.conv_in.conv.bias") + + # 1.2 Down blocks + for down_block_index in range(len(block_out_channels)): # 0 to 4 + # ResNet blocks + for resnet_block_index in range(layers_per_block): # 0 to 1 + converted[f"encoder.down_blocks.{down_block_index}.resnets.{resnet_block_index}.norm1.gamma"] = ( + original_state_dict.pop(f"encoder.down.{down_block_index}.block.{resnet_block_index}.norm1.gamma") + ) + converted[f"encoder.down_blocks.{down_block_index}.resnets.{resnet_block_index}.conv1.conv.weight"] = ( + original_state_dict.pop( + f"encoder.down.{down_block_index}.block.{resnet_block_index}.conv1.conv.weight" + ) + ) + converted[f"encoder.down_blocks.{down_block_index}.resnets.{resnet_block_index}.conv1.conv.bias"] = ( + original_state_dict.pop(f"encoder.down.{down_block_index}.block.{resnet_block_index}.conv1.conv.bias") + ) + converted[f"encoder.down_blocks.{down_block_index}.resnets.{resnet_block_index}.norm2.gamma"] = ( + original_state_dict.pop(f"encoder.down.{down_block_index}.block.{resnet_block_index}.norm2.gamma") + ) + converted[f"encoder.down_blocks.{down_block_index}.resnets.{resnet_block_index}.conv2.conv.weight"] = ( + original_state_dict.pop( + f"encoder.down.{down_block_index}.block.{resnet_block_index}.conv2.conv.weight" + ) + ) + converted[f"encoder.down_blocks.{down_block_index}.resnets.{resnet_block_index}.conv2.conv.bias"] = ( + original_state_dict.pop(f"encoder.down.{down_block_index}.block.{resnet_block_index}.conv2.conv.bias") + ) + + # Downsample (if exists) + if f"encoder.down.{down_block_index}.downsample.conv.conv.weight" in original_state_dict: + converted[f"encoder.down_blocks.{down_block_index}.downsamplers.0.conv.conv.weight"] = ( + original_state_dict.pop(f"encoder.down.{down_block_index}.downsample.conv.conv.weight") + ) + converted[f"encoder.down_blocks.{down_block_index}.downsamplers.0.conv.conv.bias"] = ( + original_state_dict.pop(f"encoder.down.{down_block_index}.downsample.conv.conv.bias") + ) + + # 1.3 Mid block + converted["encoder.mid_block.resnets.0.norm1.gamma"] = original_state_dict.pop("encoder.mid.block_1.norm1.gamma") + converted["encoder.mid_block.resnets.0.conv1.conv.weight"] = original_state_dict.pop( + "encoder.mid.block_1.conv1.conv.weight" + ) + converted["encoder.mid_block.resnets.0.conv1.conv.bias"] = original_state_dict.pop( + "encoder.mid.block_1.conv1.conv.bias" + ) + converted["encoder.mid_block.resnets.0.norm2.gamma"] = original_state_dict.pop("encoder.mid.block_1.norm2.gamma") + converted["encoder.mid_block.resnets.0.conv2.conv.weight"] = original_state_dict.pop( + "encoder.mid.block_1.conv2.conv.weight" + ) + converted["encoder.mid_block.resnets.0.conv2.conv.bias"] = original_state_dict.pop( + "encoder.mid.block_1.conv2.conv.bias" + ) + + converted["encoder.mid_block.resnets.1.norm1.gamma"] = original_state_dict.pop("encoder.mid.block_2.norm1.gamma") + converted["encoder.mid_block.resnets.1.conv1.conv.weight"] = original_state_dict.pop( + "encoder.mid.block_2.conv1.conv.weight" + ) + converted["encoder.mid_block.resnets.1.conv1.conv.bias"] = original_state_dict.pop( + "encoder.mid.block_2.conv1.conv.bias" + ) + converted["encoder.mid_block.resnets.1.norm2.gamma"] = original_state_dict.pop("encoder.mid.block_2.norm2.gamma") + converted["encoder.mid_block.resnets.1.conv2.conv.weight"] = original_state_dict.pop( + "encoder.mid.block_2.conv2.conv.weight" + ) + converted["encoder.mid_block.resnets.1.conv2.conv.bias"] = original_state_dict.pop( + "encoder.mid.block_2.conv2.conv.bias" + ) + + # Attention block + converted["encoder.mid_block.attentions.0.norm.gamma"] = original_state_dict.pop("encoder.mid.attn_1.norm.gamma") + converted["encoder.mid_block.attentions.0.to_q.weight"] = original_state_dict.pop("encoder.mid.attn_1.q.weight") + converted["encoder.mid_block.attentions.0.to_q.bias"] = original_state_dict.pop("encoder.mid.attn_1.q.bias") + converted["encoder.mid_block.attentions.0.to_k.weight"] = original_state_dict.pop("encoder.mid.attn_1.k.weight") + converted["encoder.mid_block.attentions.0.to_k.bias"] = original_state_dict.pop("encoder.mid.attn_1.k.bias") + converted["encoder.mid_block.attentions.0.to_v.weight"] = original_state_dict.pop("encoder.mid.attn_1.v.weight") + converted["encoder.mid_block.attentions.0.to_v.bias"] = original_state_dict.pop("encoder.mid.attn_1.v.bias") + converted["encoder.mid_block.attentions.0.proj_out.weight"] = original_state_dict.pop( + "encoder.mid.attn_1.proj_out.weight" + ) + converted["encoder.mid_block.attentions.0.proj_out.bias"] = original_state_dict.pop( + "encoder.mid.attn_1.proj_out.bias" + ) + + # 1.4 Encoder output + converted["encoder.norm_out.gamma"] = original_state_dict.pop("encoder.norm_out.gamma") + converted["encoder.conv_out.conv.weight"] = original_state_dict.pop("encoder.conv_out.conv.weight") + converted["encoder.conv_out.conv.bias"] = original_state_dict.pop("encoder.conv_out.conv.bias") + + # 2. Decoder + # 2.1 conv_in + converted["decoder.conv_in.conv.weight"] = original_state_dict.pop("decoder.conv_in.conv.weight") + converted["decoder.conv_in.conv.bias"] = original_state_dict.pop("decoder.conv_in.conv.bias") + + # 2.2 Mid block + converted["decoder.mid_block.resnets.0.norm1.gamma"] = original_state_dict.pop("decoder.mid.block_1.norm1.gamma") + converted["decoder.mid_block.resnets.0.conv1.conv.weight"] = original_state_dict.pop( + "decoder.mid.block_1.conv1.conv.weight" + ) + converted["decoder.mid_block.resnets.0.conv1.conv.bias"] = original_state_dict.pop( + "decoder.mid.block_1.conv1.conv.bias" + ) + converted["decoder.mid_block.resnets.0.norm2.gamma"] = original_state_dict.pop("decoder.mid.block_1.norm2.gamma") + converted["decoder.mid_block.resnets.0.conv2.conv.weight"] = original_state_dict.pop( + "decoder.mid.block_1.conv2.conv.weight" + ) + converted["decoder.mid_block.resnets.0.conv2.conv.bias"] = original_state_dict.pop( + "decoder.mid.block_1.conv2.conv.bias" + ) + + converted["decoder.mid_block.resnets.1.norm1.gamma"] = original_state_dict.pop("decoder.mid.block_2.norm1.gamma") + converted["decoder.mid_block.resnets.1.conv1.conv.weight"] = original_state_dict.pop( + "decoder.mid.block_2.conv1.conv.weight" + ) + converted["decoder.mid_block.resnets.1.conv1.conv.bias"] = original_state_dict.pop( + "decoder.mid.block_2.conv1.conv.bias" + ) + converted["decoder.mid_block.resnets.1.norm2.gamma"] = original_state_dict.pop("decoder.mid.block_2.norm2.gamma") + converted["decoder.mid_block.resnets.1.conv2.conv.weight"] = original_state_dict.pop( + "decoder.mid.block_2.conv2.conv.weight" + ) + converted["decoder.mid_block.resnets.1.conv2.conv.bias"] = original_state_dict.pop( + "decoder.mid.block_2.conv2.conv.bias" + ) + + # Decoder attention block + converted["decoder.mid_block.attentions.0.norm.gamma"] = original_state_dict.pop("decoder.mid.attn_1.norm.gamma") + converted["decoder.mid_block.attentions.0.to_q.weight"] = original_state_dict.pop("decoder.mid.attn_1.q.weight") + converted["decoder.mid_block.attentions.0.to_q.bias"] = original_state_dict.pop("decoder.mid.attn_1.q.bias") + converted["decoder.mid_block.attentions.0.to_k.weight"] = original_state_dict.pop("decoder.mid.attn_1.k.weight") + converted["decoder.mid_block.attentions.0.to_k.bias"] = original_state_dict.pop("decoder.mid.attn_1.k.bias") + converted["decoder.mid_block.attentions.0.to_v.weight"] = original_state_dict.pop("decoder.mid.attn_1.v.weight") + converted["decoder.mid_block.attentions.0.to_v.bias"] = original_state_dict.pop("decoder.mid.attn_1.v.bias") + converted["decoder.mid_block.attentions.0.proj_out.weight"] = original_state_dict.pop( + "decoder.mid.attn_1.proj_out.weight" + ) + converted["decoder.mid_block.attentions.0.proj_out.bias"] = original_state_dict.pop( + "decoder.mid.attn_1.proj_out.bias" + ) + + # 2.3 Up blocks + for up_block_index in range(len(block_out_channels)): # 0 to 5 + # ResNet blocks + for resnet_block_index in range(layers_per_block + 1): # 0 to 2 (decoder has 3 resnets per level) + converted[f"decoder.up_blocks.{up_block_index}.resnets.{resnet_block_index}.norm1.gamma"] = ( + original_state_dict.pop(f"decoder.up.{up_block_index}.block.{resnet_block_index}.norm1.gamma") + ) + converted[f"decoder.up_blocks.{up_block_index}.resnets.{resnet_block_index}.conv1.conv.weight"] = ( + original_state_dict.pop(f"decoder.up.{up_block_index}.block.{resnet_block_index}.conv1.conv.weight") + ) + converted[f"decoder.up_blocks.{up_block_index}.resnets.{resnet_block_index}.conv1.conv.bias"] = ( + original_state_dict.pop(f"decoder.up.{up_block_index}.block.{resnet_block_index}.conv1.conv.bias") + ) + converted[f"decoder.up_blocks.{up_block_index}.resnets.{resnet_block_index}.norm2.gamma"] = ( + original_state_dict.pop(f"decoder.up.{up_block_index}.block.{resnet_block_index}.norm2.gamma") + ) + converted[f"decoder.up_blocks.{up_block_index}.resnets.{resnet_block_index}.conv2.conv.weight"] = ( + original_state_dict.pop(f"decoder.up.{up_block_index}.block.{resnet_block_index}.conv2.conv.weight") + ) + converted[f"decoder.up_blocks.{up_block_index}.resnets.{resnet_block_index}.conv2.conv.bias"] = ( + original_state_dict.pop(f"decoder.up.{up_block_index}.block.{resnet_block_index}.conv2.conv.bias") + ) + + # Upsample (if exists) + if f"decoder.up.{up_block_index}.upsample.conv.conv.weight" in original_state_dict: + converted[f"decoder.up_blocks.{up_block_index}.upsamplers.0.conv.conv.weight"] = original_state_dict.pop( + f"decoder.up.{up_block_index}.upsample.conv.conv.weight" + ) + converted[f"decoder.up_blocks.{up_block_index}.upsamplers.0.conv.conv.bias"] = original_state_dict.pop( + f"decoder.up.{up_block_index}.upsample.conv.conv.bias" + ) + + # 2.4 Decoder output + converted["decoder.norm_out.gamma"] = original_state_dict.pop("decoder.norm_out.gamma") + converted["decoder.conv_out.conv.weight"] = original_state_dict.pop("decoder.conv_out.conv.weight") + converted["decoder.conv_out.conv.bias"] = original_state_dict.pop("decoder.conv_out.conv.bias") + + return converted, original_state_dict + + +def main(args): + if args.model_type == "hunyuanimage2.1": + original_transformer_state_dict = load_original_transformer_checkpoint(args) + original_vae_state_dict = load_original_vae_checkpoint(args) + + transformer_config = { + "in_channels": 64, + "out_channels": 64, + "num_attention_heads": 28, + "attention_head_dim": 128, + "num_layers": 20, + "num_single_layers": 40, + "num_refiner_layers": 2, + "patch_size": (1, 1), + "qk_norm": "rms_norm", + "guidance_embeds": False, + "text_embed_dim": 3584, + "text_embed_2_dim": 1472, + "rope_theta": 256.0, + "rope_axes_dim": (64, 64), + } + + converted_transformer_state_dict, original_transformer_state_dict = ( + convert_hunyuan_image_transformer_checkpoint_to_diffusers( + original_transformer_state_dict, use_byt5=True, guidance_distilled=False + ) + ) + + if original_transformer_state_dict: + logger.warning( + f"Unused {len(original_transformer_state_dict)} original keys for transformer: {list(original_transformer_state_dict.keys())}" + ) + + transformer = HunyuanImageTransformer2DModel(**transformer_config) + missing_keys, unexpected_key = transformer.load_state_dict(converted_transformer_state_dict, strict=True) + + if missing_keys: + logger.warning(f"Missing keys for transformer: {missing_keys}") + if unexpected_key: + logger.warning(f"Unexpected keys for transformer: {unexpected_key}") + + transformer.to(dtype).save_pretrained(f"{args.output_path}/transformer") + + vae_config_diffusers = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 64, + "block_out_channels": [128, 256, 512, 512, 1024, 1024], + "layers_per_block": 2, + "spatial_compression_ratio": 32, + "sample_size": 384, + "scaling_factor": 0.75289, + "downsample_match_channel": True, + "upsample_match_channel": True, + } + converted_vae_state_dict, original_vae_state_dict = convert_hunyuan_image_vae_checkpoint_to_diffusers( + original_vae_state_dict, block_out_channels=[128, 256, 512, 512, 1024, 1024], layers_per_block=2 + ) + if original_vae_state_dict: + logger.warning( + f"Unused {len(original_vae_state_dict)} original keys for vae: {list(original_vae_state_dict.keys())}" + ) + + vae = AutoencoderKLHunyuanImage(**vae_config_diffusers) + missing_keys, unexpected_key = vae.load_state_dict(converted_vae_state_dict, strict=True) + + if missing_keys: + logger.warning(f"Missing keys for vae: {missing_keys}") + if unexpected_key: + logger.warning(f"Unexpected keys for vae: {unexpected_key}") + + vae.to(dtype).save_pretrained(f"{args.output_path}/vae") + + elif args.model_type == "hunyuanimage2.1-distilled": + original_transformer_state_dict = load_original_transformer_checkpoint(args) + original_vae_state_dict = load_original_vae_checkpoint(args) + + transformer_config = { + "in_channels": 64, + "out_channels": 64, + "num_attention_heads": 28, + "attention_head_dim": 128, + "num_layers": 20, + "num_single_layers": 40, + "num_refiner_layers": 2, + "patch_size": (1, 1), + "qk_norm": "rms_norm", + "guidance_embeds": True, + "text_embed_dim": 3584, + "text_embed_2_dim": 1472, + "rope_theta": 256.0, + "rope_axes_dim": (64, 64), + "use_meanflow": True, + } + + converted_transformer_state_dict, original_transformer_state_dict = ( + convert_hunyuan_image_transformer_checkpoint_to_diffusers( + original_transformer_state_dict, use_byt5=True, guidance_distilled=True, use_meanflow=True + ) + ) + + if original_transformer_state_dict: + logger.warning( + f"Unused {len(original_transformer_state_dict)} original keys for transformer: {list(original_transformer_state_dict.keys())}" + ) + + transformer = HunyuanImageTransformer2DModel(**transformer_config) + missing_keys, unexpected_key = transformer.load_state_dict(converted_transformer_state_dict, strict=True) + + if missing_keys: + logger.warning(f"Missing keys for transformer: {missing_keys}") + if unexpected_key: + logger.warning(f"Unexpected keys for transformer: {unexpected_key}") + + transformer.to(dtype).save_pretrained(f"{args.output_path}/transformer") + + vae_config_diffusers = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 64, + "block_out_channels": [128, 256, 512, 512, 1024, 1024], + "layers_per_block": 2, + "spatial_compression_ratio": 32, + "sample_size": 384, + "scaling_factor": 0.75289, + "downsample_match_channel": True, + "upsample_match_channel": True, + } + converted_vae_state_dict, original_vae_state_dict = convert_hunyuan_image_vae_checkpoint_to_diffusers( + original_vae_state_dict, block_out_channels=[128, 256, 512, 512, 1024, 1024], layers_per_block=2 + ) + if original_vae_state_dict: + logger.warning( + f"Unused {len(original_vae_state_dict)} original keys for vae: {list(original_vae_state_dict.keys())}" + ) + + vae = AutoencoderKLHunyuanImage(**vae_config_diffusers) + missing_keys, unexpected_key = vae.load_state_dict(converted_vae_state_dict, strict=True) + + if missing_keys: + logger.warning(f"Missing keys for vae: {missing_keys}") + if unexpected_key: + logger.warning(f"Unexpected keys for vae: {unexpected_key}") + + vae.to(dtype).save_pretrained(f"{args.output_path}/vae") + + elif args.model_type == "hunyuanimage-refiner": + original_transformer_state_dict = load_original_transformer_checkpoint(args) + original_vae_state_dict = load_original_refiner_vae_checkpoint(args) + + transformer_config = { + "in_channels": 128, + "out_channels": 64, + "num_layers": 20, + "num_single_layers": 40, + "rope_axes_dim": [16, 56, 56], + "num_attention_heads": 26, + "attention_head_dim": 128, + "mlp_ratio": 4, + "patch_size": (1, 1, 1), + "text_embed_dim": 3584, + "guidance_embeds": True, + } + converted_transformer_state_dict, original_transformer_state_dict = ( + convert_hunyuan_image_transformer_checkpoint_to_diffusers( + original_transformer_state_dict, use_byt5=False, guidance_distilled=True + ) + ) + if original_transformer_state_dict: + logger.warning( + f"Unused {len(original_transformer_state_dict)} original keys for transformer: {list(original_transformer_state_dict.keys())}" + ) + + transformer = HunyuanImageTransformer2DModel(**transformer_config) + missing_keys, unexpected_key = transformer.load_state_dict(converted_transformer_state_dict, strict=True) + if missing_keys: + logger.warning(f"Missing keys for transformer: {missing_keys}") + if unexpected_key: + logger.warning(f"Unexpected keys for transformer: {unexpected_key}") + + transformer.to(dtype).save_pretrained(f"{args.output_path}/transformer") + + vae = AutoencoderKLHunyuanImageRefiner() + + converted_vae_state_dict, original_vae_state_dict = convert_hunyuan_image_refiner_vae_checkpoint_to_diffusers( + original_vae_state_dict + ) + if original_vae_state_dict: + logger.warning( + f"Unused {len(original_vae_state_dict)} original keys for vae: {list(original_vae_state_dict.keys())}" + ) + + missing_keys, unexpected_key = vae.load_state_dict(converted_vae_state_dict, strict=True) + logger.warning(f"Missing keys for vae: {missing_keys}") + logger.warning(f"Unexpected keys for vae: {unexpected_key}") + + vae.to(dtype).save_pretrained(f"{args.output_path}/vae") + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuan_video_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuan_video_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..c84809d7f68abfb2bc9265978a9d72eb63e95902 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuan_video_to_diffusers.py @@ -0,0 +1,353 @@ +import argparse +from typing import Any, Dict + +import torch +from accelerate import init_empty_weights +from transformers import ( + AutoModel, + AutoTokenizer, + CLIPImageProcessor, + CLIPTextModel, + CLIPTokenizer, + LlavaForConditionalGeneration, +) + +from diffusers import ( + AutoencoderKLHunyuanVideo, + FlowMatchEulerDiscreteScheduler, + HunyuanVideoImageToVideoPipeline, + HunyuanVideoPipeline, + HunyuanVideoTransformer3DModel, +) + + +def remap_norm_scale_shift_(key, state_dict): + weight = state_dict.pop(key) + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + state_dict[key.replace("final_layer.adaLN_modulation.1", "norm_out.linear")] = new_weight + + +def remap_txt_in_(key, state_dict): + def rename_key(key): + new_key = key.replace("individual_token_refiner.blocks", "token_refiner.refiner_blocks") + new_key = new_key.replace("adaLN_modulation.1", "norm_out.linear") + new_key = new_key.replace("txt_in", "context_embedder") + new_key = new_key.replace("t_embedder.mlp.0", "time_text_embed.timestep_embedder.linear_1") + new_key = new_key.replace("t_embedder.mlp.2", "time_text_embed.timestep_embedder.linear_2") + new_key = new_key.replace("c_embedder", "time_text_embed.text_embedder") + new_key = new_key.replace("mlp", "ff") + return new_key + + if "self_attn_qkv" in key: + weight = state_dict.pop(key) + to_q, to_k, to_v = weight.chunk(3, dim=0) + state_dict[rename_key(key.replace("self_attn_qkv", "attn.to_q"))] = to_q + state_dict[rename_key(key.replace("self_attn_qkv", "attn.to_k"))] = to_k + state_dict[rename_key(key.replace("self_attn_qkv", "attn.to_v"))] = to_v + else: + state_dict[rename_key(key)] = state_dict.pop(key) + + +def remap_img_attn_qkv_(key, state_dict): + weight = state_dict.pop(key) + to_q, to_k, to_v = weight.chunk(3, dim=0) + state_dict[key.replace("img_attn_qkv", "attn.to_q")] = to_q + state_dict[key.replace("img_attn_qkv", "attn.to_k")] = to_k + state_dict[key.replace("img_attn_qkv", "attn.to_v")] = to_v + + +def remap_txt_attn_qkv_(key, state_dict): + weight = state_dict.pop(key) + to_q, to_k, to_v = weight.chunk(3, dim=0) + state_dict[key.replace("txt_attn_qkv", "attn.add_q_proj")] = to_q + state_dict[key.replace("txt_attn_qkv", "attn.add_k_proj")] = to_k + state_dict[key.replace("txt_attn_qkv", "attn.add_v_proj")] = to_v + + +def remap_single_transformer_blocks_(key, state_dict): + hidden_size = 3072 + + if "linear1.weight" in key: + linear1_weight = state_dict.pop(key) + split_size = (hidden_size, hidden_size, hidden_size, linear1_weight.size(0) - 3 * hidden_size) + q, k, v, mlp = torch.split(linear1_weight, split_size, dim=0) + new_key = key.replace("single_blocks", "single_transformer_blocks").removesuffix(".linear1.weight") + state_dict[f"{new_key}.attn.to_q.weight"] = q + state_dict[f"{new_key}.attn.to_k.weight"] = k + state_dict[f"{new_key}.attn.to_v.weight"] = v + state_dict[f"{new_key}.proj_mlp.weight"] = mlp + + elif "linear1.bias" in key: + linear1_bias = state_dict.pop(key) + split_size = (hidden_size, hidden_size, hidden_size, linear1_bias.size(0) - 3 * hidden_size) + q_bias, k_bias, v_bias, mlp_bias = torch.split(linear1_bias, split_size, dim=0) + new_key = key.replace("single_blocks", "single_transformer_blocks").removesuffix(".linear1.bias") + state_dict[f"{new_key}.attn.to_q.bias"] = q_bias + state_dict[f"{new_key}.attn.to_k.bias"] = k_bias + state_dict[f"{new_key}.attn.to_v.bias"] = v_bias + state_dict[f"{new_key}.proj_mlp.bias"] = mlp_bias + + else: + new_key = key.replace("single_blocks", "single_transformer_blocks") + new_key = new_key.replace("linear2", "proj_out") + new_key = new_key.replace("q_norm", "attn.norm_q") + new_key = new_key.replace("k_norm", "attn.norm_k") + state_dict[new_key] = state_dict.pop(key) + + +TRANSFORMER_KEYS_RENAME_DICT = { + "img_in": "x_embedder", + "time_in.mlp.0": "time_text_embed.timestep_embedder.linear_1", + "time_in.mlp.2": "time_text_embed.timestep_embedder.linear_2", + "guidance_in.mlp.0": "time_text_embed.guidance_embedder.linear_1", + "guidance_in.mlp.2": "time_text_embed.guidance_embedder.linear_2", + "vector_in.in_layer": "time_text_embed.text_embedder.linear_1", + "vector_in.out_layer": "time_text_embed.text_embedder.linear_2", + "double_blocks": "transformer_blocks", + "img_attn_q_norm": "attn.norm_q", + "img_attn_k_norm": "attn.norm_k", + "img_attn_proj": "attn.to_out.0", + "txt_attn_q_norm": "attn.norm_added_q", + "txt_attn_k_norm": "attn.norm_added_k", + "txt_attn_proj": "attn.to_add_out", + "img_mod.linear": "norm1.linear", + "img_norm1": "norm1.norm", + "img_norm2": "norm2", + "img_mlp": "ff", + "txt_mod.linear": "norm1_context.linear", + "txt_norm1": "norm1.norm", + "txt_norm2": "norm2_context", + "txt_mlp": "ff_context", + "self_attn_proj": "attn.to_out.0", + "modulation.linear": "norm.linear", + "pre_norm": "norm.norm", + "final_layer.norm_final": "norm_out.norm", + "final_layer.linear": "proj_out", + "fc1": "net.0.proj", + "fc2": "net.2", + "input_embedder": "proj_in", +} + +TRANSFORMER_SPECIAL_KEYS_REMAP = { + "txt_in": remap_txt_in_, + "img_attn_qkv": remap_img_attn_qkv_, + "txt_attn_qkv": remap_txt_attn_qkv_, + "single_blocks": remap_single_transformer_blocks_, + "final_layer.adaLN_modulation.1": remap_norm_scale_shift_, +} + +VAE_KEYS_RENAME_DICT = {} + +VAE_SPECIAL_KEYS_REMAP = {} + + +TRANSFORMER_CONFIGS = { + "HYVideo-T/2-cfgdistill": { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 24, + "attention_head_dim": 128, + "num_layers": 20, + "num_single_layers": 40, + "num_refiner_layers": 2, + "mlp_ratio": 4.0, + "patch_size": 2, + "patch_size_t": 1, + "qk_norm": "rms_norm", + "guidance_embeds": True, + "text_embed_dim": 4096, + "pooled_projection_dim": 768, + "rope_theta": 256.0, + "rope_axes_dim": (16, 56, 56), + "image_condition_type": None, + }, + "HYVideo-T/2-I2V-33ch": { + "in_channels": 16 * 2 + 1, + "out_channels": 16, + "num_attention_heads": 24, + "attention_head_dim": 128, + "num_layers": 20, + "num_single_layers": 40, + "num_refiner_layers": 2, + "mlp_ratio": 4.0, + "patch_size": 2, + "patch_size_t": 1, + "qk_norm": "rms_norm", + "guidance_embeds": False, + "text_embed_dim": 4096, + "pooled_projection_dim": 768, + "rope_theta": 256.0, + "rope_axes_dim": (16, 56, 56), + "image_condition_type": "latent_concat", + }, + "HYVideo-T/2-I2V-16ch": { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 24, + "attention_head_dim": 128, + "num_layers": 20, + "num_single_layers": 40, + "num_refiner_layers": 2, + "mlp_ratio": 4.0, + "patch_size": 2, + "patch_size_t": 1, + "qk_norm": "rms_norm", + "guidance_embeds": True, + "text_embed_dim": 4096, + "pooled_projection_dim": 768, + "rope_theta": 256.0, + "rope_axes_dim": (16, 56, 56), + "image_condition_type": "token_replace", + }, +} + + +def update_state_dict_(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def get_state_dict(saved_dict: Dict[str, Any]) -> Dict[str, Any]: + state_dict = saved_dict + if "model" in saved_dict.keys(): + state_dict = state_dict["model"] + if "module" in saved_dict.keys(): + state_dict = state_dict["module"] + if "state_dict" in saved_dict.keys(): + state_dict = state_dict["state_dict"] + return state_dict + + +def convert_transformer(ckpt_path: str, transformer_type: str): + original_state_dict = get_state_dict(torch.load(ckpt_path, map_location="cpu", weights_only=True)) + config = TRANSFORMER_CONFIGS[transformer_type] + + with init_empty_weights(): + transformer = HunyuanVideoTransformer3DModel(**config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in TRANSFORMER_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in TRANSFORMER_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + transformer.load_state_dict(original_state_dict, strict=True, assign=True) + return transformer + + +def convert_vae(ckpt_path: str): + original_state_dict = get_state_dict(torch.load(ckpt_path, map_location="cpu", weights_only=True)) + + with init_empty_weights(): + vae = AutoencoderKLHunyuanVideo() + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in VAE_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in VAE_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + vae.load_state_dict(original_state_dict, strict=True, assign=True) + return vae + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--transformer_ckpt_path", type=str, default=None, help="Path to original transformer checkpoint" + ) + parser.add_argument("--vae_ckpt_path", type=str, default=None, help="Path to original VAE checkpoint") + parser.add_argument("--text_encoder_path", type=str, default=None, help="Path to original llama checkpoint") + parser.add_argument("--tokenizer_path", type=str, default=None, help="Path to original llama tokenizer") + parser.add_argument("--text_encoder_2_path", type=str, default=None, help="Path to original clip checkpoint") + parser.add_argument("--save_pipeline", action="store_true") + parser.add_argument("--output_path", type=str, required=True, help="Path where converted model should be saved") + parser.add_argument("--dtype", default="bf16", help="Torch dtype to save the transformer in.") + parser.add_argument( + "--transformer_type", type=str, default="HYVideo-T/2-cfgdistill", choices=list(TRANSFORMER_CONFIGS.keys()) + ) + parser.add_argument("--flow_shift", type=float, default=7.0) + return parser.parse_args() + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + + +if __name__ == "__main__": + args = get_args() + + transformer = None + dtype = DTYPE_MAPPING[args.dtype] + + if args.save_pipeline: + assert args.transformer_ckpt_path is not None and args.vae_ckpt_path is not None + assert args.text_encoder_path is not None + assert args.tokenizer_path is not None + assert args.text_encoder_2_path is not None + + if args.transformer_ckpt_path is not None: + transformer = convert_transformer(args.transformer_ckpt_path, args.transformer_type) + transformer = transformer.to(dtype=dtype) + if not args.save_pipeline: + transformer.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + + if args.vae_ckpt_path is not None: + vae = convert_vae(args.vae_ckpt_path) + if not args.save_pipeline: + vae.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + + if args.save_pipeline: + if args.transformer_type == "HYVideo-T/2-cfgdistill": + text_encoder = AutoModel.from_pretrained(args.text_encoder_path, torch_dtype=torch.float16) + tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_path, padding_side="right") + text_encoder_2 = CLIPTextModel.from_pretrained(args.text_encoder_2_path, torch_dtype=torch.float16) + tokenizer_2 = CLIPTokenizer.from_pretrained(args.text_encoder_2_path) + scheduler = FlowMatchEulerDiscreteScheduler(shift=args.flow_shift) + + pipe = HunyuanVideoPipeline( + transformer=transformer, + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + text_encoder_2=text_encoder_2, + tokenizer_2=tokenizer_2, + scheduler=scheduler, + ) + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") + else: + text_encoder = LlavaForConditionalGeneration.from_pretrained( + args.text_encoder_path, torch_dtype=torch.float16 + ) + tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_path, padding_side="right") + text_encoder_2 = CLIPTextModel.from_pretrained(args.text_encoder_2_path, torch_dtype=torch.float16) + tokenizer_2 = CLIPTokenizer.from_pretrained(args.text_encoder_2_path) + scheduler = FlowMatchEulerDiscreteScheduler(shift=args.flow_shift) + image_processor = CLIPImageProcessor.from_pretrained(args.text_encoder_path) + + pipe = HunyuanVideoImageToVideoPipeline( + transformer=transformer, + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + text_encoder_2=text_encoder_2, + tokenizer_2=tokenizer_2, + scheduler=scheduler, + image_processor=image_processor, + ) + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuandit_controlnet_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuandit_controlnet_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..5cef46c989833adc2cee1b36575653c66f28434c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuandit_controlnet_to_diffusers.py @@ -0,0 +1,241 @@ +import argparse + +import torch + +from diffusers import HunyuanDiT2DControlNetModel + + +def main(args): + state_dict = torch.load(args.pt_checkpoint_path, map_location="cpu") + + if args.load_key != "none": + try: + state_dict = state_dict[args.load_key] + except KeyError: + raise KeyError( + f"{args.load_key} not found in the checkpoint." + "Please load from the following keys:{state_dict.keys()}" + ) + device = "cuda" + + model_config = HunyuanDiT2DControlNetModel.load_config( + "Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers", subfolder="transformer" + ) + model_config["use_style_cond_and_image_meta_size"] = ( + args.use_style_cond_and_image_meta_size + ) ### version <= v1.1: True; version >= v1.2: False + print(model_config) + + for key in state_dict: + print("local:", key) + + model = HunyuanDiT2DControlNetModel.from_config(model_config).to(device) + + for key in model.state_dict(): + print("diffusers:", key) + + num_layers = 19 + for i in range(num_layers): + # attn1 + # Wkqv -> to_q, to_k, to_v + q, k, v = torch.chunk(state_dict[f"blocks.{i}.attn1.Wqkv.weight"], 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(state_dict[f"blocks.{i}.attn1.Wqkv.bias"], 3, dim=0) + state_dict[f"blocks.{i}.attn1.to_q.weight"] = q + state_dict[f"blocks.{i}.attn1.to_q.bias"] = q_bias + state_dict[f"blocks.{i}.attn1.to_k.weight"] = k + state_dict[f"blocks.{i}.attn1.to_k.bias"] = k_bias + state_dict[f"blocks.{i}.attn1.to_v.weight"] = v + state_dict[f"blocks.{i}.attn1.to_v.bias"] = v_bias + state_dict.pop(f"blocks.{i}.attn1.Wqkv.weight") + state_dict.pop(f"blocks.{i}.attn1.Wqkv.bias") + + # q_norm, k_norm -> norm_q, norm_k + state_dict[f"blocks.{i}.attn1.norm_q.weight"] = state_dict[f"blocks.{i}.attn1.q_norm.weight"] + state_dict[f"blocks.{i}.attn1.norm_q.bias"] = state_dict[f"blocks.{i}.attn1.q_norm.bias"] + state_dict[f"blocks.{i}.attn1.norm_k.weight"] = state_dict[f"blocks.{i}.attn1.k_norm.weight"] + state_dict[f"blocks.{i}.attn1.norm_k.bias"] = state_dict[f"blocks.{i}.attn1.k_norm.bias"] + + state_dict.pop(f"blocks.{i}.attn1.q_norm.weight") + state_dict.pop(f"blocks.{i}.attn1.q_norm.bias") + state_dict.pop(f"blocks.{i}.attn1.k_norm.weight") + state_dict.pop(f"blocks.{i}.attn1.k_norm.bias") + + # out_proj -> to_out + state_dict[f"blocks.{i}.attn1.to_out.0.weight"] = state_dict[f"blocks.{i}.attn1.out_proj.weight"] + state_dict[f"blocks.{i}.attn1.to_out.0.bias"] = state_dict[f"blocks.{i}.attn1.out_proj.bias"] + state_dict.pop(f"blocks.{i}.attn1.out_proj.weight") + state_dict.pop(f"blocks.{i}.attn1.out_proj.bias") + + # attn2 + # kq_proj -> to_k, to_v + k, v = torch.chunk(state_dict[f"blocks.{i}.attn2.kv_proj.weight"], 2, dim=0) + k_bias, v_bias = torch.chunk(state_dict[f"blocks.{i}.attn2.kv_proj.bias"], 2, dim=0) + state_dict[f"blocks.{i}.attn2.to_k.weight"] = k + state_dict[f"blocks.{i}.attn2.to_k.bias"] = k_bias + state_dict[f"blocks.{i}.attn2.to_v.weight"] = v + state_dict[f"blocks.{i}.attn2.to_v.bias"] = v_bias + state_dict.pop(f"blocks.{i}.attn2.kv_proj.weight") + state_dict.pop(f"blocks.{i}.attn2.kv_proj.bias") + + # q_proj -> to_q + state_dict[f"blocks.{i}.attn2.to_q.weight"] = state_dict[f"blocks.{i}.attn2.q_proj.weight"] + state_dict[f"blocks.{i}.attn2.to_q.bias"] = state_dict[f"blocks.{i}.attn2.q_proj.bias"] + state_dict.pop(f"blocks.{i}.attn2.q_proj.weight") + state_dict.pop(f"blocks.{i}.attn2.q_proj.bias") + + # q_norm, k_norm -> norm_q, norm_k + state_dict[f"blocks.{i}.attn2.norm_q.weight"] = state_dict[f"blocks.{i}.attn2.q_norm.weight"] + state_dict[f"blocks.{i}.attn2.norm_q.bias"] = state_dict[f"blocks.{i}.attn2.q_norm.bias"] + state_dict[f"blocks.{i}.attn2.norm_k.weight"] = state_dict[f"blocks.{i}.attn2.k_norm.weight"] + state_dict[f"blocks.{i}.attn2.norm_k.bias"] = state_dict[f"blocks.{i}.attn2.k_norm.bias"] + + state_dict.pop(f"blocks.{i}.attn2.q_norm.weight") + state_dict.pop(f"blocks.{i}.attn2.q_norm.bias") + state_dict.pop(f"blocks.{i}.attn2.k_norm.weight") + state_dict.pop(f"blocks.{i}.attn2.k_norm.bias") + + # out_proj -> to_out + state_dict[f"blocks.{i}.attn2.to_out.0.weight"] = state_dict[f"blocks.{i}.attn2.out_proj.weight"] + state_dict[f"blocks.{i}.attn2.to_out.0.bias"] = state_dict[f"blocks.{i}.attn2.out_proj.bias"] + state_dict.pop(f"blocks.{i}.attn2.out_proj.weight") + state_dict.pop(f"blocks.{i}.attn2.out_proj.bias") + + # switch norm 2 and norm 3 + norm2_weight = state_dict[f"blocks.{i}.norm2.weight"] + norm2_bias = state_dict[f"blocks.{i}.norm2.bias"] + state_dict[f"blocks.{i}.norm2.weight"] = state_dict[f"blocks.{i}.norm3.weight"] + state_dict[f"blocks.{i}.norm2.bias"] = state_dict[f"blocks.{i}.norm3.bias"] + state_dict[f"blocks.{i}.norm3.weight"] = norm2_weight + state_dict[f"blocks.{i}.norm3.bias"] = norm2_bias + + # norm1 -> norm1.norm + # default_modulation.1 -> norm1.linear + state_dict[f"blocks.{i}.norm1.norm.weight"] = state_dict[f"blocks.{i}.norm1.weight"] + state_dict[f"blocks.{i}.norm1.norm.bias"] = state_dict[f"blocks.{i}.norm1.bias"] + state_dict[f"blocks.{i}.norm1.linear.weight"] = state_dict[f"blocks.{i}.default_modulation.1.weight"] + state_dict[f"blocks.{i}.norm1.linear.bias"] = state_dict[f"blocks.{i}.default_modulation.1.bias"] + state_dict.pop(f"blocks.{i}.norm1.weight") + state_dict.pop(f"blocks.{i}.norm1.bias") + state_dict.pop(f"blocks.{i}.default_modulation.1.weight") + state_dict.pop(f"blocks.{i}.default_modulation.1.bias") + + # mlp.fc1 -> ff.net.0, mlp.fc2 -> ff.net.2 + state_dict[f"blocks.{i}.ff.net.0.proj.weight"] = state_dict[f"blocks.{i}.mlp.fc1.weight"] + state_dict[f"blocks.{i}.ff.net.0.proj.bias"] = state_dict[f"blocks.{i}.mlp.fc1.bias"] + state_dict[f"blocks.{i}.ff.net.2.weight"] = state_dict[f"blocks.{i}.mlp.fc2.weight"] + state_dict[f"blocks.{i}.ff.net.2.bias"] = state_dict[f"blocks.{i}.mlp.fc2.bias"] + state_dict.pop(f"blocks.{i}.mlp.fc1.weight") + state_dict.pop(f"blocks.{i}.mlp.fc1.bias") + state_dict.pop(f"blocks.{i}.mlp.fc2.weight") + state_dict.pop(f"blocks.{i}.mlp.fc2.bias") + + # after_proj_list -> controlnet_blocks + state_dict[f"controlnet_blocks.{i}.weight"] = state_dict[f"after_proj_list.{i}.weight"] + state_dict[f"controlnet_blocks.{i}.bias"] = state_dict[f"after_proj_list.{i}.bias"] + state_dict.pop(f"after_proj_list.{i}.weight") + state_dict.pop(f"after_proj_list.{i}.bias") + + # before_proj -> input_block + state_dict["input_block.weight"] = state_dict["before_proj.weight"] + state_dict["input_block.bias"] = state_dict["before_proj.bias"] + state_dict.pop("before_proj.weight") + state_dict.pop("before_proj.bias") + + # pooler -> time_extra_emb + state_dict["time_extra_emb.pooler.positional_embedding"] = state_dict["pooler.positional_embedding"] + state_dict["time_extra_emb.pooler.k_proj.weight"] = state_dict["pooler.k_proj.weight"] + state_dict["time_extra_emb.pooler.k_proj.bias"] = state_dict["pooler.k_proj.bias"] + state_dict["time_extra_emb.pooler.q_proj.weight"] = state_dict["pooler.q_proj.weight"] + state_dict["time_extra_emb.pooler.q_proj.bias"] = state_dict["pooler.q_proj.bias"] + state_dict["time_extra_emb.pooler.v_proj.weight"] = state_dict["pooler.v_proj.weight"] + state_dict["time_extra_emb.pooler.v_proj.bias"] = state_dict["pooler.v_proj.bias"] + state_dict["time_extra_emb.pooler.c_proj.weight"] = state_dict["pooler.c_proj.weight"] + state_dict["time_extra_emb.pooler.c_proj.bias"] = state_dict["pooler.c_proj.bias"] + state_dict.pop("pooler.k_proj.weight") + state_dict.pop("pooler.k_proj.bias") + state_dict.pop("pooler.q_proj.weight") + state_dict.pop("pooler.q_proj.bias") + state_dict.pop("pooler.v_proj.weight") + state_dict.pop("pooler.v_proj.bias") + state_dict.pop("pooler.c_proj.weight") + state_dict.pop("pooler.c_proj.bias") + state_dict.pop("pooler.positional_embedding") + + # t_embedder -> time_embedding (`TimestepEmbedding`) + state_dict["time_extra_emb.timestep_embedder.linear_1.bias"] = state_dict["t_embedder.mlp.0.bias"] + state_dict["time_extra_emb.timestep_embedder.linear_1.weight"] = state_dict["t_embedder.mlp.0.weight"] + state_dict["time_extra_emb.timestep_embedder.linear_2.bias"] = state_dict["t_embedder.mlp.2.bias"] + state_dict["time_extra_emb.timestep_embedder.linear_2.weight"] = state_dict["t_embedder.mlp.2.weight"] + + state_dict.pop("t_embedder.mlp.0.bias") + state_dict.pop("t_embedder.mlp.0.weight") + state_dict.pop("t_embedder.mlp.2.bias") + state_dict.pop("t_embedder.mlp.2.weight") + + # x_embedder -> pos_embd (`PatchEmbed`) + state_dict["pos_embed.proj.weight"] = state_dict["x_embedder.proj.weight"] + state_dict["pos_embed.proj.bias"] = state_dict["x_embedder.proj.bias"] + state_dict.pop("x_embedder.proj.weight") + state_dict.pop("x_embedder.proj.bias") + + # mlp_t5 -> text_embedder + state_dict["text_embedder.linear_1.bias"] = state_dict["mlp_t5.0.bias"] + state_dict["text_embedder.linear_1.weight"] = state_dict["mlp_t5.0.weight"] + state_dict["text_embedder.linear_2.bias"] = state_dict["mlp_t5.2.bias"] + state_dict["text_embedder.linear_2.weight"] = state_dict["mlp_t5.2.weight"] + state_dict.pop("mlp_t5.0.bias") + state_dict.pop("mlp_t5.0.weight") + state_dict.pop("mlp_t5.2.bias") + state_dict.pop("mlp_t5.2.weight") + + # extra_embedder -> extra_embedder + state_dict["time_extra_emb.extra_embedder.linear_1.bias"] = state_dict["extra_embedder.0.bias"] + state_dict["time_extra_emb.extra_embedder.linear_1.weight"] = state_dict["extra_embedder.0.weight"] + state_dict["time_extra_emb.extra_embedder.linear_2.bias"] = state_dict["extra_embedder.2.bias"] + state_dict["time_extra_emb.extra_embedder.linear_2.weight"] = state_dict["extra_embedder.2.weight"] + state_dict.pop("extra_embedder.0.bias") + state_dict.pop("extra_embedder.0.weight") + state_dict.pop("extra_embedder.2.bias") + state_dict.pop("extra_embedder.2.weight") + + # style_embedder + if model_config["use_style_cond_and_image_meta_size"]: + print(state_dict["style_embedder.weight"]) + print(state_dict["style_embedder.weight"].shape) + state_dict["time_extra_emb.style_embedder.weight"] = state_dict["style_embedder.weight"][0:1] + state_dict.pop("style_embedder.weight") + + model.load_state_dict(state_dict) + + if args.save: + model.save_pretrained(args.output_checkpoint_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--save", default=True, type=bool, required=False, help="Whether to save the converted pipeline or not." + ) + parser.add_argument( + "--pt_checkpoint_path", default=None, type=str, required=True, help="Path to the .pt pretrained model." + ) + parser.add_argument( + "--output_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the output converted diffusers pipeline.", + ) + parser.add_argument( + "--load_key", default="none", type=str, required=False, help="The key to load from the pretrained .pt file" + ) + parser.add_argument( + "--use_style_cond_and_image_meta_size", + type=bool, + default=False, + help="version <= v1.1: True; version >= v1.2: False", + ) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuandit_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuandit_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..65fcccb22a1ab2a9e8da661a5a14c26b9a077113 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_hunyuandit_to_diffusers.py @@ -0,0 +1,266 @@ +import argparse + +import torch + +from diffusers import HunyuanDiT2DModel + + +def main(args): + state_dict = torch.load(args.pt_checkpoint_path, map_location="cpu") + + if args.load_key != "none": + try: + state_dict = state_dict[args.load_key] + except KeyError: + raise KeyError( + f"{args.load_key} not found in the checkpoint.Please load from the following keys:{state_dict.keys()}" + ) + + device = "cuda" + model_config = HunyuanDiT2DModel.load_config("Tencent-Hunyuan/HunyuanDiT-Diffusers", subfolder="transformer") + model_config["use_style_cond_and_image_meta_size"] = ( + args.use_style_cond_and_image_meta_size + ) ### version <= v1.1: True; version >= v1.2: False + + # input_size -> sample_size, text_dim -> cross_attention_dim + for key in state_dict: + print("local:", key) + + model = HunyuanDiT2DModel.from_config(model_config).to(device) + + for key in model.state_dict(): + print("diffusers:", key) + + num_layers = 40 + for i in range(num_layers): + # attn1 + # Wkqv -> to_q, to_k, to_v + q, k, v = torch.chunk(state_dict[f"blocks.{i}.attn1.Wqkv.weight"], 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(state_dict[f"blocks.{i}.attn1.Wqkv.bias"], 3, dim=0) + state_dict[f"blocks.{i}.attn1.to_q.weight"] = q + state_dict[f"blocks.{i}.attn1.to_q.bias"] = q_bias + state_dict[f"blocks.{i}.attn1.to_k.weight"] = k + state_dict[f"blocks.{i}.attn1.to_k.bias"] = k_bias + state_dict[f"blocks.{i}.attn1.to_v.weight"] = v + state_dict[f"blocks.{i}.attn1.to_v.bias"] = v_bias + state_dict.pop(f"blocks.{i}.attn1.Wqkv.weight") + state_dict.pop(f"blocks.{i}.attn1.Wqkv.bias") + + # q_norm, k_norm -> norm_q, norm_k + state_dict[f"blocks.{i}.attn1.norm_q.weight"] = state_dict[f"blocks.{i}.attn1.q_norm.weight"] + state_dict[f"blocks.{i}.attn1.norm_q.bias"] = state_dict[f"blocks.{i}.attn1.q_norm.bias"] + state_dict[f"blocks.{i}.attn1.norm_k.weight"] = state_dict[f"blocks.{i}.attn1.k_norm.weight"] + state_dict[f"blocks.{i}.attn1.norm_k.bias"] = state_dict[f"blocks.{i}.attn1.k_norm.bias"] + + state_dict.pop(f"blocks.{i}.attn1.q_norm.weight") + state_dict.pop(f"blocks.{i}.attn1.q_norm.bias") + state_dict.pop(f"blocks.{i}.attn1.k_norm.weight") + state_dict.pop(f"blocks.{i}.attn1.k_norm.bias") + + # out_proj -> to_out + state_dict[f"blocks.{i}.attn1.to_out.0.weight"] = state_dict[f"blocks.{i}.attn1.out_proj.weight"] + state_dict[f"blocks.{i}.attn1.to_out.0.bias"] = state_dict[f"blocks.{i}.attn1.out_proj.bias"] + state_dict.pop(f"blocks.{i}.attn1.out_proj.weight") + state_dict.pop(f"blocks.{i}.attn1.out_proj.bias") + + # attn2 + # kq_proj -> to_k, to_v + k, v = torch.chunk(state_dict[f"blocks.{i}.attn2.kv_proj.weight"], 2, dim=0) + k_bias, v_bias = torch.chunk(state_dict[f"blocks.{i}.attn2.kv_proj.bias"], 2, dim=0) + state_dict[f"blocks.{i}.attn2.to_k.weight"] = k + state_dict[f"blocks.{i}.attn2.to_k.bias"] = k_bias + state_dict[f"blocks.{i}.attn2.to_v.weight"] = v + state_dict[f"blocks.{i}.attn2.to_v.bias"] = v_bias + state_dict.pop(f"blocks.{i}.attn2.kv_proj.weight") + state_dict.pop(f"blocks.{i}.attn2.kv_proj.bias") + + # q_proj -> to_q + state_dict[f"blocks.{i}.attn2.to_q.weight"] = state_dict[f"blocks.{i}.attn2.q_proj.weight"] + state_dict[f"blocks.{i}.attn2.to_q.bias"] = state_dict[f"blocks.{i}.attn2.q_proj.bias"] + state_dict.pop(f"blocks.{i}.attn2.q_proj.weight") + state_dict.pop(f"blocks.{i}.attn2.q_proj.bias") + + # q_norm, k_norm -> norm_q, norm_k + state_dict[f"blocks.{i}.attn2.norm_q.weight"] = state_dict[f"blocks.{i}.attn2.q_norm.weight"] + state_dict[f"blocks.{i}.attn2.norm_q.bias"] = state_dict[f"blocks.{i}.attn2.q_norm.bias"] + state_dict[f"blocks.{i}.attn2.norm_k.weight"] = state_dict[f"blocks.{i}.attn2.k_norm.weight"] + state_dict[f"blocks.{i}.attn2.norm_k.bias"] = state_dict[f"blocks.{i}.attn2.k_norm.bias"] + + state_dict.pop(f"blocks.{i}.attn2.q_norm.weight") + state_dict.pop(f"blocks.{i}.attn2.q_norm.bias") + state_dict.pop(f"blocks.{i}.attn2.k_norm.weight") + state_dict.pop(f"blocks.{i}.attn2.k_norm.bias") + + # out_proj -> to_out + state_dict[f"blocks.{i}.attn2.to_out.0.weight"] = state_dict[f"blocks.{i}.attn2.out_proj.weight"] + state_dict[f"blocks.{i}.attn2.to_out.0.bias"] = state_dict[f"blocks.{i}.attn2.out_proj.bias"] + state_dict.pop(f"blocks.{i}.attn2.out_proj.weight") + state_dict.pop(f"blocks.{i}.attn2.out_proj.bias") + + # switch norm 2 and norm 3 + norm2_weight = state_dict[f"blocks.{i}.norm2.weight"] + norm2_bias = state_dict[f"blocks.{i}.norm2.bias"] + state_dict[f"blocks.{i}.norm2.weight"] = state_dict[f"blocks.{i}.norm3.weight"] + state_dict[f"blocks.{i}.norm2.bias"] = state_dict[f"blocks.{i}.norm3.bias"] + state_dict[f"blocks.{i}.norm3.weight"] = norm2_weight + state_dict[f"blocks.{i}.norm3.bias"] = norm2_bias + + # norm1 -> norm1.norm + # default_modulation.1 -> norm1.linear + state_dict[f"blocks.{i}.norm1.norm.weight"] = state_dict[f"blocks.{i}.norm1.weight"] + state_dict[f"blocks.{i}.norm1.norm.bias"] = state_dict[f"blocks.{i}.norm1.bias"] + state_dict[f"blocks.{i}.norm1.linear.weight"] = state_dict[f"blocks.{i}.default_modulation.1.weight"] + state_dict[f"blocks.{i}.norm1.linear.bias"] = state_dict[f"blocks.{i}.default_modulation.1.bias"] + state_dict.pop(f"blocks.{i}.norm1.weight") + state_dict.pop(f"blocks.{i}.norm1.bias") + state_dict.pop(f"blocks.{i}.default_modulation.1.weight") + state_dict.pop(f"blocks.{i}.default_modulation.1.bias") + + # mlp.fc1 -> ff.net.0, mlp.fc2 -> ff.net.2 + state_dict[f"blocks.{i}.ff.net.0.proj.weight"] = state_dict[f"blocks.{i}.mlp.fc1.weight"] + state_dict[f"blocks.{i}.ff.net.0.proj.bias"] = state_dict[f"blocks.{i}.mlp.fc1.bias"] + state_dict[f"blocks.{i}.ff.net.2.weight"] = state_dict[f"blocks.{i}.mlp.fc2.weight"] + state_dict[f"blocks.{i}.ff.net.2.bias"] = state_dict[f"blocks.{i}.mlp.fc2.bias"] + state_dict.pop(f"blocks.{i}.mlp.fc1.weight") + state_dict.pop(f"blocks.{i}.mlp.fc1.bias") + state_dict.pop(f"blocks.{i}.mlp.fc2.weight") + state_dict.pop(f"blocks.{i}.mlp.fc2.bias") + + # pooler -> time_extra_emb + state_dict["time_extra_emb.pooler.positional_embedding"] = state_dict["pooler.positional_embedding"] + state_dict["time_extra_emb.pooler.k_proj.weight"] = state_dict["pooler.k_proj.weight"] + state_dict["time_extra_emb.pooler.k_proj.bias"] = state_dict["pooler.k_proj.bias"] + state_dict["time_extra_emb.pooler.q_proj.weight"] = state_dict["pooler.q_proj.weight"] + state_dict["time_extra_emb.pooler.q_proj.bias"] = state_dict["pooler.q_proj.bias"] + state_dict["time_extra_emb.pooler.v_proj.weight"] = state_dict["pooler.v_proj.weight"] + state_dict["time_extra_emb.pooler.v_proj.bias"] = state_dict["pooler.v_proj.bias"] + state_dict["time_extra_emb.pooler.c_proj.weight"] = state_dict["pooler.c_proj.weight"] + state_dict["time_extra_emb.pooler.c_proj.bias"] = state_dict["pooler.c_proj.bias"] + state_dict.pop("pooler.k_proj.weight") + state_dict.pop("pooler.k_proj.bias") + state_dict.pop("pooler.q_proj.weight") + state_dict.pop("pooler.q_proj.bias") + state_dict.pop("pooler.v_proj.weight") + state_dict.pop("pooler.v_proj.bias") + state_dict.pop("pooler.c_proj.weight") + state_dict.pop("pooler.c_proj.bias") + state_dict.pop("pooler.positional_embedding") + + # t_embedder -> time_embedding (`TimestepEmbedding`) + state_dict["time_extra_emb.timestep_embedder.linear_1.bias"] = state_dict["t_embedder.mlp.0.bias"] + state_dict["time_extra_emb.timestep_embedder.linear_1.weight"] = state_dict["t_embedder.mlp.0.weight"] + state_dict["time_extra_emb.timestep_embedder.linear_2.bias"] = state_dict["t_embedder.mlp.2.bias"] + state_dict["time_extra_emb.timestep_embedder.linear_2.weight"] = state_dict["t_embedder.mlp.2.weight"] + + state_dict.pop("t_embedder.mlp.0.bias") + state_dict.pop("t_embedder.mlp.0.weight") + state_dict.pop("t_embedder.mlp.2.bias") + state_dict.pop("t_embedder.mlp.2.weight") + + # x_embedder -> pos_embd (`PatchEmbed`) + state_dict["pos_embed.proj.weight"] = state_dict["x_embedder.proj.weight"] + state_dict["pos_embed.proj.bias"] = state_dict["x_embedder.proj.bias"] + state_dict.pop("x_embedder.proj.weight") + state_dict.pop("x_embedder.proj.bias") + + # mlp_t5 -> text_embedder + state_dict["text_embedder.linear_1.bias"] = state_dict["mlp_t5.0.bias"] + state_dict["text_embedder.linear_1.weight"] = state_dict["mlp_t5.0.weight"] + state_dict["text_embedder.linear_2.bias"] = state_dict["mlp_t5.2.bias"] + state_dict["text_embedder.linear_2.weight"] = state_dict["mlp_t5.2.weight"] + state_dict.pop("mlp_t5.0.bias") + state_dict.pop("mlp_t5.0.weight") + state_dict.pop("mlp_t5.2.bias") + state_dict.pop("mlp_t5.2.weight") + + # extra_embedder -> extra_embedder + state_dict["time_extra_emb.extra_embedder.linear_1.bias"] = state_dict["extra_embedder.0.bias"] + state_dict["time_extra_emb.extra_embedder.linear_1.weight"] = state_dict["extra_embedder.0.weight"] + state_dict["time_extra_emb.extra_embedder.linear_2.bias"] = state_dict["extra_embedder.2.bias"] + state_dict["time_extra_emb.extra_embedder.linear_2.weight"] = state_dict["extra_embedder.2.weight"] + state_dict.pop("extra_embedder.0.bias") + state_dict.pop("extra_embedder.0.weight") + state_dict.pop("extra_embedder.2.bias") + state_dict.pop("extra_embedder.2.weight") + + # model.final_adaLN_modulation.1 -> norm_out.linear + def swap_scale_shift(weight): + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + return new_weight + + state_dict["norm_out.linear.weight"] = swap_scale_shift(state_dict["final_layer.adaLN_modulation.1.weight"]) + state_dict["norm_out.linear.bias"] = swap_scale_shift(state_dict["final_layer.adaLN_modulation.1.bias"]) + state_dict.pop("final_layer.adaLN_modulation.1.weight") + state_dict.pop("final_layer.adaLN_modulation.1.bias") + + # final_linear -> proj_out + state_dict["proj_out.weight"] = state_dict["final_layer.linear.weight"] + state_dict["proj_out.bias"] = state_dict["final_layer.linear.bias"] + state_dict.pop("final_layer.linear.weight") + state_dict.pop("final_layer.linear.bias") + + # style_embedder + if model_config["use_style_cond_and_image_meta_size"]: + print(state_dict["style_embedder.weight"]) + print(state_dict["style_embedder.weight"].shape) + state_dict["time_extra_emb.style_embedder.weight"] = state_dict["style_embedder.weight"][0:1] + state_dict.pop("style_embedder.weight") + + model.load_state_dict(state_dict) + + from diffusers import HunyuanDiTPipeline + + if args.use_style_cond_and_image_meta_size: + pipe = HunyuanDiTPipeline.from_pretrained( + "Tencent-Hunyuan/HunyuanDiT-Diffusers", transformer=model, torch_dtype=torch.float32 + ) + else: + pipe = HunyuanDiTPipeline.from_pretrained( + "Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers", transformer=model, torch_dtype=torch.float32 + ) + pipe.to("cuda") + pipe.to(dtype=torch.float32) + + if args.save: + pipe.save_pretrained(args.output_checkpoint_path) + + # ### NOTE: HunyuanDiT supports both Chinese and English inputs + prompt = "一个宇航员在骑马" + # prompt = "An astronaut riding a horse" + generator = torch.Generator(device="cuda").manual_seed(0) + image = pipe( + height=1024, width=1024, prompt=prompt, generator=generator, num_inference_steps=25, guidance_scale=5.0 + ).images[0] + + image.save("img.png") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--save", default=True, type=bool, required=False, help="Whether to save the converted pipeline or not." + ) + parser.add_argument( + "--pt_checkpoint_path", default=None, type=str, required=True, help="Path to the .pt pretrained model." + ) + parser.add_argument( + "--output_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the output converted diffusers pipeline.", + ) + parser.add_argument( + "--load_key", default="none", type=str, required=False, help="The key to load from the pretrained .pt file" + ) + parser.add_argument( + "--use_style_cond_and_image_meta_size", + type=bool, + default=False, + help="version <= v1.1: True; version >= v1.2: False", + ) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_i2vgen_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_i2vgen_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..643780caac2d46b3f377719d7c05eedcf116dc5d --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_i2vgen_to_diffusers.py @@ -0,0 +1,510 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the LDM checkpoints.""" + +import argparse + +import torch +from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection + +from diffusers import DDIMScheduler, I2VGenXLPipeline, I2VGenXLUNet, StableDiffusionPipeline + + +CLIP_ID = "laion/CLIP-ViT-H-14-laion2B-s32B-b79K" + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + weight = old_checkpoint[path["old"]] + names = ["proj_attn.weight"] + names_2 = ["proj_out.weight", "proj_in.weight"] + if any(k in new_path for k in names): + checkpoint[new_path] = weight[:, :, 0] + elif any(k in new_path for k in names_2) and len(weight.shape) > 2 and ".attentions." not in new_path: + checkpoint[new_path] = weight[:, :, 0] + else: + checkpoint[new_path] = weight + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_temp_conv_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + mapping.append({"old": old_item, "new": old_item}) + + return mapping + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + if "temopral_conv" not in old_item: + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + print(f"Checkpoint {path} has both EMA and non-EMA weights.") + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + additional_embedding_substrings = [ + "local_image_concat", + "context_embedding", + "local_image_embedding", + "fps_embedding", + ] + for k in unet_state_dict: + if any(substring in k for substring in additional_embedding_substrings): + diffusers_key = k.replace("local_image_concat", "image_latents_proj_in").replace( + "local_image_embedding", "image_latents_context_embedding" + ) + new_checkpoint[diffusers_key] = unet_state_dict[k] + + # temporal encoder. + new_checkpoint["image_latents_temporal_encoder.norm1.weight"] = unet_state_dict[ + "local_temporal_encoder.layers.0.0.norm.weight" + ] + new_checkpoint["image_latents_temporal_encoder.norm1.bias"] = unet_state_dict[ + "local_temporal_encoder.layers.0.0.norm.bias" + ] + + # attention + qkv = unet_state_dict["local_temporal_encoder.layers.0.0.fn.to_qkv.weight"] + q, k, v = torch.chunk(qkv, 3, dim=0) + new_checkpoint["image_latents_temporal_encoder.attn1.to_q.weight"] = q + new_checkpoint["image_latents_temporal_encoder.attn1.to_k.weight"] = k + new_checkpoint["image_latents_temporal_encoder.attn1.to_v.weight"] = v + new_checkpoint["image_latents_temporal_encoder.attn1.to_out.0.weight"] = unet_state_dict[ + "local_temporal_encoder.layers.0.0.fn.to_out.0.weight" + ] + new_checkpoint["image_latents_temporal_encoder.attn1.to_out.0.bias"] = unet_state_dict[ + "local_temporal_encoder.layers.0.0.fn.to_out.0.bias" + ] + + # feedforward + new_checkpoint["image_latents_temporal_encoder.ff.net.0.proj.weight"] = unet_state_dict[ + "local_temporal_encoder.layers.0.1.net.0.0.weight" + ] + new_checkpoint["image_latents_temporal_encoder.ff.net.0.proj.bias"] = unet_state_dict[ + "local_temporal_encoder.layers.0.1.net.0.0.bias" + ] + new_checkpoint["image_latents_temporal_encoder.ff.net.2.weight"] = unet_state_dict[ + "local_temporal_encoder.layers.0.1.net.2.weight" + ] + new_checkpoint["image_latents_temporal_encoder.ff.net.2.bias"] = unet_state_dict[ + "local_temporal_encoder.layers.0.1.net.2.bias" + ] + + if "class_embed_type" in config: + if config["class_embed_type"] is None: + # No parameters to port + ... + elif config["class_embed_type"] == "timestep" or config["class_embed_type"] == "projection": + new_checkpoint["class_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["class_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["class_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["class_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + else: + raise NotImplementedError(f"Not implemented `class_embed_type`: {config['class_embed_type']}") + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + first_temp_attention = [v for v in unet_state_dict if v.startswith("input_blocks.0.1")] + paths = renew_attention_paths(first_temp_attention) + meta_path = {"old": "input_blocks.0.1", "new": "transformer_in"} + assign_to_checkpoint(paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config) + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + temp_attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.2" in key] + + if f"input_blocks.{i}.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + temporal_convs = [key for key in resnets if "temopral_conv" in key] + paths = renew_temp_conv_paths(temporal_convs) + meta_path = { + "old": f"input_blocks.{i}.0.temopral_conv", + "new": f"down_blocks.{block_id}.temp_convs.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(temp_attentions): + paths = renew_attention_paths(temp_attentions) + meta_path = { + "old": f"input_blocks.{i}.2", + "new": f"down_blocks.{block_id}.temp_attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + temporal_convs_0 = [key for key in resnet_0 if "temopral_conv" in key] + attentions = middle_blocks[1] + temp_attentions = middle_blocks[2] + resnet_1 = middle_blocks[3] + temporal_convs_1 = [key for key in resnet_1 if "temopral_conv" in key] + + resnet_0_paths = renew_resnet_paths(resnet_0) + meta_path = {"old": "middle_block.0", "new": "mid_block.resnets.0"} + assign_to_checkpoint( + resnet_0_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + temp_conv_0_paths = renew_temp_conv_paths(temporal_convs_0) + meta_path = {"old": "middle_block.0.temopral_conv", "new": "mid_block.temp_convs.0"} + assign_to_checkpoint( + temp_conv_0_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + resnet_1_paths = renew_resnet_paths(resnet_1) + meta_path = {"old": "middle_block.3", "new": "mid_block.resnets.1"} + assign_to_checkpoint( + resnet_1_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + temp_conv_1_paths = renew_temp_conv_paths(temporal_convs_1) + meta_path = {"old": "middle_block.3.temopral_conv", "new": "mid_block.temp_convs.1"} + assign_to_checkpoint( + temp_conv_1_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + temp_attentions_paths = renew_attention_paths(temp_attentions) + meta_path = {"old": "middle_block.2", "new": "mid_block.temp_attentions.0"} + assign_to_checkpoint( + temp_attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + temp_attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.2" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + temporal_convs = [key for key in resnets if "temopral_conv" in key] + paths = renew_temp_conv_paths(temporal_convs) + meta_path = { + "old": f"output_blocks.{i}.0.temopral_conv", + "new": f"up_blocks.{block_id}.temp_convs.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(temp_attentions): + paths = renew_attention_paths(temp_attentions) + meta_path = { + "old": f"output_blocks.{i}.2", + "new": f"up_blocks.{block_id}.temp_attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + new_checkpoint[new_path] = unet_state_dict[old_path] + + temopral_conv_paths = [l for l in output_block_layers if "temopral_conv" in l] + for path in temopral_conv_paths: + pruned_path = path.split("temopral_conv.")[-1] + old_path = ".".join(["output_blocks", str(i), str(block_id), "temopral_conv", pruned_path]) + new_path = ".".join(["up_blocks", str(block_id), "temp_convs", str(layer_in_block_id), pruned_path]) + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--unet_checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--push_to_hub", action="store_true") + args = parser.parse_args() + + # UNet + unet_checkpoint = torch.load(args.unet_checkpoint_path, map_location="cpu") + unet_checkpoint = unet_checkpoint["state_dict"] + unet = I2VGenXLUNet(sample_size=32) + + converted_ckpt = convert_ldm_unet_checkpoint(unet_checkpoint, unet.config) + + diff_0 = set(unet.state_dict().keys()) - set(converted_ckpt.keys()) + diff_1 = set(converted_ckpt.keys()) - set(unet.state_dict().keys()) + + assert len(diff_0) == len(diff_1) == 0, "Converted weights don't match" + + unet.load_state_dict(converted_ckpt, strict=True) + + # vae + temp_pipe = StableDiffusionPipeline.from_single_file( + "https://huggingface.co/ali-vilab/i2vgen-xl/blob/main/models/v2-1_512-ema-pruned.ckpt" + ) + vae = temp_pipe.vae + del temp_pipe + + # text encoder and tokenizer + text_encoder = CLIPTextModel.from_pretrained(CLIP_ID) + tokenizer = CLIPTokenizer.from_pretrained(CLIP_ID) + + # image encoder and feature extractor + image_encoder = CLIPVisionModelWithProjection.from_pretrained(CLIP_ID) + feature_extractor = CLIPImageProcessor.from_pretrained(CLIP_ID) + + # scheduler + # https://github.com/ali-vilab/i2vgen-xl/blob/main/configs/i2vgen_xl_train.yaml + scheduler = DDIMScheduler( + beta_schedule="squaredcos_cap_v2", + rescale_betas_zero_snr=True, + set_alpha_to_one=True, + clip_sample=False, + steps_offset=1, + timestep_spacing="leading", + prediction_type="v_prediction", + ) + + # final + pipeline = I2VGenXLPipeline( + unet=unet, + vae=vae, + image_encoder=image_encoder, + feature_extractor=feature_extractor, + text_encoder=text_encoder, + tokenizer=tokenizer, + scheduler=scheduler, + ) + + pipeline.save_pretrained(args.dump_path, push_to_hub=args.push_to_hub) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_if.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_if.py new file mode 100644 index 0000000000000000000000000000000000000000..85c739ca92f04bd2e1fefdaca3ff15b59f75c66e --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_if.py @@ -0,0 +1,1250 @@ +import argparse +import inspect +import os + +import numpy as np +import torch +import yaml +from torch.nn import functional as F +from transformers import CLIPConfig, CLIPImageProcessor, CLIPVisionModelWithProjection, T5EncoderModel, T5Tokenizer + +from diffusers import DDPMScheduler, IFPipeline, IFSuperResolutionPipeline, UNet2DConditionModel +from diffusers.pipelines.deepfloyd_if.safety_checker import IFSafetyChecker + + +def parse_args(): + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", required=False, default=None, type=str) + + parser.add_argument("--dump_path_stage_2", required=False, default=None, type=str) + + parser.add_argument("--dump_path_stage_3", required=False, default=None, type=str) + + parser.add_argument("--unet_config", required=False, default=None, type=str, help="Path to unet config file") + + parser.add_argument( + "--unet_checkpoint_path", required=False, default=None, type=str, help="Path to unet checkpoint file" + ) + + parser.add_argument( + "--unet_checkpoint_path_stage_2", + required=False, + default=None, + type=str, + help="Path to stage 2 unet checkpoint file", + ) + + parser.add_argument( + "--unet_checkpoint_path_stage_3", + required=False, + default=None, + type=str, + help="Path to stage 3 unet checkpoint file", + ) + + parser.add_argument("--p_head_path", type=str, required=True) + + parser.add_argument("--w_head_path", type=str, required=True) + + args = parser.parse_args() + + return args + + +def main(args): + tokenizer = T5Tokenizer.from_pretrained("google/t5-v1_1-xxl") + text_encoder = T5EncoderModel.from_pretrained("google/t5-v1_1-xxl") + + feature_extractor = CLIPImageProcessor.from_pretrained("openai/clip-vit-large-patch14") + safety_checker = convert_safety_checker(p_head_path=args.p_head_path, w_head_path=args.w_head_path) + + if args.unet_config is not None and args.unet_checkpoint_path is not None and args.dump_path is not None: + convert_stage_1_pipeline(tokenizer, text_encoder, feature_extractor, safety_checker, args) + + if args.unet_checkpoint_path_stage_2 is not None and args.dump_path_stage_2 is not None: + convert_super_res_pipeline(tokenizer, text_encoder, feature_extractor, safety_checker, args, stage=2) + + if args.unet_checkpoint_path_stage_3 is not None and args.dump_path_stage_3 is not None: + convert_super_res_pipeline(tokenizer, text_encoder, feature_extractor, safety_checker, args, stage=3) + + +def convert_stage_1_pipeline(tokenizer, text_encoder, feature_extractor, safety_checker, args): + unet = get_stage_1_unet(args.unet_config, args.unet_checkpoint_path) + + scheduler = DDPMScheduler( + variance_type="learned_range", + beta_schedule="squaredcos_cap_v2", + prediction_type="epsilon", + thresholding=True, + dynamic_thresholding_ratio=0.95, + sample_max_value=1.5, + ) + + pipe = IFPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + unet=unet, + scheduler=scheduler, + safety_checker=safety_checker, + feature_extractor=feature_extractor, + requires_safety_checker=True, + ) + + pipe.save_pretrained(args.dump_path) + + +def convert_super_res_pipeline(tokenizer, text_encoder, feature_extractor, safety_checker, args, stage): + if stage == 2: + unet_checkpoint_path = args.unet_checkpoint_path_stage_2 + sample_size = None + dump_path = args.dump_path_stage_2 + elif stage == 3: + unet_checkpoint_path = args.unet_checkpoint_path_stage_3 + sample_size = 1024 + dump_path = args.dump_path_stage_3 + else: + assert False + + unet = get_super_res_unet(unet_checkpoint_path, verify_param_count=False, sample_size=sample_size) + + image_noising_scheduler = DDPMScheduler( + beta_schedule="squaredcos_cap_v2", + ) + + scheduler = DDPMScheduler( + variance_type="learned_range", + beta_schedule="squaredcos_cap_v2", + prediction_type="epsilon", + thresholding=True, + dynamic_thresholding_ratio=0.95, + sample_max_value=1.0, + ) + + pipe = IFSuperResolutionPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + unet=unet, + scheduler=scheduler, + image_noising_scheduler=image_noising_scheduler, + safety_checker=safety_checker, + feature_extractor=feature_extractor, + requires_safety_checker=True, + ) + + pipe.save_pretrained(dump_path) + + +def get_stage_1_unet(unet_config, unet_checkpoint_path): + original_unet_config = yaml.safe_load(unet_config) + original_unet_config = original_unet_config["params"] + + unet_diffusers_config = create_unet_diffusers_config(original_unet_config) + + unet = UNet2DConditionModel(**unet_diffusers_config) + + device = "cuda" if torch.cuda.is_available() else "cpu" + unet_checkpoint = torch.load(unet_checkpoint_path, map_location=device) + + converted_unet_checkpoint = convert_ldm_unet_checkpoint( + unet_checkpoint, unet_diffusers_config, path=unet_checkpoint_path + ) + + unet.load_state_dict(converted_unet_checkpoint) + + return unet + + +def convert_safety_checker(p_head_path, w_head_path): + state_dict = {} + + # p head + + p_head = np.load(p_head_path) + + p_head_weights = p_head["weights"] + p_head_weights = torch.from_numpy(p_head_weights) + p_head_weights = p_head_weights.unsqueeze(0) + + p_head_biases = p_head["biases"] + p_head_biases = torch.from_numpy(p_head_biases) + p_head_biases = p_head_biases.unsqueeze(0) + + state_dict["p_head.weight"] = p_head_weights + state_dict["p_head.bias"] = p_head_biases + + # w head + + w_head = np.load(w_head_path) + + w_head_weights = w_head["weights"] + w_head_weights = torch.from_numpy(w_head_weights) + w_head_weights = w_head_weights.unsqueeze(0) + + w_head_biases = w_head["biases"] + w_head_biases = torch.from_numpy(w_head_biases) + w_head_biases = w_head_biases.unsqueeze(0) + + state_dict["w_head.weight"] = w_head_weights + state_dict["w_head.bias"] = w_head_biases + + # vision model + + vision_model = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") + vision_model_state_dict = vision_model.state_dict() + + for key, value in vision_model_state_dict.items(): + key = f"vision_model.{key}" + state_dict[key] = value + + # full model + + config = CLIPConfig.from_pretrained("openai/clip-vit-large-patch14") + safety_checker = IFSafetyChecker(config) + + safety_checker.load_state_dict(state_dict) + + return safety_checker + + +def create_unet_diffusers_config(original_unet_config, class_embed_type=None): + attention_resolutions = parse_list(original_unet_config["attention_resolutions"]) + attention_resolutions = [original_unet_config["image_size"] // int(res) for res in attention_resolutions] + + channel_mult = parse_list(original_unet_config["channel_mult"]) + block_out_channels = [original_unet_config["model_channels"] * mult for mult in channel_mult] + + down_block_types = [] + resolution = 1 + + for i in range(len(block_out_channels)): + if resolution in attention_resolutions: + block_type = "SimpleCrossAttnDownBlock2D" + elif original_unet_config["resblock_updown"]: + block_type = "ResnetDownsampleBlock2D" + else: + block_type = "DownBlock2D" + + down_block_types.append(block_type) + + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + if resolution in attention_resolutions: + block_type = "SimpleCrossAttnUpBlock2D" + elif original_unet_config["resblock_updown"]: + block_type = "ResnetUpsampleBlock2D" + else: + block_type = "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + head_dim = original_unet_config["num_head_channels"] + + use_linear_projection = ( + original_unet_config["use_linear_in_transformer"] + if "use_linear_in_transformer" in original_unet_config + else False + ) + if use_linear_projection: + # stable diffusion 2-base-512 and 2-768 + if head_dim is None: + head_dim = [5, 10, 20, 20] + + projection_class_embeddings_input_dim = None + + if class_embed_type is None: + if "num_classes" in original_unet_config: + if original_unet_config["num_classes"] == "sequential": + class_embed_type = "projection" + assert "adm_in_channels" in original_unet_config + projection_class_embeddings_input_dim = original_unet_config["adm_in_channels"] + else: + raise NotImplementedError( + f"Unknown conditional unet num_classes config: {original_unet_config['num_classes']}" + ) + + config = { + "sample_size": original_unet_config["image_size"], + "in_channels": original_unet_config["in_channels"], + "down_block_types": tuple(down_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": original_unet_config["num_res_blocks"], + "cross_attention_dim": original_unet_config["encoder_channels"], + "attention_head_dim": head_dim, + "use_linear_projection": use_linear_projection, + "class_embed_type": class_embed_type, + "projection_class_embeddings_input_dim": projection_class_embeddings_input_dim, + "out_channels": original_unet_config["out_channels"], + "up_block_types": tuple(up_block_types), + "upcast_attention": False, # TODO: guessing + "cross_attention_norm": "group_norm", + "mid_block_type": "UNetMidBlock2DSimpleCrossAttn", + "addition_embed_type": "text", + "act_fn": "gelu", + } + + if original_unet_config["use_scale_shift_norm"]: + config["resnet_time_scale_shift"] = "scale_shift" + + if "encoder_dim" in original_unet_config: + config["encoder_hid_dim"] = original_unet_config["encoder_dim"] + + return config + + +def convert_ldm_unet_checkpoint(unet_state_dict, config, path=None): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + if config["class_embed_type"] in [None, "identity"]: + # No parameters to port + ... + elif config["class_embed_type"] == "timestep" or config["class_embed_type"] == "projection": + new_checkpoint["class_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["class_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["class_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["class_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + else: + raise NotImplementedError(f"Not implemented `class_embed_type`: {config['class_embed_type']}") + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}." in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}." in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + + # TODO need better check than i in [4, 8, 12, 16] + block_type = config["down_block_types"][block_id] + if (block_type == "ResnetDownsampleBlock2D" or block_type == "SimpleCrossAttnDownBlock2D") and i in [ + 4, + 8, + 12, + 16, + ]: + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.downsamplers.0"} + else: + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + old_path = f"input_blocks.{i}.1" + new_path = f"down_blocks.{block_id}.attentions.{layer_in_block_id}" + + assign_attention_to_checkpoint( + new_checkpoint=new_checkpoint, + unet_state_dict=unet_state_dict, + old_path=old_path, + new_path=new_path, + config=config, + ) + + paths = renew_attention_paths(attentions) + meta_path = {"old": old_path, "new": new_path} + assign_to_checkpoint( + paths, + new_checkpoint, + unet_state_dict, + additional_replacements=[meta_path], + config=config, + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + old_path = "middle_block.1" + new_path = "mid_block.attentions.0" + + assign_attention_to_checkpoint( + new_checkpoint=new_checkpoint, + unet_state_dict=unet_state_dict, + old_path=old_path, + new_path=new_path, + config=config, + ) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + # len(output_block_list) == 1 -> resnet + # len(output_block_list) == 2 -> resnet, attention + # len(output_block_list) == 3 -> resnet, attention, upscale resnet + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + old_path = f"output_blocks.{i}.1" + new_path = f"up_blocks.{block_id}.attentions.{layer_in_block_id}" + + assign_attention_to_checkpoint( + new_checkpoint=new_checkpoint, + unet_state_dict=unet_state_dict, + old_path=old_path, + new_path=new_path, + config=config, + ) + + paths = renew_attention_paths(attentions) + meta_path = { + "old": old_path, + "new": new_path, + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(output_block_list) == 3: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.2" in key] + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"output_blocks.{i}.2", "new": f"up_blocks.{block_id}.upsamplers.0"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + if "encoder_proj.weight" in unet_state_dict: + new_checkpoint["encoder_hid_proj.weight"] = unet_state_dict.pop("encoder_proj.weight") + new_checkpoint["encoder_hid_proj.bias"] = unet_state_dict.pop("encoder_proj.bias") + + if "encoder_pooling.0.weight" in unet_state_dict: + new_checkpoint["add_embedding.norm1.weight"] = unet_state_dict.pop("encoder_pooling.0.weight") + new_checkpoint["add_embedding.norm1.bias"] = unet_state_dict.pop("encoder_pooling.0.bias") + + new_checkpoint["add_embedding.pool.positional_embedding"] = unet_state_dict.pop( + "encoder_pooling.1.positional_embedding" + ) + new_checkpoint["add_embedding.pool.k_proj.weight"] = unet_state_dict.pop("encoder_pooling.1.k_proj.weight") + new_checkpoint["add_embedding.pool.k_proj.bias"] = unet_state_dict.pop("encoder_pooling.1.k_proj.bias") + new_checkpoint["add_embedding.pool.q_proj.weight"] = unet_state_dict.pop("encoder_pooling.1.q_proj.weight") + new_checkpoint["add_embedding.pool.q_proj.bias"] = unet_state_dict.pop("encoder_pooling.1.q_proj.bias") + new_checkpoint["add_embedding.pool.v_proj.weight"] = unet_state_dict.pop("encoder_pooling.1.v_proj.weight") + new_checkpoint["add_embedding.pool.v_proj.bias"] = unet_state_dict.pop("encoder_pooling.1.v_proj.bias") + + new_checkpoint["add_embedding.proj.weight"] = unet_state_dict.pop("encoder_pooling.2.weight") + new_checkpoint["add_embedding.proj.bias"] = unet_state_dict.pop("encoder_pooling.2.bias") + + new_checkpoint["add_embedding.norm2.weight"] = unet_state_dict.pop("encoder_pooling.3.weight") + new_checkpoint["add_embedding.norm2.bias"] = unet_state_dict.pop("encoder_pooling.3.bias") + + return new_checkpoint + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + if "qkv" in new_item: + continue + + if "encoder_kv" in new_item: + continue + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("proj_out.weight", "to_out.0.weight") + new_item = new_item.replace("proj_out.bias", "to_out.0.bias") + + new_item = new_item.replace("norm_encoder.weight", "norm_cross.weight") + new_item = new_item.replace("norm_encoder.bias", "norm_cross.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def assign_attention_to_checkpoint(new_checkpoint, unet_state_dict, old_path, new_path, config): + qkv_weight = unet_state_dict.pop(f"{old_path}.qkv.weight") + qkv_weight = qkv_weight[:, :, 0] + + qkv_bias = unet_state_dict.pop(f"{old_path}.qkv.bias") + + is_cross_attn_only = "only_cross_attention" in config and config["only_cross_attention"] + + split = 1 if is_cross_attn_only else 3 + + weights, bias = split_attentions( + weight=qkv_weight, + bias=qkv_bias, + split=split, + chunk_size=config["attention_head_dim"], + ) + + if is_cross_attn_only: + query_weight, q_bias = weights, bias + new_checkpoint[f"{new_path}.to_q.weight"] = query_weight[0] + new_checkpoint[f"{new_path}.to_q.bias"] = q_bias[0] + else: + [query_weight, key_weight, value_weight], [q_bias, k_bias, v_bias] = weights, bias + new_checkpoint[f"{new_path}.to_q.weight"] = query_weight + new_checkpoint[f"{new_path}.to_q.bias"] = q_bias + new_checkpoint[f"{new_path}.to_k.weight"] = key_weight + new_checkpoint[f"{new_path}.to_k.bias"] = k_bias + new_checkpoint[f"{new_path}.to_v.weight"] = value_weight + new_checkpoint[f"{new_path}.to_v.bias"] = v_bias + + encoder_kv_weight = unet_state_dict.pop(f"{old_path}.encoder_kv.weight") + encoder_kv_weight = encoder_kv_weight[:, :, 0] + + encoder_kv_bias = unet_state_dict.pop(f"{old_path}.encoder_kv.bias") + + [encoder_k_weight, encoder_v_weight], [encoder_k_bias, encoder_v_bias] = split_attentions( + weight=encoder_kv_weight, + bias=encoder_kv_bias, + split=2, + chunk_size=config["attention_head_dim"], + ) + + new_checkpoint[f"{new_path}.add_k_proj.weight"] = encoder_k_weight + new_checkpoint[f"{new_path}.add_k_proj.bias"] = encoder_k_bias + new_checkpoint[f"{new_path}.add_v_proj.weight"] = encoder_v_weight + new_checkpoint[f"{new_path}.add_v_proj.bias"] = encoder_v_bias + + +def assign_to_checkpoint(paths, checkpoint, old_checkpoint, additional_replacements=None, config=None): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + for path in paths: + new_path = path["new"] + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + if "proj_attn.weight" in new_path or "to_out.0.weight" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +# TODO maybe document and/or can do more efficiently (build indices in for loop and extract once for each split?) +def split_attentions(*, weight, bias, split, chunk_size): + weights = [None] * split + biases = [None] * split + + weights_biases_idx = 0 + + for starting_row_index in range(0, weight.shape[0], chunk_size): + row_indices = torch.arange(starting_row_index, starting_row_index + chunk_size) + + weight_rows = weight[row_indices, :] + bias_rows = bias[row_indices] + + if weights[weights_biases_idx] is None: + weights[weights_biases_idx] = weight_rows + biases[weights_biases_idx] = bias_rows + else: + assert weights[weights_biases_idx] is not None + weights[weights_biases_idx] = torch.concat([weights[weights_biases_idx], weight_rows]) + biases[weights_biases_idx] = torch.concat([biases[weights_biases_idx], bias_rows]) + + weights_biases_idx = (weights_biases_idx + 1) % split + + return weights, biases + + +def parse_list(value): + if isinstance(value, str): + value = value.split(",") + value = [int(v) for v in value] + elif isinstance(value, list): + pass + else: + raise ValueError(f"Can't parse list for type: {type(value)}") + + return value + + +# below is copy and pasted from original convert_if_stage_2.py script + + +def get_super_res_unet(unet_checkpoint_path, verify_param_count=True, sample_size=None): + orig_path = unet_checkpoint_path + + original_unet_config = yaml.safe_load(os.path.join(orig_path, "config.yml")) + original_unet_config = original_unet_config["params"] + + unet_diffusers_config = superres_create_unet_diffusers_config(original_unet_config) + unet_diffusers_config["time_embedding_dim"] = original_unet_config["model_channels"] * int( + original_unet_config["channel_mult"].split(",")[-1] + ) + if original_unet_config["encoder_dim"] != original_unet_config["encoder_channels"]: + unet_diffusers_config["encoder_hid_dim"] = original_unet_config["encoder_dim"] + unet_diffusers_config["class_embed_type"] = "timestep" + unet_diffusers_config["addition_embed_type"] = "text" + + unet_diffusers_config["time_embedding_act_fn"] = "gelu" + unet_diffusers_config["resnet_skip_time_act"] = True + unet_diffusers_config["resnet_out_scale_factor"] = 1 / 0.7071 + unet_diffusers_config["mid_block_scale_factor"] = 1 / 0.7071 + unet_diffusers_config["only_cross_attention"] = ( + bool(original_unet_config["disable_self_attentions"]) + if ( + "disable_self_attentions" in original_unet_config + and isinstance(original_unet_config["disable_self_attentions"], int) + ) + else True + ) + + if sample_size is None: + unet_diffusers_config["sample_size"] = original_unet_config["image_size"] + else: + # The second upscaler unet's sample size is incorrectly specified + # in the config and is instead hardcoded in source + unet_diffusers_config["sample_size"] = sample_size + + unet_checkpoint = torch.load(os.path.join(unet_checkpoint_path, "pytorch_model.bin"), map_location="cpu") + + if verify_param_count: + # check that architecture matches - is a bit slow + verify_param_count(orig_path, unet_diffusers_config) + + converted_unet_checkpoint = superres_convert_ldm_unet_checkpoint( + unet_checkpoint, unet_diffusers_config, path=unet_checkpoint_path + ) + converted_keys = converted_unet_checkpoint.keys() + + model = UNet2DConditionModel(**unet_diffusers_config) + expected_weights = model.state_dict().keys() + + diff_c_e = set(converted_keys) - set(expected_weights) + diff_e_c = set(expected_weights) - set(converted_keys) + + assert len(diff_e_c) == 0, f"Expected, but not converted: {diff_e_c}" + assert len(diff_c_e) == 0, f"Converted, but not expected: {diff_c_e}" + + model.load_state_dict(converted_unet_checkpoint) + + return model + + +def superres_create_unet_diffusers_config(original_unet_config): + attention_resolutions = parse_list(original_unet_config["attention_resolutions"]) + attention_resolutions = [original_unet_config["image_size"] // int(res) for res in attention_resolutions] + + channel_mult = parse_list(original_unet_config["channel_mult"]) + block_out_channels = [original_unet_config["model_channels"] * mult for mult in channel_mult] + + down_block_types = [] + resolution = 1 + + for i in range(len(block_out_channels)): + if resolution in attention_resolutions: + block_type = "SimpleCrossAttnDownBlock2D" + elif original_unet_config["resblock_updown"]: + block_type = "ResnetDownsampleBlock2D" + else: + block_type = "DownBlock2D" + + down_block_types.append(block_type) + + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + if resolution in attention_resolutions: + block_type = "SimpleCrossAttnUpBlock2D" + elif original_unet_config["resblock_updown"]: + block_type = "ResnetUpsampleBlock2D" + else: + block_type = "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + head_dim = original_unet_config["num_head_channels"] + use_linear_projection = ( + original_unet_config["use_linear_in_transformer"] + if "use_linear_in_transformer" in original_unet_config + else False + ) + if use_linear_projection: + # stable diffusion 2-base-512 and 2-768 + if head_dim is None: + head_dim = [5, 10, 20, 20] + + class_embed_type = None + projection_class_embeddings_input_dim = None + + if "num_classes" in original_unet_config: + if original_unet_config["num_classes"] == "sequential": + class_embed_type = "projection" + assert "adm_in_channels" in original_unet_config + projection_class_embeddings_input_dim = original_unet_config["adm_in_channels"] + else: + raise NotImplementedError( + f"Unknown conditional unet num_classes config: {original_unet_config['num_classes']}" + ) + + config = { + "in_channels": original_unet_config["in_channels"], + "down_block_types": tuple(down_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": tuple(original_unet_config["num_res_blocks"]), + "cross_attention_dim": original_unet_config["encoder_channels"], + "attention_head_dim": head_dim, + "use_linear_projection": use_linear_projection, + "class_embed_type": class_embed_type, + "projection_class_embeddings_input_dim": projection_class_embeddings_input_dim, + "out_channels": original_unet_config["out_channels"], + "up_block_types": tuple(up_block_types), + "upcast_attention": False, # TODO: guessing + "cross_attention_norm": "group_norm", + "mid_block_type": "UNetMidBlock2DSimpleCrossAttn", + "act_fn": "gelu", + } + + if original_unet_config["use_scale_shift_norm"]: + config["resnet_time_scale_shift"] = "scale_shift" + + return config + + +def superres_convert_ldm_unet_checkpoint(unet_state_dict, config, path=None, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + if config["class_embed_type"] is None: + # No parameters to port + ... + elif config["class_embed_type"] == "timestep" or config["class_embed_type"] == "projection": + new_checkpoint["class_embedding.linear_1.weight"] = unet_state_dict["aug_proj.0.weight"] + new_checkpoint["class_embedding.linear_1.bias"] = unet_state_dict["aug_proj.0.bias"] + new_checkpoint["class_embedding.linear_2.weight"] = unet_state_dict["aug_proj.2.weight"] + new_checkpoint["class_embedding.linear_2.bias"] = unet_state_dict["aug_proj.2.bias"] + else: + raise NotImplementedError(f"Not implemented `class_embed_type`: {config['class_embed_type']}") + + if "encoder_proj.weight" in unet_state_dict: + new_checkpoint["encoder_hid_proj.weight"] = unet_state_dict["encoder_proj.weight"] + new_checkpoint["encoder_hid_proj.bias"] = unet_state_dict["encoder_proj.bias"] + + if "encoder_pooling.0.weight" in unet_state_dict: + mapping = { + "encoder_pooling.0": "add_embedding.norm1", + "encoder_pooling.1": "add_embedding.pool", + "encoder_pooling.2": "add_embedding.proj", + "encoder_pooling.3": "add_embedding.norm2", + } + for key in unet_state_dict.keys(): + if key.startswith("encoder_pooling"): + prefix = key[: len("encoder_pooling.0")] + new_key = key.replace(prefix, mapping[prefix]) + new_checkpoint[new_key] = unet_state_dict[key] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}." in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}." in key] + for layer_id in range(num_output_blocks) + } + if not isinstance(config["layers_per_block"], int): + layers_per_block_list = [e + 1 for e in config["layers_per_block"]] + layers_per_block_cumsum = list(np.cumsum(layers_per_block_list)) + downsampler_ids = layers_per_block_cumsum + else: + # TODO need better check than i in [4, 8, 12, 16] + downsampler_ids = [4, 8, 12, 16] + + for i in range(1, num_input_blocks): + if isinstance(config["layers_per_block"], int): + layers_per_block = config["layers_per_block"] + block_id = (i - 1) // (layers_per_block + 1) + layer_in_block_id = (i - 1) % (layers_per_block + 1) + else: + block_id = next(k for k, n in enumerate(layers_per_block_cumsum) if (i - 1) < n) + passed_blocks = layers_per_block_cumsum[block_id - 1] if block_id > 0 else 0 + layer_in_block_id = (i - 1) - passed_blocks + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + + block_type = config["down_block_types"][block_id] + if ( + block_type == "ResnetDownsampleBlock2D" or block_type == "SimpleCrossAttnDownBlock2D" + ) and i in downsampler_ids: + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.downsamplers.0"} + else: + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + old_path = f"input_blocks.{i}.1" + new_path = f"down_blocks.{block_id}.attentions.{layer_in_block_id}" + + assign_attention_to_checkpoint( + new_checkpoint=new_checkpoint, + unet_state_dict=unet_state_dict, + old_path=old_path, + new_path=new_path, + config=config, + ) + + paths = renew_attention_paths(attentions) + meta_path = {"old": old_path, "new": new_path} + assign_to_checkpoint( + paths, + new_checkpoint, + unet_state_dict, + additional_replacements=[meta_path], + config=config, + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + old_path = "middle_block.1" + new_path = "mid_block.attentions.0" + + assign_attention_to_checkpoint( + new_checkpoint=new_checkpoint, + unet_state_dict=unet_state_dict, + old_path=old_path, + new_path=new_path, + config=config, + ) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + if not isinstance(config["layers_per_block"], int): + layers_per_block_list = list(reversed([e + 1 for e in config["layers_per_block"]])) + layers_per_block_cumsum = list(np.cumsum(layers_per_block_list)) + + for i in range(num_output_blocks): + if isinstance(config["layers_per_block"], int): + layers_per_block = config["layers_per_block"] + block_id = i // (layers_per_block + 1) + layer_in_block_id = i % (layers_per_block + 1) + else: + block_id = next(k for k, n in enumerate(layers_per_block_cumsum) if i < n) + passed_blocks = layers_per_block_cumsum[block_id - 1] if block_id > 0 else 0 + layer_in_block_id = i - passed_blocks + + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + # len(output_block_list) == 1 -> resnet + # len(output_block_list) == 2 -> resnet, attention or resnet, upscale resnet + # len(output_block_list) == 3 -> resnet, attention, upscale resnet + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + + has_attention = True + if len(output_block_list) == 2 and any("in_layers" in k for k in output_block_list["1"]): + has_attention = False + + maybe_attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # this layer was no attention + has_attention = False + maybe_attentions = [] + + if has_attention: + old_path = f"output_blocks.{i}.1" + new_path = f"up_blocks.{block_id}.attentions.{layer_in_block_id}" + + assign_attention_to_checkpoint( + new_checkpoint=new_checkpoint, + unet_state_dict=unet_state_dict, + old_path=old_path, + new_path=new_path, + config=config, + ) + + paths = renew_attention_paths(maybe_attentions) + meta_path = { + "old": old_path, + "new": new_path, + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(output_block_list) == 3 or (not has_attention and len(maybe_attentions) > 0): + layer_id = len(output_block_list) - 1 + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.{layer_id}" in key] + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"output_blocks.{i}.{layer_id}", "new": f"up_blocks.{block_id}.upsamplers.0"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +def verify_param_count(orig_path, unet_diffusers_config): + if "-II-" in orig_path: + from deepfloyd_if.modules import IFStageII + + if_II = IFStageII(device="cpu", dir_or_name=orig_path) + elif "-III-" in orig_path: + from deepfloyd_if.modules import IFStageIII + + if_II = IFStageIII(device="cpu", dir_or_name=orig_path) + else: + assert f"Weird name. Should have -II- or -III- in path: {orig_path}" + + unet = UNet2DConditionModel(**unet_diffusers_config) + + # in params + assert_param_count(unet.time_embedding, if_II.model.time_embed) + assert_param_count(unet.conv_in, if_II.model.input_blocks[:1]) + + # downblocks + assert_param_count(unet.down_blocks[0], if_II.model.input_blocks[1:4]) + assert_param_count(unet.down_blocks[1], if_II.model.input_blocks[4:7]) + assert_param_count(unet.down_blocks[2], if_II.model.input_blocks[7:11]) + + if "-II-" in orig_path: + assert_param_count(unet.down_blocks[3], if_II.model.input_blocks[11:17]) + assert_param_count(unet.down_blocks[4], if_II.model.input_blocks[17:]) + if "-III-" in orig_path: + assert_param_count(unet.down_blocks[3], if_II.model.input_blocks[11:15]) + assert_param_count(unet.down_blocks[4], if_II.model.input_blocks[15:20]) + assert_param_count(unet.down_blocks[5], if_II.model.input_blocks[20:]) + + # mid block + assert_param_count(unet.mid_block, if_II.model.middle_block) + + # up block + if "-II-" in orig_path: + assert_param_count(unet.up_blocks[0], if_II.model.output_blocks[:6]) + assert_param_count(unet.up_blocks[1], if_II.model.output_blocks[6:12]) + assert_param_count(unet.up_blocks[2], if_II.model.output_blocks[12:16]) + assert_param_count(unet.up_blocks[3], if_II.model.output_blocks[16:19]) + assert_param_count(unet.up_blocks[4], if_II.model.output_blocks[19:]) + if "-III-" in orig_path: + assert_param_count(unet.up_blocks[0], if_II.model.output_blocks[:5]) + assert_param_count(unet.up_blocks[1], if_II.model.output_blocks[5:10]) + assert_param_count(unet.up_blocks[2], if_II.model.output_blocks[10:14]) + assert_param_count(unet.up_blocks[3], if_II.model.output_blocks[14:18]) + assert_param_count(unet.up_blocks[4], if_II.model.output_blocks[18:21]) + assert_param_count(unet.up_blocks[5], if_II.model.output_blocks[21:24]) + + # out params + assert_param_count(unet.conv_norm_out, if_II.model.out[0]) + assert_param_count(unet.conv_out, if_II.model.out[2]) + + # make sure all model architecture has same param count + assert_param_count(unet, if_II.model) + + +def assert_param_count(model_1, model_2): + count_1 = sum(p.numel() for p in model_1.parameters()) + count_2 = sum(p.numel() for p in model_2.parameters()) + assert count_1 == count_2, f"{model_1.__class__}: {count_1} != {model_2.__class__}: {count_2}" + + +def superres_check_against_original(dump_path, unet_checkpoint_path): + model_path = dump_path + model = UNet2DConditionModel.from_pretrained(model_path) + model.to("cuda") + orig_path = unet_checkpoint_path + + if "-II-" in orig_path: + from deepfloyd_if.modules import IFStageII + + if_II_model = IFStageII(device="cuda", dir_or_name=orig_path, model_kwargs={"precision": "fp32"}).model + elif "-III-" in orig_path: + from deepfloyd_if.modules import IFStageIII + + if_II_model = IFStageIII(device="cuda", dir_or_name=orig_path, model_kwargs={"precision": "fp32"}).model + + batch_size = 1 + channels = model.config.in_channels // 2 + height = model.config.sample_size + width = model.config.sample_size + height = 1024 + width = 1024 + + torch.manual_seed(0) + + latents = torch.randn((batch_size, channels, height, width), device=model.device) + image_small = torch.randn((batch_size, channels, height // 4, width // 4), device=model.device) + + interpolate_antialias = {} + if "antialias" in inspect.signature(F.interpolate).parameters: + interpolate_antialias["antialias"] = True + image_upscaled = F.interpolate( + image_small, size=[height, width], mode="bicubic", align_corners=False, **interpolate_antialias + ) + + latent_model_input = torch.cat([latents, image_upscaled], dim=1).to(model.dtype) + t = torch.tensor([5], device=model.device).to(model.dtype) + + seq_len = 64 + encoder_hidden_states = torch.randn((batch_size, seq_len, model.config.encoder_hid_dim), device=model.device).to( + model.dtype + ) + + fake_class_labels = torch.tensor([t], device=model.device).to(model.dtype) + + with torch.no_grad(): + out = if_II_model(latent_model_input, t, aug_steps=fake_class_labels, text_emb=encoder_hidden_states) + + if_II_model.to("cpu") + del if_II_model + import gc + + torch.cuda.empty_cache() + gc.collect() + print(50 * "=") + + with torch.no_grad(): + noise_pred = model( + sample=latent_model_input, + encoder_hidden_states=encoder_hidden_states, + class_labels=fake_class_labels, + timestep=t, + ).sample + + print("Out shape", noise_pred.shape) + print("Diff", (out - noise_pred).abs().sum()) + + +if __name__ == "__main__": + main(parse_args()) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_k_upscaler_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_k_upscaler_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..cff845ef80998b9b3c3aae0b4c52bbb8ae182048 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_k_upscaler_to_diffusers.py @@ -0,0 +1,297 @@ +import argparse + +import huggingface_hub +import k_diffusion as K +import torch + +from diffusers import UNet2DConditionModel + + +UPSCALER_REPO = "pcuenq/k-upscaler" + + +def resnet_to_diffusers_checkpoint(resnet, checkpoint, *, diffusers_resnet_prefix, resnet_prefix): + rv = { + # norm1 + f"{diffusers_resnet_prefix}.norm1.linear.weight": checkpoint[f"{resnet_prefix}.main.0.mapper.weight"], + f"{diffusers_resnet_prefix}.norm1.linear.bias": checkpoint[f"{resnet_prefix}.main.0.mapper.bias"], + # conv1 + f"{diffusers_resnet_prefix}.conv1.weight": checkpoint[f"{resnet_prefix}.main.2.weight"], + f"{diffusers_resnet_prefix}.conv1.bias": checkpoint[f"{resnet_prefix}.main.2.bias"], + # norm2 + f"{diffusers_resnet_prefix}.norm2.linear.weight": checkpoint[f"{resnet_prefix}.main.4.mapper.weight"], + f"{diffusers_resnet_prefix}.norm2.linear.bias": checkpoint[f"{resnet_prefix}.main.4.mapper.bias"], + # conv2 + f"{diffusers_resnet_prefix}.conv2.weight": checkpoint[f"{resnet_prefix}.main.6.weight"], + f"{diffusers_resnet_prefix}.conv2.bias": checkpoint[f"{resnet_prefix}.main.6.bias"], + } + + if resnet.conv_shortcut is not None: + rv.update( + { + f"{diffusers_resnet_prefix}.conv_shortcut.weight": checkpoint[f"{resnet_prefix}.skip.weight"], + } + ) + + return rv + + +def self_attn_to_diffusers_checkpoint(checkpoint, *, diffusers_attention_prefix, attention_prefix): + weight_q, weight_k, weight_v = checkpoint[f"{attention_prefix}.qkv_proj.weight"].chunk(3, dim=0) + bias_q, bias_k, bias_v = checkpoint[f"{attention_prefix}.qkv_proj.bias"].chunk(3, dim=0) + rv = { + # norm + f"{diffusers_attention_prefix}.norm1.linear.weight": checkpoint[f"{attention_prefix}.norm_in.mapper.weight"], + f"{diffusers_attention_prefix}.norm1.linear.bias": checkpoint[f"{attention_prefix}.norm_in.mapper.bias"], + # to_q + f"{diffusers_attention_prefix}.attn1.to_q.weight": weight_q.squeeze(-1).squeeze(-1), + f"{diffusers_attention_prefix}.attn1.to_q.bias": bias_q, + # to_k + f"{diffusers_attention_prefix}.attn1.to_k.weight": weight_k.squeeze(-1).squeeze(-1), + f"{diffusers_attention_prefix}.attn1.to_k.bias": bias_k, + # to_v + f"{diffusers_attention_prefix}.attn1.to_v.weight": weight_v.squeeze(-1).squeeze(-1), + f"{diffusers_attention_prefix}.attn1.to_v.bias": bias_v, + # to_out + f"{diffusers_attention_prefix}.attn1.to_out.0.weight": checkpoint[f"{attention_prefix}.out_proj.weight"] + .squeeze(-1) + .squeeze(-1), + f"{diffusers_attention_prefix}.attn1.to_out.0.bias": checkpoint[f"{attention_prefix}.out_proj.bias"], + } + + return rv + + +def cross_attn_to_diffusers_checkpoint( + checkpoint, *, diffusers_attention_prefix, diffusers_attention_index, attention_prefix +): + weight_k, weight_v = checkpoint[f"{attention_prefix}.kv_proj.weight"].chunk(2, dim=0) + bias_k, bias_v = checkpoint[f"{attention_prefix}.kv_proj.bias"].chunk(2, dim=0) + + rv = { + # norm2 (ada groupnorm) + f"{diffusers_attention_prefix}.norm{diffusers_attention_index}.linear.weight": checkpoint[ + f"{attention_prefix}.norm_dec.mapper.weight" + ], + f"{diffusers_attention_prefix}.norm{diffusers_attention_index}.linear.bias": checkpoint[ + f"{attention_prefix}.norm_dec.mapper.bias" + ], + # layernorm on encoder_hidden_state + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.norm_cross.weight": checkpoint[ + f"{attention_prefix}.norm_enc.weight" + ], + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.norm_cross.bias": checkpoint[ + f"{attention_prefix}.norm_enc.bias" + ], + # to_q + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_q.weight": checkpoint[ + f"{attention_prefix}.q_proj.weight" + ] + .squeeze(-1) + .squeeze(-1), + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_q.bias": checkpoint[ + f"{attention_prefix}.q_proj.bias" + ], + # to_k + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_k.weight": weight_k.squeeze(-1).squeeze(-1), + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_k.bias": bias_k, + # to_v + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_v.weight": weight_v.squeeze(-1).squeeze(-1), + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_v.bias": bias_v, + # to_out + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_out.0.weight": checkpoint[ + f"{attention_prefix}.out_proj.weight" + ] + .squeeze(-1) + .squeeze(-1), + f"{diffusers_attention_prefix}.attn{diffusers_attention_index}.to_out.0.bias": checkpoint[ + f"{attention_prefix}.out_proj.bias" + ], + } + + return rv + + +def block_to_diffusers_checkpoint(block, checkpoint, block_idx, block_type): + block_prefix = "inner_model.u_net.u_blocks" if block_type == "up" else "inner_model.u_net.d_blocks" + block_prefix = f"{block_prefix}.{block_idx}" + + diffusers_checkpoint = {} + + if not hasattr(block, "attentions"): + n = 1 # resnet only + elif not block.attentions[0].add_self_attention: + n = 2 # resnet -> cross-attention + else: + n = 3 # resnet -> self-attention -> cross-attention) + + for resnet_idx, resnet in enumerate(block.resnets): + # diffusers_resnet_prefix = f"{diffusers_up_block_prefix}.resnets.{resnet_idx}" + diffusers_resnet_prefix = f"{block_type}_blocks.{block_idx}.resnets.{resnet_idx}" + idx = n * resnet_idx if block_type == "up" else n * resnet_idx + 1 + resnet_prefix = f"{block_prefix}.{idx}" if block_type == "up" else f"{block_prefix}.{idx}" + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + if hasattr(block, "attentions"): + for attention_idx, attention in enumerate(block.attentions): + diffusers_attention_prefix = f"{block_type}_blocks.{block_idx}.attentions.{attention_idx}" + idx = n * attention_idx + 1 if block_type == "up" else n * attention_idx + 2 + self_attention_prefix = f"{block_prefix}.{idx}" + cross_attention_prefix = f"{block_prefix}.{idx}" + cross_attention_index = 1 if not attention.add_self_attention else 2 + idx = ( + n * attention_idx + cross_attention_index + if block_type == "up" + else n * attention_idx + cross_attention_index + 1 + ) + cross_attention_prefix = f"{block_prefix}.{idx}" + + diffusers_checkpoint.update( + cross_attn_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + diffusers_attention_index=2, + attention_prefix=cross_attention_prefix, + ) + ) + + if attention.add_self_attention is True: + diffusers_checkpoint.update( + self_attn_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + attention_prefix=self_attention_prefix, + ) + ) + + return diffusers_checkpoint + + +def unet_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # pre-processing + diffusers_checkpoint.update( + { + "conv_in.weight": checkpoint["inner_model.proj_in.weight"], + "conv_in.bias": checkpoint["inner_model.proj_in.bias"], + } + ) + + # timestep and class embedding + diffusers_checkpoint.update( + { + "time_proj.weight": checkpoint["inner_model.timestep_embed.weight"].squeeze(-1), + "time_embedding.linear_1.weight": checkpoint["inner_model.mapping.0.weight"], + "time_embedding.linear_1.bias": checkpoint["inner_model.mapping.0.bias"], + "time_embedding.linear_2.weight": checkpoint["inner_model.mapping.2.weight"], + "time_embedding.linear_2.bias": checkpoint["inner_model.mapping.2.bias"], + "time_embedding.cond_proj.weight": checkpoint["inner_model.mapping_cond.weight"], + } + ) + + # down_blocks + for down_block_idx, down_block in enumerate(model.down_blocks): + diffusers_checkpoint.update(block_to_diffusers_checkpoint(down_block, checkpoint, down_block_idx, "down")) + + # up_blocks + for up_block_idx, up_block in enumerate(model.up_blocks): + diffusers_checkpoint.update(block_to_diffusers_checkpoint(up_block, checkpoint, up_block_idx, "up")) + + # post-processing + diffusers_checkpoint.update( + { + "conv_out.weight": checkpoint["inner_model.proj_out.weight"], + "conv_out.bias": checkpoint["inner_model.proj_out.bias"], + } + ) + + return diffusers_checkpoint + + +def unet_model_from_original_config(original_config): + in_channels = original_config["input_channels"] + original_config["unet_cond_dim"] + out_channels = original_config["input_channels"] + (1 if original_config["has_variance"] else 0) + + block_out_channels = original_config["channels"] + + assert len(set(original_config["depths"])) == 1, ( + "UNet2DConditionModel currently do not support blocks with different number of layers" + ) + layers_per_block = original_config["depths"][0] + + class_labels_dim = original_config["mapping_cond_dim"] + cross_attention_dim = original_config["cross_cond_dim"] + + attn1_types = [] + attn2_types = [] + for s, c in zip(original_config["self_attn_depths"], original_config["cross_attn_depths"]): + if s: + a1 = "self" + a2 = "cross" if c else None + elif c: + a1 = "cross" + a2 = None + else: + a1 = None + a2 = None + attn1_types.append(a1) + attn2_types.append(a2) + + unet = UNet2DConditionModel( + in_channels=in_channels, + out_channels=out_channels, + down_block_types=("KDownBlock2D", "KCrossAttnDownBlock2D", "KCrossAttnDownBlock2D", "KCrossAttnDownBlock2D"), + mid_block_type=None, + up_block_types=("KCrossAttnUpBlock2D", "KCrossAttnUpBlock2D", "KCrossAttnUpBlock2D", "KUpBlock2D"), + block_out_channels=block_out_channels, + layers_per_block=layers_per_block, + act_fn="gelu", + norm_num_groups=None, + cross_attention_dim=cross_attention_dim, + attention_head_dim=64, + time_cond_proj_dim=class_labels_dim, + resnet_time_scale_shift="scale_shift", + time_embedding_type="fourier", + timestep_post_act="gelu", + conv_in_kernel=1, + conv_out_kernel=1, + ) + + return unet + + +def main(args): + device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + + orig_config_path = huggingface_hub.hf_hub_download(UPSCALER_REPO, "config_laion_text_cond_latent_upscaler_2.json") + orig_weights_path = huggingface_hub.hf_hub_download( + UPSCALER_REPO, "laion_text_cond_latent_upscaler_2_1_00470000_slim.pth" + ) + print(f"loading original model configuration from {orig_config_path}") + print(f"loading original model checkpoint from {orig_weights_path}") + + print("converting to diffusers unet") + orig_config = K.config.load_config(open(orig_config_path))["model"] + model = unet_model_from_original_config(orig_config) + + orig_checkpoint = torch.load(orig_weights_path, map_location=device)["model_ema"] + converted_checkpoint = unet_to_diffusers_checkpoint(model, orig_checkpoint) + + model.load_state_dict(converted_checkpoint, strict=True) + model.save_pretrained(args.dump_path) + print(f"saving converted unet model in {args.dump_path}") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + args = parser.parse_args() + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kakao_brain_unclip_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kakao_brain_unclip_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..5135eaed5b98391733185122f7f147201f4e4591 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kakao_brain_unclip_to_diffusers.py @@ -0,0 +1,1159 @@ +import argparse +import tempfile + +import torch +from accelerate import load_checkpoint_and_dispatch +from transformers import CLIPTextModelWithProjection, CLIPTokenizer + +from diffusers import UnCLIPPipeline, UNet2DConditionModel, UNet2DModel +from diffusers.models.transformers.prior_transformer import PriorTransformer +from diffusers.pipelines.unclip.text_proj import UnCLIPTextProjModel +from diffusers.schedulers.scheduling_unclip import UnCLIPScheduler + + +r""" +Example - From the diffusers root directory: + +Download weights: +```sh +$ wget https://arena.kakaocdn.net/brainrepo/models/karlo-public/v1.0.0.alpha/efdf6206d8ed593961593dc029a8affa/decoder-ckpt-step%3D01000000-of-01000000.ckpt +$ wget https://arena.kakaocdn.net/brainrepo/models/karlo-public/v1.0.0.alpha/4226b831ae0279020d134281f3c31590/improved-sr-ckpt-step%3D1.2M.ckpt +$ wget https://arena.kakaocdn.net/brainrepo/models/karlo-public/v1.0.0.alpha/85626483eaca9f581e2a78d31ff905ca/prior-ckpt-step%3D01000000-of-01000000.ckpt +$ wget https://arena.kakaocdn.net/brainrepo/models/karlo-public/v1.0.0.alpha/0b62380a75e56f073e2844ab5199153d/ViT-L-14_stats.th +``` + +Convert the model: +```sh +$ python scripts/convert_kakao_brain_unclip_to_diffusers.py \ + --decoder_checkpoint_path ./decoder-ckpt-step\=01000000-of-01000000.ckpt \ + --super_res_unet_checkpoint_path ./improved-sr-ckpt-step\=1.2M.ckpt \ + --prior_checkpoint_path ./prior-ckpt-step\=01000000-of-01000000.ckpt \ + --clip_stat_path ./ViT-L-14_stats.th \ + --dump_path +``` +""" + + +# prior + +PRIOR_ORIGINAL_PREFIX = "model" + +# Uses default arguments +PRIOR_CONFIG = {} + + +def prior_model_from_original_config(): + model = PriorTransformer(**PRIOR_CONFIG) + + return model + + +def prior_original_checkpoint_to_diffusers_checkpoint(model, checkpoint, clip_stats_checkpoint): + diffusers_checkpoint = {} + + # .time_embed.0 -> .time_embedding.linear_1 + diffusers_checkpoint.update( + { + "time_embedding.linear_1.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.0.weight"], + "time_embedding.linear_1.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.0.bias"], + } + ) + + # .clip_img_proj -> .proj_in + diffusers_checkpoint.update( + { + "proj_in.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.clip_img_proj.weight"], + "proj_in.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.clip_img_proj.bias"], + } + ) + + # .text_emb_proj -> .embedding_proj + diffusers_checkpoint.update( + { + "embedding_proj.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_emb_proj.weight"], + "embedding_proj.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_emb_proj.bias"], + } + ) + + # .text_enc_proj -> .encoder_hidden_states_proj + diffusers_checkpoint.update( + { + "encoder_hidden_states_proj.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_enc_proj.weight"], + "encoder_hidden_states_proj.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_enc_proj.bias"], + } + ) + + # .positional_embedding -> .positional_embedding + diffusers_checkpoint.update({"positional_embedding": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.positional_embedding"]}) + + # .prd_emb -> .prd_embedding + diffusers_checkpoint.update({"prd_embedding": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.prd_emb"]}) + + # .time_embed.2 -> .time_embedding.linear_2 + diffusers_checkpoint.update( + { + "time_embedding.linear_2.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.2.weight"], + "time_embedding.linear_2.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.2.bias"], + } + ) + + # .resblocks. -> .transformer_blocks. + for idx in range(len(model.transformer_blocks)): + diffusers_transformer_prefix = f"transformer_blocks.{idx}" + original_transformer_prefix = f"{PRIOR_ORIGINAL_PREFIX}.transformer.resblocks.{idx}" + + # .attn -> .attn1 + diffusers_attention_prefix = f"{diffusers_transformer_prefix}.attn1" + original_attention_prefix = f"{original_transformer_prefix}.attn" + diffusers_checkpoint.update( + prior_attention_to_diffusers( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + original_attention_prefix=original_attention_prefix, + attention_head_dim=model.attention_head_dim, + ) + ) + + # .mlp -> .ff + diffusers_ff_prefix = f"{diffusers_transformer_prefix}.ff" + original_ff_prefix = f"{original_transformer_prefix}.mlp" + diffusers_checkpoint.update( + prior_ff_to_diffusers( + checkpoint, diffusers_ff_prefix=diffusers_ff_prefix, original_ff_prefix=original_ff_prefix + ) + ) + + # .ln_1 -> .norm1 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm1.weight": checkpoint[ + f"{original_transformer_prefix}.ln_1.weight" + ], + f"{diffusers_transformer_prefix}.norm1.bias": checkpoint[f"{original_transformer_prefix}.ln_1.bias"], + } + ) + + # .ln_2 -> .norm3 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm3.weight": checkpoint[ + f"{original_transformer_prefix}.ln_2.weight" + ], + f"{diffusers_transformer_prefix}.norm3.bias": checkpoint[f"{original_transformer_prefix}.ln_2.bias"], + } + ) + + # .final_ln -> .norm_out + diffusers_checkpoint.update( + { + "norm_out.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.final_ln.weight"], + "norm_out.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.final_ln.bias"], + } + ) + + # .out_proj -> .proj_to_clip_embeddings + diffusers_checkpoint.update( + { + "proj_to_clip_embeddings.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.out_proj.weight"], + "proj_to_clip_embeddings.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.out_proj.bias"], + } + ) + + # clip stats + clip_mean, clip_std = clip_stats_checkpoint + clip_mean = clip_mean[None, :] + clip_std = clip_std[None, :] + + diffusers_checkpoint.update({"clip_mean": clip_mean, "clip_std": clip_std}) + + return diffusers_checkpoint + + +def prior_attention_to_diffusers( + checkpoint, *, diffusers_attention_prefix, original_attention_prefix, attention_head_dim +): + diffusers_checkpoint = {} + + # .c_qkv -> .{to_q, to_k, to_v} + [q_weight, k_weight, v_weight], [q_bias, k_bias, v_bias] = split_attentions( + weight=checkpoint[f"{original_attention_prefix}.c_qkv.weight"], + bias=checkpoint[f"{original_attention_prefix}.c_qkv.bias"], + split=3, + chunk_size=attention_head_dim, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_q.weight": q_weight, + f"{diffusers_attention_prefix}.to_q.bias": q_bias, + f"{diffusers_attention_prefix}.to_k.weight": k_weight, + f"{diffusers_attention_prefix}.to_k.bias": k_bias, + f"{diffusers_attention_prefix}.to_v.weight": v_weight, + f"{diffusers_attention_prefix}.to_v.bias": v_bias, + } + ) + + # .c_proj -> .to_out.0 + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{original_attention_prefix}.c_proj.weight"], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{original_attention_prefix}.c_proj.bias"], + } + ) + + return diffusers_checkpoint + + +def prior_ff_to_diffusers(checkpoint, *, diffusers_ff_prefix, original_ff_prefix): + diffusers_checkpoint = { + # .c_fc -> .net.0.proj + f"{diffusers_ff_prefix}.net.{0}.proj.weight": checkpoint[f"{original_ff_prefix}.c_fc.weight"], + f"{diffusers_ff_prefix}.net.{0}.proj.bias": checkpoint[f"{original_ff_prefix}.c_fc.bias"], + # .c_proj -> .net.2 + f"{diffusers_ff_prefix}.net.{2}.weight": checkpoint[f"{original_ff_prefix}.c_proj.weight"], + f"{diffusers_ff_prefix}.net.{2}.bias": checkpoint[f"{original_ff_prefix}.c_proj.bias"], + } + + return diffusers_checkpoint + + +# done prior + + +# decoder + +DECODER_ORIGINAL_PREFIX = "model" + +# We are hardcoding the model configuration for now. If we need to generalize to more model configurations, we can +# update then. +DECODER_CONFIG = { + "sample_size": 64, + "layers_per_block": 3, + "down_block_types": ( + "ResnetDownsampleBlock2D", + "SimpleCrossAttnDownBlock2D", + "SimpleCrossAttnDownBlock2D", + "SimpleCrossAttnDownBlock2D", + ), + "up_block_types": ( + "SimpleCrossAttnUpBlock2D", + "SimpleCrossAttnUpBlock2D", + "SimpleCrossAttnUpBlock2D", + "ResnetUpsampleBlock2D", + ), + "mid_block_type": "UNetMidBlock2DSimpleCrossAttn", + "block_out_channels": (320, 640, 960, 1280), + "in_channels": 3, + "out_channels": 6, + "cross_attention_dim": 1536, + "class_embed_type": "identity", + "attention_head_dim": 64, + "resnet_time_scale_shift": "scale_shift", +} + + +def decoder_model_from_original_config(): + model = UNet2DConditionModel(**DECODER_CONFIG) + + return model + + +def decoder_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + original_unet_prefix = DECODER_ORIGINAL_PREFIX + num_head_channels = DECODER_CONFIG["attention_head_dim"] + + diffusers_checkpoint.update(unet_time_embeddings(checkpoint, original_unet_prefix)) + diffusers_checkpoint.update(unet_conv_in(checkpoint, original_unet_prefix)) + + # .input_blocks -> .down_blocks + + original_down_block_idx = 1 + + for diffusers_down_block_idx in range(len(model.down_blocks)): + checkpoint_update, num_original_down_blocks = unet_downblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_down_block_idx=diffusers_down_block_idx, + original_down_block_idx=original_down_block_idx, + original_unet_prefix=original_unet_prefix, + num_head_channels=num_head_channels, + ) + + original_down_block_idx += num_original_down_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .input_blocks -> .down_blocks + + diffusers_checkpoint.update( + unet_midblock_to_diffusers_checkpoint( + model, + checkpoint, + original_unet_prefix=original_unet_prefix, + num_head_channels=num_head_channels, + ) + ) + + # .output_blocks -> .up_blocks + + original_up_block_idx = 0 + + for diffusers_up_block_idx in range(len(model.up_blocks)): + checkpoint_update, num_original_up_blocks = unet_upblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_up_block_idx=diffusers_up_block_idx, + original_up_block_idx=original_up_block_idx, + original_unet_prefix=original_unet_prefix, + num_head_channels=num_head_channels, + ) + + original_up_block_idx += num_original_up_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .output_blocks -> .up_blocks + + diffusers_checkpoint.update(unet_conv_norm_out(checkpoint, original_unet_prefix)) + diffusers_checkpoint.update(unet_conv_out(checkpoint, original_unet_prefix)) + + return diffusers_checkpoint + + +# done decoder + +# text proj + + +def text_proj_from_original_config(): + # From the conditional unet constructor where the dimension of the projected time embeddings is + # constructed + time_embed_dim = DECODER_CONFIG["block_out_channels"][0] * 4 + + cross_attention_dim = DECODER_CONFIG["cross_attention_dim"] + + model = UnCLIPTextProjModel(time_embed_dim=time_embed_dim, cross_attention_dim=cross_attention_dim) + + return model + + +# Note that the input checkpoint is the original decoder checkpoint +def text_proj_original_checkpoint_to_diffusers_checkpoint(checkpoint): + diffusers_checkpoint = { + # .text_seq_proj.0 -> .encoder_hidden_states_proj + "encoder_hidden_states_proj.weight": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.text_seq_proj.0.weight"], + "encoder_hidden_states_proj.bias": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.text_seq_proj.0.bias"], + # .text_seq_proj.1 -> .text_encoder_hidden_states_norm + "text_encoder_hidden_states_norm.weight": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.text_seq_proj.1.weight"], + "text_encoder_hidden_states_norm.bias": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.text_seq_proj.1.bias"], + # .clip_tok_proj -> .clip_extra_context_tokens_proj + "clip_extra_context_tokens_proj.weight": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.clip_tok_proj.weight"], + "clip_extra_context_tokens_proj.bias": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.clip_tok_proj.bias"], + # .text_feat_proj -> .embedding_proj + "embedding_proj.weight": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.text_feat_proj.weight"], + "embedding_proj.bias": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.text_feat_proj.bias"], + # .cf_param -> .learned_classifier_free_guidance_embeddings + "learned_classifier_free_guidance_embeddings": checkpoint[f"{DECODER_ORIGINAL_PREFIX}.cf_param"], + # .clip_emb -> .clip_image_embeddings_project_to_time_embeddings + "clip_image_embeddings_project_to_time_embeddings.weight": checkpoint[ + f"{DECODER_ORIGINAL_PREFIX}.clip_emb.weight" + ], + "clip_image_embeddings_project_to_time_embeddings.bias": checkpoint[ + f"{DECODER_ORIGINAL_PREFIX}.clip_emb.bias" + ], + } + + return diffusers_checkpoint + + +# done text proj + +# super res unet first steps + +SUPER_RES_UNET_FIRST_STEPS_PREFIX = "model_first_steps" + +SUPER_RES_UNET_FIRST_STEPS_CONFIG = { + "sample_size": 256, + "layers_per_block": 3, + "down_block_types": ( + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + ), + "up_block_types": ( + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + ), + "block_out_channels": (320, 640, 960, 1280), + "in_channels": 6, + "out_channels": 3, + "add_attention": False, +} + + +def super_res_unet_first_steps_model_from_original_config(): + model = UNet2DModel(**SUPER_RES_UNET_FIRST_STEPS_CONFIG) + + return model + + +def super_res_unet_first_steps_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + original_unet_prefix = SUPER_RES_UNET_FIRST_STEPS_PREFIX + + diffusers_checkpoint.update(unet_time_embeddings(checkpoint, original_unet_prefix)) + diffusers_checkpoint.update(unet_conv_in(checkpoint, original_unet_prefix)) + + # .input_blocks -> .down_blocks + + original_down_block_idx = 1 + + for diffusers_down_block_idx in range(len(model.down_blocks)): + checkpoint_update, num_original_down_blocks = unet_downblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_down_block_idx=diffusers_down_block_idx, + original_down_block_idx=original_down_block_idx, + original_unet_prefix=original_unet_prefix, + num_head_channels=None, + ) + + original_down_block_idx += num_original_down_blocks + + diffusers_checkpoint.update(checkpoint_update) + + diffusers_checkpoint.update( + unet_midblock_to_diffusers_checkpoint( + model, + checkpoint, + original_unet_prefix=original_unet_prefix, + num_head_channels=None, + ) + ) + + # .output_blocks -> .up_blocks + + original_up_block_idx = 0 + + for diffusers_up_block_idx in range(len(model.up_blocks)): + checkpoint_update, num_original_up_blocks = unet_upblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_up_block_idx=diffusers_up_block_idx, + original_up_block_idx=original_up_block_idx, + original_unet_prefix=original_unet_prefix, + num_head_channels=None, + ) + + original_up_block_idx += num_original_up_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .output_blocks -> .up_blocks + + diffusers_checkpoint.update(unet_conv_norm_out(checkpoint, original_unet_prefix)) + diffusers_checkpoint.update(unet_conv_out(checkpoint, original_unet_prefix)) + + return diffusers_checkpoint + + +# done super res unet first steps + +# super res unet last step + +SUPER_RES_UNET_LAST_STEP_PREFIX = "model_last_step" + +SUPER_RES_UNET_LAST_STEP_CONFIG = { + "sample_size": 256, + "layers_per_block": 3, + "down_block_types": ( + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + "ResnetDownsampleBlock2D", + ), + "up_block_types": ( + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + "ResnetUpsampleBlock2D", + ), + "block_out_channels": (320, 640, 960, 1280), + "in_channels": 6, + "out_channels": 3, + "add_attention": False, +} + + +def super_res_unet_last_step_model_from_original_config(): + model = UNet2DModel(**SUPER_RES_UNET_LAST_STEP_CONFIG) + + return model + + +def super_res_unet_last_step_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + original_unet_prefix = SUPER_RES_UNET_LAST_STEP_PREFIX + + diffusers_checkpoint.update(unet_time_embeddings(checkpoint, original_unet_prefix)) + diffusers_checkpoint.update(unet_conv_in(checkpoint, original_unet_prefix)) + + # .input_blocks -> .down_blocks + + original_down_block_idx = 1 + + for diffusers_down_block_idx in range(len(model.down_blocks)): + checkpoint_update, num_original_down_blocks = unet_downblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_down_block_idx=diffusers_down_block_idx, + original_down_block_idx=original_down_block_idx, + original_unet_prefix=original_unet_prefix, + num_head_channels=None, + ) + + original_down_block_idx += num_original_down_blocks + + diffusers_checkpoint.update(checkpoint_update) + + diffusers_checkpoint.update( + unet_midblock_to_diffusers_checkpoint( + model, + checkpoint, + original_unet_prefix=original_unet_prefix, + num_head_channels=None, + ) + ) + + # .output_blocks -> .up_blocks + + original_up_block_idx = 0 + + for diffusers_up_block_idx in range(len(model.up_blocks)): + checkpoint_update, num_original_up_blocks = unet_upblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_up_block_idx=diffusers_up_block_idx, + original_up_block_idx=original_up_block_idx, + original_unet_prefix=original_unet_prefix, + num_head_channels=None, + ) + + original_up_block_idx += num_original_up_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .output_blocks -> .up_blocks + + diffusers_checkpoint.update(unet_conv_norm_out(checkpoint, original_unet_prefix)) + diffusers_checkpoint.update(unet_conv_out(checkpoint, original_unet_prefix)) + + return diffusers_checkpoint + + +# done super res unet last step + + +# unet utils + + +# .time_embed -> .time_embedding +def unet_time_embeddings(checkpoint, original_unet_prefix): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "time_embedding.linear_1.weight": checkpoint[f"{original_unet_prefix}.time_embed.0.weight"], + "time_embedding.linear_1.bias": checkpoint[f"{original_unet_prefix}.time_embed.0.bias"], + "time_embedding.linear_2.weight": checkpoint[f"{original_unet_prefix}.time_embed.2.weight"], + "time_embedding.linear_2.bias": checkpoint[f"{original_unet_prefix}.time_embed.2.bias"], + } + ) + + return diffusers_checkpoint + + +# .input_blocks.0 -> .conv_in +def unet_conv_in(checkpoint, original_unet_prefix): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "conv_in.weight": checkpoint[f"{original_unet_prefix}.input_blocks.0.0.weight"], + "conv_in.bias": checkpoint[f"{original_unet_prefix}.input_blocks.0.0.bias"], + } + ) + + return diffusers_checkpoint + + +# .out.0 -> .conv_norm_out +def unet_conv_norm_out(checkpoint, original_unet_prefix): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "conv_norm_out.weight": checkpoint[f"{original_unet_prefix}.out.0.weight"], + "conv_norm_out.bias": checkpoint[f"{original_unet_prefix}.out.0.bias"], + } + ) + + return diffusers_checkpoint + + +# .out.2 -> .conv_out +def unet_conv_out(checkpoint, original_unet_prefix): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "conv_out.weight": checkpoint[f"{original_unet_prefix}.out.2.weight"], + "conv_out.bias": checkpoint[f"{original_unet_prefix}.out.2.bias"], + } + ) + + return diffusers_checkpoint + + +# .input_blocks -> .down_blocks +def unet_downblock_to_diffusers_checkpoint( + model, checkpoint, *, diffusers_down_block_idx, original_down_block_idx, original_unet_prefix, num_head_channels +): + diffusers_checkpoint = {} + + diffusers_resnet_prefix = f"down_blocks.{diffusers_down_block_idx}.resnets" + original_down_block_prefix = f"{original_unet_prefix}.input_blocks" + + down_block = model.down_blocks[diffusers_down_block_idx] + + num_resnets = len(down_block.resnets) + + if down_block.downsamplers is None: + downsampler = False + else: + assert len(down_block.downsamplers) == 1 + downsampler = True + # The downsample block is also a resnet + num_resnets += 1 + + for resnet_idx_inc in range(num_resnets): + full_resnet_prefix = f"{original_down_block_prefix}.{original_down_block_idx + resnet_idx_inc}.0" + + if downsampler and resnet_idx_inc == num_resnets - 1: + # this is a downsample block + full_diffusers_resnet_prefix = f"down_blocks.{diffusers_down_block_idx}.downsamplers.0" + else: + # this is a regular resnet block + full_diffusers_resnet_prefix = f"{diffusers_resnet_prefix}.{resnet_idx_inc}" + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, resnet_prefix=full_resnet_prefix, diffusers_resnet_prefix=full_diffusers_resnet_prefix + ) + ) + + if hasattr(down_block, "attentions"): + num_attentions = len(down_block.attentions) + diffusers_attention_prefix = f"down_blocks.{diffusers_down_block_idx}.attentions" + + for attention_idx_inc in range(num_attentions): + full_attention_prefix = f"{original_down_block_prefix}.{original_down_block_idx + attention_idx_inc}.1" + full_diffusers_attention_prefix = f"{diffusers_attention_prefix}.{attention_idx_inc}" + + diffusers_checkpoint.update( + attention_to_diffusers_checkpoint( + checkpoint, + attention_prefix=full_attention_prefix, + diffusers_attention_prefix=full_diffusers_attention_prefix, + num_head_channels=num_head_channels, + ) + ) + + num_original_down_blocks = num_resnets + + return diffusers_checkpoint, num_original_down_blocks + + +# .middle_block -> .mid_block +def unet_midblock_to_diffusers_checkpoint(model, checkpoint, *, original_unet_prefix, num_head_channels): + diffusers_checkpoint = {} + + # block 0 + + original_block_idx = 0 + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, + diffusers_resnet_prefix="mid_block.resnets.0", + resnet_prefix=f"{original_unet_prefix}.middle_block.{original_block_idx}", + ) + ) + + original_block_idx += 1 + + # optional block 1 + + if hasattr(model.mid_block, "attentions") and model.mid_block.attentions[0] is not None: + diffusers_checkpoint.update( + attention_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix="mid_block.attentions.0", + attention_prefix=f"{original_unet_prefix}.middle_block.{original_block_idx}", + num_head_channels=num_head_channels, + ) + ) + original_block_idx += 1 + + # block 1 or block 2 + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, + diffusers_resnet_prefix="mid_block.resnets.1", + resnet_prefix=f"{original_unet_prefix}.middle_block.{original_block_idx}", + ) + ) + + return diffusers_checkpoint + + +# .output_blocks -> .up_blocks +def unet_upblock_to_diffusers_checkpoint( + model, checkpoint, *, diffusers_up_block_idx, original_up_block_idx, original_unet_prefix, num_head_channels +): + diffusers_checkpoint = {} + + diffusers_resnet_prefix = f"up_blocks.{diffusers_up_block_idx}.resnets" + original_up_block_prefix = f"{original_unet_prefix}.output_blocks" + + up_block = model.up_blocks[diffusers_up_block_idx] + + num_resnets = len(up_block.resnets) + + if up_block.upsamplers is None: + upsampler = False + else: + assert len(up_block.upsamplers) == 1 + upsampler = True + # The upsample block is also a resnet + num_resnets += 1 + + has_attentions = hasattr(up_block, "attentions") + + for resnet_idx_inc in range(num_resnets): + if upsampler and resnet_idx_inc == num_resnets - 1: + # this is an upsample block + if has_attentions: + # There is a middle attention block that we skip + original_resnet_block_idx = 2 + else: + original_resnet_block_idx = 1 + + # we add the `minus 1` because the last two resnets are stuck together in the same output block + full_resnet_prefix = ( + f"{original_up_block_prefix}.{original_up_block_idx + resnet_idx_inc - 1}.{original_resnet_block_idx}" + ) + + full_diffusers_resnet_prefix = f"up_blocks.{diffusers_up_block_idx}.upsamplers.0" + else: + # this is a regular resnet block + full_resnet_prefix = f"{original_up_block_prefix}.{original_up_block_idx + resnet_idx_inc}.0" + full_diffusers_resnet_prefix = f"{diffusers_resnet_prefix}.{resnet_idx_inc}" + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, resnet_prefix=full_resnet_prefix, diffusers_resnet_prefix=full_diffusers_resnet_prefix + ) + ) + + if has_attentions: + num_attentions = len(up_block.attentions) + diffusers_attention_prefix = f"up_blocks.{diffusers_up_block_idx}.attentions" + + for attention_idx_inc in range(num_attentions): + full_attention_prefix = f"{original_up_block_prefix}.{original_up_block_idx + attention_idx_inc}.1" + full_diffusers_attention_prefix = f"{diffusers_attention_prefix}.{attention_idx_inc}" + + diffusers_checkpoint.update( + attention_to_diffusers_checkpoint( + checkpoint, + attention_prefix=full_attention_prefix, + diffusers_attention_prefix=full_diffusers_attention_prefix, + num_head_channels=num_head_channels, + ) + ) + + num_original_down_blocks = num_resnets - 1 if upsampler else num_resnets + + return diffusers_checkpoint, num_original_down_blocks + + +def resnet_to_diffusers_checkpoint(checkpoint, *, diffusers_resnet_prefix, resnet_prefix): + diffusers_checkpoint = { + f"{diffusers_resnet_prefix}.norm1.weight": checkpoint[f"{resnet_prefix}.in_layers.0.weight"], + f"{diffusers_resnet_prefix}.norm1.bias": checkpoint[f"{resnet_prefix}.in_layers.0.bias"], + f"{diffusers_resnet_prefix}.conv1.weight": checkpoint[f"{resnet_prefix}.in_layers.2.weight"], + f"{diffusers_resnet_prefix}.conv1.bias": checkpoint[f"{resnet_prefix}.in_layers.2.bias"], + f"{diffusers_resnet_prefix}.time_emb_proj.weight": checkpoint[f"{resnet_prefix}.emb_layers.1.weight"], + f"{diffusers_resnet_prefix}.time_emb_proj.bias": checkpoint[f"{resnet_prefix}.emb_layers.1.bias"], + f"{diffusers_resnet_prefix}.norm2.weight": checkpoint[f"{resnet_prefix}.out_layers.0.weight"], + f"{diffusers_resnet_prefix}.norm2.bias": checkpoint[f"{resnet_prefix}.out_layers.0.bias"], + f"{diffusers_resnet_prefix}.conv2.weight": checkpoint[f"{resnet_prefix}.out_layers.3.weight"], + f"{diffusers_resnet_prefix}.conv2.bias": checkpoint[f"{resnet_prefix}.out_layers.3.bias"], + } + + skip_connection_prefix = f"{resnet_prefix}.skip_connection" + + if f"{skip_connection_prefix}.weight" in checkpoint: + diffusers_checkpoint.update( + { + f"{diffusers_resnet_prefix}.conv_shortcut.weight": checkpoint[f"{skip_connection_prefix}.weight"], + f"{diffusers_resnet_prefix}.conv_shortcut.bias": checkpoint[f"{skip_connection_prefix}.bias"], + } + ) + + return diffusers_checkpoint + + +def attention_to_diffusers_checkpoint(checkpoint, *, diffusers_attention_prefix, attention_prefix, num_head_channels): + diffusers_checkpoint = {} + + # .norm -> .group_norm + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.group_norm.weight": checkpoint[f"{attention_prefix}.norm.weight"], + f"{diffusers_attention_prefix}.group_norm.bias": checkpoint[f"{attention_prefix}.norm.bias"], + } + ) + + # .qkv -> .{query, key, value} + [q_weight, k_weight, v_weight], [q_bias, k_bias, v_bias] = split_attentions( + weight=checkpoint[f"{attention_prefix}.qkv.weight"][:, :, 0], + bias=checkpoint[f"{attention_prefix}.qkv.bias"], + split=3, + chunk_size=num_head_channels, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_q.weight": q_weight, + f"{diffusers_attention_prefix}.to_q.bias": q_bias, + f"{diffusers_attention_prefix}.to_k.weight": k_weight, + f"{diffusers_attention_prefix}.to_k.bias": k_bias, + f"{diffusers_attention_prefix}.to_v.weight": v_weight, + f"{diffusers_attention_prefix}.to_v.bias": v_bias, + } + ) + + # .encoder_kv -> .{context_key, context_value} + [encoder_k_weight, encoder_v_weight], [encoder_k_bias, encoder_v_bias] = split_attentions( + weight=checkpoint[f"{attention_prefix}.encoder_kv.weight"][:, :, 0], + bias=checkpoint[f"{attention_prefix}.encoder_kv.bias"], + split=2, + chunk_size=num_head_channels, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.add_k_proj.weight": encoder_k_weight, + f"{diffusers_attention_prefix}.add_k_proj.bias": encoder_k_bias, + f"{diffusers_attention_prefix}.add_v_proj.weight": encoder_v_weight, + f"{diffusers_attention_prefix}.add_v_proj.bias": encoder_v_bias, + } + ) + + # .proj_out (1d conv) -> .proj_attn (linear) + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{attention_prefix}.proj_out.weight"][ + :, :, 0 + ], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{attention_prefix}.proj_out.bias"], + } + ) + + return diffusers_checkpoint + + +# TODO maybe document and/or can do more efficiently (build indices in for loop and extract once for each split?) +def split_attentions(*, weight, bias, split, chunk_size): + weights = [None] * split + biases = [None] * split + + weights_biases_idx = 0 + + for starting_row_index in range(0, weight.shape[0], chunk_size): + row_indices = torch.arange(starting_row_index, starting_row_index + chunk_size) + + weight_rows = weight[row_indices, :] + bias_rows = bias[row_indices] + + if weights[weights_biases_idx] is None: + assert weights[weights_biases_idx] is None + weights[weights_biases_idx] = weight_rows + biases[weights_biases_idx] = bias_rows + else: + assert weights[weights_biases_idx] is not None + weights[weights_biases_idx] = torch.concat([weights[weights_biases_idx], weight_rows]) + biases[weights_biases_idx] = torch.concat([biases[weights_biases_idx], bias_rows]) + + weights_biases_idx = (weights_biases_idx + 1) % split + + return weights, biases + + +# done unet utils + + +# Driver functions + + +def text_encoder(): + print("loading CLIP text encoder") + + clip_name = "openai/clip-vit-large-patch14" + + # sets pad_value to 0 + pad_token = "!" + + tokenizer_model = CLIPTokenizer.from_pretrained(clip_name, pad_token=pad_token, device_map="auto") + + assert tokenizer_model.convert_tokens_to_ids(pad_token) == 0 + + text_encoder_model = CLIPTextModelWithProjection.from_pretrained( + clip_name, + # `CLIPTextModel` does not support device_map="auto" + # device_map="auto" + ) + + print("done loading CLIP text encoder") + + return text_encoder_model, tokenizer_model + + +def prior(*, args, checkpoint_map_location): + print("loading prior") + + prior_checkpoint = torch.load(args.prior_checkpoint_path, map_location=checkpoint_map_location) + prior_checkpoint = prior_checkpoint["state_dict"] + + clip_stats_checkpoint = torch.load(args.clip_stat_path, map_location=checkpoint_map_location) + + prior_model = prior_model_from_original_config() + + prior_diffusers_checkpoint = prior_original_checkpoint_to_diffusers_checkpoint( + prior_model, prior_checkpoint, clip_stats_checkpoint + ) + + del prior_checkpoint + del clip_stats_checkpoint + + load_checkpoint_to_model(prior_diffusers_checkpoint, prior_model, strict=True) + + print("done loading prior") + + return prior_model + + +def decoder(*, args, checkpoint_map_location): + print("loading decoder") + + decoder_checkpoint = torch.load(args.decoder_checkpoint_path, map_location=checkpoint_map_location) + decoder_checkpoint = decoder_checkpoint["state_dict"] + + decoder_model = decoder_model_from_original_config() + + decoder_diffusers_checkpoint = decoder_original_checkpoint_to_diffusers_checkpoint( + decoder_model, decoder_checkpoint + ) + + # text proj interlude + + # The original decoder implementation includes a set of parameters that are used + # for creating the `encoder_hidden_states` which are what the U-net is conditioned + # on. The diffusers conditional unet directly takes the encoder_hidden_states. We pull + # the parameters into the UnCLIPTextProjModel class + text_proj_model = text_proj_from_original_config() + + text_proj_checkpoint = text_proj_original_checkpoint_to_diffusers_checkpoint(decoder_checkpoint) + + load_checkpoint_to_model(text_proj_checkpoint, text_proj_model, strict=True) + + # done text proj interlude + + del decoder_checkpoint + + load_checkpoint_to_model(decoder_diffusers_checkpoint, decoder_model, strict=True) + + print("done loading decoder") + + return decoder_model, text_proj_model + + +def super_res_unet(*, args, checkpoint_map_location): + print("loading super resolution unet") + + super_res_checkpoint = torch.load(args.super_res_unet_checkpoint_path, map_location=checkpoint_map_location) + super_res_checkpoint = super_res_checkpoint["state_dict"] + + # model_first_steps + + super_res_first_model = super_res_unet_first_steps_model_from_original_config() + + super_res_first_steps_checkpoint = super_res_unet_first_steps_original_checkpoint_to_diffusers_checkpoint( + super_res_first_model, super_res_checkpoint + ) + + # model_last_step + super_res_last_model = super_res_unet_last_step_model_from_original_config() + + super_res_last_step_checkpoint = super_res_unet_last_step_original_checkpoint_to_diffusers_checkpoint( + super_res_last_model, super_res_checkpoint + ) + + del super_res_checkpoint + + load_checkpoint_to_model(super_res_first_steps_checkpoint, super_res_first_model, strict=True) + + load_checkpoint_to_model(super_res_last_step_checkpoint, super_res_last_model, strict=True) + + print("done loading super resolution unet") + + return super_res_first_model, super_res_last_model + + +def load_checkpoint_to_model(checkpoint, model, strict=False): + with tempfile.NamedTemporaryFile() as file: + torch.save(checkpoint, file.name) + del checkpoint + if strict: + model.load_state_dict(torch.load(file.name), strict=True) + else: + load_checkpoint_and_dispatch(model, file.name, device_map="auto") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--prior_checkpoint_path", + default=None, + type=str, + required=True, + help="Path to the prior checkpoint to convert.", + ) + + parser.add_argument( + "--decoder_checkpoint_path", + default=None, + type=str, + required=True, + help="Path to the decoder checkpoint to convert.", + ) + + parser.add_argument( + "--super_res_unet_checkpoint_path", + default=None, + type=str, + required=True, + help="Path to the super resolution checkpoint to convert.", + ) + + parser.add_argument( + "--clip_stat_path", default=None, type=str, required=True, help="Path to the clip stats checkpoint to convert." + ) + + parser.add_argument( + "--checkpoint_load_device", + default="cpu", + type=str, + required=False, + help="The device passed to `map_location` when loading checkpoints.", + ) + + parser.add_argument( + "--debug", + default=None, + type=str, + required=False, + help="Only run a specific stage of the convert script. Used for debugging", + ) + + args = parser.parse_args() + + print(f"loading checkpoints to {args.checkpoint_load_device}") + + checkpoint_map_location = torch.device(args.checkpoint_load_device) + + if args.debug is not None: + print(f"debug: only executing {args.debug}") + + if args.debug is None: + text_encoder_model, tokenizer_model = text_encoder() + + prior_model = prior(args=args, checkpoint_map_location=checkpoint_map_location) + + decoder_model, text_proj_model = decoder(args=args, checkpoint_map_location=checkpoint_map_location) + + super_res_first_model, super_res_last_model = super_res_unet( + args=args, checkpoint_map_location=checkpoint_map_location + ) + + prior_scheduler = UnCLIPScheduler( + variance_type="fixed_small_log", + prediction_type="sample", + num_train_timesteps=1000, + clip_sample_range=5.0, + ) + + decoder_scheduler = UnCLIPScheduler( + variance_type="learned_range", + prediction_type="epsilon", + num_train_timesteps=1000, + ) + + super_res_scheduler = UnCLIPScheduler( + variance_type="fixed_small_log", + prediction_type="epsilon", + num_train_timesteps=1000, + ) + + print(f"saving Kakao Brain unCLIP to {args.dump_path}") + + pipe = UnCLIPPipeline( + prior=prior_model, + decoder=decoder_model, + text_proj=text_proj_model, + tokenizer=tokenizer_model, + text_encoder=text_encoder_model, + super_res_first=super_res_first_model, + super_res_last=super_res_last_model, + prior_scheduler=prior_scheduler, + decoder_scheduler=decoder_scheduler, + super_res_scheduler=super_res_scheduler, + ) + pipe.save_pretrained(args.dump_path) + + print("done writing Kakao Brain unCLIP") + elif args.debug == "text_encoder": + text_encoder_model, tokenizer_model = text_encoder() + elif args.debug == "prior": + prior_model = prior(args=args, checkpoint_map_location=checkpoint_map_location) + elif args.debug == "decoder": + decoder_model, text_proj_model = decoder(args=args, checkpoint_map_location=checkpoint_map_location) + elif args.debug == "super_res_unet": + super_res_first_model, super_res_last_model = super_res_unet( + args=args, checkpoint_map_location=checkpoint_map_location + ) + else: + raise ValueError(f"unknown debug value : {args.debug}") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kandinsky3_unet.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kandinsky3_unet.py new file mode 100644 index 0000000000000000000000000000000000000000..4fe8c54eb7fc17150a6d927aeefd5ca21dce9636 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kandinsky3_unet.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 +import argparse +import fnmatch + +from safetensors.torch import load_file + +from diffusers import Kandinsky3UNet + + +MAPPING = { + "to_time_embed.1": "time_embedding.linear_1", + "to_time_embed.3": "time_embedding.linear_2", + "in_layer": "conv_in", + "out_layer.0": "conv_norm_out", + "out_layer.2": "conv_out", + "down_samples": "down_blocks", + "up_samples": "up_blocks", + "projection_lin": "encoder_hid_proj.projection_linear", + "projection_ln": "encoder_hid_proj.projection_norm", + "feature_pooling": "add_time_condition", + "to_query": "to_q", + "to_key": "to_k", + "to_value": "to_v", + "output_layer": "to_out.0", + "self_attention_block": "attentions.0", +} + +DYNAMIC_MAP = { + "resnet_attn_blocks.*.0": "resnets_in.*", + "resnet_attn_blocks.*.1": ("attentions.*", 1), + "resnet_attn_blocks.*.2": "resnets_out.*", +} +# MAPPING = {} + + +def convert_state_dict(unet_state_dict): + """ + Convert the state dict of a U-Net model to match the key format expected by Kandinsky3UNet model. + Args: + unet_model (torch.nn.Module): The original U-Net model. + unet_kandi3_model (torch.nn.Module): The Kandinsky3UNet model to match keys with. + + Returns: + OrderedDict: The converted state dictionary. + """ + # Example of renaming logic (this will vary based on your model's architecture) + converted_state_dict = {} + for key in unet_state_dict: + new_key = key + for pattern, new_pattern in MAPPING.items(): + new_key = new_key.replace(pattern, new_pattern) + + for dyn_pattern, dyn_new_pattern in DYNAMIC_MAP.items(): + has_matched = False + if fnmatch.fnmatch(new_key, f"*.{dyn_pattern}.*") and not has_matched: + star = int(new_key.split(dyn_pattern.split(".")[0])[-1].split(".")[1]) + + if isinstance(dyn_new_pattern, tuple): + new_star = star + dyn_new_pattern[-1] + dyn_new_pattern = dyn_new_pattern[0] + else: + new_star = star + + pattern = dyn_pattern.replace("*", str(star)) + new_pattern = dyn_new_pattern.replace("*", str(new_star)) + + new_key = new_key.replace(pattern, new_pattern) + has_matched = True + + converted_state_dict[new_key] = unet_state_dict[key] + + return converted_state_dict + + +def main(model_path, output_path): + # Load your original U-Net model + unet_state_dict = load_file(model_path) + + # Initialize your Kandinsky3UNet model + config = {} + + # Convert the state dict + converted_state_dict = convert_state_dict(unet_state_dict) + + unet = Kandinsky3UNet(config) + unet.load_state_dict(converted_state_dict) + + unet.save_pretrained(output_path) + print(f"Converted model saved to {output_path}") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Convert U-Net PyTorch model to Kandinsky3UNet format") + parser.add_argument("--model_path", type=str, required=True, help="Path to the original U-Net PyTorch model") + parser.add_argument("--output_path", type=str, required=True, help="Path to save the converted model") + + args = parser.parse_args() + main(args.model_path, args.output_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kandinsky_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kandinsky_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..8d3f7b63d0c1075679efc4b0322b6ae37c5acd6c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_kandinsky_to_diffusers.py @@ -0,0 +1,1411 @@ +import argparse +import os +import tempfile + +import torch +from accelerate import load_checkpoint_and_dispatch + +from diffusers import UNet2DConditionModel +from diffusers.models.transformers.prior_transformer import PriorTransformer +from diffusers.models.vq_model import VQModel + + +""" +Example - From the diffusers root directory: + +Download weights: +```sh +$ wget https://huggingface.co/ai-forever/Kandinsky_2.1/blob/main/prior_fp16.ckpt +``` + +Convert the model: +```sh +python scripts/convert_kandinsky_to_diffusers.py \ + --prior_checkpoint_path /home/yiyi_huggingface_co/Kandinsky-2/checkpoints_Kandinsky_2.1/prior_fp16.ckpt \ + --clip_stat_path /home/yiyi_huggingface_co/Kandinsky-2/checkpoints_Kandinsky_2.1/ViT-L-14_stats.th \ + --text2img_checkpoint_path /home/yiyi_huggingface_co/Kandinsky-2/checkpoints_Kandinsky_2.1/decoder_fp16.ckpt \ + --inpaint_text2img_checkpoint_path /home/yiyi_huggingface_co/Kandinsky-2/checkpoints_Kandinsky_2.1/inpainting_fp16.ckpt \ + --movq_checkpoint_path /home/yiyi_huggingface_co/Kandinsky-2/checkpoints_Kandinsky_2.1/movq_final.ckpt \ + --dump_path /home/yiyi_huggingface_co/dump \ + --debug decoder +``` +""" + + +# prior + +PRIOR_ORIGINAL_PREFIX = "model" + +# Uses default arguments +PRIOR_CONFIG = {} + + +def prior_model_from_original_config(): + model = PriorTransformer(**PRIOR_CONFIG) + + return model + + +def prior_original_checkpoint_to_diffusers_checkpoint(model, checkpoint, clip_stats_checkpoint): + diffusers_checkpoint = {} + + # .time_embed.0 -> .time_embedding.linear_1 + diffusers_checkpoint.update( + { + "time_embedding.linear_1.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.0.weight"], + "time_embedding.linear_1.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.0.bias"], + } + ) + + # .clip_img_proj -> .proj_in + diffusers_checkpoint.update( + { + "proj_in.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.clip_img_proj.weight"], + "proj_in.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.clip_img_proj.bias"], + } + ) + + # .text_emb_proj -> .embedding_proj + diffusers_checkpoint.update( + { + "embedding_proj.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_emb_proj.weight"], + "embedding_proj.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_emb_proj.bias"], + } + ) + + # .text_enc_proj -> .encoder_hidden_states_proj + diffusers_checkpoint.update( + { + "encoder_hidden_states_proj.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_enc_proj.weight"], + "encoder_hidden_states_proj.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.text_enc_proj.bias"], + } + ) + + # .positional_embedding -> .positional_embedding + diffusers_checkpoint.update({"positional_embedding": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.positional_embedding"]}) + + # .prd_emb -> .prd_embedding + diffusers_checkpoint.update({"prd_embedding": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.prd_emb"]}) + + # .time_embed.2 -> .time_embedding.linear_2 + diffusers_checkpoint.update( + { + "time_embedding.linear_2.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.2.weight"], + "time_embedding.linear_2.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.2.bias"], + } + ) + + # .resblocks. -> .transformer_blocks. + for idx in range(len(model.transformer_blocks)): + diffusers_transformer_prefix = f"transformer_blocks.{idx}" + original_transformer_prefix = f"{PRIOR_ORIGINAL_PREFIX}.transformer.resblocks.{idx}" + + # .attn -> .attn1 + diffusers_attention_prefix = f"{diffusers_transformer_prefix}.attn1" + original_attention_prefix = f"{original_transformer_prefix}.attn" + diffusers_checkpoint.update( + prior_attention_to_diffusers( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + original_attention_prefix=original_attention_prefix, + attention_head_dim=model.attention_head_dim, + ) + ) + + # .mlp -> .ff + diffusers_ff_prefix = f"{diffusers_transformer_prefix}.ff" + original_ff_prefix = f"{original_transformer_prefix}.mlp" + diffusers_checkpoint.update( + prior_ff_to_diffusers( + checkpoint, diffusers_ff_prefix=diffusers_ff_prefix, original_ff_prefix=original_ff_prefix + ) + ) + + # .ln_1 -> .norm1 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm1.weight": checkpoint[ + f"{original_transformer_prefix}.ln_1.weight" + ], + f"{diffusers_transformer_prefix}.norm1.bias": checkpoint[f"{original_transformer_prefix}.ln_1.bias"], + } + ) + + # .ln_2 -> .norm3 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm3.weight": checkpoint[ + f"{original_transformer_prefix}.ln_2.weight" + ], + f"{diffusers_transformer_prefix}.norm3.bias": checkpoint[f"{original_transformer_prefix}.ln_2.bias"], + } + ) + + # .final_ln -> .norm_out + diffusers_checkpoint.update( + { + "norm_out.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.final_ln.weight"], + "norm_out.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.final_ln.bias"], + } + ) + + # .out_proj -> .proj_to_clip_embeddings + diffusers_checkpoint.update( + { + "proj_to_clip_embeddings.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.out_proj.weight"], + "proj_to_clip_embeddings.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.out_proj.bias"], + } + ) + + # clip stats + clip_mean, clip_std = clip_stats_checkpoint + clip_mean = clip_mean[None, :] + clip_std = clip_std[None, :] + + diffusers_checkpoint.update({"clip_mean": clip_mean, "clip_std": clip_std}) + + return diffusers_checkpoint + + +def prior_attention_to_diffusers( + checkpoint, *, diffusers_attention_prefix, original_attention_prefix, attention_head_dim +): + diffusers_checkpoint = {} + + # .c_qkv -> .{to_q, to_k, to_v} + [q_weight, k_weight, v_weight], [q_bias, k_bias, v_bias] = split_attentions( + weight=checkpoint[f"{original_attention_prefix}.c_qkv.weight"], + bias=checkpoint[f"{original_attention_prefix}.c_qkv.bias"], + split=3, + chunk_size=attention_head_dim, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_q.weight": q_weight, + f"{diffusers_attention_prefix}.to_q.bias": q_bias, + f"{diffusers_attention_prefix}.to_k.weight": k_weight, + f"{diffusers_attention_prefix}.to_k.bias": k_bias, + f"{diffusers_attention_prefix}.to_v.weight": v_weight, + f"{diffusers_attention_prefix}.to_v.bias": v_bias, + } + ) + + # .c_proj -> .to_out.0 + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{original_attention_prefix}.c_proj.weight"], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{original_attention_prefix}.c_proj.bias"], + } + ) + + return diffusers_checkpoint + + +def prior_ff_to_diffusers(checkpoint, *, diffusers_ff_prefix, original_ff_prefix): + diffusers_checkpoint = { + # .c_fc -> .net.0.proj + f"{diffusers_ff_prefix}.net.{0}.proj.weight": checkpoint[f"{original_ff_prefix}.c_fc.weight"], + f"{diffusers_ff_prefix}.net.{0}.proj.bias": checkpoint[f"{original_ff_prefix}.c_fc.bias"], + # .c_proj -> .net.2 + f"{diffusers_ff_prefix}.net.{2}.weight": checkpoint[f"{original_ff_prefix}.c_proj.weight"], + f"{diffusers_ff_prefix}.net.{2}.bias": checkpoint[f"{original_ff_prefix}.c_proj.bias"], + } + + return diffusers_checkpoint + + +# done prior + +# unet + +# We are hardcoding the model configuration for now. If we need to generalize to more model configurations, we can +# update then. + +UNET_CONFIG = { + "act_fn": "silu", + "addition_embed_type": "text_image", + "addition_embed_type_num_heads": 64, + "attention_head_dim": 64, + "block_out_channels": [384, 768, 1152, 1536], + "center_input_sample": False, + "class_embed_type": None, + "class_embeddings_concat": False, + "conv_in_kernel": 3, + "conv_out_kernel": 3, + "cross_attention_dim": 768, + "cross_attention_norm": None, + "down_block_types": [ + "ResnetDownsampleBlock2D", + "SimpleCrossAttnDownBlock2D", + "SimpleCrossAttnDownBlock2D", + "SimpleCrossAttnDownBlock2D", + ], + "downsample_padding": 1, + "dual_cross_attention": False, + "encoder_hid_dim": 1024, + "encoder_hid_dim_type": "text_image_proj", + "flip_sin_to_cos": True, + "freq_shift": 0, + "in_channels": 4, + "layers_per_block": 3, + "mid_block_only_cross_attention": None, + "mid_block_scale_factor": 1, + "mid_block_type": "UNetMidBlock2DSimpleCrossAttn", + "norm_eps": 1e-05, + "norm_num_groups": 32, + "num_class_embeds": None, + "only_cross_attention": False, + "out_channels": 8, + "projection_class_embeddings_input_dim": None, + "resnet_out_scale_factor": 1.0, + "resnet_skip_time_act": False, + "resnet_time_scale_shift": "scale_shift", + "sample_size": 64, + "time_cond_proj_dim": None, + "time_embedding_act_fn": None, + "time_embedding_dim": None, + "time_embedding_type": "positional", + "timestep_post_act": None, + "up_block_types": [ + "SimpleCrossAttnUpBlock2D", + "SimpleCrossAttnUpBlock2D", + "SimpleCrossAttnUpBlock2D", + "ResnetUpsampleBlock2D", + ], + "upcast_attention": False, + "use_linear_projection": False, +} + + +def unet_model_from_original_config(): + model = UNet2DConditionModel(**UNET_CONFIG) + + return model + + +def unet_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + num_head_channels = UNET_CONFIG["attention_head_dim"] + + diffusers_checkpoint.update(unet_time_embeddings(checkpoint)) + diffusers_checkpoint.update(unet_conv_in(checkpoint)) + diffusers_checkpoint.update(unet_add_embedding(checkpoint)) + diffusers_checkpoint.update(unet_encoder_hid_proj(checkpoint)) + + # .input_blocks -> .down_blocks + + original_down_block_idx = 1 + + for diffusers_down_block_idx in range(len(model.down_blocks)): + checkpoint_update, num_original_down_blocks = unet_downblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_down_block_idx=diffusers_down_block_idx, + original_down_block_idx=original_down_block_idx, + num_head_channels=num_head_channels, + ) + + original_down_block_idx += num_original_down_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .input_blocks -> .down_blocks + + diffusers_checkpoint.update( + unet_midblock_to_diffusers_checkpoint( + model, + checkpoint, + num_head_channels=num_head_channels, + ) + ) + + # .output_blocks -> .up_blocks + + original_up_block_idx = 0 + + for diffusers_up_block_idx in range(len(model.up_blocks)): + checkpoint_update, num_original_up_blocks = unet_upblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_up_block_idx=diffusers_up_block_idx, + original_up_block_idx=original_up_block_idx, + num_head_channels=num_head_channels, + ) + + original_up_block_idx += num_original_up_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .output_blocks -> .up_blocks + + diffusers_checkpoint.update(unet_conv_norm_out(checkpoint)) + diffusers_checkpoint.update(unet_conv_out(checkpoint)) + + return diffusers_checkpoint + + +# done unet + +# inpaint unet + +# We are hardcoding the model configuration for now. If we need to generalize to more model configurations, we can +# update then. + +INPAINT_UNET_CONFIG = { + "act_fn": "silu", + "addition_embed_type": "text_image", + "addition_embed_type_num_heads": 64, + "attention_head_dim": 64, + "block_out_channels": [384, 768, 1152, 1536], + "center_input_sample": False, + "class_embed_type": None, + "class_embeddings_concat": None, + "conv_in_kernel": 3, + "conv_out_kernel": 3, + "cross_attention_dim": 768, + "cross_attention_norm": None, + "down_block_types": [ + "ResnetDownsampleBlock2D", + "SimpleCrossAttnDownBlock2D", + "SimpleCrossAttnDownBlock2D", + "SimpleCrossAttnDownBlock2D", + ], + "downsample_padding": 1, + "dual_cross_attention": False, + "encoder_hid_dim": 1024, + "encoder_hid_dim_type": "text_image_proj", + "flip_sin_to_cos": True, + "freq_shift": 0, + "in_channels": 9, + "layers_per_block": 3, + "mid_block_only_cross_attention": None, + "mid_block_scale_factor": 1, + "mid_block_type": "UNetMidBlock2DSimpleCrossAttn", + "norm_eps": 1e-05, + "norm_num_groups": 32, + "num_class_embeds": None, + "only_cross_attention": False, + "out_channels": 8, + "projection_class_embeddings_input_dim": None, + "resnet_out_scale_factor": 1.0, + "resnet_skip_time_act": False, + "resnet_time_scale_shift": "scale_shift", + "sample_size": 64, + "time_cond_proj_dim": None, + "time_embedding_act_fn": None, + "time_embedding_dim": None, + "time_embedding_type": "positional", + "timestep_post_act": None, + "up_block_types": [ + "SimpleCrossAttnUpBlock2D", + "SimpleCrossAttnUpBlock2D", + "SimpleCrossAttnUpBlock2D", + "ResnetUpsampleBlock2D", + ], + "upcast_attention": False, + "use_linear_projection": False, +} + + +def inpaint_unet_model_from_original_config(): + model = UNet2DConditionModel(**INPAINT_UNET_CONFIG) + + return model + + +def inpaint_unet_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + num_head_channels = INPAINT_UNET_CONFIG["attention_head_dim"] + + diffusers_checkpoint.update(unet_time_embeddings(checkpoint)) + diffusers_checkpoint.update(unet_conv_in(checkpoint)) + diffusers_checkpoint.update(unet_add_embedding(checkpoint)) + diffusers_checkpoint.update(unet_encoder_hid_proj(checkpoint)) + + # .input_blocks -> .down_blocks + + original_down_block_idx = 1 + + for diffusers_down_block_idx in range(len(model.down_blocks)): + checkpoint_update, num_original_down_blocks = unet_downblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_down_block_idx=diffusers_down_block_idx, + original_down_block_idx=original_down_block_idx, + num_head_channels=num_head_channels, + ) + + original_down_block_idx += num_original_down_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .input_blocks -> .down_blocks + + diffusers_checkpoint.update( + unet_midblock_to_diffusers_checkpoint( + model, + checkpoint, + num_head_channels=num_head_channels, + ) + ) + + # .output_blocks -> .up_blocks + + original_up_block_idx = 0 + + for diffusers_up_block_idx in range(len(model.up_blocks)): + checkpoint_update, num_original_up_blocks = unet_upblock_to_diffusers_checkpoint( + model, + checkpoint, + diffusers_up_block_idx=diffusers_up_block_idx, + original_up_block_idx=original_up_block_idx, + num_head_channels=num_head_channels, + ) + + original_up_block_idx += num_original_up_blocks + + diffusers_checkpoint.update(checkpoint_update) + + # done .output_blocks -> .up_blocks + + diffusers_checkpoint.update(unet_conv_norm_out(checkpoint)) + diffusers_checkpoint.update(unet_conv_out(checkpoint)) + + return diffusers_checkpoint + + +# done inpaint unet + + +# unet utils + + +# .time_embed -> .time_embedding +def unet_time_embeddings(checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "time_embedding.linear_1.weight": checkpoint["time_embed.0.weight"], + "time_embedding.linear_1.bias": checkpoint["time_embed.0.bias"], + "time_embedding.linear_2.weight": checkpoint["time_embed.2.weight"], + "time_embedding.linear_2.bias": checkpoint["time_embed.2.bias"], + } + ) + + return diffusers_checkpoint + + +# .input_blocks.0 -> .conv_in +def unet_conv_in(checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "conv_in.weight": checkpoint["input_blocks.0.0.weight"], + "conv_in.bias": checkpoint["input_blocks.0.0.bias"], + } + ) + + return diffusers_checkpoint + + +def unet_add_embedding(checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "add_embedding.text_norm.weight": checkpoint["ln_model_n.weight"], + "add_embedding.text_norm.bias": checkpoint["ln_model_n.bias"], + "add_embedding.text_proj.weight": checkpoint["proj_n.weight"], + "add_embedding.text_proj.bias": checkpoint["proj_n.bias"], + "add_embedding.image_proj.weight": checkpoint["img_layer.weight"], + "add_embedding.image_proj.bias": checkpoint["img_layer.bias"], + } + ) + + return diffusers_checkpoint + + +def unet_encoder_hid_proj(checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "encoder_hid_proj.image_embeds.weight": checkpoint["clip_to_seq.weight"], + "encoder_hid_proj.image_embeds.bias": checkpoint["clip_to_seq.bias"], + "encoder_hid_proj.text_proj.weight": checkpoint["to_model_dim_n.weight"], + "encoder_hid_proj.text_proj.bias": checkpoint["to_model_dim_n.bias"], + } + ) + + return diffusers_checkpoint + + +# .out.0 -> .conv_norm_out +def unet_conv_norm_out(checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "conv_norm_out.weight": checkpoint["out.0.weight"], + "conv_norm_out.bias": checkpoint["out.0.bias"], + } + ) + + return diffusers_checkpoint + + +# .out.2 -> .conv_out +def unet_conv_out(checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update( + { + "conv_out.weight": checkpoint["out.2.weight"], + "conv_out.bias": checkpoint["out.2.bias"], + } + ) + + return diffusers_checkpoint + + +# .input_blocks -> .down_blocks +def unet_downblock_to_diffusers_checkpoint( + model, checkpoint, *, diffusers_down_block_idx, original_down_block_idx, num_head_channels +): + diffusers_checkpoint = {} + + diffusers_resnet_prefix = f"down_blocks.{diffusers_down_block_idx}.resnets" + original_down_block_prefix = "input_blocks" + + down_block = model.down_blocks[diffusers_down_block_idx] + + num_resnets = len(down_block.resnets) + + if down_block.downsamplers is None: + downsampler = False + else: + assert len(down_block.downsamplers) == 1 + downsampler = True + # The downsample block is also a resnet + num_resnets += 1 + + for resnet_idx_inc in range(num_resnets): + full_resnet_prefix = f"{original_down_block_prefix}.{original_down_block_idx + resnet_idx_inc}.0" + + if downsampler and resnet_idx_inc == num_resnets - 1: + # this is a downsample block + full_diffusers_resnet_prefix = f"down_blocks.{diffusers_down_block_idx}.downsamplers.0" + else: + # this is a regular resnet block + full_diffusers_resnet_prefix = f"{diffusers_resnet_prefix}.{resnet_idx_inc}" + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, resnet_prefix=full_resnet_prefix, diffusers_resnet_prefix=full_diffusers_resnet_prefix + ) + ) + + if hasattr(down_block, "attentions"): + num_attentions = len(down_block.attentions) + diffusers_attention_prefix = f"down_blocks.{diffusers_down_block_idx}.attentions" + + for attention_idx_inc in range(num_attentions): + full_attention_prefix = f"{original_down_block_prefix}.{original_down_block_idx + attention_idx_inc}.1" + full_diffusers_attention_prefix = f"{diffusers_attention_prefix}.{attention_idx_inc}" + + diffusers_checkpoint.update( + attention_to_diffusers_checkpoint( + checkpoint, + attention_prefix=full_attention_prefix, + diffusers_attention_prefix=full_diffusers_attention_prefix, + num_head_channels=num_head_channels, + ) + ) + + num_original_down_blocks = num_resnets + + return diffusers_checkpoint, num_original_down_blocks + + +# .middle_block -> .mid_block +def unet_midblock_to_diffusers_checkpoint(model, checkpoint, *, num_head_channels): + diffusers_checkpoint = {} + + # block 0 + + original_block_idx = 0 + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, + diffusers_resnet_prefix="mid_block.resnets.0", + resnet_prefix=f"middle_block.{original_block_idx}", + ) + ) + + original_block_idx += 1 + + # optional block 1 + + if hasattr(model.mid_block, "attentions") and model.mid_block.attentions[0] is not None: + diffusers_checkpoint.update( + attention_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix="mid_block.attentions.0", + attention_prefix=f"middle_block.{original_block_idx}", + num_head_channels=num_head_channels, + ) + ) + original_block_idx += 1 + + # block 1 or block 2 + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, + diffusers_resnet_prefix="mid_block.resnets.1", + resnet_prefix=f"middle_block.{original_block_idx}", + ) + ) + + return diffusers_checkpoint + + +# .output_blocks -> .up_blocks +def unet_upblock_to_diffusers_checkpoint( + model, checkpoint, *, diffusers_up_block_idx, original_up_block_idx, num_head_channels +): + diffusers_checkpoint = {} + + diffusers_resnet_prefix = f"up_blocks.{diffusers_up_block_idx}.resnets" + original_up_block_prefix = "output_blocks" + + up_block = model.up_blocks[diffusers_up_block_idx] + + num_resnets = len(up_block.resnets) + + if up_block.upsamplers is None: + upsampler = False + else: + assert len(up_block.upsamplers) == 1 + upsampler = True + # The upsample block is also a resnet + num_resnets += 1 + + has_attentions = hasattr(up_block, "attentions") + + for resnet_idx_inc in range(num_resnets): + if upsampler and resnet_idx_inc == num_resnets - 1: + # this is an upsample block + if has_attentions: + # There is a middle attention block that we skip + original_resnet_block_idx = 2 + else: + original_resnet_block_idx = 1 + + # we add the `minus 1` because the last two resnets are stuck together in the same output block + full_resnet_prefix = ( + f"{original_up_block_prefix}.{original_up_block_idx + resnet_idx_inc - 1}.{original_resnet_block_idx}" + ) + + full_diffusers_resnet_prefix = f"up_blocks.{diffusers_up_block_idx}.upsamplers.0" + else: + # this is a regular resnet block + full_resnet_prefix = f"{original_up_block_prefix}.{original_up_block_idx + resnet_idx_inc}.0" + full_diffusers_resnet_prefix = f"{diffusers_resnet_prefix}.{resnet_idx_inc}" + + diffusers_checkpoint.update( + resnet_to_diffusers_checkpoint( + checkpoint, resnet_prefix=full_resnet_prefix, diffusers_resnet_prefix=full_diffusers_resnet_prefix + ) + ) + + if has_attentions: + num_attentions = len(up_block.attentions) + diffusers_attention_prefix = f"up_blocks.{diffusers_up_block_idx}.attentions" + + for attention_idx_inc in range(num_attentions): + full_attention_prefix = f"{original_up_block_prefix}.{original_up_block_idx + attention_idx_inc}.1" + full_diffusers_attention_prefix = f"{diffusers_attention_prefix}.{attention_idx_inc}" + + diffusers_checkpoint.update( + attention_to_diffusers_checkpoint( + checkpoint, + attention_prefix=full_attention_prefix, + diffusers_attention_prefix=full_diffusers_attention_prefix, + num_head_channels=num_head_channels, + ) + ) + + num_original_down_blocks = num_resnets - 1 if upsampler else num_resnets + + return diffusers_checkpoint, num_original_down_blocks + + +def resnet_to_diffusers_checkpoint(checkpoint, *, diffusers_resnet_prefix, resnet_prefix): + diffusers_checkpoint = { + f"{diffusers_resnet_prefix}.norm1.weight": checkpoint[f"{resnet_prefix}.in_layers.0.weight"], + f"{diffusers_resnet_prefix}.norm1.bias": checkpoint[f"{resnet_prefix}.in_layers.0.bias"], + f"{diffusers_resnet_prefix}.conv1.weight": checkpoint[f"{resnet_prefix}.in_layers.2.weight"], + f"{diffusers_resnet_prefix}.conv1.bias": checkpoint[f"{resnet_prefix}.in_layers.2.bias"], + f"{diffusers_resnet_prefix}.time_emb_proj.weight": checkpoint[f"{resnet_prefix}.emb_layers.1.weight"], + f"{diffusers_resnet_prefix}.time_emb_proj.bias": checkpoint[f"{resnet_prefix}.emb_layers.1.bias"], + f"{diffusers_resnet_prefix}.norm2.weight": checkpoint[f"{resnet_prefix}.out_layers.0.weight"], + f"{diffusers_resnet_prefix}.norm2.bias": checkpoint[f"{resnet_prefix}.out_layers.0.bias"], + f"{diffusers_resnet_prefix}.conv2.weight": checkpoint[f"{resnet_prefix}.out_layers.3.weight"], + f"{diffusers_resnet_prefix}.conv2.bias": checkpoint[f"{resnet_prefix}.out_layers.3.bias"], + } + + skip_connection_prefix = f"{resnet_prefix}.skip_connection" + + if f"{skip_connection_prefix}.weight" in checkpoint: + diffusers_checkpoint.update( + { + f"{diffusers_resnet_prefix}.conv_shortcut.weight": checkpoint[f"{skip_connection_prefix}.weight"], + f"{diffusers_resnet_prefix}.conv_shortcut.bias": checkpoint[f"{skip_connection_prefix}.bias"], + } + ) + + return diffusers_checkpoint + + +def attention_to_diffusers_checkpoint(checkpoint, *, diffusers_attention_prefix, attention_prefix, num_head_channels): + diffusers_checkpoint = {} + + # .norm -> .group_norm + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.group_norm.weight": checkpoint[f"{attention_prefix}.norm.weight"], + f"{diffusers_attention_prefix}.group_norm.bias": checkpoint[f"{attention_prefix}.norm.bias"], + } + ) + + # .qkv -> .{query, key, value} + [q_weight, k_weight, v_weight], [q_bias, k_bias, v_bias] = split_attentions( + weight=checkpoint[f"{attention_prefix}.qkv.weight"][:, :, 0], + bias=checkpoint[f"{attention_prefix}.qkv.bias"], + split=3, + chunk_size=num_head_channels, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_q.weight": q_weight, + f"{diffusers_attention_prefix}.to_q.bias": q_bias, + f"{diffusers_attention_prefix}.to_k.weight": k_weight, + f"{diffusers_attention_prefix}.to_k.bias": k_bias, + f"{diffusers_attention_prefix}.to_v.weight": v_weight, + f"{diffusers_attention_prefix}.to_v.bias": v_bias, + } + ) + + # .encoder_kv -> .{context_key, context_value} + [encoder_k_weight, encoder_v_weight], [encoder_k_bias, encoder_v_bias] = split_attentions( + weight=checkpoint[f"{attention_prefix}.encoder_kv.weight"][:, :, 0], + bias=checkpoint[f"{attention_prefix}.encoder_kv.bias"], + split=2, + chunk_size=num_head_channels, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.add_k_proj.weight": encoder_k_weight, + f"{diffusers_attention_prefix}.add_k_proj.bias": encoder_k_bias, + f"{diffusers_attention_prefix}.add_v_proj.weight": encoder_v_weight, + f"{diffusers_attention_prefix}.add_v_proj.bias": encoder_v_bias, + } + ) + + # .proj_out (1d conv) -> .proj_attn (linear) + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{attention_prefix}.proj_out.weight"][ + :, :, 0 + ], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{attention_prefix}.proj_out.bias"], + } + ) + + return diffusers_checkpoint + + +# TODO maybe document and/or can do more efficiently (build indices in for loop and extract once for each split?) +def split_attentions(*, weight, bias, split, chunk_size): + weights = [None] * split + biases = [None] * split + + weights_biases_idx = 0 + + for starting_row_index in range(0, weight.shape[0], chunk_size): + row_indices = torch.arange(starting_row_index, starting_row_index + chunk_size) + + weight_rows = weight[row_indices, :] + bias_rows = bias[row_indices] + + if weights[weights_biases_idx] is None: + assert weights[weights_biases_idx] is None + weights[weights_biases_idx] = weight_rows + biases[weights_biases_idx] = bias_rows + else: + assert weights[weights_biases_idx] is not None + weights[weights_biases_idx] = torch.concat([weights[weights_biases_idx], weight_rows]) + biases[weights_biases_idx] = torch.concat([biases[weights_biases_idx], bias_rows]) + + weights_biases_idx = (weights_biases_idx + 1) % split + + return weights, biases + + +# done unet utils + + +def prior(*, args, checkpoint_map_location): + print("loading prior") + + prior_checkpoint = torch.load(args.prior_checkpoint_path, map_location=checkpoint_map_location) + + clip_stats_checkpoint = torch.load(args.clip_stat_path, map_location=checkpoint_map_location) + + prior_model = prior_model_from_original_config() + + prior_diffusers_checkpoint = prior_original_checkpoint_to_diffusers_checkpoint( + prior_model, prior_checkpoint, clip_stats_checkpoint + ) + + del prior_checkpoint + del clip_stats_checkpoint + + load_checkpoint_to_model(prior_diffusers_checkpoint, prior_model, strict=True) + + print("done loading prior") + + return prior_model + + +def text2img(*, args, checkpoint_map_location): + print("loading text2img") + + text2img_checkpoint = torch.load(args.text2img_checkpoint_path, map_location=checkpoint_map_location) + + unet_model = unet_model_from_original_config() + + unet_diffusers_checkpoint = unet_original_checkpoint_to_diffusers_checkpoint(unet_model, text2img_checkpoint) + + del text2img_checkpoint + + load_checkpoint_to_model(unet_diffusers_checkpoint, unet_model, strict=True) + + print("done loading text2img") + + return unet_model + + +def inpaint_text2img(*, args, checkpoint_map_location): + print("loading inpaint text2img") + + inpaint_text2img_checkpoint = torch.load( + args.inpaint_text2img_checkpoint_path, map_location=checkpoint_map_location + ) + + inpaint_unet_model = inpaint_unet_model_from_original_config() + + inpaint_unet_diffusers_checkpoint = inpaint_unet_original_checkpoint_to_diffusers_checkpoint( + inpaint_unet_model, inpaint_text2img_checkpoint + ) + + del inpaint_text2img_checkpoint + + load_checkpoint_to_model(inpaint_unet_diffusers_checkpoint, inpaint_unet_model, strict=True) + + print("done loading inpaint text2img") + + return inpaint_unet_model + + +# movq + +MOVQ_CONFIG = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 4, + "down_block_types": ("DownEncoderBlock2D", "DownEncoderBlock2D", "DownEncoderBlock2D", "AttnDownEncoderBlock2D"), + "up_block_types": ("AttnUpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D"), + "num_vq_embeddings": 16384, + "block_out_channels": (128, 256, 256, 512), + "vq_embed_dim": 4, + "layers_per_block": 2, + "norm_type": "spatial", +} + + +def movq_model_from_original_config(): + movq = VQModel(**MOVQ_CONFIG) + return movq + + +def movq_encoder_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # conv_in + diffusers_checkpoint.update( + { + "encoder.conv_in.weight": checkpoint["encoder.conv_in.weight"], + "encoder.conv_in.bias": checkpoint["encoder.conv_in.bias"], + } + ) + + # down_blocks + for down_block_idx, down_block in enumerate(model.encoder.down_blocks): + diffusers_down_block_prefix = f"encoder.down_blocks.{down_block_idx}" + down_block_prefix = f"encoder.down.{down_block_idx}" + + # resnets + for resnet_idx, resnet in enumerate(down_block.resnets): + diffusers_resnet_prefix = f"{diffusers_down_block_prefix}.resnets.{resnet_idx}" + resnet_prefix = f"{down_block_prefix}.block.{resnet_idx}" + + diffusers_checkpoint.update( + movq_resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + # downsample + + # do not include the downsample when on the last down block + # There is no downsample on the last down block + if down_block_idx != len(model.encoder.down_blocks) - 1: + # There's a single downsample in the original checkpoint but a list of downsamples + # in the diffusers model. + diffusers_downsample_prefix = f"{diffusers_down_block_prefix}.downsamplers.0.conv" + downsample_prefix = f"{down_block_prefix}.downsample.conv" + diffusers_checkpoint.update( + { + f"{diffusers_downsample_prefix}.weight": checkpoint[f"{downsample_prefix}.weight"], + f"{diffusers_downsample_prefix}.bias": checkpoint[f"{downsample_prefix}.bias"], + } + ) + + # attentions + + if hasattr(down_block, "attentions"): + for attention_idx, _ in enumerate(down_block.attentions): + diffusers_attention_prefix = f"{diffusers_down_block_prefix}.attentions.{attention_idx}" + attention_prefix = f"{down_block_prefix}.attn.{attention_idx}" + diffusers_checkpoint.update( + movq_attention_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + attention_prefix=attention_prefix, + ) + ) + + # mid block + + # mid block attentions + + # There is a single hardcoded attention block in the middle of the VQ-diffusion encoder + diffusers_attention_prefix = "encoder.mid_block.attentions.0" + attention_prefix = "encoder.mid.attn_1" + diffusers_checkpoint.update( + movq_attention_to_diffusers_checkpoint( + checkpoint, diffusers_attention_prefix=diffusers_attention_prefix, attention_prefix=attention_prefix + ) + ) + + # mid block resnets + + for diffusers_resnet_idx, resnet in enumerate(model.encoder.mid_block.resnets): + diffusers_resnet_prefix = f"encoder.mid_block.resnets.{diffusers_resnet_idx}" + + # the hardcoded prefixes to `block_` are 1 and 2 + orig_resnet_idx = diffusers_resnet_idx + 1 + # There are two hardcoded resnets in the middle of the VQ-diffusion encoder + resnet_prefix = f"encoder.mid.block_{orig_resnet_idx}" + + diffusers_checkpoint.update( + movq_resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + diffusers_checkpoint.update( + { + # conv_norm_out + "encoder.conv_norm_out.weight": checkpoint["encoder.norm_out.weight"], + "encoder.conv_norm_out.bias": checkpoint["encoder.norm_out.bias"], + # conv_out + "encoder.conv_out.weight": checkpoint["encoder.conv_out.weight"], + "encoder.conv_out.bias": checkpoint["encoder.conv_out.bias"], + } + ) + + return diffusers_checkpoint + + +def movq_decoder_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # conv in + diffusers_checkpoint.update( + { + "decoder.conv_in.weight": checkpoint["decoder.conv_in.weight"], + "decoder.conv_in.bias": checkpoint["decoder.conv_in.bias"], + } + ) + + # up_blocks + + for diffusers_up_block_idx, up_block in enumerate(model.decoder.up_blocks): + # up_blocks are stored in reverse order in the VQ-diffusion checkpoint + orig_up_block_idx = len(model.decoder.up_blocks) - 1 - diffusers_up_block_idx + + diffusers_up_block_prefix = f"decoder.up_blocks.{diffusers_up_block_idx}" + up_block_prefix = f"decoder.up.{orig_up_block_idx}" + + # resnets + for resnet_idx, resnet in enumerate(up_block.resnets): + diffusers_resnet_prefix = f"{diffusers_up_block_prefix}.resnets.{resnet_idx}" + resnet_prefix = f"{up_block_prefix}.block.{resnet_idx}" + + diffusers_checkpoint.update( + movq_resnet_to_diffusers_checkpoint_spatial_norm( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + # upsample + + # there is no up sample on the last up block + if diffusers_up_block_idx != len(model.decoder.up_blocks) - 1: + # There's a single upsample in the VQ-diffusion checkpoint but a list of downsamples + # in the diffusers model. + diffusers_downsample_prefix = f"{diffusers_up_block_prefix}.upsamplers.0.conv" + downsample_prefix = f"{up_block_prefix}.upsample.conv" + diffusers_checkpoint.update( + { + f"{diffusers_downsample_prefix}.weight": checkpoint[f"{downsample_prefix}.weight"], + f"{diffusers_downsample_prefix}.bias": checkpoint[f"{downsample_prefix}.bias"], + } + ) + + # attentions + + if hasattr(up_block, "attentions"): + for attention_idx, _ in enumerate(up_block.attentions): + diffusers_attention_prefix = f"{diffusers_up_block_prefix}.attentions.{attention_idx}" + attention_prefix = f"{up_block_prefix}.attn.{attention_idx}" + diffusers_checkpoint.update( + movq_attention_to_diffusers_checkpoint_spatial_norm( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + attention_prefix=attention_prefix, + ) + ) + + # mid block + + # mid block attentions + + # There is a single hardcoded attention block in the middle of the VQ-diffusion decoder + diffusers_attention_prefix = "decoder.mid_block.attentions.0" + attention_prefix = "decoder.mid.attn_1" + diffusers_checkpoint.update( + movq_attention_to_diffusers_checkpoint_spatial_norm( + checkpoint, diffusers_attention_prefix=diffusers_attention_prefix, attention_prefix=attention_prefix + ) + ) + + # mid block resnets + + for diffusers_resnet_idx, resnet in enumerate(model.encoder.mid_block.resnets): + diffusers_resnet_prefix = f"decoder.mid_block.resnets.{diffusers_resnet_idx}" + + # the hardcoded prefixes to `block_` are 1 and 2 + orig_resnet_idx = diffusers_resnet_idx + 1 + # There are two hardcoded resnets in the middle of the VQ-diffusion decoder + resnet_prefix = f"decoder.mid.block_{orig_resnet_idx}" + + diffusers_checkpoint.update( + movq_resnet_to_diffusers_checkpoint_spatial_norm( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + diffusers_checkpoint.update( + { + # conv_norm_out + "decoder.conv_norm_out.norm_layer.weight": checkpoint["decoder.norm_out.norm_layer.weight"], + "decoder.conv_norm_out.norm_layer.bias": checkpoint["decoder.norm_out.norm_layer.bias"], + "decoder.conv_norm_out.conv_y.weight": checkpoint["decoder.norm_out.conv_y.weight"], + "decoder.conv_norm_out.conv_y.bias": checkpoint["decoder.norm_out.conv_y.bias"], + "decoder.conv_norm_out.conv_b.weight": checkpoint["decoder.norm_out.conv_b.weight"], + "decoder.conv_norm_out.conv_b.bias": checkpoint["decoder.norm_out.conv_b.bias"], + # conv_out + "decoder.conv_out.weight": checkpoint["decoder.conv_out.weight"], + "decoder.conv_out.bias": checkpoint["decoder.conv_out.bias"], + } + ) + + return diffusers_checkpoint + + +def movq_resnet_to_diffusers_checkpoint(resnet, checkpoint, *, diffusers_resnet_prefix, resnet_prefix): + rv = { + # norm1 + f"{diffusers_resnet_prefix}.norm1.weight": checkpoint[f"{resnet_prefix}.norm1.weight"], + f"{diffusers_resnet_prefix}.norm1.bias": checkpoint[f"{resnet_prefix}.norm1.bias"], + # conv1 + f"{diffusers_resnet_prefix}.conv1.weight": checkpoint[f"{resnet_prefix}.conv1.weight"], + f"{diffusers_resnet_prefix}.conv1.bias": checkpoint[f"{resnet_prefix}.conv1.bias"], + # norm2 + f"{diffusers_resnet_prefix}.norm2.weight": checkpoint[f"{resnet_prefix}.norm2.weight"], + f"{diffusers_resnet_prefix}.norm2.bias": checkpoint[f"{resnet_prefix}.norm2.bias"], + # conv2 + f"{diffusers_resnet_prefix}.conv2.weight": checkpoint[f"{resnet_prefix}.conv2.weight"], + f"{diffusers_resnet_prefix}.conv2.bias": checkpoint[f"{resnet_prefix}.conv2.bias"], + } + + if resnet.conv_shortcut is not None: + rv.update( + { + f"{diffusers_resnet_prefix}.conv_shortcut.weight": checkpoint[f"{resnet_prefix}.nin_shortcut.weight"], + f"{diffusers_resnet_prefix}.conv_shortcut.bias": checkpoint[f"{resnet_prefix}.nin_shortcut.bias"], + } + ) + + return rv + + +def movq_resnet_to_diffusers_checkpoint_spatial_norm(resnet, checkpoint, *, diffusers_resnet_prefix, resnet_prefix): + rv = { + # norm1 + f"{diffusers_resnet_prefix}.norm1.norm_layer.weight": checkpoint[f"{resnet_prefix}.norm1.norm_layer.weight"], + f"{diffusers_resnet_prefix}.norm1.norm_layer.bias": checkpoint[f"{resnet_prefix}.norm1.norm_layer.bias"], + f"{diffusers_resnet_prefix}.norm1.conv_y.weight": checkpoint[f"{resnet_prefix}.norm1.conv_y.weight"], + f"{diffusers_resnet_prefix}.norm1.conv_y.bias": checkpoint[f"{resnet_prefix}.norm1.conv_y.bias"], + f"{diffusers_resnet_prefix}.norm1.conv_b.weight": checkpoint[f"{resnet_prefix}.norm1.conv_b.weight"], + f"{diffusers_resnet_prefix}.norm1.conv_b.bias": checkpoint[f"{resnet_prefix}.norm1.conv_b.bias"], + # conv1 + f"{diffusers_resnet_prefix}.conv1.weight": checkpoint[f"{resnet_prefix}.conv1.weight"], + f"{diffusers_resnet_prefix}.conv1.bias": checkpoint[f"{resnet_prefix}.conv1.bias"], + # norm2 + f"{diffusers_resnet_prefix}.norm2.norm_layer.weight": checkpoint[f"{resnet_prefix}.norm2.norm_layer.weight"], + f"{diffusers_resnet_prefix}.norm2.norm_layer.bias": checkpoint[f"{resnet_prefix}.norm2.norm_layer.bias"], + f"{diffusers_resnet_prefix}.norm2.conv_y.weight": checkpoint[f"{resnet_prefix}.norm2.conv_y.weight"], + f"{diffusers_resnet_prefix}.norm2.conv_y.bias": checkpoint[f"{resnet_prefix}.norm2.conv_y.bias"], + f"{diffusers_resnet_prefix}.norm2.conv_b.weight": checkpoint[f"{resnet_prefix}.norm2.conv_b.weight"], + f"{diffusers_resnet_prefix}.norm2.conv_b.bias": checkpoint[f"{resnet_prefix}.norm2.conv_b.bias"], + # conv2 + f"{diffusers_resnet_prefix}.conv2.weight": checkpoint[f"{resnet_prefix}.conv2.weight"], + f"{diffusers_resnet_prefix}.conv2.bias": checkpoint[f"{resnet_prefix}.conv2.bias"], + } + + if resnet.conv_shortcut is not None: + rv.update( + { + f"{diffusers_resnet_prefix}.conv_shortcut.weight": checkpoint[f"{resnet_prefix}.nin_shortcut.weight"], + f"{diffusers_resnet_prefix}.conv_shortcut.bias": checkpoint[f"{resnet_prefix}.nin_shortcut.bias"], + } + ) + + return rv + + +def movq_attention_to_diffusers_checkpoint(checkpoint, *, diffusers_attention_prefix, attention_prefix): + return { + # norm + f"{diffusers_attention_prefix}.group_norm.weight": checkpoint[f"{attention_prefix}.norm.weight"], + f"{diffusers_attention_prefix}.group_norm.bias": checkpoint[f"{attention_prefix}.norm.bias"], + # query + f"{diffusers_attention_prefix}.to_q.weight": checkpoint[f"{attention_prefix}.q.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_q.bias": checkpoint[f"{attention_prefix}.q.bias"], + # key + f"{diffusers_attention_prefix}.to_k.weight": checkpoint[f"{attention_prefix}.k.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_k.bias": checkpoint[f"{attention_prefix}.k.bias"], + # value + f"{diffusers_attention_prefix}.to_v.weight": checkpoint[f"{attention_prefix}.v.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_v.bias": checkpoint[f"{attention_prefix}.v.bias"], + # proj_attn + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{attention_prefix}.proj_out.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{attention_prefix}.proj_out.bias"], + } + + +def movq_attention_to_diffusers_checkpoint_spatial_norm(checkpoint, *, diffusers_attention_prefix, attention_prefix): + return { + # norm + f"{diffusers_attention_prefix}.spatial_norm.norm_layer.weight": checkpoint[ + f"{attention_prefix}.norm.norm_layer.weight" + ], + f"{diffusers_attention_prefix}.spatial_norm.norm_layer.bias": checkpoint[ + f"{attention_prefix}.norm.norm_layer.bias" + ], + f"{diffusers_attention_prefix}.spatial_norm.conv_y.weight": checkpoint[ + f"{attention_prefix}.norm.conv_y.weight" + ], + f"{diffusers_attention_prefix}.spatial_norm.conv_y.bias": checkpoint[f"{attention_prefix}.norm.conv_y.bias"], + f"{diffusers_attention_prefix}.spatial_norm.conv_b.weight": checkpoint[ + f"{attention_prefix}.norm.conv_b.weight" + ], + f"{diffusers_attention_prefix}.spatial_norm.conv_b.bias": checkpoint[f"{attention_prefix}.norm.conv_b.bias"], + # query + f"{diffusers_attention_prefix}.to_q.weight": checkpoint[f"{attention_prefix}.q.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_q.bias": checkpoint[f"{attention_prefix}.q.bias"], + # key + f"{diffusers_attention_prefix}.to_k.weight": checkpoint[f"{attention_prefix}.k.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_k.bias": checkpoint[f"{attention_prefix}.k.bias"], + # value + f"{diffusers_attention_prefix}.to_v.weight": checkpoint[f"{attention_prefix}.v.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_v.bias": checkpoint[f"{attention_prefix}.v.bias"], + # proj_attn + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{attention_prefix}.proj_out.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{attention_prefix}.proj_out.bias"], + } + + +def movq_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + diffusers_checkpoint.update(movq_encoder_to_diffusers_checkpoint(model, checkpoint)) + + # quant_conv + + diffusers_checkpoint.update( + { + "quant_conv.weight": checkpoint["quant_conv.weight"], + "quant_conv.bias": checkpoint["quant_conv.bias"], + } + ) + + # quantize + diffusers_checkpoint.update({"quantize.embedding.weight": checkpoint["quantize.embedding.weight"]}) + + # post_quant_conv + diffusers_checkpoint.update( + { + "post_quant_conv.weight": checkpoint["post_quant_conv.weight"], + "post_quant_conv.bias": checkpoint["post_quant_conv.bias"], + } + ) + + # decoder + diffusers_checkpoint.update(movq_decoder_to_diffusers_checkpoint(model, checkpoint)) + + return diffusers_checkpoint + + +def movq(*, args, checkpoint_map_location): + print("loading movq") + + movq_checkpoint = torch.load(args.movq_checkpoint_path, map_location=checkpoint_map_location) + + movq_model = movq_model_from_original_config() + + movq_diffusers_checkpoint = movq_original_checkpoint_to_diffusers_checkpoint(movq_model, movq_checkpoint) + + del movq_checkpoint + + load_checkpoint_to_model(movq_diffusers_checkpoint, movq_model, strict=True) + + print("done loading movq") + + return movq_model + + +def load_checkpoint_to_model(checkpoint, model, strict=False): + with tempfile.NamedTemporaryFile(delete=False) as file: + torch.save(checkpoint, file.name) + del checkpoint + if strict: + model.load_state_dict(torch.load(file.name), strict=True) + else: + load_checkpoint_and_dispatch(model, file.name, device_map="auto") + os.remove(file.name) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--prior_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the prior checkpoint to convert.", + ) + parser.add_argument( + "--clip_stat_path", + default=None, + type=str, + required=False, + help="Path to the clip stats checkpoint to convert.", + ) + parser.add_argument( + "--text2img_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the text2img checkpoint to convert.", + ) + parser.add_argument( + "--movq_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the text2img checkpoint to convert.", + ) + parser.add_argument( + "--inpaint_text2img_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the inpaint text2img checkpoint to convert.", + ) + parser.add_argument( + "--checkpoint_load_device", + default="cpu", + type=str, + required=False, + help="The device passed to `map_location` when loading checkpoints.", + ) + + parser.add_argument( + "--debug", + default=None, + type=str, + required=False, + help="Only run a specific stage of the convert script. Used for debugging", + ) + + args = parser.parse_args() + + print(f"loading checkpoints to {args.checkpoint_load_device}") + + checkpoint_map_location = torch.device(args.checkpoint_load_device) + + if args.debug is not None: + print(f"debug: only executing {args.debug}") + + if args.debug is None: + print("to-do") + elif args.debug == "prior": + prior_model = prior(args=args, checkpoint_map_location=checkpoint_map_location) + prior_model.save_pretrained(args.dump_path) + elif args.debug == "text2img": + unet_model = text2img(args=args, checkpoint_map_location=checkpoint_map_location) + unet_model.save_pretrained(f"{args.dump_path}/unet") + elif args.debug == "inpaint_text2img": + inpaint_unet_model = inpaint_text2img(args=args, checkpoint_map_location=checkpoint_map_location) + inpaint_unet_model.save_pretrained(f"{args.dump_path}/inpaint_unet") + elif args.debug == "decoder": + decoder = movq(args=args, checkpoint_map_location=checkpoint_map_location) + decoder.save_pretrained(f"{args.dump_path}/decoder") + else: + raise ValueError(f"unknown debug value : {args.debug}") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ldm_original_checkpoint_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ldm_original_checkpoint_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..cdaf317af752817775fac81fc6ca7dd062ff630a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ldm_original_checkpoint_to_diffusers.py @@ -0,0 +1,359 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the LDM checkpoints.""" + +import argparse +import json + +import torch + +from diffusers import DDPMScheduler, LDMPipeline, UNet2DModel, VQModel + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("proj_out.weight", "proj_attn.weight") + new_item = new_item.replace("proj_out.bias", "proj_attn.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming + to them. It splits attention layers, and takes into account additional replacements + that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + if "proj_attn.weight" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def convert_ldm_checkpoint(checkpoint, config): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = checkpoint["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = checkpoint["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = checkpoint["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = checkpoint["time_embed.2.bias"] + + new_checkpoint["conv_in.weight"] = checkpoint["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = checkpoint["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = checkpoint["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = checkpoint["out.0.bias"] + new_checkpoint["conv_out.weight"] = checkpoint["out.2.weight"] + new_checkpoint["conv_out.bias"] = checkpoint["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in checkpoint if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in checkpoint if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in checkpoint if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in checkpoint if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in checkpoint if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in checkpoint if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["num_res_blocks"] + 1) + layer_in_block_id = (i - 1) % (config["num_res_blocks"] + 1) + + resnets = [key for key in input_blocks[i] if f"input_blocks.{i}.0" in key] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in checkpoint: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = checkpoint[ + f"input_blocks.{i}.0.op.weight" + ] + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = checkpoint[ + f"input_blocks.{i}.0.op.bias" + ] + continue + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + resnet_op = {"old": "resnets.2.op", "new": "downsamplers.0.op"} + assign_to_checkpoint( + paths, new_checkpoint, checkpoint, additional_replacements=[meta_path, resnet_op], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"input_blocks.{i}.1", + "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}", + } + to_split = { + f"input_blocks.{i}.1.qkv.bias": { + "key": f"down_blocks.{block_id}.attentions.{layer_in_block_id}.key.bias", + "query": f"down_blocks.{block_id}.attentions.{layer_in_block_id}.query.bias", + "value": f"down_blocks.{block_id}.attentions.{layer_in_block_id}.value.bias", + }, + f"input_blocks.{i}.1.qkv.weight": { + "key": f"down_blocks.{block_id}.attentions.{layer_in_block_id}.key.weight", + "query": f"down_blocks.{block_id}.attentions.{layer_in_block_id}.query.weight", + "value": f"down_blocks.{block_id}.attentions.{layer_in_block_id}.value.weight", + }, + } + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[meta_path], + attention_paths_to_split=to_split, + config=config, + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, checkpoint, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, checkpoint, config=config) + + attentions_paths = renew_attention_paths(attentions) + to_split = { + "middle_block.1.qkv.bias": { + "key": "mid_block.attentions.0.key.bias", + "query": "mid_block.attentions.0.query.bias", + "value": "mid_block.attentions.0.value.bias", + }, + "middle_block.1.qkv.weight": { + "key": "mid_block.attentions.0.key.weight", + "query": "mid_block.attentions.0.query.weight", + "value": "mid_block.attentions.0.value.weight", + }, + } + assign_to_checkpoint( + attentions_paths, new_checkpoint, checkpoint, attention_paths_to_split=to_split, config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["num_res_blocks"] + 1) + layer_in_block_id = i % (config["num_res_blocks"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint(paths, new_checkpoint, checkpoint, additional_replacements=[meta_path], config=config) + + if ["conv.weight", "conv.bias"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.weight", "conv.bias"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = checkpoint[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = checkpoint[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + to_split = { + f"output_blocks.{i}.1.qkv.bias": { + "key": f"up_blocks.{block_id}.attentions.{layer_in_block_id}.key.bias", + "query": f"up_blocks.{block_id}.attentions.{layer_in_block_id}.query.bias", + "value": f"up_blocks.{block_id}.attentions.{layer_in_block_id}.value.bias", + }, + f"output_blocks.{i}.1.qkv.weight": { + "key": f"up_blocks.{block_id}.attentions.{layer_in_block_id}.key.weight", + "query": f"up_blocks.{block_id}.attentions.{layer_in_block_id}.query.weight", + "value": f"up_blocks.{block_id}.attentions.{layer_in_block_id}.value.weight", + }, + } + assign_to_checkpoint( + paths, + new_checkpoint, + checkpoint, + additional_replacements=[meta_path], + attention_paths_to_split=to_split if any("qkv" in key for key in attentions) else None, + config=config, + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = checkpoint[old_path] + + return new_checkpoint + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + + parser.add_argument( + "--config_file", + default=None, + type=str, + required=True, + help="The config json file corresponding to the architecture.", + ) + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + args = parser.parse_args() + + checkpoint = torch.load(args.checkpoint_path) + + with open(args.config_file) as f: + config = json.loads(f.read()) + + converted_checkpoint = convert_ldm_checkpoint(checkpoint, config) + + if "ldm" in config: + del config["ldm"] + + model = UNet2DModel(**config) + model.load_state_dict(converted_checkpoint) + + try: + scheduler = DDPMScheduler.from_config("/".join(args.checkpoint_path.split("/")[:-1])) + vqvae = VQModel.from_pretrained("/".join(args.checkpoint_path.split("/")[:-1])) + + pipe = LDMPipeline(unet=model, scheduler=scheduler, vae=vqvae) + pipe.save_pretrained(args.dump_path) + except: # noqa: E722 + model.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_lora_safetensor_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_lora_safetensor_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..4237452e2ed16a82ef53199651f8a48c60b051a8 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_lora_safetensor_to_diffusers.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# Copyright 2024, Haofan Wang, Qixun Wang, All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Conversion script for the LoRA's safetensors checkpoints.""" + +import argparse + +import torch +from safetensors.torch import load_file + +from diffusers import StableDiffusionPipeline + + +def convert(base_model_path, checkpoint_path, LORA_PREFIX_UNET, LORA_PREFIX_TEXT_ENCODER, alpha): + # load base model + pipeline = StableDiffusionPipeline.from_pretrained(base_model_path, torch_dtype=torch.float32) + + # load LoRA weight from .safetensors + state_dict = load_file(checkpoint_path) + + visited = [] + + # directly update weight in diffusers model + for key in state_dict: + # it is suggested to print out the key, it usually will be something like below + # "lora_te_text_model_encoder_layers_0_self_attn_k_proj.lora_down.weight" + + # as we have set the alpha beforehand, so just skip + if ".alpha" in key or key in visited: + continue + + if "text" in key: + layer_infos = key.split(".")[0].split(LORA_PREFIX_TEXT_ENCODER + "_")[-1].split("_") + curr_layer = pipeline.text_encoder + else: + layer_infos = key.split(".")[0].split(LORA_PREFIX_UNET + "_")[-1].split("_") + curr_layer = pipeline.unet + + # find the target layer + temp_name = layer_infos.pop(0) + while len(layer_infos) > -1: + try: + curr_layer = curr_layer.__getattr__(temp_name) + if len(layer_infos) > 0: + temp_name = layer_infos.pop(0) + elif len(layer_infos) == 0: + break + except Exception: + if len(temp_name) > 0: + temp_name += "_" + layer_infos.pop(0) + else: + temp_name = layer_infos.pop(0) + + pair_keys = [] + if "lora_down" in key: + pair_keys.append(key.replace("lora_down", "lora_up")) + pair_keys.append(key) + else: + pair_keys.append(key) + pair_keys.append(key.replace("lora_up", "lora_down")) + + # update weight + if len(state_dict[pair_keys[0]].shape) == 4: + weight_up = state_dict[pair_keys[0]].squeeze(3).squeeze(2).to(torch.float32) + weight_down = state_dict[pair_keys[1]].squeeze(3).squeeze(2).to(torch.float32) + curr_layer.weight.data += alpha * torch.mm(weight_up, weight_down).unsqueeze(2).unsqueeze(3) + else: + weight_up = state_dict[pair_keys[0]].to(torch.float32) + weight_down = state_dict[pair_keys[1]].to(torch.float32) + curr_layer.weight.data += alpha * torch.mm(weight_up, weight_down) + + # update visited list + for item in pair_keys: + visited.append(item) + + return pipeline + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--base_model_path", default=None, type=str, required=True, help="Path to the base model in diffusers format." + ) + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument( + "--lora_prefix_unet", default="lora_unet", type=str, help="The prefix of UNet weight in safetensors" + ) + parser.add_argument( + "--lora_prefix_text_encoder", + default="lora_te", + type=str, + help="The prefix of text encoder weight in safetensors", + ) + parser.add_argument("--alpha", default=0.75, type=float, help="The merging ratio in W = W0 + alpha * deltaW") + parser.add_argument( + "--to_safetensors", action="store_true", help="Whether to store pipeline in safetensors format or not." + ) + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + + args = parser.parse_args() + + base_model_path = args.base_model_path + checkpoint_path = args.checkpoint_path + dump_path = args.dump_path + lora_prefix_unet = args.lora_prefix_unet + lora_prefix_text_encoder = args.lora_prefix_text_encoder + alpha = args.alpha + + pipe = convert(base_model_path, checkpoint_path, lora_prefix_unet, lora_prefix_text_encoder, alpha) + + pipe = pipe.to(args.device) + pipe.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ltx_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ltx_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..19e5602039e5fe2dbdbcf61c44763a06f7018448 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ltx_to_diffusers.py @@ -0,0 +1,525 @@ +import argparse +from pathlib import Path +from typing import Any, Dict + +import torch +from accelerate import init_empty_weights +from safetensors.torch import load_file +from transformers import T5EncoderModel, T5Tokenizer + +from diffusers import ( + AutoencoderKLLTXVideo, + FlowMatchEulerDiscreteScheduler, + LTXConditionPipeline, + LTXLatentUpsamplePipeline, + LTXPipeline, + LTXVideoTransformer3DModel, +) +from diffusers.pipelines.ltx.modeling_latent_upsampler import LTXLatentUpsamplerModel + + +def remove_keys_(key: str, state_dict: Dict[str, Any]): + state_dict.pop(key) + + +TOKENIZER_MAX_LENGTH = 128 + +TRANSFORMER_KEYS_RENAME_DICT = { + "patchify_proj": "proj_in", + "adaln_single": "time_embed", + "q_norm": "norm_q", + "k_norm": "norm_k", +} + +TRANSFORMER_SPECIAL_KEYS_REMAP = { + "vae": remove_keys_, +} + +VAE_KEYS_RENAME_DICT = { + # decoder + "up_blocks.0": "mid_block", + "up_blocks.1": "up_blocks.0", + "up_blocks.2": "up_blocks.1.upsamplers.0", + "up_blocks.3": "up_blocks.1", + "up_blocks.4": "up_blocks.2.conv_in", + "up_blocks.5": "up_blocks.2.upsamplers.0", + "up_blocks.6": "up_blocks.2", + "up_blocks.7": "up_blocks.3.conv_in", + "up_blocks.8": "up_blocks.3.upsamplers.0", + "up_blocks.9": "up_blocks.3", + # encoder + "down_blocks.0": "down_blocks.0", + "down_blocks.1": "down_blocks.0.downsamplers.0", + "down_blocks.2": "down_blocks.0.conv_out", + "down_blocks.3": "down_blocks.1", + "down_blocks.4": "down_blocks.1.downsamplers.0", + "down_blocks.5": "down_blocks.1.conv_out", + "down_blocks.6": "down_blocks.2", + "down_blocks.7": "down_blocks.2.downsamplers.0", + "down_blocks.8": "down_blocks.3", + "down_blocks.9": "mid_block", + # common + "conv_shortcut": "conv_shortcut.conv", + "res_blocks": "resnets", + "norm3.norm": "norm3", + "per_channel_statistics.mean-of-means": "latents_mean", + "per_channel_statistics.std-of-means": "latents_std", +} + +VAE_091_RENAME_DICT = { + # decoder + "up_blocks.0": "mid_block", + "up_blocks.1": "up_blocks.0.upsamplers.0", + "up_blocks.2": "up_blocks.0", + "up_blocks.3": "up_blocks.1.upsamplers.0", + "up_blocks.4": "up_blocks.1", + "up_blocks.5": "up_blocks.2.upsamplers.0", + "up_blocks.6": "up_blocks.2", + "up_blocks.7": "up_blocks.3.upsamplers.0", + "up_blocks.8": "up_blocks.3", + # common + "last_time_embedder": "time_embedder", + "last_scale_shift_table": "scale_shift_table", +} + +VAE_095_RENAME_DICT = { + # decoder + "up_blocks.0": "mid_block", + "up_blocks.1": "up_blocks.0.upsamplers.0", + "up_blocks.2": "up_blocks.0", + "up_blocks.3": "up_blocks.1.upsamplers.0", + "up_blocks.4": "up_blocks.1", + "up_blocks.5": "up_blocks.2.upsamplers.0", + "up_blocks.6": "up_blocks.2", + "up_blocks.7": "up_blocks.3.upsamplers.0", + "up_blocks.8": "up_blocks.3", + # encoder + "down_blocks.0": "down_blocks.0", + "down_blocks.1": "down_blocks.0.downsamplers.0", + "down_blocks.2": "down_blocks.1", + "down_blocks.3": "down_blocks.1.downsamplers.0", + "down_blocks.4": "down_blocks.2", + "down_blocks.5": "down_blocks.2.downsamplers.0", + "down_blocks.6": "down_blocks.3", + "down_blocks.7": "down_blocks.3.downsamplers.0", + "down_blocks.8": "mid_block", + # common + "last_time_embedder": "time_embedder", + "last_scale_shift_table": "scale_shift_table", +} + +VAE_SPECIAL_KEYS_REMAP = { + "per_channel_statistics.channel": remove_keys_, + "per_channel_statistics.mean-of-means": remove_keys_, + "per_channel_statistics.mean-of-stds": remove_keys_, + "model.diffusion_model": remove_keys_, +} + + +def get_state_dict(saved_dict: Dict[str, Any]) -> Dict[str, Any]: + state_dict = saved_dict + if "model" in saved_dict.keys(): + state_dict = state_dict["model"] + if "module" in saved_dict.keys(): + state_dict = state_dict["module"] + if "state_dict" in saved_dict.keys(): + state_dict = state_dict["state_dict"] + return state_dict + + +def update_state_dict_inplace(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def convert_transformer(ckpt_path: str, config, dtype: torch.dtype): + PREFIX_KEY = "model.diffusion_model." + + original_state_dict = get_state_dict(load_file(ckpt_path)) + with init_empty_weights(): + transformer = LTXVideoTransformer3DModel(**config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + if new_key.startswith(PREFIX_KEY): + new_key = key[len(PREFIX_KEY) :] + for replace_key, rename_key in TRANSFORMER_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_inplace(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in TRANSFORMER_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + transformer.load_state_dict(original_state_dict, strict=True, assign=True) + return transformer + + +def convert_vae(ckpt_path: str, config, dtype: torch.dtype): + PREFIX_KEY = "vae." + + original_state_dict = get_state_dict(load_file(ckpt_path)) + with init_empty_weights(): + vae = AutoencoderKLLTXVideo(**config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + if new_key.startswith(PREFIX_KEY): + new_key = key[len(PREFIX_KEY) :] + for replace_key, rename_key in VAE_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_inplace(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in VAE_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + vae.load_state_dict(original_state_dict, strict=True, assign=True) + return vae + + +def convert_spatial_latent_upsampler(ckpt_path: str, config, dtype: torch.dtype): + original_state_dict = get_state_dict(load_file(ckpt_path)) + + with init_empty_weights(): + latent_upsampler = LTXLatentUpsamplerModel(**config) + + latent_upsampler.load_state_dict(original_state_dict, strict=True, assign=True) + latent_upsampler.to(dtype) + return latent_upsampler + + +def get_transformer_config(version: str) -> Dict[str, Any]: + if version == "0.9.7": + config = { + "in_channels": 128, + "out_channels": 128, + "patch_size": 1, + "patch_size_t": 1, + "num_attention_heads": 32, + "attention_head_dim": 128, + "cross_attention_dim": 4096, + "num_layers": 48, + "activation_fn": "gelu-approximate", + "qk_norm": "rms_norm_across_heads", + "norm_elementwise_affine": False, + "norm_eps": 1e-6, + "caption_channels": 4096, + "attention_bias": True, + "attention_out_bias": True, + } + else: + config = { + "in_channels": 128, + "out_channels": 128, + "patch_size": 1, + "patch_size_t": 1, + "num_attention_heads": 32, + "attention_head_dim": 64, + "cross_attention_dim": 2048, + "num_layers": 28, + "activation_fn": "gelu-approximate", + "qk_norm": "rms_norm_across_heads", + "norm_elementwise_affine": False, + "norm_eps": 1e-6, + "caption_channels": 4096, + "attention_bias": True, + "attention_out_bias": True, + } + return config + + +def get_vae_config(version: str) -> Dict[str, Any]: + if version in ["0.9.0"]: + config = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 128, + "block_out_channels": (128, 256, 512, 512), + "down_block_types": ( + "LTXVideoDownBlock3D", + "LTXVideoDownBlock3D", + "LTXVideoDownBlock3D", + "LTXVideoDownBlock3D", + ), + "decoder_block_out_channels": (128, 256, 512, 512), + "layers_per_block": (4, 3, 3, 3, 4), + "decoder_layers_per_block": (4, 3, 3, 3, 4), + "spatio_temporal_scaling": (True, True, True, False), + "decoder_spatio_temporal_scaling": (True, True, True, False), + "decoder_inject_noise": (False, False, False, False, False), + "downsample_type": ("conv", "conv", "conv", "conv"), + "upsample_residual": (False, False, False, False), + "upsample_factor": (1, 1, 1, 1), + "patch_size": 4, + "patch_size_t": 1, + "resnet_norm_eps": 1e-6, + "scaling_factor": 1.0, + "encoder_causal": True, + "decoder_causal": False, + "timestep_conditioning": False, + } + elif version in ["0.9.1"]: + config = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 128, + "block_out_channels": (128, 256, 512, 512), + "down_block_types": ( + "LTXVideoDownBlock3D", + "LTXVideoDownBlock3D", + "LTXVideoDownBlock3D", + "LTXVideoDownBlock3D", + ), + "decoder_block_out_channels": (256, 512, 1024), + "layers_per_block": (4, 3, 3, 3, 4), + "decoder_layers_per_block": (5, 6, 7, 8), + "spatio_temporal_scaling": (True, True, True, False), + "decoder_spatio_temporal_scaling": (True, True, True), + "decoder_inject_noise": (True, True, True, False), + "downsample_type": ("conv", "conv", "conv", "conv"), + "upsample_residual": (True, True, True), + "upsample_factor": (2, 2, 2), + "timestep_conditioning": True, + "patch_size": 4, + "patch_size_t": 1, + "resnet_norm_eps": 1e-6, + "scaling_factor": 1.0, + "encoder_causal": True, + "decoder_causal": False, + } + VAE_KEYS_RENAME_DICT.update(VAE_091_RENAME_DICT) + elif version in ["0.9.5"]: + config = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 128, + "block_out_channels": (128, 256, 512, 1024, 2048), + "down_block_types": ( + "LTXVideo095DownBlock3D", + "LTXVideo095DownBlock3D", + "LTXVideo095DownBlock3D", + "LTXVideo095DownBlock3D", + ), + "decoder_block_out_channels": (256, 512, 1024), + "layers_per_block": (4, 6, 6, 2, 2), + "decoder_layers_per_block": (5, 5, 5, 5), + "spatio_temporal_scaling": (True, True, True, True), + "decoder_spatio_temporal_scaling": (True, True, True), + "decoder_inject_noise": (False, False, False, False), + "downsample_type": ("spatial", "temporal", "spatiotemporal", "spatiotemporal"), + "upsample_residual": (True, True, True), + "upsample_factor": (2, 2, 2), + "timestep_conditioning": True, + "patch_size": 4, + "patch_size_t": 1, + "resnet_norm_eps": 1e-6, + "scaling_factor": 1.0, + "encoder_causal": True, + "decoder_causal": False, + "spatial_compression_ratio": 32, + "temporal_compression_ratio": 8, + } + VAE_KEYS_RENAME_DICT.update(VAE_095_RENAME_DICT) + elif version in ["0.9.7"]: + config = { + "in_channels": 3, + "out_channels": 3, + "latent_channels": 128, + "block_out_channels": (128, 256, 512, 1024, 2048), + "down_block_types": ( + "LTXVideo095DownBlock3D", + "LTXVideo095DownBlock3D", + "LTXVideo095DownBlock3D", + "LTXVideo095DownBlock3D", + ), + "decoder_block_out_channels": (256, 512, 1024), + "layers_per_block": (4, 6, 6, 2, 2), + "decoder_layers_per_block": (5, 5, 5, 5), + "spatio_temporal_scaling": (True, True, True, True), + "decoder_spatio_temporal_scaling": (True, True, True), + "decoder_inject_noise": (False, False, False, False), + "downsample_type": ("spatial", "temporal", "spatiotemporal", "spatiotemporal"), + "upsample_residual": (True, True, True), + "upsample_factor": (2, 2, 2), + "timestep_conditioning": True, + "patch_size": 4, + "patch_size_t": 1, + "resnet_norm_eps": 1e-6, + "scaling_factor": 1.0, + "encoder_causal": True, + "decoder_causal": False, + "spatial_compression_ratio": 32, + "temporal_compression_ratio": 8, + } + VAE_KEYS_RENAME_DICT.update(VAE_095_RENAME_DICT) + return config + + +def get_spatial_latent_upsampler_config(version: str) -> Dict[str, Any]: + if version == "0.9.7": + config = { + "in_channels": 128, + "mid_channels": 512, + "num_blocks_per_stage": 4, + "dims": 3, + "spatial_upsample": True, + "temporal_upsample": False, + } + elif version == "0.9.8": + config = { + "in_channels": 128, + "mid_channels": 512, + "num_blocks_per_stage": 4, + "dims": 3, + "spatial_upsample": True, + "temporal_upsample": False, + } + else: + raise ValueError(f"Unsupported version: {version}") + return config + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--transformer_ckpt_path", type=str, default=None, help="Path to original transformer checkpoint" + ) + parser.add_argument("--vae_ckpt_path", type=str, default=None, help="Path to original vae checkpoint") + parser.add_argument( + "--spatial_latent_upsampler_path", + type=str, + default=None, + help="Path to original spatial latent upsampler checkpoint", + ) + parser.add_argument( + "--text_encoder_cache_dir", type=str, default=None, help="Path to text encoder cache directory" + ) + parser.add_argument( + "--typecast_text_encoder", + action="store_true", + default=False, + help="Whether or not to apply fp16/bf16 precision to text_encoder", + ) + parser.add_argument("--save_pipeline", action="store_true") + parser.add_argument("--output_path", type=str, required=True, help="Path where converted model should be saved") + parser.add_argument("--dtype", default="fp32", help="Torch dtype to save the model in.") + parser.add_argument( + "--version", + type=str, + default="0.9.0", + choices=["0.9.0", "0.9.1", "0.9.5", "0.9.7", "0.9.8"], + help="Version of the LTX model", + ) + return parser.parse_args() + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + +VARIANT_MAPPING = { + "fp32": None, + "fp16": "fp16", + "bf16": "bf16", +} + + +if __name__ == "__main__": + args = get_args() + + transformer = None + dtype = DTYPE_MAPPING[args.dtype] + variant = VARIANT_MAPPING[args.dtype] + output_path = Path(args.output_path) + + if args.transformer_ckpt_path is not None: + config = get_transformer_config(args.version) + transformer: LTXVideoTransformer3DModel = convert_transformer(args.transformer_ckpt_path, config, dtype) + if not args.save_pipeline: + transformer.save_pretrained( + output_path / "transformer", safe_serialization=True, max_shard_size="5GB", variant=variant + ) + + if args.vae_ckpt_path is not None: + config = get_vae_config(args.version) + vae: AutoencoderKLLTXVideo = convert_vae(args.vae_ckpt_path, config, dtype) + if not args.save_pipeline: + vae.save_pretrained(output_path / "vae", safe_serialization=True, max_shard_size="5GB", variant=variant) + + if args.spatial_latent_upsampler_path is not None: + config = get_spatial_latent_upsampler_config(args.version) + latent_upsampler: LTXLatentUpsamplerModel = convert_spatial_latent_upsampler( + args.spatial_latent_upsampler_path, config, dtype + ) + if not args.save_pipeline: + latent_upsampler.save_pretrained( + output_path / "latent_upsampler", safe_serialization=True, max_shard_size="5GB", variant=variant + ) + + if args.save_pipeline: + text_encoder_id = "google/t5-v1_1-xxl" + tokenizer = T5Tokenizer.from_pretrained(text_encoder_id, model_max_length=TOKENIZER_MAX_LENGTH) + text_encoder = T5EncoderModel.from_pretrained(text_encoder_id, cache_dir=args.text_encoder_cache_dir) + + if args.typecast_text_encoder: + text_encoder = text_encoder.to(dtype=dtype) + + # Apparently, the conversion does not work anymore without this :shrug: + for param in text_encoder.parameters(): + param.data = param.data.contiguous() + + if args.version in ["0.9.5", "0.9.7"]: + scheduler = FlowMatchEulerDiscreteScheduler(use_dynamic_shifting=False) + else: + scheduler = FlowMatchEulerDiscreteScheduler( + use_dynamic_shifting=True, + base_shift=0.95, + max_shift=2.05, + base_image_seq_len=1024, + max_image_seq_len=4096, + shift_terminal=0.1, + ) + + if args.version in ["0.9.0", "0.9.1", "0.9.5"]: + pipe = LTXPipeline( + scheduler=scheduler, + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + transformer=transformer, + ) + pipe.save_pretrained( + output_path.as_posix(), safe_serialization=True, variant=variant, max_shard_size="5GB" + ) + elif args.version in ["0.9.7"]: + pipe = LTXConditionPipeline( + scheduler=scheduler, + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + transformer=transformer, + ) + pipe_upsample = LTXLatentUpsamplePipeline( + vae=vae, + latent_upsampler=latent_upsampler, + ) + pipe.save_pretrained( + (output_path / "ltx_pipeline").as_posix(), + safe_serialization=True, + variant=variant, + max_shard_size="5GB", + ) + pipe_upsample.save_pretrained( + (output_path / "ltx_upsample_pipeline").as_posix(), + safe_serialization=True, + variant=variant, + max_shard_size="5GB", + ) + else: + raise ValueError(f"Unsupported version: {args.version}") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_lumina_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_lumina_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..c14aad3c6bf2fba8e663bf81293a3308395011fe --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_lumina_to_diffusers.py @@ -0,0 +1,142 @@ +import argparse +import os + +import torch +from safetensors.torch import load_file +from transformers import AutoModel, AutoTokenizer + +from diffusers import AutoencoderKL, FlowMatchEulerDiscreteScheduler, LuminaNextDiT2DModel, LuminaPipeline + + +def main(args): + # checkpoint from https://huggingface.co/Alpha-VLLM/Lumina-Next-SFT or https://huggingface.co/Alpha-VLLM/Lumina-Next-T2I + all_sd = load_file(args.origin_ckpt_path, device="cpu") + converted_state_dict = {} + # pad token + converted_state_dict["pad_token"] = all_sd["pad_token"] + + # patch embed + converted_state_dict["patch_embedder.weight"] = all_sd["x_embedder.weight"] + converted_state_dict["patch_embedder.bias"] = all_sd["x_embedder.bias"] + + # time and caption embed + converted_state_dict["time_caption_embed.timestep_embedder.linear_1.weight"] = all_sd["t_embedder.mlp.0.weight"] + converted_state_dict["time_caption_embed.timestep_embedder.linear_1.bias"] = all_sd["t_embedder.mlp.0.bias"] + converted_state_dict["time_caption_embed.timestep_embedder.linear_2.weight"] = all_sd["t_embedder.mlp.2.weight"] + converted_state_dict["time_caption_embed.timestep_embedder.linear_2.bias"] = all_sd["t_embedder.mlp.2.bias"] + converted_state_dict["time_caption_embed.caption_embedder.0.weight"] = all_sd["cap_embedder.0.weight"] + converted_state_dict["time_caption_embed.caption_embedder.0.bias"] = all_sd["cap_embedder.0.bias"] + converted_state_dict["time_caption_embed.caption_embedder.1.weight"] = all_sd["cap_embedder.1.weight"] + converted_state_dict["time_caption_embed.caption_embedder.1.bias"] = all_sd["cap_embedder.1.bias"] + + for i in range(24): + # adaln + converted_state_dict[f"layers.{i}.gate"] = all_sd[f"layers.{i}.attention.gate"] + converted_state_dict[f"layers.{i}.adaLN_modulation.1.weight"] = all_sd[f"layers.{i}.adaLN_modulation.1.weight"] + converted_state_dict[f"layers.{i}.adaLN_modulation.1.bias"] = all_sd[f"layers.{i}.adaLN_modulation.1.bias"] + + # qkv + converted_state_dict[f"layers.{i}.attn1.to_q.weight"] = all_sd[f"layers.{i}.attention.wq.weight"] + converted_state_dict[f"layers.{i}.attn1.to_k.weight"] = all_sd[f"layers.{i}.attention.wk.weight"] + converted_state_dict[f"layers.{i}.attn1.to_v.weight"] = all_sd[f"layers.{i}.attention.wv.weight"] + + # cap + converted_state_dict[f"layers.{i}.attn2.to_q.weight"] = all_sd[f"layers.{i}.attention.wq.weight"] + converted_state_dict[f"layers.{i}.attn2.to_k.weight"] = all_sd[f"layers.{i}.attention.wk_y.weight"] + converted_state_dict[f"layers.{i}.attn2.to_v.weight"] = all_sd[f"layers.{i}.attention.wv_y.weight"] + + # output + converted_state_dict[f"layers.{i}.attn2.to_out.0.weight"] = all_sd[f"layers.{i}.attention.wo.weight"] + + # attention + # qk norm + converted_state_dict[f"layers.{i}.attn1.norm_q.weight"] = all_sd[f"layers.{i}.attention.q_norm.weight"] + converted_state_dict[f"layers.{i}.attn1.norm_q.bias"] = all_sd[f"layers.{i}.attention.q_norm.bias"] + + converted_state_dict[f"layers.{i}.attn1.norm_k.weight"] = all_sd[f"layers.{i}.attention.k_norm.weight"] + converted_state_dict[f"layers.{i}.attn1.norm_k.bias"] = all_sd[f"layers.{i}.attention.k_norm.bias"] + + converted_state_dict[f"layers.{i}.attn2.norm_q.weight"] = all_sd[f"layers.{i}.attention.q_norm.weight"] + converted_state_dict[f"layers.{i}.attn2.norm_q.bias"] = all_sd[f"layers.{i}.attention.q_norm.bias"] + + converted_state_dict[f"layers.{i}.attn2.norm_k.weight"] = all_sd[f"layers.{i}.attention.ky_norm.weight"] + converted_state_dict[f"layers.{i}.attn2.norm_k.bias"] = all_sd[f"layers.{i}.attention.ky_norm.bias"] + + # attention norm + converted_state_dict[f"layers.{i}.attn_norm1.weight"] = all_sd[f"layers.{i}.attention_norm1.weight"] + converted_state_dict[f"layers.{i}.attn_norm2.weight"] = all_sd[f"layers.{i}.attention_norm2.weight"] + converted_state_dict[f"layers.{i}.norm1_context.weight"] = all_sd[f"layers.{i}.attention_y_norm.weight"] + + # feed forward + converted_state_dict[f"layers.{i}.feed_forward.linear_1.weight"] = all_sd[f"layers.{i}.feed_forward.w1.weight"] + converted_state_dict[f"layers.{i}.feed_forward.linear_2.weight"] = all_sd[f"layers.{i}.feed_forward.w2.weight"] + converted_state_dict[f"layers.{i}.feed_forward.linear_3.weight"] = all_sd[f"layers.{i}.feed_forward.w3.weight"] + + # feed forward norm + converted_state_dict[f"layers.{i}.ffn_norm1.weight"] = all_sd[f"layers.{i}.ffn_norm1.weight"] + converted_state_dict[f"layers.{i}.ffn_norm2.weight"] = all_sd[f"layers.{i}.ffn_norm2.weight"] + + # final layer + converted_state_dict["final_layer.linear.weight"] = all_sd["final_layer.linear.weight"] + converted_state_dict["final_layer.linear.bias"] = all_sd["final_layer.linear.bias"] + + converted_state_dict["final_layer.adaLN_modulation.1.weight"] = all_sd["final_layer.adaLN_modulation.1.weight"] + converted_state_dict["final_layer.adaLN_modulation.1.bias"] = all_sd["final_layer.adaLN_modulation.1.bias"] + + # Lumina-Next-SFT 2B + transformer = LuminaNextDiT2DModel( + sample_size=128, + patch_size=2, + in_channels=4, + hidden_size=2304, + num_layers=24, + num_attention_heads=32, + num_kv_heads=8, + multiple_of=256, + ffn_dim_multiplier=None, + norm_eps=1e-5, + learn_sigma=True, + qk_norm=True, + cross_attention_dim=2048, + scaling_factor=1.0, + ) + transformer.load_state_dict(converted_state_dict, strict=True) + + num_model_params = sum(p.numel() for p in transformer.parameters()) + print(f"Total number of transformer parameters: {num_model_params}") + + if args.only_transformer: + transformer.save_pretrained(os.path.join(args.dump_path, "transformer")) + else: + scheduler = FlowMatchEulerDiscreteScheduler() + + vae = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae", torch_dtype=torch.float32) + + tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b") + text_encoder = AutoModel.from_pretrained("google/gemma-2b") + + pipeline = LuminaPipeline( + tokenizer=tokenizer, text_encoder=text_encoder, transformer=transformer, vae=vae, scheduler=scheduler + ) + pipeline.save_pretrained(args.dump_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--origin_ckpt_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--image_size", + default=1024, + type=int, + choices=[256, 512, 1024], + required=False, + help="Image size of pretrained model, either 512 or 1024.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.") + parser.add_argument("--only_transformer", default=True, type=bool, required=True) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_mochi_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_mochi_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..64e4f69eac178d02684e3a6c7211f71d43dad14c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_mochi_to_diffusers.py @@ -0,0 +1,463 @@ +import argparse +from contextlib import nullcontext + +import torch +from accelerate import init_empty_weights +from safetensors.torch import load_file +from transformers import T5EncoderModel, T5Tokenizer + +from diffusers import AutoencoderKLMochi, FlowMatchEulerDiscreteScheduler, MochiPipeline, MochiTransformer3DModel +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available() else nullcontext + +TOKENIZER_MAX_LENGTH = 256 + +parser = argparse.ArgumentParser() +parser.add_argument("--transformer_checkpoint_path", default=None, type=str) +parser.add_argument("--vae_encoder_checkpoint_path", default=None, type=str) +parser.add_argument("--vae_decoder_checkpoint_path", default=None, type=str) +parser.add_argument("--output_path", required=True, type=str) +parser.add_argument("--push_to_hub", action="store_true", default=False, help="Whether to push to HF Hub after saving") +parser.add_argument("--text_encoder_cache_dir", type=str, default=None, help="Path to text encoder cache directory") +parser.add_argument("--dtype", type=str, default=None) + +args = parser.parse_args() + + +# This is specific to `AdaLayerNormContinuous`: +# Diffusers implementation split the linear projection into the scale, shift while Mochi split it into shift, scale +def swap_scale_shift(weight, dim): + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + return new_weight + + +def swap_proj_gate(weight): + proj, gate = weight.chunk(2, dim=0) + new_weight = torch.cat([gate, proj], dim=0) + return new_weight + + +def convert_mochi_transformer_checkpoint_to_diffusers(ckpt_path): + original_state_dict = load_file(ckpt_path, device="cpu") + new_state_dict = {} + + # Convert patch_embed + new_state_dict["patch_embed.proj.weight"] = original_state_dict.pop("x_embedder.proj.weight") + new_state_dict["patch_embed.proj.bias"] = original_state_dict.pop("x_embedder.proj.bias") + + # Convert time_embed + new_state_dict["time_embed.timestep_embedder.linear_1.weight"] = original_state_dict.pop("t_embedder.mlp.0.weight") + new_state_dict["time_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop("t_embedder.mlp.0.bias") + new_state_dict["time_embed.timestep_embedder.linear_2.weight"] = original_state_dict.pop("t_embedder.mlp.2.weight") + new_state_dict["time_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop("t_embedder.mlp.2.bias") + new_state_dict["time_embed.pooler.to_kv.weight"] = original_state_dict.pop("t5_y_embedder.to_kv.weight") + new_state_dict["time_embed.pooler.to_kv.bias"] = original_state_dict.pop("t5_y_embedder.to_kv.bias") + new_state_dict["time_embed.pooler.to_q.weight"] = original_state_dict.pop("t5_y_embedder.to_q.weight") + new_state_dict["time_embed.pooler.to_q.bias"] = original_state_dict.pop("t5_y_embedder.to_q.bias") + new_state_dict["time_embed.pooler.to_out.weight"] = original_state_dict.pop("t5_y_embedder.to_out.weight") + new_state_dict["time_embed.pooler.to_out.bias"] = original_state_dict.pop("t5_y_embedder.to_out.bias") + new_state_dict["time_embed.caption_proj.weight"] = original_state_dict.pop("t5_yproj.weight") + new_state_dict["time_embed.caption_proj.bias"] = original_state_dict.pop("t5_yproj.bias") + + # Convert transformer blocks + num_layers = 48 + for i in range(num_layers): + block_prefix = f"transformer_blocks.{i}." + old_prefix = f"blocks.{i}." + + # norm1 + new_state_dict[block_prefix + "norm1.linear.weight"] = original_state_dict.pop(old_prefix + "mod_x.weight") + new_state_dict[block_prefix + "norm1.linear.bias"] = original_state_dict.pop(old_prefix + "mod_x.bias") + if i < num_layers - 1: + new_state_dict[block_prefix + "norm1_context.linear.weight"] = original_state_dict.pop( + old_prefix + "mod_y.weight" + ) + new_state_dict[block_prefix + "norm1_context.linear.bias"] = original_state_dict.pop( + old_prefix + "mod_y.bias" + ) + else: + new_state_dict[block_prefix + "norm1_context.linear_1.weight"] = original_state_dict.pop( + old_prefix + "mod_y.weight" + ) + new_state_dict[block_prefix + "norm1_context.linear_1.bias"] = original_state_dict.pop( + old_prefix + "mod_y.bias" + ) + + # Visual attention + qkv_weight = original_state_dict.pop(old_prefix + "attn.qkv_x.weight") + q, k, v = qkv_weight.chunk(3, dim=0) + + new_state_dict[block_prefix + "attn1.to_q.weight"] = q + new_state_dict[block_prefix + "attn1.to_k.weight"] = k + new_state_dict[block_prefix + "attn1.to_v.weight"] = v + new_state_dict[block_prefix + "attn1.norm_q.weight"] = original_state_dict.pop( + old_prefix + "attn.q_norm_x.weight" + ) + new_state_dict[block_prefix + "attn1.norm_k.weight"] = original_state_dict.pop( + old_prefix + "attn.k_norm_x.weight" + ) + new_state_dict[block_prefix + "attn1.to_out.0.weight"] = original_state_dict.pop( + old_prefix + "attn.proj_x.weight" + ) + new_state_dict[block_prefix + "attn1.to_out.0.bias"] = original_state_dict.pop(old_prefix + "attn.proj_x.bias") + + # Context attention + qkv_weight = original_state_dict.pop(old_prefix + "attn.qkv_y.weight") + q, k, v = qkv_weight.chunk(3, dim=0) + + new_state_dict[block_prefix + "attn1.add_q_proj.weight"] = q + new_state_dict[block_prefix + "attn1.add_k_proj.weight"] = k + new_state_dict[block_prefix + "attn1.add_v_proj.weight"] = v + new_state_dict[block_prefix + "attn1.norm_added_q.weight"] = original_state_dict.pop( + old_prefix + "attn.q_norm_y.weight" + ) + new_state_dict[block_prefix + "attn1.norm_added_k.weight"] = original_state_dict.pop( + old_prefix + "attn.k_norm_y.weight" + ) + if i < num_layers - 1: + new_state_dict[block_prefix + "attn1.to_add_out.weight"] = original_state_dict.pop( + old_prefix + "attn.proj_y.weight" + ) + new_state_dict[block_prefix + "attn1.to_add_out.bias"] = original_state_dict.pop( + old_prefix + "attn.proj_y.bias" + ) + + # MLP + new_state_dict[block_prefix + "ff.net.0.proj.weight"] = swap_proj_gate( + original_state_dict.pop(old_prefix + "mlp_x.w1.weight") + ) + new_state_dict[block_prefix + "ff.net.2.weight"] = original_state_dict.pop(old_prefix + "mlp_x.w2.weight") + if i < num_layers - 1: + new_state_dict[block_prefix + "ff_context.net.0.proj.weight"] = swap_proj_gate( + original_state_dict.pop(old_prefix + "mlp_y.w1.weight") + ) + new_state_dict[block_prefix + "ff_context.net.2.weight"] = original_state_dict.pop( + old_prefix + "mlp_y.w2.weight" + ) + + # Output layers + new_state_dict["norm_out.linear.weight"] = swap_scale_shift( + original_state_dict.pop("final_layer.mod.weight"), dim=0 + ) + new_state_dict["norm_out.linear.bias"] = swap_scale_shift(original_state_dict.pop("final_layer.mod.bias"), dim=0) + new_state_dict["proj_out.weight"] = original_state_dict.pop("final_layer.linear.weight") + new_state_dict["proj_out.bias"] = original_state_dict.pop("final_layer.linear.bias") + + new_state_dict["pos_frequencies"] = original_state_dict.pop("pos_frequencies") + + print("Remaining Keys:", original_state_dict.keys()) + + return new_state_dict + + +def convert_mochi_vae_state_dict_to_diffusers(encoder_ckpt_path, decoder_ckpt_path): + encoder_state_dict = load_file(encoder_ckpt_path, device="cpu") + decoder_state_dict = load_file(decoder_ckpt_path, device="cpu") + new_state_dict = {} + + # ==== Decoder ===== + prefix = "decoder." + + # Convert conv_in + new_state_dict[f"{prefix}conv_in.weight"] = decoder_state_dict.pop("blocks.0.0.weight") + new_state_dict[f"{prefix}conv_in.bias"] = decoder_state_dict.pop("blocks.0.0.bias") + + # Convert block_in (MochiMidBlock3D) + for i in range(3): # layers_per_block[-1] = 3 + new_state_dict[f"{prefix}block_in.resnets.{i}.norm1.norm_layer.weight"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.0.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.norm1.norm_layer.bias"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.0.bias" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv1.conv.weight"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.2.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv1.conv.bias"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.2.bias" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.norm2.norm_layer.weight"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.3.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.norm2.norm_layer.bias"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.3.bias" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv2.conv.weight"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.5.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv2.conv.bias"] = decoder_state_dict.pop( + f"blocks.0.{i + 1}.stack.5.bias" + ) + + # Convert up_blocks (MochiUpBlock3D) + down_block_layers = [6, 4, 3] # layers_per_block[-2], layers_per_block[-3], layers_per_block[-4] + for block in range(3): + for i in range(down_block_layers[block]): + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.norm1.norm_layer.weight"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.0.weight" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.norm1.norm_layer.bias"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.0.bias" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.conv1.conv.weight"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.2.weight" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.conv1.conv.bias"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.2.bias" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.norm2.norm_layer.weight"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.3.weight" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.norm2.norm_layer.bias"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.3.bias" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.conv2.conv.weight"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.5.weight" + ) + new_state_dict[f"{prefix}up_blocks.{block}.resnets.{i}.conv2.conv.bias"] = decoder_state_dict.pop( + f"blocks.{block + 1}.blocks.{i}.stack.5.bias" + ) + new_state_dict[f"{prefix}up_blocks.{block}.proj.weight"] = decoder_state_dict.pop( + f"blocks.{block + 1}.proj.weight" + ) + new_state_dict[f"{prefix}up_blocks.{block}.proj.bias"] = decoder_state_dict.pop( + f"blocks.{block + 1}.proj.bias" + ) + + # Convert block_out (MochiMidBlock3D) + for i in range(3): # layers_per_block[0] = 3 + new_state_dict[f"{prefix}block_out.resnets.{i}.norm1.norm_layer.weight"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.0.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.norm1.norm_layer.bias"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.0.bias" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv1.conv.weight"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.2.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv1.conv.bias"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.2.bias" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.norm2.norm_layer.weight"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.3.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.norm2.norm_layer.bias"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.3.bias" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv2.conv.weight"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.5.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv2.conv.bias"] = decoder_state_dict.pop( + f"blocks.4.{i}.stack.5.bias" + ) + + # Convert proj_out (Conv1x1 ~= nn.Linear) + new_state_dict[f"{prefix}proj_out.weight"] = decoder_state_dict.pop("output_proj.weight") + new_state_dict[f"{prefix}proj_out.bias"] = decoder_state_dict.pop("output_proj.bias") + + print("Remaining Decoder Keys:", decoder_state_dict.keys()) + + # ==== Encoder ===== + prefix = "encoder." + + new_state_dict[f"{prefix}proj_in.weight"] = encoder_state_dict.pop("layers.0.weight") + new_state_dict[f"{prefix}proj_in.bias"] = encoder_state_dict.pop("layers.0.bias") + + # Convert block_in (MochiMidBlock3D) + for i in range(3): # layers_per_block[0] = 3 + new_state_dict[f"{prefix}block_in.resnets.{i}.norm1.norm_layer.weight"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.0.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.norm1.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.0.bias" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv1.conv.weight"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.2.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv1.conv.bias"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.2.bias" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.norm2.norm_layer.weight"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.3.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.norm2.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.3.bias" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv2.conv.weight"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.5.weight" + ) + new_state_dict[f"{prefix}block_in.resnets.{i}.conv2.conv.bias"] = encoder_state_dict.pop( + f"layers.{i + 1}.stack.5.bias" + ) + + # Convert down_blocks (MochiDownBlock3D) + down_block_layers = [3, 4, 6] # layers_per_block[1], layers_per_block[2], layers_per_block[3] + for block in range(3): + new_state_dict[f"{prefix}down_blocks.{block}.conv_in.conv.weight"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.0.weight" + ) + new_state_dict[f"{prefix}down_blocks.{block}.conv_in.conv.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.0.bias" + ) + + for i in range(down_block_layers[block]): + # Convert resnets + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.norm1.norm_layer.weight"] = ( + encoder_state_dict.pop(f"layers.{block + 4}.layers.{i + 1}.stack.0.weight") + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.norm1.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.stack.0.bias" + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.conv1.conv.weight"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.stack.2.weight" + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.conv1.conv.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.stack.2.bias" + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.norm2.norm_layer.weight"] = ( + encoder_state_dict.pop(f"layers.{block + 4}.layers.{i + 1}.stack.3.weight") + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.norm2.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.stack.3.bias" + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.conv2.conv.weight"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.stack.5.weight" + ) + new_state_dict[f"{prefix}down_blocks.{block}.resnets.{i}.conv2.conv.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.stack.5.bias" + ) + + # Convert attentions + qkv_weight = encoder_state_dict.pop(f"layers.{block + 4}.layers.{i + 1}.attn_block.attn.qkv.weight") + q, k, v = qkv_weight.chunk(3, dim=0) + + new_state_dict[f"{prefix}down_blocks.{block}.attentions.{i}.to_q.weight"] = q + new_state_dict[f"{prefix}down_blocks.{block}.attentions.{i}.to_k.weight"] = k + new_state_dict[f"{prefix}down_blocks.{block}.attentions.{i}.to_v.weight"] = v + new_state_dict[f"{prefix}down_blocks.{block}.attentions.{i}.to_out.0.weight"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.attn_block.attn.out.weight" + ) + new_state_dict[f"{prefix}down_blocks.{block}.attentions.{i}.to_out.0.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.attn_block.attn.out.bias" + ) + new_state_dict[f"{prefix}down_blocks.{block}.norms.{i}.norm_layer.weight"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.attn_block.norm.weight" + ) + new_state_dict[f"{prefix}down_blocks.{block}.norms.{i}.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{block + 4}.layers.{i + 1}.attn_block.norm.bias" + ) + + # Convert block_out (MochiMidBlock3D) + for i in range(3): # layers_per_block[-1] = 3 + # Convert resnets + new_state_dict[f"{prefix}block_out.resnets.{i}.norm1.norm_layer.weight"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.0.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.norm1.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.0.bias" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv1.conv.weight"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.2.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv1.conv.bias"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.2.bias" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.norm2.norm_layer.weight"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.3.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.norm2.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.3.bias" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv2.conv.weight"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.5.weight" + ) + new_state_dict[f"{prefix}block_out.resnets.{i}.conv2.conv.bias"] = encoder_state_dict.pop( + f"layers.{i + 7}.stack.5.bias" + ) + + # Convert attentions + qkv_weight = encoder_state_dict.pop(f"layers.{i + 7}.attn_block.attn.qkv.weight") + q, k, v = qkv_weight.chunk(3, dim=0) + + new_state_dict[f"{prefix}block_out.attentions.{i}.to_q.weight"] = q + new_state_dict[f"{prefix}block_out.attentions.{i}.to_k.weight"] = k + new_state_dict[f"{prefix}block_out.attentions.{i}.to_v.weight"] = v + new_state_dict[f"{prefix}block_out.attentions.{i}.to_out.0.weight"] = encoder_state_dict.pop( + f"layers.{i + 7}.attn_block.attn.out.weight" + ) + new_state_dict[f"{prefix}block_out.attentions.{i}.to_out.0.bias"] = encoder_state_dict.pop( + f"layers.{i + 7}.attn_block.attn.out.bias" + ) + new_state_dict[f"{prefix}block_out.norms.{i}.norm_layer.weight"] = encoder_state_dict.pop( + f"layers.{i + 7}.attn_block.norm.weight" + ) + new_state_dict[f"{prefix}block_out.norms.{i}.norm_layer.bias"] = encoder_state_dict.pop( + f"layers.{i + 7}.attn_block.norm.bias" + ) + + # Convert output layers + new_state_dict[f"{prefix}norm_out.norm_layer.weight"] = encoder_state_dict.pop("output_norm.weight") + new_state_dict[f"{prefix}norm_out.norm_layer.bias"] = encoder_state_dict.pop("output_norm.bias") + new_state_dict[f"{prefix}proj_out.weight"] = encoder_state_dict.pop("output_proj.weight") + + print("Remaining Encoder Keys:", encoder_state_dict.keys()) + + return new_state_dict + + +def main(args): + if args.dtype is None: + dtype = None + if args.dtype == "fp16": + dtype = torch.float16 + elif args.dtype == "bf16": + dtype = torch.bfloat16 + elif args.dtype == "fp32": + dtype = torch.float32 + else: + raise ValueError(f"Unsupported dtype: {args.dtype}") + + transformer = None + vae = None + + if args.transformer_checkpoint_path is not None: + converted_transformer_state_dict = convert_mochi_transformer_checkpoint_to_diffusers( + args.transformer_checkpoint_path + ) + transformer = MochiTransformer3DModel() + transformer.load_state_dict(converted_transformer_state_dict, strict=True) + if dtype is not None: + transformer = transformer.to(dtype=dtype) + + if args.vae_encoder_checkpoint_path is not None and args.vae_decoder_checkpoint_path is not None: + vae = AutoencoderKLMochi(latent_channels=12, out_channels=3) + converted_vae_state_dict = convert_mochi_vae_state_dict_to_diffusers( + args.vae_encoder_checkpoint_path, args.vae_decoder_checkpoint_path + ) + vae.load_state_dict(converted_vae_state_dict, strict=True) + if dtype is not None: + vae = vae.to(dtype=dtype) + + text_encoder_id = "google/t5-v1_1-xxl" + tokenizer = T5Tokenizer.from_pretrained(text_encoder_id, model_max_length=TOKENIZER_MAX_LENGTH) + text_encoder = T5EncoderModel.from_pretrained(text_encoder_id, cache_dir=args.text_encoder_cache_dir) + + # Apparently, the conversion does not work anymore without this :shrug: + for param in text_encoder.parameters(): + param.data = param.data.contiguous() + + pipe = MochiPipeline( + scheduler=FlowMatchEulerDiscreteScheduler(invert_sigmas=True), + vae=vae, + text_encoder=text_encoder, + tokenizer=tokenizer, + transformer=transformer, + ) + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB", push_to_hub=args.push_to_hub) + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_models_diffuser_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_models_diffuser_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..cc5321e33fe088c652f6014c6dab813bb8d5f246 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_models_diffuser_to_diffusers.py @@ -0,0 +1,100 @@ +import json +import os + +import torch + +from diffusers import UNet1DModel + + +os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) +os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) + +os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) + + +def unet(hor): + if hor == 128: + down_block_types = ("DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D") + block_out_channels = (32, 128, 256) + up_block_types = ("UpResnetBlock1D", "UpResnetBlock1D") + + elif hor == 32: + down_block_types = ("DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D") + block_out_channels = (32, 64, 128, 256) + up_block_types = ("UpResnetBlock1D", "UpResnetBlock1D", "UpResnetBlock1D") + model = torch.load(f"/Users/bglickenhaus/Documents/diffuser/temporal_unet-hopper-mediumv2-hor{hor}.torch") + state_dict = model.state_dict() + config = { + "down_block_types": down_block_types, + "block_out_channels": block_out_channels, + "up_block_types": up_block_types, + "layers_per_block": 1, + "use_timestep_embedding": True, + "out_block_type": "OutConv1DBlock", + "norm_num_groups": 8, + "downsample_each_block": False, + "in_channels": 14, + "out_channels": 14, + "extra_in_channels": 0, + "time_embedding_type": "positional", + "flip_sin_to_cos": False, + "freq_shift": 1, + "sample_size": 65536, + "mid_block_type": "MidResTemporalBlock1D", + "act_fn": "mish", + } + hf_value_function = UNet1DModel(**config) + print(f"length of state dict: {len(state_dict.keys())}") + print(f"length of value function dict: {len(hf_value_function.state_dict().keys())}") + mapping = dict(zip(model.state_dict().keys(), hf_value_function.state_dict().keys())) + for k, v in mapping.items(): + state_dict[v] = state_dict.pop(k) + hf_value_function.load_state_dict(state_dict) + + torch.save(hf_value_function.state_dict(), f"hub/hopper-medium-v2/unet/hor{hor}/diffusion_pytorch_model.bin") + with open(f"hub/hopper-medium-v2/unet/hor{hor}/config.json", "w") as f: + json.dump(config, f) + + +def value_function(): + config = { + "in_channels": 14, + "down_block_types": ("DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D"), + "up_block_types": (), + "out_block_type": "ValueFunction", + "mid_block_type": "ValueFunctionMidBlock1D", + "block_out_channels": (32, 64, 128, 256), + "layers_per_block": 1, + "downsample_each_block": True, + "sample_size": 65536, + "out_channels": 14, + "extra_in_channels": 0, + "time_embedding_type": "positional", + "use_timestep_embedding": True, + "flip_sin_to_cos": False, + "freq_shift": 1, + "norm_num_groups": 8, + "act_fn": "mish", + } + + model = torch.load("/Users/bglickenhaus/Documents/diffuser/value_function-hopper-mediumv2-hor32.torch") + state_dict = model + hf_value_function = UNet1DModel(**config) + print(f"length of state dict: {len(state_dict.keys())}") + print(f"length of value function dict: {len(hf_value_function.state_dict().keys())}") + + mapping = dict(zip(state_dict.keys(), hf_value_function.state_dict().keys())) + for k, v in mapping.items(): + state_dict[v] = state_dict.pop(k) + + hf_value_function.load_state_dict(state_dict) + + torch.save(hf_value_function.state_dict(), "hub/hopper-medium-v2/value_function/diffusion_pytorch_model.bin") + with open("hub/hopper-medium-v2/value_function/config.json", "w") as f: + json.dump(config, f) + + +if __name__ == "__main__": + unet(32) + # unet(128) + value_function() diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ms_text_to_video_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ms_text_to_video_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..e150a491a0b0d16f7b3145effe79dc96b92f0beb --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ms_text_to_video_to_diffusers.py @@ -0,0 +1,428 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the LDM checkpoints.""" + +import argparse + +import torch + +from diffusers import UNet3DConditionModel + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + weight = old_checkpoint[path["old"]] + names = ["proj_attn.weight"] + names_2 = ["proj_out.weight", "proj_in.weight"] + if any(k in new_path for k in names): + checkpoint[new_path] = weight[:, :, 0] + elif any(k in new_path for k in names_2) and len(weight.shape) > 2 and ".attentions." not in new_path: + checkpoint[new_path] = weight[:, :, 0] + else: + checkpoint[new_path] = weight + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_temp_conv_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + mapping.append({"old": old_item, "new": old_item}) + + return mapping + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + if "temopral_conv" not in old_item: + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + print(f"Checkpoint {path} has both EMA and non-EMA weights.") + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + if config["class_embed_type"] is None: + # No parameters to port + ... + elif config["class_embed_type"] == "timestep" or config["class_embed_type"] == "projection": + new_checkpoint["class_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["class_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["class_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["class_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + else: + raise NotImplementedError(f"Not implemented `class_embed_type`: {config['class_embed_type']}") + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + first_temp_attention = [v for v in unet_state_dict if v.startswith("input_blocks.0.1")] + paths = renew_attention_paths(first_temp_attention) + meta_path = {"old": "input_blocks.0.1", "new": "transformer_in"} + assign_to_checkpoint(paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config) + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + temp_attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.2" in key] + + if f"input_blocks.{i}.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + temporal_convs = [key for key in resnets if "temopral_conv" in key] + paths = renew_temp_conv_paths(temporal_convs) + meta_path = { + "old": f"input_blocks.{i}.0.temopral_conv", + "new": f"down_blocks.{block_id}.temp_convs.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(temp_attentions): + paths = renew_attention_paths(temp_attentions) + meta_path = { + "old": f"input_blocks.{i}.2", + "new": f"down_blocks.{block_id}.temp_attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + temporal_convs_0 = [key for key in resnet_0 if "temopral_conv" in key] + attentions = middle_blocks[1] + temp_attentions = middle_blocks[2] + resnet_1 = middle_blocks[3] + temporal_convs_1 = [key for key in resnet_1 if "temopral_conv" in key] + + resnet_0_paths = renew_resnet_paths(resnet_0) + meta_path = {"old": "middle_block.0", "new": "mid_block.resnets.0"} + assign_to_checkpoint( + resnet_0_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + temp_conv_0_paths = renew_temp_conv_paths(temporal_convs_0) + meta_path = {"old": "middle_block.0.temopral_conv", "new": "mid_block.temp_convs.0"} + assign_to_checkpoint( + temp_conv_0_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + resnet_1_paths = renew_resnet_paths(resnet_1) + meta_path = {"old": "middle_block.3", "new": "mid_block.resnets.1"} + assign_to_checkpoint( + resnet_1_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + temp_conv_1_paths = renew_temp_conv_paths(temporal_convs_1) + meta_path = {"old": "middle_block.3.temopral_conv", "new": "mid_block.temp_convs.1"} + assign_to_checkpoint( + temp_conv_1_paths, new_checkpoint, unet_state_dict, config=config, additional_replacements=[meta_path] + ) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + temp_attentions_paths = renew_attention_paths(temp_attentions) + meta_path = {"old": "middle_block.2", "new": "mid_block.temp_attentions.0"} + assign_to_checkpoint( + temp_attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + temp_attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.2" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + temporal_convs = [key for key in resnets if "temopral_conv" in key] + paths = renew_temp_conv_paths(temporal_convs) + meta_path = { + "old": f"output_blocks.{i}.0.temopral_conv", + "new": f"up_blocks.{block_id}.temp_convs.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(temp_attentions): + paths = renew_attention_paths(temp_attentions) + meta_path = { + "old": f"output_blocks.{i}.2", + "new": f"up_blocks.{block_id}.temp_attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + new_checkpoint[new_path] = unet_state_dict[old_path] + + temopral_conv_paths = [l for l in output_block_layers if "temopral_conv" in l] + for path in temopral_conv_paths: + pruned_path = path.split("temopral_conv.")[-1] + old_path = ".".join(["output_blocks", str(i), str(block_id), "temopral_conv", pruned_path]) + new_path = ".".join(["up_blocks", str(block_id), "temp_convs", str(layer_in_block_id), pruned_path]) + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + args = parser.parse_args() + + unet_checkpoint = torch.load(args.checkpoint_path, map_location="cpu") + unet = UNet3DConditionModel() + + converted_ckpt = convert_ldm_unet_checkpoint(unet_checkpoint, unet.config) + + diff_0 = set(unet.state_dict().keys()) - set(converted_ckpt.keys()) + diff_1 = set(converted_ckpt.keys()) - set(unet.state_dict().keys()) + + assert len(diff_0) == len(diff_1) == 0, "Converted weights don't match" + + # load state_dict + unet.load_state_dict(converted_ckpt) + + unet.save_pretrained(args.dump_path) + + # -- finish converting the unet -- diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_music_spectrogram_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_music_spectrogram_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..1ac9ceddb57eb7bfe4bf26498f7fd573c5f390c1 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_music_spectrogram_to_diffusers.py @@ -0,0 +1,203 @@ +#!/usr/bin/env python3 +import argparse +import os + +import jax as jnp +import numpy as onp +import torch +import torch.nn as nn +from music_spectrogram_diffusion import inference +from t5x import checkpoints + +from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline +from diffusers.pipelines.spectrogram_diffusion import SpectrogramContEncoder, SpectrogramNotesEncoder, T5FilmDecoder + + +MODEL = "base_with_context" + + +def load_notes_encoder(weights, model): + model.token_embedder.weight = nn.Parameter(torch.Tensor(weights["token_embedder"]["embedding"])) + model.position_encoding.weight = nn.Parameter(torch.Tensor(weights["Embed_0"]["embedding"]), requires_grad=False) + for lyr_num, lyr in enumerate(model.encoders): + ly_weight = weights[f"layers_{lyr_num}"] + lyr.layer[0].layer_norm.weight = nn.Parameter(torch.Tensor(ly_weight["pre_attention_layer_norm"]["scale"])) + + attention_weights = ly_weight["attention"] + lyr.layer[0].SelfAttention.q.weight = nn.Parameter(torch.Tensor(attention_weights["query"]["kernel"].T)) + lyr.layer[0].SelfAttention.k.weight = nn.Parameter(torch.Tensor(attention_weights["key"]["kernel"].T)) + lyr.layer[0].SelfAttention.v.weight = nn.Parameter(torch.Tensor(attention_weights["value"]["kernel"].T)) + lyr.layer[0].SelfAttention.o.weight = nn.Parameter(torch.Tensor(attention_weights["out"]["kernel"].T)) + + lyr.layer[1].layer_norm.weight = nn.Parameter(torch.Tensor(ly_weight["pre_mlp_layer_norm"]["scale"])) + + lyr.layer[1].DenseReluDense.wi_0.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wi_0"]["kernel"].T)) + lyr.layer[1].DenseReluDense.wi_1.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wi_1"]["kernel"].T)) + lyr.layer[1].DenseReluDense.wo.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wo"]["kernel"].T)) + + model.layer_norm.weight = nn.Parameter(torch.Tensor(weights["encoder_norm"]["scale"])) + return model + + +def load_continuous_encoder(weights, model): + model.input_proj.weight = nn.Parameter(torch.Tensor(weights["input_proj"]["kernel"].T)) + + model.position_encoding.weight = nn.Parameter(torch.Tensor(weights["Embed_0"]["embedding"]), requires_grad=False) + + for lyr_num, lyr in enumerate(model.encoders): + ly_weight = weights[f"layers_{lyr_num}"] + attention_weights = ly_weight["attention"] + + lyr.layer[0].SelfAttention.q.weight = nn.Parameter(torch.Tensor(attention_weights["query"]["kernel"].T)) + lyr.layer[0].SelfAttention.k.weight = nn.Parameter(torch.Tensor(attention_weights["key"]["kernel"].T)) + lyr.layer[0].SelfAttention.v.weight = nn.Parameter(torch.Tensor(attention_weights["value"]["kernel"].T)) + lyr.layer[0].SelfAttention.o.weight = nn.Parameter(torch.Tensor(attention_weights["out"]["kernel"].T)) + lyr.layer[0].layer_norm.weight = nn.Parameter(torch.Tensor(ly_weight["pre_attention_layer_norm"]["scale"])) + + lyr.layer[1].DenseReluDense.wi_0.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wi_0"]["kernel"].T)) + lyr.layer[1].DenseReluDense.wi_1.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wi_1"]["kernel"].T)) + lyr.layer[1].DenseReluDense.wo.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wo"]["kernel"].T)) + lyr.layer[1].layer_norm.weight = nn.Parameter(torch.Tensor(ly_weight["pre_mlp_layer_norm"]["scale"])) + + model.layer_norm.weight = nn.Parameter(torch.Tensor(weights["encoder_norm"]["scale"])) + + return model + + +def load_decoder(weights, model): + model.conditioning_emb[0].weight = nn.Parameter(torch.Tensor(weights["time_emb_dense0"]["kernel"].T)) + model.conditioning_emb[2].weight = nn.Parameter(torch.Tensor(weights["time_emb_dense1"]["kernel"].T)) + + model.position_encoding.weight = nn.Parameter(torch.Tensor(weights["Embed_0"]["embedding"]), requires_grad=False) + + model.continuous_inputs_projection.weight = nn.Parameter( + torch.Tensor(weights["continuous_inputs_projection"]["kernel"].T) + ) + + for lyr_num, lyr in enumerate(model.decoders): + ly_weight = weights[f"layers_{lyr_num}"] + lyr.layer[0].layer_norm.weight = nn.Parameter( + torch.Tensor(ly_weight["pre_self_attention_layer_norm"]["scale"]) + ) + + lyr.layer[0].FiLMLayer.scale_bias.weight = nn.Parameter( + torch.Tensor(ly_weight["FiLMLayer_0"]["DenseGeneral_0"]["kernel"].T) + ) + + attention_weights = ly_weight["self_attention"] + lyr.layer[0].attention.to_q.weight = nn.Parameter(torch.Tensor(attention_weights["query"]["kernel"].T)) + lyr.layer[0].attention.to_k.weight = nn.Parameter(torch.Tensor(attention_weights["key"]["kernel"].T)) + lyr.layer[0].attention.to_v.weight = nn.Parameter(torch.Tensor(attention_weights["value"]["kernel"].T)) + lyr.layer[0].attention.to_out[0].weight = nn.Parameter(torch.Tensor(attention_weights["out"]["kernel"].T)) + + attention_weights = ly_weight["MultiHeadDotProductAttention_0"] + lyr.layer[1].attention.to_q.weight = nn.Parameter(torch.Tensor(attention_weights["query"]["kernel"].T)) + lyr.layer[1].attention.to_k.weight = nn.Parameter(torch.Tensor(attention_weights["key"]["kernel"].T)) + lyr.layer[1].attention.to_v.weight = nn.Parameter(torch.Tensor(attention_weights["value"]["kernel"].T)) + lyr.layer[1].attention.to_out[0].weight = nn.Parameter(torch.Tensor(attention_weights["out"]["kernel"].T)) + lyr.layer[1].layer_norm.weight = nn.Parameter( + torch.Tensor(ly_weight["pre_cross_attention_layer_norm"]["scale"]) + ) + + lyr.layer[2].layer_norm.weight = nn.Parameter(torch.Tensor(ly_weight["pre_mlp_layer_norm"]["scale"])) + lyr.layer[2].film.scale_bias.weight = nn.Parameter( + torch.Tensor(ly_weight["FiLMLayer_1"]["DenseGeneral_0"]["kernel"].T) + ) + lyr.layer[2].DenseReluDense.wi_0.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wi_0"]["kernel"].T)) + lyr.layer[2].DenseReluDense.wi_1.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wi_1"]["kernel"].T)) + lyr.layer[2].DenseReluDense.wo.weight = nn.Parameter(torch.Tensor(ly_weight["mlp"]["wo"]["kernel"].T)) + + model.decoder_norm.weight = nn.Parameter(torch.Tensor(weights["decoder_norm"]["scale"])) + + model.spec_out.weight = nn.Parameter(torch.Tensor(weights["spec_out_dense"]["kernel"].T)) + + return model + + +def main(args): + t5_checkpoint = checkpoints.load_t5x_checkpoint(args.checkpoint_path) + t5_checkpoint = jnp.tree_util.tree_map(onp.array, t5_checkpoint) + + gin_overrides = [ + "from __gin__ import dynamic_registration", + "from music_spectrogram_diffusion.models.diffusion import diffusion_utils", + "diffusion_utils.ClassifierFreeGuidanceConfig.eval_condition_weight = 2.0", + "diffusion_utils.DiffusionConfig.classifier_free_guidance = @diffusion_utils.ClassifierFreeGuidanceConfig()", + ] + + gin_file = os.path.join(args.checkpoint_path, "..", "config.gin") + gin_config = inference.parse_training_gin_file(gin_file, gin_overrides) + synth_model = inference.InferenceModel(args.checkpoint_path, gin_config) + + scheduler = DDPMScheduler(beta_schedule="squaredcos_cap_v2", variance_type="fixed_large") + + notes_encoder = SpectrogramNotesEncoder( + max_length=synth_model.sequence_length["inputs"], + vocab_size=synth_model.model.module.config.vocab_size, + d_model=synth_model.model.module.config.emb_dim, + dropout_rate=synth_model.model.module.config.dropout_rate, + num_layers=synth_model.model.module.config.num_encoder_layers, + num_heads=synth_model.model.module.config.num_heads, + d_kv=synth_model.model.module.config.head_dim, + d_ff=synth_model.model.module.config.mlp_dim, + feed_forward_proj="gated-gelu", + ) + + continuous_encoder = SpectrogramContEncoder( + input_dims=synth_model.audio_codec.n_dims, + targets_context_length=synth_model.sequence_length["targets_context"], + d_model=synth_model.model.module.config.emb_dim, + dropout_rate=synth_model.model.module.config.dropout_rate, + num_layers=synth_model.model.module.config.num_encoder_layers, + num_heads=synth_model.model.module.config.num_heads, + d_kv=synth_model.model.module.config.head_dim, + d_ff=synth_model.model.module.config.mlp_dim, + feed_forward_proj="gated-gelu", + ) + + decoder = T5FilmDecoder( + input_dims=synth_model.audio_codec.n_dims, + targets_length=synth_model.sequence_length["targets_context"], + max_decoder_noise_time=synth_model.model.module.config.max_decoder_noise_time, + d_model=synth_model.model.module.config.emb_dim, + num_layers=synth_model.model.module.config.num_decoder_layers, + num_heads=synth_model.model.module.config.num_heads, + d_kv=synth_model.model.module.config.head_dim, + d_ff=synth_model.model.module.config.mlp_dim, + dropout_rate=synth_model.model.module.config.dropout_rate, + ) + + notes_encoder = load_notes_encoder(t5_checkpoint["target"]["token_encoder"], notes_encoder) + continuous_encoder = load_continuous_encoder(t5_checkpoint["target"]["continuous_encoder"], continuous_encoder) + decoder = load_decoder(t5_checkpoint["target"]["decoder"], decoder) + + melgan = OnnxRuntimeModel.from_pretrained("kashif/soundstream_mel_decoder") + + pipe = SpectrogramDiffusionPipeline( + notes_encoder=notes_encoder, + continuous_encoder=continuous_encoder, + decoder=decoder, + scheduler=scheduler, + melgan=melgan, + ) + if args.save: + pipe.save_pretrained(args.output_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--output_path", default=None, type=str, required=True, help="Path to the converted model.") + parser.add_argument( + "--save", default=True, type=bool, required=False, help="Whether to save the converted model or not." + ) + parser.add_argument( + "--checkpoint_path", + default=f"{MODEL}/checkpoint_500000", + type=str, + required=False, + help="Path to the original jax model checkpoint.", + ) + args = parser.parse_args() + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..bcab90e2a3dbdd7b755ed86cd84f6bf2f1147dac --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py @@ -0,0 +1,185 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the NCSNPP checkpoints.""" + +import argparse +import json + +import torch + +from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNet2DModel + + +def convert_ncsnpp_checkpoint(checkpoint, config): + """ + Takes a state dict and the path to + """ + new_model_architecture = UNet2DModel(**config) + new_model_architecture.time_proj.W.data = checkpoint["all_modules.0.W"].data + new_model_architecture.time_proj.weight.data = checkpoint["all_modules.0.W"].data + new_model_architecture.time_embedding.linear_1.weight.data = checkpoint["all_modules.1.weight"].data + new_model_architecture.time_embedding.linear_1.bias.data = checkpoint["all_modules.1.bias"].data + + new_model_architecture.time_embedding.linear_2.weight.data = checkpoint["all_modules.2.weight"].data + new_model_architecture.time_embedding.linear_2.bias.data = checkpoint["all_modules.2.bias"].data + + new_model_architecture.conv_in.weight.data = checkpoint["all_modules.3.weight"].data + new_model_architecture.conv_in.bias.data = checkpoint["all_modules.3.bias"].data + + new_model_architecture.conv_norm_out.weight.data = checkpoint[list(checkpoint.keys())[-4]].data + new_model_architecture.conv_norm_out.bias.data = checkpoint[list(checkpoint.keys())[-3]].data + new_model_architecture.conv_out.weight.data = checkpoint[list(checkpoint.keys())[-2]].data + new_model_architecture.conv_out.bias.data = checkpoint[list(checkpoint.keys())[-1]].data + + module_index = 4 + + def set_attention_weights(new_layer, old_checkpoint, index): + new_layer.query.weight.data = old_checkpoint[f"all_modules.{index}.NIN_0.W"].data.T + new_layer.key.weight.data = old_checkpoint[f"all_modules.{index}.NIN_1.W"].data.T + new_layer.value.weight.data = old_checkpoint[f"all_modules.{index}.NIN_2.W"].data.T + + new_layer.query.bias.data = old_checkpoint[f"all_modules.{index}.NIN_0.b"].data + new_layer.key.bias.data = old_checkpoint[f"all_modules.{index}.NIN_1.b"].data + new_layer.value.bias.data = old_checkpoint[f"all_modules.{index}.NIN_2.b"].data + + new_layer.proj_attn.weight.data = old_checkpoint[f"all_modules.{index}.NIN_3.W"].data.T + new_layer.proj_attn.bias.data = old_checkpoint[f"all_modules.{index}.NIN_3.b"].data + + new_layer.group_norm.weight.data = old_checkpoint[f"all_modules.{index}.GroupNorm_0.weight"].data + new_layer.group_norm.bias.data = old_checkpoint[f"all_modules.{index}.GroupNorm_0.bias"].data + + def set_resnet_weights(new_layer, old_checkpoint, index): + new_layer.conv1.weight.data = old_checkpoint[f"all_modules.{index}.Conv_0.weight"].data + new_layer.conv1.bias.data = old_checkpoint[f"all_modules.{index}.Conv_0.bias"].data + new_layer.norm1.weight.data = old_checkpoint[f"all_modules.{index}.GroupNorm_0.weight"].data + new_layer.norm1.bias.data = old_checkpoint[f"all_modules.{index}.GroupNorm_0.bias"].data + + new_layer.conv2.weight.data = old_checkpoint[f"all_modules.{index}.Conv_1.weight"].data + new_layer.conv2.bias.data = old_checkpoint[f"all_modules.{index}.Conv_1.bias"].data + new_layer.norm2.weight.data = old_checkpoint[f"all_modules.{index}.GroupNorm_1.weight"].data + new_layer.norm2.bias.data = old_checkpoint[f"all_modules.{index}.GroupNorm_1.bias"].data + + new_layer.time_emb_proj.weight.data = old_checkpoint[f"all_modules.{index}.Dense_0.weight"].data + new_layer.time_emb_proj.bias.data = old_checkpoint[f"all_modules.{index}.Dense_0.bias"].data + + if new_layer.in_channels != new_layer.out_channels or new_layer.up or new_layer.down: + new_layer.conv_shortcut.weight.data = old_checkpoint[f"all_modules.{index}.Conv_2.weight"].data + new_layer.conv_shortcut.bias.data = old_checkpoint[f"all_modules.{index}.Conv_2.bias"].data + + for i, block in enumerate(new_model_architecture.downsample_blocks): + has_attentions = hasattr(block, "attentions") + for j in range(len(block.resnets)): + set_resnet_weights(block.resnets[j], checkpoint, module_index) + module_index += 1 + if has_attentions: + set_attention_weights(block.attentions[j], checkpoint, module_index) + module_index += 1 + + if hasattr(block, "downsamplers") and block.downsamplers is not None: + set_resnet_weights(block.resnet_down, checkpoint, module_index) + module_index += 1 + block.skip_conv.weight.data = checkpoint[f"all_modules.{module_index}.Conv_0.weight"].data + block.skip_conv.bias.data = checkpoint[f"all_modules.{module_index}.Conv_0.bias"].data + module_index += 1 + + set_resnet_weights(new_model_architecture.mid_block.resnets[0], checkpoint, module_index) + module_index += 1 + set_attention_weights(new_model_architecture.mid_block.attentions[0], checkpoint, module_index) + module_index += 1 + set_resnet_weights(new_model_architecture.mid_block.resnets[1], checkpoint, module_index) + module_index += 1 + + for i, block in enumerate(new_model_architecture.up_blocks): + has_attentions = hasattr(block, "attentions") + for j in range(len(block.resnets)): + set_resnet_weights(block.resnets[j], checkpoint, module_index) + module_index += 1 + if has_attentions: + set_attention_weights( + block.attentions[0], checkpoint, module_index + ) # why can there only be a single attention layer for up? + module_index += 1 + + if hasattr(block, "resnet_up") and block.resnet_up is not None: + block.skip_norm.weight.data = checkpoint[f"all_modules.{module_index}.weight"].data + block.skip_norm.bias.data = checkpoint[f"all_modules.{module_index}.bias"].data + module_index += 1 + block.skip_conv.weight.data = checkpoint[f"all_modules.{module_index}.weight"].data + block.skip_conv.bias.data = checkpoint[f"all_modules.{module_index}.bias"].data + module_index += 1 + set_resnet_weights(block.resnet_up, checkpoint, module_index) + module_index += 1 + + new_model_architecture.conv_norm_out.weight.data = checkpoint[f"all_modules.{module_index}.weight"].data + new_model_architecture.conv_norm_out.bias.data = checkpoint[f"all_modules.{module_index}.bias"].data + module_index += 1 + new_model_architecture.conv_out.weight.data = checkpoint[f"all_modules.{module_index}.weight"].data + new_model_architecture.conv_out.bias.data = checkpoint[f"all_modules.{module_index}.bias"].data + + return new_model_architecture.state_dict() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", + default="/Users/arthurzucker/Work/diffusers/ArthurZ/diffusion_pytorch_model.bin", + type=str, + required=False, + help="Path to the checkpoint to convert.", + ) + + parser.add_argument( + "--config_file", + default="/Users/arthurzucker/Work/diffusers/ArthurZ/config.json", + type=str, + required=False, + help="The config json file corresponding to the architecture.", + ) + + parser.add_argument( + "--dump_path", + default="/Users/arthurzucker/Work/diffusers/ArthurZ/diffusion_model_new.pt", + type=str, + required=False, + help="Path to the output model.", + ) + + args = parser.parse_args() + + checkpoint = torch.load(args.checkpoint_path, map_location="cpu") + + with open(args.config_file) as f: + config = json.loads(f.read()) + + converted_checkpoint = convert_ncsnpp_checkpoint( + checkpoint, + config, + ) + + if "sde" in config: + del config["sde"] + + model = UNet2DModel(**config) + model.load_state_dict(converted_checkpoint) + + try: + scheduler = ScoreSdeVeScheduler.from_config("/".join(args.checkpoint_path.split("/")[:-1])) + + pipe = ScoreSdeVePipeline(unet=model, scheduler=scheduler) + pipe.save_pretrained(args.dump_path) + except: # noqa: E722 + model.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_omnigen_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_omnigen_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..96bc935633f0df54a2871329e7132b36fc7ee72a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_omnigen_to_diffusers.py @@ -0,0 +1,203 @@ +import argparse +import os + +import torch +from huggingface_hub import snapshot_download +from safetensors.torch import load_file +from transformers import AutoTokenizer + +from diffusers import AutoencoderKL, FlowMatchEulerDiscreteScheduler, OmniGenPipeline, OmniGenTransformer2DModel + + +def main(args): + # checkpoint from https://huggingface.co/Shitao/OmniGen-v1 + + if not os.path.exists(args.origin_ckpt_path): + print("Model not found, downloading...") + cache_folder = os.getenv("HF_HUB_CACHE") + args.origin_ckpt_path = snapshot_download( + repo_id=args.origin_ckpt_path, + cache_dir=cache_folder, + ignore_patterns=["flax_model.msgpack", "rust_model.ot", "tf_model.h5", "model.pt"], + ) + print(f"Downloaded model to {args.origin_ckpt_path}") + + ckpt = os.path.join(args.origin_ckpt_path, "model.safetensors") + ckpt = load_file(ckpt, device="cpu") + + mapping_dict = { + "pos_embed": "patch_embedding.pos_embed", + "x_embedder.proj.weight": "patch_embedding.output_image_proj.weight", + "x_embedder.proj.bias": "patch_embedding.output_image_proj.bias", + "input_x_embedder.proj.weight": "patch_embedding.input_image_proj.weight", + "input_x_embedder.proj.bias": "patch_embedding.input_image_proj.bias", + "final_layer.adaLN_modulation.1.weight": "norm_out.linear.weight", + "final_layer.adaLN_modulation.1.bias": "norm_out.linear.bias", + "final_layer.linear.weight": "proj_out.weight", + "final_layer.linear.bias": "proj_out.bias", + "time_token.mlp.0.weight": "time_token.linear_1.weight", + "time_token.mlp.0.bias": "time_token.linear_1.bias", + "time_token.mlp.2.weight": "time_token.linear_2.weight", + "time_token.mlp.2.bias": "time_token.linear_2.bias", + "t_embedder.mlp.0.weight": "t_embedder.linear_1.weight", + "t_embedder.mlp.0.bias": "t_embedder.linear_1.bias", + "t_embedder.mlp.2.weight": "t_embedder.linear_2.weight", + "t_embedder.mlp.2.bias": "t_embedder.linear_2.bias", + "llm.embed_tokens.weight": "embed_tokens.weight", + } + + converted_state_dict = {} + for k, v in ckpt.items(): + if k in mapping_dict: + converted_state_dict[mapping_dict[k]] = v + elif "qkv" in k: + to_q, to_k, to_v = v.chunk(3) + converted_state_dict[f"layers.{k.split('.')[2]}.self_attn.to_q.weight"] = to_q + converted_state_dict[f"layers.{k.split('.')[2]}.self_attn.to_k.weight"] = to_k + converted_state_dict[f"layers.{k.split('.')[2]}.self_attn.to_v.weight"] = to_v + elif "o_proj" in k: + converted_state_dict[f"layers.{k.split('.')[2]}.self_attn.to_out.0.weight"] = v + else: + converted_state_dict[k[4:]] = v + + transformer = OmniGenTransformer2DModel( + rope_scaling={ + "long_factor": [ + 1.0299999713897705, + 1.0499999523162842, + 1.0499999523162842, + 1.0799999237060547, + 1.2299998998641968, + 1.2299998998641968, + 1.2999999523162842, + 1.4499999284744263, + 1.5999999046325684, + 1.6499998569488525, + 1.8999998569488525, + 2.859999895095825, + 3.68999981880188, + 5.419999599456787, + 5.489999771118164, + 5.489999771118164, + 9.09000015258789, + 11.579999923706055, + 15.65999984741211, + 15.769999504089355, + 15.789999961853027, + 18.360000610351562, + 21.989999771118164, + 23.079999923706055, + 30.009998321533203, + 32.35000228881836, + 32.590003967285156, + 35.56000518798828, + 39.95000457763672, + 53.840003967285156, + 56.20000457763672, + 57.95000457763672, + 59.29000473022461, + 59.77000427246094, + 59.920005798339844, + 61.190006256103516, + 61.96000671386719, + 62.50000762939453, + 63.3700065612793, + 63.48000717163086, + 63.48000717163086, + 63.66000747680664, + 63.850006103515625, + 64.08000946044922, + 64.760009765625, + 64.80001068115234, + 64.81001281738281, + 64.81001281738281, + ], + "short_factor": [ + 1.05, + 1.05, + 1.05, + 1.1, + 1.1, + 1.1, + 1.2500000000000002, + 1.2500000000000002, + 1.4000000000000004, + 1.4500000000000004, + 1.5500000000000005, + 1.8500000000000008, + 1.9000000000000008, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.000000000000001, + 2.1000000000000005, + 2.1000000000000005, + 2.2, + 2.3499999999999996, + 2.3499999999999996, + 2.3499999999999996, + 2.3499999999999996, + 2.3999999999999995, + 2.3999999999999995, + 2.6499999999999986, + 2.6999999999999984, + 2.8999999999999977, + 2.9499999999999975, + 3.049999999999997, + 3.049999999999997, + 3.049999999999997, + ], + "type": "su", + }, + patch_size=2, + in_channels=4, + pos_embed_max_size=192, + ) + transformer.load_state_dict(converted_state_dict, strict=True) + transformer.to(torch.bfloat16) + + num_model_params = sum(p.numel() for p in transformer.parameters()) + print(f"Total number of transformer parameters: {num_model_params}") + + scheduler = FlowMatchEulerDiscreteScheduler(invert_sigmas=True, num_train_timesteps=1) + + vae = AutoencoderKL.from_pretrained(os.path.join(args.origin_ckpt_path, "vae"), torch_dtype=torch.float32) + + tokenizer = AutoTokenizer.from_pretrained(args.origin_ckpt_path) + + pipeline = OmniGenPipeline(tokenizer=tokenizer, transformer=transformer, vae=vae, scheduler=scheduler) + pipeline.save_pretrained(args.dump_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--origin_ckpt_path", + default="Shitao/OmniGen-v1", + type=str, + required=False, + help="Path to the checkpoint to convert.", + ) + + parser.add_argument( + "--dump_path", default="OmniGen-v1-diffusers", type=str, required=False, help="Path to the output pipeline." + ) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_audioldm2_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_audioldm2_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..2c0695ce55953aceaa2c7dfa32a92892d8e59150 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_audioldm2_to_diffusers.py @@ -0,0 +1,1135 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the AudioLDM2 checkpoints.""" + +import argparse +import re +from typing import List, Union + +import torch +import yaml +from transformers import ( + AutoFeatureExtractor, + AutoTokenizer, + ClapConfig, + ClapModel, + GPT2Config, + GPT2Model, + SpeechT5HifiGan, + SpeechT5HifiGanConfig, + T5Config, + T5EncoderModel, +) + +from diffusers import ( + AudioLDM2Pipeline, + AudioLDM2ProjectionModel, + AudioLDM2UNet2DConditionModel, + AutoencoderKL, + DDIMScheduler, + DPMSolverMultistepScheduler, + EulerAncestralDiscreteScheduler, + EulerDiscreteScheduler, + HeunDiscreteScheduler, + LMSDiscreteScheduler, + PNDMScheduler, +) +from diffusers.utils import is_safetensors_available +from diffusers.utils.import_utils import BACKENDS_MAPPING + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.shave_segments +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_resnet_paths +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_resnet_paths +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_attention_paths +def renew_attention_paths(old_list): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "to_q.weight") + new_item = new_item.replace("q.bias", "to_q.bias") + + new_item = new_item.replace("k.weight", "to_k.weight") + new_item = new_item.replace("k.bias", "to_k.bias") + + new_item = new_item.replace("v.weight", "to_v.weight") + new_item = new_item.replace("v.bias", "to_v.bias") + + new_item = new_item.replace("proj_out.weight", "to_out.0.weight") + new_item = new_item.replace("proj_out.bias", "to_out.0.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + if "proj_attn.weight" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["to_q.weight", "to_k.weight", "to_v.weight"] + proj_key = "to_out.0.weight" + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys or ".".join(key.split(".")[-3:]) == proj_key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key].squeeze() + + +def create_unet_diffusers_config(original_config, image_size: int): + """ + Creates a UNet config for diffusers based on the config of the original AudioLDM2 model. + """ + unet_params = original_config["model"]["params"]["unet_config"]["params"] + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + + block_out_channels = [unet_params["model_channels"] * mult for mult in unet_params["channel_mult"]] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlock2D" if resolution in unet_params["attention_resolutions"] else "DownBlock2D" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlock2D" if resolution in unet_params["attention_resolutions"] else "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + vae_scale_factor = 2 ** (len(vae_params["ch_mult"]) - 1) + + cross_attention_dim = list(unet_params["context_dim"]) if "context_dim" in unet_params else block_out_channels + if len(cross_attention_dim) > 1: + # require two or more cross-attention layers per-block, each of different dimension + cross_attention_dim = [cross_attention_dim for _ in range(len(block_out_channels))] + + config = { + "sample_size": image_size // vae_scale_factor, + "in_channels": unet_params["in_channels"], + "out_channels": unet_params["out_channels"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params["num_res_blocks"], + "transformer_layers_per_block": unet_params["transformer_depth"], + "cross_attention_dim": tuple(cross_attention_dim), + } + + return config + + +# Adapted from diffusers.pipelines.stable_diffusion.convert_from_ckpt.create_vae_diffusers_config +def create_vae_diffusers_config(original_config, checkpoint, image_size: int): + """ + Creates a VAE config for diffusers based on the config of the original AudioLDM2 model. Compared to the original + Stable Diffusion conversion, this function passes a *learnt* VAE scaling factor to the diffusers VAE. + """ + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + _ = original_config["model"]["params"]["first_stage_config"]["params"]["embed_dim"] + + block_out_channels = [vae_params["ch"] * mult for mult in vae_params["ch_mult"]] + down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) + up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) + + scaling_factor = checkpoint["scale_factor"] if "scale_by_std" in original_config["model"]["params"] else 0.18215 + + config = { + "sample_size": image_size, + "in_channels": vae_params["in_channels"], + "out_channels": vae_params["out_ch"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "latent_channels": vae_params["z_channels"], + "layers_per_block": vae_params["num_res_blocks"], + "scaling_factor": float(scaling_factor), + } + return config + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.create_diffusers_schedular +def create_diffusers_schedular(original_config): + schedular = DDIMScheduler( + num_train_timesteps=original_config["model"]["params"]["timesteps"], + beta_start=original_config["model"]["params"]["linear_start"], + beta_end=original_config["model"]["params"]["linear_end"], + beta_schedule="scaled_linear", + ) + return schedular + + +def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted UNet checkpoint. + """ + + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + print(f"Checkpoint {path} has both EMA and non-EMA weights.") + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + # strip the unet prefix from the weight names + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}." in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}." in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}." in key] + for layer_id in range(num_output_blocks) + } + + # Check how many Transformer blocks we have per layer + if isinstance(config.get("cross_attention_dim"), (list, tuple)): + if isinstance(config["cross_attention_dim"][0], (list, tuple)): + # in this case we have multiple cross-attention layers per-block + num_attention_layers = len(config.get("cross_attention_dim")[0]) + else: + num_attention_layers = 1 + + if config.get("extra_self_attn_layer"): + num_attention_layers += 1 + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.0" not in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = [ + { + "old": f"input_blocks.{i}.{1 + layer_id}", + "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id * num_attention_layers + layer_id}", + } + for layer_id in range(num_attention_layers) + ] + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=meta_path, config=config + ) + + resnet_0 = middle_blocks[0] + resnet_1 = middle_blocks[num_middle_blocks - 1] + + resnet_0_paths = renew_resnet_paths(resnet_0) + meta_path = {"old": "middle_block.0", "new": "mid_block.resnets.0"} + assign_to_checkpoint( + resnet_0_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_1_paths = renew_resnet_paths(resnet_1) + meta_path = {"old": f"middle_block.{len(middle_blocks) - 1}", "new": "mid_block.resnets.1"} + assign_to_checkpoint( + resnet_1_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(1, num_middle_blocks - 1): + attentions = middle_blocks[i] + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": f"middle_block.{i}", "new": f"mid_block.attentions.{i - 1}"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.0" not in key] + + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + attentions.remove(f"output_blocks.{i}.{index}.conv.bias") + attentions.remove(f"output_blocks.{i}.{index}.conv.weight") + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = [ + { + "old": f"output_blocks.{i}.{1 + layer_id}", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id * num_attention_layers + layer_id}", + } + for layer_id in range(num_attention_layers) + ] + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=meta_path, config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +def convert_ldm_vae_checkpoint(checkpoint, config): + # extract state dict for VAE + vae_state_dict = {} + vae_key = "first_stage_model." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(vae_key): + vae_state_dict[key.replace(vae_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint + + +CLAP_KEYS_TO_MODIFY_MAPPING = { + "text_branch": "text_model", + "audio_branch": "audio_model.audio_encoder", + "attn": "attention.self", + "self.proj": "output.dense", + "attention.self_mask": "attn_mask", + "mlp.fc1": "intermediate.dense", + "mlp.fc2": "output.dense", + "norm1": "layernorm_before", + "norm2": "layernorm_after", + "bn0": "batch_norm", +} + +CLAP_KEYS_TO_IGNORE = [ + "text_transform", + "audio_transform", + "stft", + "logmel_extractor", + "tscam_conv", + "head", + "attn_mask", +] + +CLAP_EXPECTED_MISSING_KEYS = ["text_model.embeddings.token_type_ids"] + + +def convert_open_clap_checkpoint(checkpoint): + """ + Takes a state dict and returns a converted CLAP checkpoint. + """ + # extract state dict for CLAP text embedding model, discarding the audio component + model_state_dict = {} + model_key = "clap.model." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(model_key): + model_state_dict[key.replace(model_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + sequential_layers_pattern = r".*sequential.(\d+).*" + text_projection_pattern = r".*_projection.(\d+).*" + + for key, value in model_state_dict.items(): + # check if key should be ignored in mapping - if so map it to a key name that we'll filter out at the end + for key_to_ignore in CLAP_KEYS_TO_IGNORE: + if key_to_ignore in key: + key = "spectrogram" + + # check if any key needs to be modified + for key_to_modify, new_key in CLAP_KEYS_TO_MODIFY_MAPPING.items(): + if key_to_modify in key: + key = key.replace(key_to_modify, new_key) + + if re.match(sequential_layers_pattern, key): + # replace sequential layers with list + sequential_layer = re.match(sequential_layers_pattern, key).group(1) + + key = key.replace(f"sequential.{sequential_layer}.", f"layers.{int(sequential_layer) // 3}.linear.") + elif re.match(text_projection_pattern, key): + projecton_layer = int(re.match(text_projection_pattern, key).group(1)) + + # Because in CLAP they use `nn.Sequential`... + transformers_projection_layer = 1 if projecton_layer == 0 else 2 + + key = key.replace(f"_projection.{projecton_layer}.", f"_projection.linear{transformers_projection_layer}.") + + if "audio" and "qkv" in key: + # split qkv into query key and value + mixed_qkv = value + qkv_dim = mixed_qkv.size(0) // 3 + + query_layer = mixed_qkv[:qkv_dim] + key_layer = mixed_qkv[qkv_dim : qkv_dim * 2] + value_layer = mixed_qkv[qkv_dim * 2 :] + + new_checkpoint[key.replace("qkv", "query")] = query_layer + new_checkpoint[key.replace("qkv", "key")] = key_layer + new_checkpoint[key.replace("qkv", "value")] = value_layer + elif key != "spectrogram": + new_checkpoint[key] = value + + return new_checkpoint + + +def create_transformers_vocoder_config(original_config): + """ + Creates a config for transformers SpeechT5HifiGan based on the config of the vocoder model. + """ + vocoder_params = original_config["model"]["params"]["vocoder_config"]["params"] + + config = { + "model_in_dim": vocoder_params["num_mels"], + "sampling_rate": vocoder_params["sampling_rate"], + "upsample_initial_channel": vocoder_params["upsample_initial_channel"], + "upsample_rates": list(vocoder_params["upsample_rates"]), + "upsample_kernel_sizes": list(vocoder_params["upsample_kernel_sizes"]), + "resblock_kernel_sizes": list(vocoder_params["resblock_kernel_sizes"]), + "resblock_dilation_sizes": [ + list(resblock_dilation) for resblock_dilation in vocoder_params["resblock_dilation_sizes"] + ], + "normalize_before": False, + } + + return config + + +def extract_sub_model(checkpoint, key_prefix): + """ + Takes a state dict and returns the state dict for a particular sub-model. + """ + + sub_model_state_dict = {} + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(key_prefix): + sub_model_state_dict[key.replace(key_prefix, "")] = checkpoint.get(key) + + return sub_model_state_dict + + +def convert_hifigan_checkpoint(checkpoint, config): + """ + Takes a state dict and config, and returns a converted HiFiGAN vocoder checkpoint. + """ + # extract state dict for vocoder + vocoder_state_dict = extract_sub_model(checkpoint, key_prefix="first_stage_model.vocoder.") + + # fix upsampler keys, everything else is correct already + for i in range(len(config.upsample_rates)): + vocoder_state_dict[f"upsampler.{i}.weight"] = vocoder_state_dict.pop(f"ups.{i}.weight") + vocoder_state_dict[f"upsampler.{i}.bias"] = vocoder_state_dict.pop(f"ups.{i}.bias") + + if not config.normalize_before: + # if we don't set normalize_before then these variables are unused, so we set them to their initialised values + vocoder_state_dict["mean"] = torch.zeros(config.model_in_dim) + vocoder_state_dict["scale"] = torch.ones(config.model_in_dim) + + return vocoder_state_dict + + +def convert_projection_checkpoint(checkpoint): + projection_state_dict = {} + conditioner_state_dict = extract_sub_model(checkpoint, key_prefix="cond_stage_models.0.") + + projection_state_dict["sos_embed"] = conditioner_state_dict["start_of_sequence_tokens.weight"][0] + projection_state_dict["sos_embed_1"] = conditioner_state_dict["start_of_sequence_tokens.weight"][1] + + projection_state_dict["eos_embed"] = conditioner_state_dict["end_of_sequence_tokens.weight"][0] + projection_state_dict["eos_embed_1"] = conditioner_state_dict["end_of_sequence_tokens.weight"][1] + + projection_state_dict["projection.weight"] = conditioner_state_dict["input_sequence_embed_linear.0.weight"] + projection_state_dict["projection.bias"] = conditioner_state_dict["input_sequence_embed_linear.0.bias"] + + projection_state_dict["projection_1.weight"] = conditioner_state_dict["input_sequence_embed_linear.1.weight"] + projection_state_dict["projection_1.bias"] = conditioner_state_dict["input_sequence_embed_linear.1.bias"] + + return projection_state_dict + + +# Adapted from https://github.com/haoheliu/AudioLDM2/blob/81ad2c6ce015c1310387695e2dae975a7d2ed6fd/audioldm2/utils.py#L143 +DEFAULT_CONFIG = { + "model": { + "params": { + "linear_start": 0.0015, + "linear_end": 0.0195, + "timesteps": 1000, + "channels": 8, + "scale_by_std": True, + "unet_config": { + "target": "audioldm2.latent_diffusion.openaimodel.UNetModel", + "params": { + "context_dim": [None, 768, 1024], + "in_channels": 8, + "out_channels": 8, + "model_channels": 128, + "attention_resolutions": [8, 4, 2], + "num_res_blocks": 2, + "channel_mult": [1, 2, 3, 5], + "num_head_channels": 32, + "transformer_depth": 1, + }, + }, + "first_stage_config": { + "target": "audioldm2.variational_autoencoder.autoencoder.AutoencoderKL", + "params": { + "embed_dim": 8, + "ddconfig": { + "z_channels": 8, + "resolution": 256, + "in_channels": 1, + "out_ch": 1, + "ch": 128, + "ch_mult": [1, 2, 4], + "num_res_blocks": 2, + }, + }, + }, + "cond_stage_config": { + "crossattn_audiomae_generated": { + "target": "audioldm2.latent_diffusion.modules.encoders.modules.SequenceGenAudioMAECond", + "params": { + "sequence_gen_length": 8, + "sequence_input_embed_dim": [512, 1024], + }, + } + }, + "vocoder_config": { + "target": "audioldm2.first_stage_model.vocoder", + "params": { + "upsample_rates": [5, 4, 2, 2, 2], + "upsample_kernel_sizes": [16, 16, 8, 4, 4], + "upsample_initial_channel": 1024, + "resblock_kernel_sizes": [3, 7, 11], + "resblock_dilation_sizes": [[1, 3, 5], [1, 3, 5], [1, 3, 5]], + "num_mels": 64, + "sampling_rate": 16000, + }, + }, + }, + }, +} + + +def load_pipeline_from_original_AudioLDM2_ckpt( + checkpoint_path: str, + original_config_file: str = None, + image_size: int = 1024, + prediction_type: str = None, + extract_ema: bool = False, + scheduler_type: str = "ddim", + cross_attention_dim: Union[List, List[List]] = None, + transformer_layers_per_block: int = None, + device: str = None, + from_safetensors: bool = False, +) -> AudioLDM2Pipeline: + """ + Load an AudioLDM2 pipeline object from a `.ckpt`/`.safetensors` file and (ideally) a `.yaml` config file. + + Although many of the arguments can be automatically inferred, some of these rely on brittle checks against the + global step count, which will likely fail for models that have undergone further fine-tuning. Therefore, it is + recommended that you override the default values and/or supply an `original_config_file` wherever possible. + + Args: + checkpoint_path (`str`): Path to `.ckpt` file. + original_config_file (`str`): + Path to `.yaml` config file corresponding to the original architecture. If `None`, will be automatically + set to the AudioLDM2 base config. + image_size (`int`, *optional*, defaults to 1024): + The image size that the model was trained on. + prediction_type (`str`, *optional*): + The prediction type that the model was trained on. If `None`, will be automatically + inferred by looking for a key in the config. For the default config, the prediction type is `'epsilon'`. + scheduler_type (`str`, *optional*, defaults to 'ddim'): + Type of scheduler to use. Should be one of `["pndm", "lms", "heun", "euler", "euler-ancestral", "dpm", + "ddim"]`. + cross_attention_dim (`list`, *optional*, defaults to `None`): + The dimension of the cross-attention layers. If `None`, the cross-attention dimension will be + automatically inferred. Set to `[768, 1024]` for the base model, or `[768, 1024, None]` for the large model. + transformer_layers_per_block (`int`, *optional*, defaults to `None`): + The number of transformer layers in each transformer block. If `None`, number of layers will be " + "automatically inferred. Set to `1` for the base model, or `2` for the large model. + extract_ema (`bool`, *optional*, defaults to `False`): Only relevant for + checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights or not. Defaults to + `False`. Pass `True` to extract the EMA weights. EMA weights usually yield higher quality images for + inference. Non-EMA weights are usually better to continue fine-tuning. + device (`str`, *optional*, defaults to `None`): + The device to use. Pass `None` to determine automatically. + from_safetensors (`str`, *optional*, defaults to `False`): + If `checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch. + return: An AudioLDM2Pipeline object representing the passed-in `.ckpt`/`.safetensors` file. + """ + + if from_safetensors: + if not is_safetensors_available(): + raise ValueError(BACKENDS_MAPPING["safetensors"][1]) + + from safetensors import safe_open + + checkpoint = {} + with safe_open(checkpoint_path, framework="pt", device="cpu") as f: + for key in f.keys(): + checkpoint[key] = f.get_tensor(key) + else: + if device is None: + device = "cuda" if torch.cuda.is_available() else "cpu" + checkpoint = torch.load(checkpoint_path, map_location=device) + else: + checkpoint = torch.load(checkpoint_path, map_location=device) + + if "state_dict" in checkpoint: + checkpoint = checkpoint["state_dict"] + + if original_config_file is None: + original_config = DEFAULT_CONFIG + else: + original_config = yaml.safe_load(original_config_file) + + if image_size is not None: + original_config["model"]["params"]["unet_config"]["params"]["image_size"] = image_size + + if cross_attention_dim is not None: + original_config["model"]["params"]["unet_config"]["params"]["context_dim"] = cross_attention_dim + + if transformer_layers_per_block is not None: + original_config["model"]["params"]["unet_config"]["params"]["transformer_depth"] = transformer_layers_per_block + + if ( + "parameterization" in original_config["model"]["params"] + and original_config["model"]["params"]["parameterization"] == "v" + ): + if prediction_type is None: + prediction_type = "v_prediction" + else: + if prediction_type is None: + prediction_type = "epsilon" + + num_train_timesteps = original_config["model"]["params"]["timesteps"] + beta_start = original_config["model"]["params"]["linear_start"] + beta_end = original_config["model"]["params"]["linear_end"] + + scheduler = DDIMScheduler( + beta_end=beta_end, + beta_schedule="scaled_linear", + beta_start=beta_start, + num_train_timesteps=num_train_timesteps, + steps_offset=1, + clip_sample=False, + set_alpha_to_one=False, + prediction_type=prediction_type, + ) + # make sure scheduler works correctly with DDIM + scheduler.register_to_config(clip_sample=False) + + if scheduler_type == "pndm": + config = dict(scheduler.config) + config["skip_prk_steps"] = True + scheduler = PNDMScheduler.from_config(config) + elif scheduler_type == "lms": + scheduler = LMSDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "heun": + scheduler = HeunDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "euler": + scheduler = EulerDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "euler-ancestral": + scheduler = EulerAncestralDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "dpm": + scheduler = DPMSolverMultistepScheduler.from_config(scheduler.config) + elif scheduler_type == "ddim": + scheduler = scheduler + else: + raise ValueError(f"Scheduler of type {scheduler_type} doesn't exist!") + + # Convert the UNet2DModel + unet_config = create_unet_diffusers_config(original_config, image_size=image_size) + unet = AudioLDM2UNet2DConditionModel(**unet_config) + + converted_unet_checkpoint = convert_ldm_unet_checkpoint( + checkpoint, unet_config, path=checkpoint_path, extract_ema=extract_ema + ) + + unet.load_state_dict(converted_unet_checkpoint) + + # Convert the VAE model + vae_config = create_vae_diffusers_config(original_config, checkpoint=checkpoint, image_size=image_size) + converted_vae_checkpoint = convert_ldm_vae_checkpoint(checkpoint, vae_config) + + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_checkpoint) + + # Convert the joint audio-text encoding model + clap_config = ClapConfig.from_pretrained("laion/clap-htsat-unfused") + clap_config.audio_config.update( + { + "patch_embeds_hidden_size": 128, + "hidden_size": 1024, + "depths": [2, 2, 12, 2], + } + ) + # AudioLDM2 uses the same tokenizer and feature extractor as the original CLAP model + clap_tokenizer = AutoTokenizer.from_pretrained("laion/clap-htsat-unfused") + clap_feature_extractor = AutoFeatureExtractor.from_pretrained("laion/clap-htsat-unfused") + + converted_clap_model = convert_open_clap_checkpoint(checkpoint) + clap_model = ClapModel(clap_config) + + missing_keys, unexpected_keys = clap_model.load_state_dict(converted_clap_model, strict=False) + # we expect not to have token_type_ids in our original state dict so let's ignore them + missing_keys = list(set(missing_keys) - set(CLAP_EXPECTED_MISSING_KEYS)) + + if len(unexpected_keys) > 0: + raise ValueError(f"Unexpected keys when loading CLAP model: {unexpected_keys}") + + if len(missing_keys) > 0: + raise ValueError(f"Missing keys when loading CLAP model: {missing_keys}") + + # Convert the vocoder model + vocoder_config = create_transformers_vocoder_config(original_config) + vocoder_config = SpeechT5HifiGanConfig(**vocoder_config) + converted_vocoder_checkpoint = convert_hifigan_checkpoint(checkpoint, vocoder_config) + + vocoder = SpeechT5HifiGan(vocoder_config) + vocoder.load_state_dict(converted_vocoder_checkpoint) + + # Convert the Flan-T5 encoder model: AudioLDM2 uses the same configuration and tokenizer as the original Flan-T5 large model + t5_config = T5Config.from_pretrained("google/flan-t5-large") + converted_t5_checkpoint = extract_sub_model(checkpoint, key_prefix="cond_stage_models.1.model.") + + t5_tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-large") + # hard-coded in the original implementation (i.e. not retrievable from the config) + t5_tokenizer.model_max_length = 128 + t5_model = T5EncoderModel(t5_config) + t5_model.load_state_dict(converted_t5_checkpoint) + + # Convert the GPT2 encoder model: AudioLDM2 uses the same configuration as the original GPT2 base model + gpt2_config = GPT2Config.from_pretrained("gpt2") + gpt2_model = GPT2Model(gpt2_config) + gpt2_model.config.max_new_tokens = original_config["model"]["params"]["cond_stage_config"][ + "crossattn_audiomae_generated" + ]["params"]["sequence_gen_length"] + + converted_gpt2_checkpoint = extract_sub_model(checkpoint, key_prefix="cond_stage_models.0.model.") + gpt2_model.load_state_dict(converted_gpt2_checkpoint) + + # Convert the extra embedding / projection layers + projection_model = AudioLDM2ProjectionModel(clap_config.projection_dim, t5_config.d_model, gpt2_config.n_embd) + + converted_projection_checkpoint = convert_projection_checkpoint(checkpoint) + projection_model.load_state_dict(converted_projection_checkpoint) + + # Instantiate the diffusers pipeline + pipe = AudioLDM2Pipeline( + vae=vae, + text_encoder=clap_model, + text_encoder_2=t5_model, + projection_model=projection_model, + language_model=gpt2_model, + tokenizer=clap_tokenizer, + tokenizer_2=t5_tokenizer, + feature_extractor=clap_feature_extractor, + unet=unet, + scheduler=scheduler, + vocoder=vocoder, + ) + + return pipe + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--original_config_file", + default=None, + type=str, + help="The YAML config file corresponding to the original architecture.", + ) + parser.add_argument( + "--cross_attention_dim", + default=None, + type=int, + nargs="+", + help="The dimension of the cross-attention layers. If `None`, the cross-attention dimension will be " + "automatically inferred. Set to `768+1024` for the base model, or `768+1024+640` for the large model", + ) + parser.add_argument( + "--transformer_layers_per_block", + default=None, + type=int, + help="The number of transformer layers in each transformer block. If `None`, number of layers will be " + "automatically inferred. Set to `1` for the base model, or `2` for the large model.", + ) + parser.add_argument( + "--scheduler_type", + default="ddim", + type=str, + help="Type of scheduler to use. Should be one of ['pndm', 'lms', 'ddim', 'euler', 'euler-ancestral', 'dpm']", + ) + parser.add_argument( + "--image_size", + default=1048, + type=int, + help="The image size that the model was trained on.", + ) + parser.add_argument( + "--prediction_type", + default=None, + type=str, + help=("The prediction type that the model was trained on."), + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--from_safetensors", + action="store_true", + help="If `--checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch.", + ) + parser.add_argument( + "--to_safetensors", + action="store_true", + help="Whether to store pipeline in safetensors format or not.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + args = parser.parse_args() + + pipe = load_pipeline_from_original_AudioLDM2_ckpt( + checkpoint_path=args.checkpoint_path, + original_config_file=args.original_config_file, + image_size=args.image_size, + prediction_type=args.prediction_type, + extract_ema=args.extract_ema, + scheduler_type=args.scheduler_type, + cross_attention_dim=args.cross_attention_dim, + transformer_layers_per_block=args.transformer_layers_per_block, + from_safetensors=args.from_safetensors, + device=args.device, + ) + pipe.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_audioldm_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_audioldm_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..44183f1aea2936a4c37a10d944ee5d8ac4060af9 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_audioldm_to_diffusers.py @@ -0,0 +1,1042 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the AudioLDM checkpoints.""" + +import argparse +import re + +import torch +import yaml +from transformers import ( + AutoTokenizer, + ClapTextConfig, + ClapTextModelWithProjection, + SpeechT5HifiGan, + SpeechT5HifiGanConfig, +) + +from diffusers import ( + AudioLDMPipeline, + AutoencoderKL, + DDIMScheduler, + DPMSolverMultistepScheduler, + EulerAncestralDiscreteScheduler, + EulerDiscreteScheduler, + HeunDiscreteScheduler, + LMSDiscreteScheduler, + PNDMScheduler, + UNet2DConditionModel, +) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.shave_segments +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_resnet_paths +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_resnet_paths +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_attention_paths +def renew_attention_paths(old_list): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_attention_paths +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "query.weight") + new_item = new_item.replace("q.bias", "query.bias") + + new_item = new_item.replace("k.weight", "key.weight") + new_item = new_item.replace("k.bias", "key.bias") + + new_item = new_item.replace("v.weight", "value.weight") + new_item = new_item.replace("v.bias", "value.bias") + + new_item = new_item.replace("proj_out.weight", "proj_attn.weight") + new_item = new_item.replace("proj_out.bias", "proj_attn.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.assign_to_checkpoint +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + if "proj_attn.weight" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.conv_attn_to_linear +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["query.weight", "key.weight", "value.weight"] + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0, 0] + elif "proj_attn.weight" in key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0] + + +def create_unet_diffusers_config(original_config, image_size: int): + """ + Creates a UNet config for diffusers based on the config of the original AudioLDM model. + """ + unet_params = original_config["model"]["params"]["unet_config"]["params"] + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + + block_out_channels = [unet_params["model_channels"] * mult for mult in unet_params["channel_mult"]] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlock2D" if resolution in unet_params["attention_resolutions"] else "DownBlock2D" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlock2D" if resolution in unet_params["attention_resolutions"] else "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + vae_scale_factor = 2 ** (len(vae_params["ch_mult"]) - 1) + + cross_attention_dim = ( + unet_params["cross_attention_dim"] if "cross_attention_dim" in unet_params else block_out_channels + ) + + class_embed_type = "simple_projection" if "extra_film_condition_dim" in unet_params else None + projection_class_embeddings_input_dim = ( + unet_params["extra_film_condition_dim"] if "extra_film_condition_dim" in unet_params else None + ) + class_embeddings_concat = unet_params["extra_film_use_concat"] if "extra_film_use_concat" in unet_params else None + + config = { + "sample_size": image_size // vae_scale_factor, + "in_channels": unet_params["in_channels"], + "out_channels": unet_params["out_channels"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params["num_res_blocks"], + "cross_attention_dim": cross_attention_dim, + "class_embed_type": class_embed_type, + "projection_class_embeddings_input_dim": projection_class_embeddings_input_dim, + "class_embeddings_concat": class_embeddings_concat, + } + + return config + + +# Adapted from diffusers.pipelines.stable_diffusion.convert_from_ckpt.create_vae_diffusers_config +def create_vae_diffusers_config(original_config, checkpoint, image_size: int): + """ + Creates a VAE config for diffusers based on the config of the original AudioLDM model. Compared to the original + Stable Diffusion conversion, this function passes a *learnt* VAE scaling factor to the diffusers VAE. + """ + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + _ = original_config["model"]["params"]["first_stage_config"]["params"]["embed_dim"] + + block_out_channels = [vae_params["ch"] * mult for mult in vae_params["ch_mult"]] + down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) + up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) + + scaling_factor = checkpoint["scale_factor"] if "scale_by_std" in original_config["model"]["params"] else 0.18215 + + config = { + "sample_size": image_size, + "in_channels": vae_params["in_channels"], + "out_channels": vae_params["out_ch"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "latent_channels": vae_params["z_channels"], + "layers_per_block": vae_params["num_res_blocks"], + "scaling_factor": float(scaling_factor), + } + return config + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.create_diffusers_schedular +def create_diffusers_schedular(original_config): + schedular = DDIMScheduler( + num_train_timesteps=original_config["model"]["params"]["timesteps"], + beta_start=original_config["model"]["params"]["linear_start"], + beta_end=original_config["model"]["params"]["linear_end"], + beta_schedule="scaled_linear", + ) + return schedular + + +# Adapted from diffusers.pipelines.stable_diffusion.convert_from_ckpt.convert_ldm_unet_checkpoint +def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted checkpoint. Compared to the original Stable Diffusion + conversion, this function additionally converts the learnt film embedding linear layer. + """ + + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + print(f"Checkpoint {path} has both EMA and non-EMA weights.") + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + new_checkpoint["class_embedding.weight"] = unet_state_dict["film_emb.weight"] + new_checkpoint["class_embedding.bias"] = unet_state_dict["film_emb.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.convert_ldm_vae_checkpoint +def convert_ldm_vae_checkpoint(checkpoint, config): + # extract state dict for VAE + vae_state_dict = {} + vae_key = "first_stage_model." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(vae_key): + vae_state_dict[key.replace(vae_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint + + +CLAP_KEYS_TO_MODIFY_MAPPING = { + "text_branch": "text_model", + "attn": "attention.self", + "self.proj": "output.dense", + "attention.self_mask": "attn_mask", + "mlp.fc1": "intermediate.dense", + "mlp.fc2": "output.dense", + "norm1": "layernorm_before", + "norm2": "layernorm_after", + "bn0": "batch_norm", +} + +CLAP_KEYS_TO_IGNORE = ["text_transform"] + +CLAP_EXPECTED_MISSING_KEYS = ["text_model.embeddings.token_type_ids"] + + +def convert_open_clap_checkpoint(checkpoint): + """ + Takes a state dict and returns a converted CLAP checkpoint. + """ + # extract state dict for CLAP text embedding model, discarding the audio component + model_state_dict = {} + model_key = "cond_stage_model.model.text_" + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(model_key): + model_state_dict[key.replace(model_key, "text_")] = checkpoint.get(key) + + new_checkpoint = {} + + sequential_layers_pattern = r".*sequential.(\d+).*" + text_projection_pattern = r".*_projection.(\d+).*" + + for key, value in model_state_dict.items(): + # check if key should be ignored in mapping + if key.split(".")[0] in CLAP_KEYS_TO_IGNORE: + continue + + # check if any key needs to be modified + for key_to_modify, new_key in CLAP_KEYS_TO_MODIFY_MAPPING.items(): + if key_to_modify in key: + key = key.replace(key_to_modify, new_key) + + if re.match(sequential_layers_pattern, key): + # replace sequential layers with list + sequential_layer = re.match(sequential_layers_pattern, key).group(1) + + key = key.replace(f"sequential.{sequential_layer}.", f"layers.{int(sequential_layer) // 3}.linear.") + elif re.match(text_projection_pattern, key): + projecton_layer = int(re.match(text_projection_pattern, key).group(1)) + + # Because in CLAP they use `nn.Sequential`... + transformers_projection_layer = 1 if projecton_layer == 0 else 2 + + key = key.replace(f"_projection.{projecton_layer}.", f"_projection.linear{transformers_projection_layer}.") + + if "audio" and "qkv" in key: + # split qkv into query key and value + mixed_qkv = value + qkv_dim = mixed_qkv.size(0) // 3 + + query_layer = mixed_qkv[:qkv_dim] + key_layer = mixed_qkv[qkv_dim : qkv_dim * 2] + value_layer = mixed_qkv[qkv_dim * 2 :] + + new_checkpoint[key.replace("qkv", "query")] = query_layer + new_checkpoint[key.replace("qkv", "key")] = key_layer + new_checkpoint[key.replace("qkv", "value")] = value_layer + else: + new_checkpoint[key] = value + + return new_checkpoint + + +def create_transformers_vocoder_config(original_config): + """ + Creates a config for transformers SpeechT5HifiGan based on the config of the vocoder model. + """ + vocoder_params = original_config["model"]["params"]["vocoder_config"]["params"] + + config = { + "model_in_dim": vocoder_params["num_mels"], + "sampling_rate": vocoder_params["sampling_rate"], + "upsample_initial_channel": vocoder_params["upsample_initial_channel"], + "upsample_rates": list(vocoder_params["upsample_rates"]), + "upsample_kernel_sizes": list(vocoder_params["upsample_kernel_sizes"]), + "resblock_kernel_sizes": list(vocoder_params["resblock_kernel_sizes"]), + "resblock_dilation_sizes": [ + list(resblock_dilation) for resblock_dilation in vocoder_params["resblock_dilation_sizes"] + ], + "normalize_before": False, + } + + return config + + +def convert_hifigan_checkpoint(checkpoint, config): + """ + Takes a state dict and config, and returns a converted HiFiGAN vocoder checkpoint. + """ + # extract state dict for vocoder + vocoder_state_dict = {} + vocoder_key = "first_stage_model.vocoder." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(vocoder_key): + vocoder_state_dict[key.replace(vocoder_key, "")] = checkpoint.get(key) + + # fix upsampler keys, everything else is correct already + for i in range(len(config.upsample_rates)): + vocoder_state_dict[f"upsampler.{i}.weight"] = vocoder_state_dict.pop(f"ups.{i}.weight") + vocoder_state_dict[f"upsampler.{i}.bias"] = vocoder_state_dict.pop(f"ups.{i}.bias") + + if not config.normalize_before: + # if we don't set normalize_before then these variables are unused, so we set them to their initialised values + vocoder_state_dict["mean"] = torch.zeros(config.model_in_dim) + vocoder_state_dict["scale"] = torch.ones(config.model_in_dim) + + return vocoder_state_dict + + +# Adapted from https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation/blob/84a0384742a22bd80c44e903e241f0623e874f1d/audioldm/utils.py#L72-L73 +DEFAULT_CONFIG = { + "model": { + "params": { + "linear_start": 0.0015, + "linear_end": 0.0195, + "timesteps": 1000, + "channels": 8, + "scale_by_std": True, + "unet_config": { + "target": "audioldm.latent_diffusion.openaimodel.UNetModel", + "params": { + "extra_film_condition_dim": 512, + "extra_film_use_concat": True, + "in_channels": 8, + "out_channels": 8, + "model_channels": 128, + "attention_resolutions": [8, 4, 2], + "num_res_blocks": 2, + "channel_mult": [1, 2, 3, 5], + "num_head_channels": 32, + }, + }, + "first_stage_config": { + "target": "audioldm.variational_autoencoder.autoencoder.AutoencoderKL", + "params": { + "embed_dim": 8, + "ddconfig": { + "z_channels": 8, + "resolution": 256, + "in_channels": 1, + "out_ch": 1, + "ch": 128, + "ch_mult": [1, 2, 4], + "num_res_blocks": 2, + }, + }, + }, + "vocoder_config": { + "target": "audioldm.first_stage_model.vocoder", + "params": { + "upsample_rates": [5, 4, 2, 2, 2], + "upsample_kernel_sizes": [16, 16, 8, 4, 4], + "upsample_initial_channel": 1024, + "resblock_kernel_sizes": [3, 7, 11], + "resblock_dilation_sizes": [[1, 3, 5], [1, 3, 5], [1, 3, 5]], + "num_mels": 64, + "sampling_rate": 16000, + }, + }, + }, + }, +} + + +def load_pipeline_from_original_audioldm_ckpt( + checkpoint_path: str, + original_config_file: str = None, + image_size: int = 512, + prediction_type: str = None, + extract_ema: bool = False, + scheduler_type: str = "ddim", + num_in_channels: int = None, + model_channels: int = None, + num_head_channels: int = None, + device: str = None, + from_safetensors: bool = False, +) -> AudioLDMPipeline: + """ + Load an AudioLDM pipeline object from a `.ckpt`/`.safetensors` file and (ideally) a `.yaml` config file. + + Although many of the arguments can be automatically inferred, some of these rely on brittle checks against the + global step count, which will likely fail for models that have undergone further fine-tuning. Therefore, it is + recommended that you override the default values and/or supply an `original_config_file` wherever possible. + + Args: + checkpoint_path (`str`): Path to `.ckpt` file. + original_config_file (`str`): + Path to `.yaml` config file corresponding to the original architecture. If `None`, will be automatically + set to the audioldm-s-full-v2 config. + image_size (`int`, *optional*, defaults to 512): + The image size that the model was trained on. + prediction_type (`str`, *optional*): + The prediction type that the model was trained on. If `None`, will be automatically + inferred by looking for a key in the config. For the default config, the prediction type is `'epsilon'`. + num_in_channels (`int`, *optional*, defaults to None): + The number of UNet input channels. If `None`, it will be automatically inferred from the config. + model_channels (`int`, *optional*, defaults to None): + The number of UNet model channels. If `None`, it will be automatically inferred from the config. Override + to 128 for the small checkpoints, 192 for the medium checkpoints and 256 for the large. + num_head_channels (`int`, *optional*, defaults to None): + The number of UNet head channels. If `None`, it will be automatically inferred from the config. Override + to 32 for the small and medium checkpoints, and 64 for the large. + scheduler_type (`str`, *optional*, defaults to 'pndm'): + Type of scheduler to use. Should be one of `["pndm", "lms", "heun", "euler", "euler-ancestral", "dpm", + "ddim"]`. + extract_ema (`bool`, *optional*, defaults to `False`): Only relevant for + checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights or not. Defaults to + `False`. Pass `True` to extract the EMA weights. EMA weights usually yield higher quality images for + inference. Non-EMA weights are usually better to continue fine-tuning. + device (`str`, *optional*, defaults to `None`): + The device to use. Pass `None` to determine automatically. + from_safetensors (`str`, *optional*, defaults to `False`): + If `checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch. + return: An AudioLDMPipeline object representing the passed-in `.ckpt`/`.safetensors` file. + """ + + if from_safetensors: + from safetensors import safe_open + + checkpoint = {} + with safe_open(checkpoint_path, framework="pt", device="cpu") as f: + for key in f.keys(): + checkpoint[key] = f.get_tensor(key) + else: + if device is None: + device = "cuda" if torch.cuda.is_available() else "cpu" + checkpoint = torch.load(checkpoint_path, map_location=device) + else: + checkpoint = torch.load(checkpoint_path, map_location=device) + + if "state_dict" in checkpoint: + checkpoint = checkpoint["state_dict"] + + if original_config_file is None: + original_config = DEFAULT_CONFIG + else: + original_config = yaml.safe_load(original_config_file) + + if num_in_channels is not None: + original_config["model"]["params"]["unet_config"]["params"]["in_channels"] = num_in_channels + + if model_channels is not None: + original_config["model"]["params"]["unet_config"]["params"]["model_channels"] = model_channels + + if num_head_channels is not None: + original_config["model"]["params"]["unet_config"]["params"]["num_head_channels"] = num_head_channels + + if ( + "parameterization" in original_config["model"]["params"] + and original_config["model"]["params"]["parameterization"] == "v" + ): + if prediction_type is None: + prediction_type = "v_prediction" + else: + if prediction_type is None: + prediction_type = "epsilon" + + if image_size is None: + image_size = 512 + + num_train_timesteps = original_config["model"]["params"]["timesteps"] + beta_start = original_config["model"]["params"]["linear_start"] + beta_end = original_config["model"]["params"]["linear_end"] + + scheduler = DDIMScheduler( + beta_end=beta_end, + beta_schedule="scaled_linear", + beta_start=beta_start, + num_train_timesteps=num_train_timesteps, + steps_offset=1, + clip_sample=False, + set_alpha_to_one=False, + prediction_type=prediction_type, + ) + # make sure scheduler works correctly with DDIM + scheduler.register_to_config(clip_sample=False) + + if scheduler_type == "pndm": + config = dict(scheduler.config) + config["skip_prk_steps"] = True + scheduler = PNDMScheduler.from_config(config) + elif scheduler_type == "lms": + scheduler = LMSDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "heun": + scheduler = HeunDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "euler": + scheduler = EulerDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "euler-ancestral": + scheduler = EulerAncestralDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "dpm": + scheduler = DPMSolverMultistepScheduler.from_config(scheduler.config) + elif scheduler_type == "ddim": + scheduler = scheduler + else: + raise ValueError(f"Scheduler of type {scheduler_type} doesn't exist!") + + # Convert the UNet2DModel + unet_config = create_unet_diffusers_config(original_config, image_size=image_size) + unet = UNet2DConditionModel(**unet_config) + + converted_unet_checkpoint = convert_ldm_unet_checkpoint( + checkpoint, unet_config, path=checkpoint_path, extract_ema=extract_ema + ) + + unet.load_state_dict(converted_unet_checkpoint) + + # Convert the VAE model + vae_config = create_vae_diffusers_config(original_config, checkpoint=checkpoint, image_size=image_size) + converted_vae_checkpoint = convert_ldm_vae_checkpoint(checkpoint, vae_config) + + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_checkpoint) + + # Convert the text model + # AudioLDM uses the same configuration and tokenizer as the original CLAP model + config = ClapTextConfig.from_pretrained("laion/clap-htsat-unfused") + tokenizer = AutoTokenizer.from_pretrained("laion/clap-htsat-unfused") + + converted_text_model = convert_open_clap_checkpoint(checkpoint) + text_model = ClapTextModelWithProjection(config) + + missing_keys, unexpected_keys = text_model.load_state_dict(converted_text_model, strict=False) + # we expect not to have token_type_ids in our original state dict so let's ignore them + missing_keys = list(set(missing_keys) - set(CLAP_EXPECTED_MISSING_KEYS)) + + if len(unexpected_keys) > 0: + raise ValueError(f"Unexpected keys when loading CLAP model: {unexpected_keys}") + + if len(missing_keys) > 0: + raise ValueError(f"Missing keys when loading CLAP model: {missing_keys}") + + # Convert the vocoder model + vocoder_config = create_transformers_vocoder_config(original_config) + vocoder_config = SpeechT5HifiGanConfig(**vocoder_config) + converted_vocoder_checkpoint = convert_hifigan_checkpoint(checkpoint, vocoder_config) + + vocoder = SpeechT5HifiGan(vocoder_config) + vocoder.load_state_dict(converted_vocoder_checkpoint) + + # Instantiate the diffusers pipeline + pipe = AudioLDMPipeline( + vae=vae, + text_encoder=text_model, + tokenizer=tokenizer, + unet=unet, + scheduler=scheduler, + vocoder=vocoder, + ) + + return pipe + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--original_config_file", + default=None, + type=str, + help="The YAML config file corresponding to the original architecture.", + ) + parser.add_argument( + "--num_in_channels", + default=None, + type=int, + help="The number of input channels. If `None` number of input channels will be automatically inferred.", + ) + parser.add_argument( + "--model_channels", + default=None, + type=int, + help="The number of UNet model channels. If `None`, it will be automatically inferred from the config. Override" + " to 128 for the small checkpoints, 192 for the medium checkpoints and 256 for the large.", + ) + parser.add_argument( + "--num_head_channels", + default=None, + type=int, + help="The number of UNet head channels. If `None`, it will be automatically inferred from the config. Override" + " to 32 for the small and medium checkpoints, and 64 for the large.", + ) + parser.add_argument( + "--scheduler_type", + default="ddim", + type=str, + help="Type of scheduler to use. Should be one of ['pndm', 'lms', 'ddim', 'euler', 'euler-ancestral', 'dpm']", + ) + parser.add_argument( + "--image_size", + default=None, + type=int, + help=("The image size that the model was trained on."), + ) + parser.add_argument( + "--prediction_type", + default=None, + type=str, + help=("The prediction type that the model was trained on."), + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--from_safetensors", + action="store_true", + help="If `--checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch.", + ) + parser.add_argument( + "--to_safetensors", + action="store_true", + help="Whether to store pipeline in safetensors format or not.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + args = parser.parse_args() + + pipe = load_pipeline_from_original_audioldm_ckpt( + checkpoint_path=args.checkpoint_path, + original_config_file=args.original_config_file, + image_size=args.image_size, + prediction_type=args.prediction_type, + extract_ema=args.extract_ema, + scheduler_type=args.scheduler_type, + num_in_channels=args.num_in_channels, + model_channels=args.model_channels, + num_head_channels=args.num_head_channels, + from_safetensors=args.from_safetensors, + device=args.device, + ) + pipe.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_controlnet_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_controlnet_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..4c6fe90cb09f10af84bf0399ac907c4c44f47a0e --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_controlnet_to_diffusers.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for stable diffusion checkpoints which _only_ contain a controlnet.""" + +import argparse + +from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--original_config_file", + type=str, + required=True, + help="The YAML config file corresponding to the original architecture.", + ) + parser.add_argument( + "--num_in_channels", + default=None, + type=int, + help="The number of input channels. If `None` number of input channels will be automatically inferred.", + ) + parser.add_argument( + "--image_size", + default=512, + type=int, + help=( + "The image size that the model was trained on. Use 512 for Stable Diffusion v1.X and Stable Diffusion v2" + " Base. Use 768 for Stable Diffusion v2." + ), + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--upcast_attention", + action="store_true", + help=( + "Whether the attention computation should always be upcasted. This is necessary when running stable" + " diffusion 2.1." + ), + ) + parser.add_argument( + "--from_safetensors", + action="store_true", + help="If `--checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch.", + ) + parser.add_argument( + "--to_safetensors", + action="store_true", + help="Whether to store pipeline in safetensors format or not.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + + # small workaround to get argparser to parse a boolean input as either true _or_ false + def parse_bool(string): + if string == "True": + return True + elif string == "False": + return False + else: + raise ValueError(f"could not parse string as bool {string}") + + parser.add_argument( + "--use_linear_projection", help="Override for use linear projection", required=False, type=parse_bool + ) + + parser.add_argument("--cross_attention_dim", help="Override for cross attention_dim", required=False, type=int) + + args = parser.parse_args() + + controlnet = download_controlnet_from_original_ckpt( + checkpoint_path=args.checkpoint_path, + original_config_file=args.original_config_file, + image_size=args.image_size, + extract_ema=args.extract_ema, + num_in_channels=args.num_in_channels, + upcast_attention=args.upcast_attention, + from_safetensors=args.from_safetensors, + device=args.device, + use_linear_projection=args.use_linear_projection, + cross_attention_dim=args.cross_attention_dim, + ) + + controlnet.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_musicldm_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_musicldm_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..00836fde2592126ade0ee95918e1fd38cf138b0e --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_musicldm_to_diffusers.py @@ -0,0 +1,1056 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the MusicLDM checkpoints.""" + +import argparse +import re + +import torch +import yaml +from transformers import ( + AutoFeatureExtractor, + AutoTokenizer, + ClapConfig, + ClapModel, + SpeechT5HifiGan, + SpeechT5HifiGanConfig, +) + +from diffusers import ( + AutoencoderKL, + DDIMScheduler, + DPMSolverMultistepScheduler, + EulerAncestralDiscreteScheduler, + EulerDiscreteScheduler, + HeunDiscreteScheduler, + LMSDiscreteScheduler, + MusicLDMPipeline, + PNDMScheduler, + UNet2DConditionModel, +) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.shave_segments +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_resnet_paths +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_resnet_paths +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_attention_paths +def renew_attention_paths(old_list): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "to_q.weight") + new_item = new_item.replace("q.bias", "to_q.bias") + + new_item = new_item.replace("k.weight", "to_k.weight") + new_item = new_item.replace("k.bias", "to_k.bias") + + new_item = new_item.replace("v.weight", "to_v.weight") + new_item = new_item.replace("v.bias", "to_v.bias") + + new_item = new_item.replace("proj_out.weight", "to_out.0.weight") + new_item = new_item.replace("proj_out.bias", "to_out.0.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.assign_to_checkpoint +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + if "proj_attn.weight" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["to_q.weight", "to_k.weight", "to_v.weight"] + proj_key = "to_out.0.weight" + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys or ".".join(key.split(".")[-3:]) == proj_key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key].squeeze() + + +def create_unet_diffusers_config(original_config, image_size: int): + """ + Creates a UNet config for diffusers based on the config of the original MusicLDM model. + """ + unet_params = original_config["model"]["params"]["unet_config"]["params"] + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + + block_out_channels = [unet_params["model_channels"] * mult for mult in unet_params["channel_mult"]] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlock2D" if resolution in unet_params["attention_resolutions"] else "DownBlock2D" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlock2D" if resolution in unet_params["attention_resolutions"] else "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + vae_scale_factor = 2 ** (len(vae_params["ch_mult"]) - 1) + + cross_attention_dim = ( + unet_params["cross_attention_dim"] if "cross_attention_dim" in unet_params else block_out_channels + ) + + class_embed_type = "simple_projection" if "extra_film_condition_dim" in unet_params else None + projection_class_embeddings_input_dim = ( + unet_params["extra_film_condition_dim"] if "extra_film_condition_dim" in unet_params else None + ) + class_embeddings_concat = unet_params["extra_film_use_concat"] if "extra_film_use_concat" in unet_params else None + + config = { + "sample_size": image_size // vae_scale_factor, + "in_channels": unet_params["in_channels"], + "out_channels": unet_params["out_channels"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params["num_res_blocks"], + "cross_attention_dim": cross_attention_dim, + "class_embed_type": class_embed_type, + "projection_class_embeddings_input_dim": projection_class_embeddings_input_dim, + "class_embeddings_concat": class_embeddings_concat, + } + + return config + + +# Adapted from diffusers.pipelines.stable_diffusion.convert_from_ckpt.create_vae_diffusers_config +def create_vae_diffusers_config(original_config, checkpoint, image_size: int): + """ + Creates a VAE config for diffusers based on the config of the original MusicLDM model. Compared to the original + Stable Diffusion conversion, this function passes a *learnt* VAE scaling factor to the diffusers VAE. + """ + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + _ = original_config["model"]["params"]["first_stage_config"]["params"]["embed_dim"] + + block_out_channels = [vae_params["ch"] * mult for mult in vae_params["ch_mult"]] + down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) + up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) + + scaling_factor = checkpoint["scale_factor"] if "scale_by_std" in original_config["model"]["params"] else 0.18215 + + config = { + "sample_size": image_size, + "in_channels": vae_params["in_channels"], + "out_channels": vae_params["out_ch"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "latent_channels": vae_params["z_channels"], + "layers_per_block": vae_params["num_res_blocks"], + "scaling_factor": float(scaling_factor), + } + return config + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.create_diffusers_schedular +def create_diffusers_schedular(original_config): + schedular = DDIMScheduler( + num_train_timesteps=original_config["model"]["params"]["timesteps"], + beta_start=original_config["model"]["params"]["linear_start"], + beta_end=original_config["model"]["params"]["linear_end"], + beta_schedule="scaled_linear", + ) + return schedular + + +def convert_ldm_unet_checkpoint(checkpoint, config, path=None, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted checkpoint. Compared to the original Stable Diffusion + conversion, this function additionally converts the learnt film embedding linear layer. + """ + + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + print(f"Checkpoint {path} has both EMA and non-EMA weights.") + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + new_checkpoint["class_embedding.weight"] = unet_state_dict["film_emb.weight"] + new_checkpoint["class_embedding.bias"] = unet_state_dict["film_emb.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.convert_ldm_vae_checkpoint +def convert_ldm_vae_checkpoint(checkpoint, config): + # extract state dict for VAE + vae_state_dict = {} + vae_key = "first_stage_model." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(vae_key): + vae_state_dict[key.replace(vae_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint + + +CLAP_KEYS_TO_MODIFY_MAPPING = { + "text_branch": "text_model", + "audio_branch": "audio_model.audio_encoder", + "attn": "attention.self", + "self.proj": "output.dense", + "attention.self_mask": "attn_mask", + "mlp.fc1": "intermediate.dense", + "mlp.fc2": "output.dense", + "norm1": "layernorm_before", + "norm2": "layernorm_after", + "bn0": "batch_norm", +} + +CLAP_KEYS_TO_IGNORE = [ + "text_transform", + "audio_transform", + "stft", + "logmel_extractor", + "tscam_conv", + "head", + "attn_mask", +] + +CLAP_EXPECTED_MISSING_KEYS = ["text_model.embeddings.token_type_ids"] + + +def convert_open_clap_checkpoint(checkpoint): + """ + Takes a state dict and returns a converted CLAP checkpoint. + """ + # extract state dict for CLAP text embedding model, discarding the audio component + model_state_dict = {} + model_key = "cond_stage_model.model." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(model_key): + model_state_dict[key.replace(model_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + sequential_layers_pattern = r".*sequential.(\d+).*" + text_projection_pattern = r".*_projection.(\d+).*" + + for key, value in model_state_dict.items(): + # check if key should be ignored in mapping - if so map it to a key name that we'll filter out at the end + for key_to_ignore in CLAP_KEYS_TO_IGNORE: + if key_to_ignore in key: + key = "spectrogram" + + # check if any key needs to be modified + for key_to_modify, new_key in CLAP_KEYS_TO_MODIFY_MAPPING.items(): + if key_to_modify in key: + key = key.replace(key_to_modify, new_key) + + if re.match(sequential_layers_pattern, key): + # replace sequential layers with list + sequential_layer = re.match(sequential_layers_pattern, key).group(1) + + key = key.replace(f"sequential.{sequential_layer}.", f"layers.{int(sequential_layer) // 3}.linear.") + elif re.match(text_projection_pattern, key): + projecton_layer = int(re.match(text_projection_pattern, key).group(1)) + + # Because in CLAP they use `nn.Sequential`... + transformers_projection_layer = 1 if projecton_layer == 0 else 2 + + key = key.replace(f"_projection.{projecton_layer}.", f"_projection.linear{transformers_projection_layer}.") + + if "audio" and "qkv" in key: + # split qkv into query key and value + mixed_qkv = value + qkv_dim = mixed_qkv.size(0) // 3 + + query_layer = mixed_qkv[:qkv_dim] + key_layer = mixed_qkv[qkv_dim : qkv_dim * 2] + value_layer = mixed_qkv[qkv_dim * 2 :] + + new_checkpoint[key.replace("qkv", "query")] = query_layer + new_checkpoint[key.replace("qkv", "key")] = key_layer + new_checkpoint[key.replace("qkv", "value")] = value_layer + elif key != "spectrogram": + new_checkpoint[key] = value + + return new_checkpoint + + +def create_transformers_vocoder_config(original_config): + """ + Creates a config for transformers SpeechT5HifiGan based on the config of the vocoder model. + """ + vocoder_params = original_config["model"]["params"]["vocoder_config"]["params"] + + config = { + "model_in_dim": vocoder_params["num_mels"], + "sampling_rate": vocoder_params["sampling_rate"], + "upsample_initial_channel": vocoder_params["upsample_initial_channel"], + "upsample_rates": list(vocoder_params["upsample_rates"]), + "upsample_kernel_sizes": list(vocoder_params["upsample_kernel_sizes"]), + "resblock_kernel_sizes": list(vocoder_params["resblock_kernel_sizes"]), + "resblock_dilation_sizes": [ + list(resblock_dilation) for resblock_dilation in vocoder_params["resblock_dilation_sizes"] + ], + "normalize_before": False, + } + + return config + + +def convert_hifigan_checkpoint(checkpoint, config): + """ + Takes a state dict and config, and returns a converted HiFiGAN vocoder checkpoint. + """ + # extract state dict for vocoder + vocoder_state_dict = {} + vocoder_key = "first_stage_model.vocoder." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(vocoder_key): + vocoder_state_dict[key.replace(vocoder_key, "")] = checkpoint.get(key) + + # fix upsampler keys, everything else is correct already + for i in range(len(config.upsample_rates)): + vocoder_state_dict[f"upsampler.{i}.weight"] = vocoder_state_dict.pop(f"ups.{i}.weight") + vocoder_state_dict[f"upsampler.{i}.bias"] = vocoder_state_dict.pop(f"ups.{i}.bias") + + if not config.normalize_before: + # if we don't set normalize_before then these variables are unused, so we set them to their initialised values + vocoder_state_dict["mean"] = torch.zeros(config.model_in_dim) + vocoder_state_dict["scale"] = torch.ones(config.model_in_dim) + + return vocoder_state_dict + + +# Adapted from https://huggingface.co/spaces/haoheliu/MusicLDM-text-to-audio-generation/blob/84a0384742a22bd80c44e903e241f0623e874f1d/MusicLDM/utils.py#L72-L73 +DEFAULT_CONFIG = { + "model": { + "params": { + "linear_start": 0.0015, + "linear_end": 0.0195, + "timesteps": 1000, + "channels": 8, + "scale_by_std": True, + "unet_config": { + "target": "MusicLDM.latent_diffusion.openaimodel.UNetModel", + "params": { + "extra_film_condition_dim": 512, + "extra_film_use_concat": True, + "in_channels": 8, + "out_channels": 8, + "model_channels": 128, + "attention_resolutions": [8, 4, 2], + "num_res_blocks": 2, + "channel_mult": [1, 2, 3, 5], + "num_head_channels": 32, + }, + }, + "first_stage_config": { + "target": "MusicLDM.variational_autoencoder.autoencoder.AutoencoderKL", + "params": { + "embed_dim": 8, + "ddconfig": { + "z_channels": 8, + "resolution": 256, + "in_channels": 1, + "out_ch": 1, + "ch": 128, + "ch_mult": [1, 2, 4], + "num_res_blocks": 2, + }, + }, + }, + "vocoder_config": { + "target": "MusicLDM.first_stage_model.vocoder", + "params": { + "upsample_rates": [5, 4, 2, 2, 2], + "upsample_kernel_sizes": [16, 16, 8, 4, 4], + "upsample_initial_channel": 1024, + "resblock_kernel_sizes": [3, 7, 11], + "resblock_dilation_sizes": [[1, 3, 5], [1, 3, 5], [1, 3, 5]], + "num_mels": 64, + "sampling_rate": 16000, + }, + }, + }, + }, +} + + +def load_pipeline_from_original_MusicLDM_ckpt( + checkpoint_path: str, + original_config_file: str = None, + image_size: int = 1024, + prediction_type: str = None, + extract_ema: bool = False, + scheduler_type: str = "ddim", + num_in_channels: int = None, + model_channels: int = None, + num_head_channels: int = None, + device: str = None, + from_safetensors: bool = False, +) -> MusicLDMPipeline: + """ + Load an MusicLDM pipeline object from a `.ckpt`/`.safetensors` file and (ideally) a `.yaml` config file. + + Although many of the arguments can be automatically inferred, some of these rely on brittle checks against the + global step count, which will likely fail for models that have undergone further fine-tuning. Therefore, it is + recommended that you override the default values and/or supply an `original_config_file` wherever possible. + + Args: + checkpoint_path (`str`): Path to `.ckpt` file. + original_config_file (`str`): + Path to `.yaml` config file corresponding to the original architecture. If `None`, will be automatically + set to the MusicLDM-s-full-v2 config. + image_size (`int`, *optional*, defaults to 1024): + The image size that the model was trained on. + prediction_type (`str`, *optional*): + The prediction type that the model was trained on. If `None`, will be automatically + inferred by looking for a key in the config. For the default config, the prediction type is `'epsilon'`. + num_in_channels (`int`, *optional*, defaults to None): + The number of UNet input channels. If `None`, it will be automatically inferred from the config. + model_channels (`int`, *optional*, defaults to None): + The number of UNet model channels. If `None`, it will be automatically inferred from the config. Override + to 128 for the small checkpoints, 192 for the medium checkpoints and 256 for the large. + num_head_channels (`int`, *optional*, defaults to None): + The number of UNet head channels. If `None`, it will be automatically inferred from the config. Override + to 32 for the small and medium checkpoints, and 64 for the large. + scheduler_type (`str`, *optional*, defaults to 'pndm'): + Type of scheduler to use. Should be one of `["pndm", "lms", "heun", "euler", "euler-ancestral", "dpm", + "ddim"]`. + extract_ema (`bool`, *optional*, defaults to `False`): Only relevant for + checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights or not. Defaults to + `False`. Pass `True` to extract the EMA weights. EMA weights usually yield higher quality images for + inference. Non-EMA weights are usually better to continue fine-tuning. + device (`str`, *optional*, defaults to `None`): + The device to use. Pass `None` to determine automatically. + from_safetensors (`str`, *optional*, defaults to `False`): + If `checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch. + return: An MusicLDMPipeline object representing the passed-in `.ckpt`/`.safetensors` file. + """ + if from_safetensors: + from safetensors import safe_open + + checkpoint = {} + with safe_open(checkpoint_path, framework="pt", device="cpu") as f: + for key in f.keys(): + checkpoint[key] = f.get_tensor(key) + else: + if device is None: + device = "cuda" if torch.cuda.is_available() else "cpu" + checkpoint = torch.load(checkpoint_path, map_location=device) + else: + checkpoint = torch.load(checkpoint_path, map_location=device) + + if "state_dict" in checkpoint: + checkpoint = checkpoint["state_dict"] + + if original_config_file is None: + original_config = DEFAULT_CONFIG + else: + original_config = yaml.safe_load(original_config_file) + + if num_in_channels is not None: + original_config["model"]["params"]["unet_config"]["params"]["in_channels"] = num_in_channels + + if model_channels is not None: + original_config["model"]["params"]["unet_config"]["params"]["model_channels"] = model_channels + + if num_head_channels is not None: + original_config["model"]["params"]["unet_config"]["params"]["num_head_channels"] = num_head_channels + + if ( + "parameterization" in original_config["model"]["params"] + and original_config["model"]["params"]["parameterization"] == "v" + ): + if prediction_type is None: + prediction_type = "v_prediction" + else: + if prediction_type is None: + prediction_type = "epsilon" + + if image_size is None: + image_size = 512 + + num_train_timesteps = original_config["model"]["params"]["timesteps"] + beta_start = original_config["model"]["params"]["linear_start"] + beta_end = original_config["model"]["params"]["linear_end"] + + scheduler = DDIMScheduler( + beta_end=beta_end, + beta_schedule="scaled_linear", + beta_start=beta_start, + num_train_timesteps=num_train_timesteps, + steps_offset=1, + clip_sample=False, + set_alpha_to_one=False, + prediction_type=prediction_type, + ) + # make sure scheduler works correctly with DDIM + scheduler.register_to_config(clip_sample=False) + + if scheduler_type == "pndm": + config = dict(scheduler.config) + config["skip_prk_steps"] = True + scheduler = PNDMScheduler.from_config(config) + elif scheduler_type == "lms": + scheduler = LMSDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "heun": + scheduler = HeunDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "euler": + scheduler = EulerDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "euler-ancestral": + scheduler = EulerAncestralDiscreteScheduler.from_config(scheduler.config) + elif scheduler_type == "dpm": + scheduler = DPMSolverMultistepScheduler.from_config(scheduler.config) + elif scheduler_type == "ddim": + scheduler = scheduler + else: + raise ValueError(f"Scheduler of type {scheduler_type} doesn't exist!") + + # Convert the UNet2DModel + unet_config = create_unet_diffusers_config(original_config, image_size=image_size) + unet = UNet2DConditionModel(**unet_config) + + converted_unet_checkpoint = convert_ldm_unet_checkpoint( + checkpoint, unet_config, path=checkpoint_path, extract_ema=extract_ema + ) + + unet.load_state_dict(converted_unet_checkpoint) + + # Convert the VAE model + vae_config = create_vae_diffusers_config(original_config, checkpoint=checkpoint, image_size=image_size) + converted_vae_checkpoint = convert_ldm_vae_checkpoint(checkpoint, vae_config) + + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_checkpoint) + + # Convert the text model + # MusicLDM uses the same tokenizer as the original CLAP model, but a slightly different configuration + config = ClapConfig.from_pretrained("laion/clap-htsat-unfused") + config.audio_config.update( + { + "patch_embeds_hidden_size": 128, + "hidden_size": 1024, + "depths": [2, 2, 12, 2], + } + ) + tokenizer = AutoTokenizer.from_pretrained("laion/clap-htsat-unfused") + feature_extractor = AutoFeatureExtractor.from_pretrained("laion/clap-htsat-unfused") + + converted_text_model = convert_open_clap_checkpoint(checkpoint) + text_model = ClapModel(config) + + missing_keys, unexpected_keys = text_model.load_state_dict(converted_text_model, strict=False) + # we expect not to have token_type_ids in our original state dict so let's ignore them + missing_keys = list(set(missing_keys) - set(CLAP_EXPECTED_MISSING_KEYS)) + + if len(unexpected_keys) > 0: + raise ValueError(f"Unexpected keys when loading CLAP model: {unexpected_keys}") + + if len(missing_keys) > 0: + raise ValueError(f"Missing keys when loading CLAP model: {missing_keys}") + + # Convert the vocoder model + vocoder_config = create_transformers_vocoder_config(original_config) + vocoder_config = SpeechT5HifiGanConfig(**vocoder_config) + converted_vocoder_checkpoint = convert_hifigan_checkpoint(checkpoint, vocoder_config) + + vocoder = SpeechT5HifiGan(vocoder_config) + vocoder.load_state_dict(converted_vocoder_checkpoint) + + # Instantiate the diffusers pipeline + pipe = MusicLDMPipeline( + vae=vae, + text_encoder=text_model, + tokenizer=tokenizer, + unet=unet, + scheduler=scheduler, + vocoder=vocoder, + feature_extractor=feature_extractor, + ) + + return pipe + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--original_config_file", + default=None, + type=str, + help="The YAML config file corresponding to the original architecture.", + ) + parser.add_argument( + "--num_in_channels", + default=None, + type=int, + help="The number of input channels. If `None` number of input channels will be automatically inferred.", + ) + parser.add_argument( + "--model_channels", + default=None, + type=int, + help="The number of UNet model channels. If `None`, it will be automatically inferred from the config. Override" + " to 128 for the small checkpoints, 192 for the medium checkpoints and 256 for the large.", + ) + parser.add_argument( + "--num_head_channels", + default=None, + type=int, + help="The number of UNet head channels. If `None`, it will be automatically inferred from the config. Override" + " to 32 for the small and medium checkpoints, and 64 for the large.", + ) + parser.add_argument( + "--scheduler_type", + default="ddim", + type=str, + help="Type of scheduler to use. Should be one of ['pndm', 'lms', 'ddim', 'euler', 'euler-ancestral', 'dpm']", + ) + parser.add_argument( + "--image_size", + default=None, + type=int, + help=("The image size that the model was trained on."), + ) + parser.add_argument( + "--prediction_type", + default=None, + type=str, + help=("The prediction type that the model was trained on."), + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--from_safetensors", + action="store_true", + help="If `--checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch.", + ) + parser.add_argument( + "--to_safetensors", + action="store_true", + help="Whether to store pipeline in safetensors format or not.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + args = parser.parse_args() + + pipe = load_pipeline_from_original_MusicLDM_ckpt( + checkpoint_path=args.checkpoint_path, + original_config_file=args.original_config_file, + image_size=args.image_size, + prediction_type=args.prediction_type, + extract_ema=args.extract_ema, + scheduler_type=args.scheduler_type, + num_in_channels=args.num_in_channels, + model_channels=args.model_channels, + num_head_channels=args.num_head_channels, + from_safetensors=args.from_safetensors, + device=args.device, + ) + pipe.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_stable_diffusion_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_stable_diffusion_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..59eeeec24c799718ff525269cf5455c97205935d --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_stable_diffusion_to_diffusers.py @@ -0,0 +1,188 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the LDM checkpoints.""" + +import argparse +import importlib + +import torch + +from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + # !wget https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml + parser.add_argument( + "--original_config_file", + default=None, + type=str, + help="The YAML config file corresponding to the original architecture.", + ) + parser.add_argument( + "--config_files", + default=None, + type=str, + help="The YAML config file corresponding to the architecture.", + ) + parser.add_argument( + "--num_in_channels", + default=None, + type=int, + help="The number of input channels. If `None` number of input channels will be automatically inferred.", + ) + parser.add_argument( + "--scheduler_type", + default="pndm", + type=str, + help="Type of scheduler to use. Should be one of ['pndm', 'lms', 'ddim', 'euler', 'euler-ancestral', 'dpm']", + ) + parser.add_argument( + "--pipeline_type", + default=None, + type=str, + help=( + "The pipeline type. One of 'FrozenOpenCLIPEmbedder', 'FrozenCLIPEmbedder', 'PaintByExample'" + ". If `None` pipeline will be automatically inferred." + ), + ) + parser.add_argument( + "--image_size", + default=None, + type=int, + help=( + "The image size that the model was trained on. Use 512 for Stable Diffusion v1.X and Stable Diffusion v2" + " Base. Use 768 for Stable Diffusion v2." + ), + ) + parser.add_argument( + "--prediction_type", + default=None, + type=str, + help=( + "The prediction type that the model was trained on. Use 'epsilon' for Stable Diffusion v1.X and Stable" + " Diffusion v2 Base. Use 'v_prediction' for Stable Diffusion v2." + ), + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--upcast_attention", + action="store_true", + help=( + "Whether the attention computation should always be upcasted. This is necessary when running stable" + " diffusion 2.1." + ), + ) + parser.add_argument( + "--from_safetensors", + action="store_true", + help="If `--checkpoint_path` is in `safetensors` format, load checkpoint with safetensors instead of PyTorch.", + ) + parser.add_argument( + "--to_safetensors", + action="store_true", + help="Whether to store pipeline in safetensors format or not.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + parser.add_argument( + "--stable_unclip", + type=str, + default=None, + required=False, + help="Set if this is a stable unCLIP model. One of 'txt2img' or 'img2img'.", + ) + parser.add_argument( + "--stable_unclip_prior", + type=str, + default=None, + required=False, + help="Set if this is a stable unCLIP txt2img model. Selects which prior to use. If `--stable_unclip` is set to `txt2img`, the karlo prior (https://huggingface.co/kakaobrain/karlo-v1-alpha/tree/main/prior) is selected by default.", + ) + parser.add_argument( + "--clip_stats_path", + type=str, + help="Path to the clip stats file. Only required if the stable unclip model's config specifies `model.params.noise_aug_config.params.clip_stats_path`.", + required=False, + ) + parser.add_argument( + "--controlnet", action="store_true", default=None, help="Set flag if this is a controlnet checkpoint." + ) + parser.add_argument("--half", action="store_true", help="Save weights in half precision.") + parser.add_argument( + "--vae_path", + type=str, + default=None, + required=False, + help="Set to a path, hub id to an already converted vae to not convert it again.", + ) + parser.add_argument( + "--pipeline_class_name", + type=str, + default=None, + required=False, + help="Specify the pipeline class name", + ) + + args = parser.parse_args() + + if args.pipeline_class_name is not None: + library = importlib.import_module("diffusers") + class_obj = getattr(library, args.pipeline_class_name) + pipeline_class = class_obj + else: + pipeline_class = None + + pipe = download_from_original_stable_diffusion_ckpt( + checkpoint_path_or_dict=args.checkpoint_path, + original_config_file=args.original_config_file, + config_files=args.config_files, + image_size=args.image_size, + prediction_type=args.prediction_type, + model_type=args.pipeline_type, + extract_ema=args.extract_ema, + scheduler_type=args.scheduler_type, + num_in_channels=args.num_in_channels, + upcast_attention=args.upcast_attention, + from_safetensors=args.from_safetensors, + device=args.device, + stable_unclip=args.stable_unclip, + stable_unclip_prior=args.stable_unclip_prior, + clip_stats_path=args.clip_stats_path, + controlnet=args.controlnet, + vae_path=args.vae_path, + pipeline_class=pipeline_class, + ) + + if args.half: + pipe.to(dtype=torch.float16) + + if args.controlnet: + # only save the controlnet model + pipe.controlnet.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) + else: + pipe.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_t2i_adapter.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_t2i_adapter.py new file mode 100644 index 0000000000000000000000000000000000000000..e23a2431ce9e036db1f35fee034ab4da263b2cf1 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_original_t2i_adapter.py @@ -0,0 +1,250 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Conversion script for the T2I-Adapter checkpoints. +""" + +import argparse + +import torch + +from diffusers import T2IAdapter + + +def convert_adapter(src_state, in_channels): + original_body_length = max([int(x.split(".")[1]) for x in src_state.keys() if "body." in x]) + 1 + + assert original_body_length == 8 + + # (0, 1) -> channels 1 + assert src_state["body.0.block1.weight"].shape == (320, 320, 3, 3) + + # (2, 3) -> channels 2 + assert src_state["body.2.in_conv.weight"].shape == (640, 320, 1, 1) + + # (4, 5) -> channels 3 + assert src_state["body.4.in_conv.weight"].shape == (1280, 640, 1, 1) + + # (6, 7) -> channels 4 + assert src_state["body.6.block1.weight"].shape == (1280, 1280, 3, 3) + + res_state = { + "adapter.conv_in.weight": src_state.pop("conv_in.weight"), + "adapter.conv_in.bias": src_state.pop("conv_in.bias"), + # 0.resnets.0 + "adapter.body.0.resnets.0.block1.weight": src_state.pop("body.0.block1.weight"), + "adapter.body.0.resnets.0.block1.bias": src_state.pop("body.0.block1.bias"), + "adapter.body.0.resnets.0.block2.weight": src_state.pop("body.0.block2.weight"), + "adapter.body.0.resnets.0.block2.bias": src_state.pop("body.0.block2.bias"), + # 0.resnets.1 + "adapter.body.0.resnets.1.block1.weight": src_state.pop("body.1.block1.weight"), + "adapter.body.0.resnets.1.block1.bias": src_state.pop("body.1.block1.bias"), + "adapter.body.0.resnets.1.block2.weight": src_state.pop("body.1.block2.weight"), + "adapter.body.0.resnets.1.block2.bias": src_state.pop("body.1.block2.bias"), + # 1 + "adapter.body.1.in_conv.weight": src_state.pop("body.2.in_conv.weight"), + "adapter.body.1.in_conv.bias": src_state.pop("body.2.in_conv.bias"), + # 1.resnets.0 + "adapter.body.1.resnets.0.block1.weight": src_state.pop("body.2.block1.weight"), + "adapter.body.1.resnets.0.block1.bias": src_state.pop("body.2.block1.bias"), + "adapter.body.1.resnets.0.block2.weight": src_state.pop("body.2.block2.weight"), + "adapter.body.1.resnets.0.block2.bias": src_state.pop("body.2.block2.bias"), + # 1.resnets.1 + "adapter.body.1.resnets.1.block1.weight": src_state.pop("body.3.block1.weight"), + "adapter.body.1.resnets.1.block1.bias": src_state.pop("body.3.block1.bias"), + "adapter.body.1.resnets.1.block2.weight": src_state.pop("body.3.block2.weight"), + "adapter.body.1.resnets.1.block2.bias": src_state.pop("body.3.block2.bias"), + # 2 + "adapter.body.2.in_conv.weight": src_state.pop("body.4.in_conv.weight"), + "adapter.body.2.in_conv.bias": src_state.pop("body.4.in_conv.bias"), + # 2.resnets.0 + "adapter.body.2.resnets.0.block1.weight": src_state.pop("body.4.block1.weight"), + "adapter.body.2.resnets.0.block1.bias": src_state.pop("body.4.block1.bias"), + "adapter.body.2.resnets.0.block2.weight": src_state.pop("body.4.block2.weight"), + "adapter.body.2.resnets.0.block2.bias": src_state.pop("body.4.block2.bias"), + # 2.resnets.1 + "adapter.body.2.resnets.1.block1.weight": src_state.pop("body.5.block1.weight"), + "adapter.body.2.resnets.1.block1.bias": src_state.pop("body.5.block1.bias"), + "adapter.body.2.resnets.1.block2.weight": src_state.pop("body.5.block2.weight"), + "adapter.body.2.resnets.1.block2.bias": src_state.pop("body.5.block2.bias"), + # 3.resnets.0 + "adapter.body.3.resnets.0.block1.weight": src_state.pop("body.6.block1.weight"), + "adapter.body.3.resnets.0.block1.bias": src_state.pop("body.6.block1.bias"), + "adapter.body.3.resnets.0.block2.weight": src_state.pop("body.6.block2.weight"), + "adapter.body.3.resnets.0.block2.bias": src_state.pop("body.6.block2.bias"), + # 3.resnets.1 + "adapter.body.3.resnets.1.block1.weight": src_state.pop("body.7.block1.weight"), + "adapter.body.3.resnets.1.block1.bias": src_state.pop("body.7.block1.bias"), + "adapter.body.3.resnets.1.block2.weight": src_state.pop("body.7.block2.weight"), + "adapter.body.3.resnets.1.block2.bias": src_state.pop("body.7.block2.bias"), + } + + assert len(src_state) == 0 + + adapter = T2IAdapter(in_channels=in_channels, adapter_type="full_adapter") + + adapter.load_state_dict(res_state) + + return adapter + + +def convert_light_adapter(src_state): + original_body_length = max([int(x.split(".")[1]) for x in src_state.keys() if "body." in x]) + 1 + + assert original_body_length == 4 + + res_state = { + # body.0.in_conv + "adapter.body.0.in_conv.weight": src_state.pop("body.0.in_conv.weight"), + "adapter.body.0.in_conv.bias": src_state.pop("body.0.in_conv.bias"), + # body.0.resnets.0 + "adapter.body.0.resnets.0.block1.weight": src_state.pop("body.0.body.0.block1.weight"), + "adapter.body.0.resnets.0.block1.bias": src_state.pop("body.0.body.0.block1.bias"), + "adapter.body.0.resnets.0.block2.weight": src_state.pop("body.0.body.0.block2.weight"), + "adapter.body.0.resnets.0.block2.bias": src_state.pop("body.0.body.0.block2.bias"), + # body.0.resnets.1 + "adapter.body.0.resnets.1.block1.weight": src_state.pop("body.0.body.1.block1.weight"), + "adapter.body.0.resnets.1.block1.bias": src_state.pop("body.0.body.1.block1.bias"), + "adapter.body.0.resnets.1.block2.weight": src_state.pop("body.0.body.1.block2.weight"), + "adapter.body.0.resnets.1.block2.bias": src_state.pop("body.0.body.1.block2.bias"), + # body.0.resnets.2 + "adapter.body.0.resnets.2.block1.weight": src_state.pop("body.0.body.2.block1.weight"), + "adapter.body.0.resnets.2.block1.bias": src_state.pop("body.0.body.2.block1.bias"), + "adapter.body.0.resnets.2.block2.weight": src_state.pop("body.0.body.2.block2.weight"), + "adapter.body.0.resnets.2.block2.bias": src_state.pop("body.0.body.2.block2.bias"), + # body.0.resnets.3 + "adapter.body.0.resnets.3.block1.weight": src_state.pop("body.0.body.3.block1.weight"), + "adapter.body.0.resnets.3.block1.bias": src_state.pop("body.0.body.3.block1.bias"), + "adapter.body.0.resnets.3.block2.weight": src_state.pop("body.0.body.3.block2.weight"), + "adapter.body.0.resnets.3.block2.bias": src_state.pop("body.0.body.3.block2.bias"), + # body.0.out_conv + "adapter.body.0.out_conv.weight": src_state.pop("body.0.out_conv.weight"), + "adapter.body.0.out_conv.bias": src_state.pop("body.0.out_conv.bias"), + # body.1.in_conv + "adapter.body.1.in_conv.weight": src_state.pop("body.1.in_conv.weight"), + "adapter.body.1.in_conv.bias": src_state.pop("body.1.in_conv.bias"), + # body.1.resnets.0 + "adapter.body.1.resnets.0.block1.weight": src_state.pop("body.1.body.0.block1.weight"), + "adapter.body.1.resnets.0.block1.bias": src_state.pop("body.1.body.0.block1.bias"), + "adapter.body.1.resnets.0.block2.weight": src_state.pop("body.1.body.0.block2.weight"), + "adapter.body.1.resnets.0.block2.bias": src_state.pop("body.1.body.0.block2.bias"), + # body.1.resnets.1 + "adapter.body.1.resnets.1.block1.weight": src_state.pop("body.1.body.1.block1.weight"), + "adapter.body.1.resnets.1.block1.bias": src_state.pop("body.1.body.1.block1.bias"), + "adapter.body.1.resnets.1.block2.weight": src_state.pop("body.1.body.1.block2.weight"), + "adapter.body.1.resnets.1.block2.bias": src_state.pop("body.1.body.1.block2.bias"), + # body.1.body.2 + "adapter.body.1.resnets.2.block1.weight": src_state.pop("body.1.body.2.block1.weight"), + "adapter.body.1.resnets.2.block1.bias": src_state.pop("body.1.body.2.block1.bias"), + "adapter.body.1.resnets.2.block2.weight": src_state.pop("body.1.body.2.block2.weight"), + "adapter.body.1.resnets.2.block2.bias": src_state.pop("body.1.body.2.block2.bias"), + # body.1.body.3 + "adapter.body.1.resnets.3.block1.weight": src_state.pop("body.1.body.3.block1.weight"), + "adapter.body.1.resnets.3.block1.bias": src_state.pop("body.1.body.3.block1.bias"), + "adapter.body.1.resnets.3.block2.weight": src_state.pop("body.1.body.3.block2.weight"), + "adapter.body.1.resnets.3.block2.bias": src_state.pop("body.1.body.3.block2.bias"), + # body.1.out_conv + "adapter.body.1.out_conv.weight": src_state.pop("body.1.out_conv.weight"), + "adapter.body.1.out_conv.bias": src_state.pop("body.1.out_conv.bias"), + # body.2.in_conv + "adapter.body.2.in_conv.weight": src_state.pop("body.2.in_conv.weight"), + "adapter.body.2.in_conv.bias": src_state.pop("body.2.in_conv.bias"), + # body.2.body.0 + "adapter.body.2.resnets.0.block1.weight": src_state.pop("body.2.body.0.block1.weight"), + "adapter.body.2.resnets.0.block1.bias": src_state.pop("body.2.body.0.block1.bias"), + "adapter.body.2.resnets.0.block2.weight": src_state.pop("body.2.body.0.block2.weight"), + "adapter.body.2.resnets.0.block2.bias": src_state.pop("body.2.body.0.block2.bias"), + # body.2.body.1 + "adapter.body.2.resnets.1.block1.weight": src_state.pop("body.2.body.1.block1.weight"), + "adapter.body.2.resnets.1.block1.bias": src_state.pop("body.2.body.1.block1.bias"), + "adapter.body.2.resnets.1.block2.weight": src_state.pop("body.2.body.1.block2.weight"), + "adapter.body.2.resnets.1.block2.bias": src_state.pop("body.2.body.1.block2.bias"), + # body.2.body.2 + "adapter.body.2.resnets.2.block1.weight": src_state.pop("body.2.body.2.block1.weight"), + "adapter.body.2.resnets.2.block1.bias": src_state.pop("body.2.body.2.block1.bias"), + "adapter.body.2.resnets.2.block2.weight": src_state.pop("body.2.body.2.block2.weight"), + "adapter.body.2.resnets.2.block2.bias": src_state.pop("body.2.body.2.block2.bias"), + # body.2.body.3 + "adapter.body.2.resnets.3.block1.weight": src_state.pop("body.2.body.3.block1.weight"), + "adapter.body.2.resnets.3.block1.bias": src_state.pop("body.2.body.3.block1.bias"), + "adapter.body.2.resnets.3.block2.weight": src_state.pop("body.2.body.3.block2.weight"), + "adapter.body.2.resnets.3.block2.bias": src_state.pop("body.2.body.3.block2.bias"), + # body.2.out_conv + "adapter.body.2.out_conv.weight": src_state.pop("body.2.out_conv.weight"), + "adapter.body.2.out_conv.bias": src_state.pop("body.2.out_conv.bias"), + # body.3.in_conv + "adapter.body.3.in_conv.weight": src_state.pop("body.3.in_conv.weight"), + "adapter.body.3.in_conv.bias": src_state.pop("body.3.in_conv.bias"), + # body.3.body.0 + "adapter.body.3.resnets.0.block1.weight": src_state.pop("body.3.body.0.block1.weight"), + "adapter.body.3.resnets.0.block1.bias": src_state.pop("body.3.body.0.block1.bias"), + "adapter.body.3.resnets.0.block2.weight": src_state.pop("body.3.body.0.block2.weight"), + "adapter.body.3.resnets.0.block2.bias": src_state.pop("body.3.body.0.block2.bias"), + # body.3.body.1 + "adapter.body.3.resnets.1.block1.weight": src_state.pop("body.3.body.1.block1.weight"), + "adapter.body.3.resnets.1.block1.bias": src_state.pop("body.3.body.1.block1.bias"), + "adapter.body.3.resnets.1.block2.weight": src_state.pop("body.3.body.1.block2.weight"), + "adapter.body.3.resnets.1.block2.bias": src_state.pop("body.3.body.1.block2.bias"), + # body.3.body.2 + "adapter.body.3.resnets.2.block1.weight": src_state.pop("body.3.body.2.block1.weight"), + "adapter.body.3.resnets.2.block1.bias": src_state.pop("body.3.body.2.block1.bias"), + "adapter.body.3.resnets.2.block2.weight": src_state.pop("body.3.body.2.block2.weight"), + "adapter.body.3.resnets.2.block2.bias": src_state.pop("body.3.body.2.block2.bias"), + # body.3.body.3 + "adapter.body.3.resnets.3.block1.weight": src_state.pop("body.3.body.3.block1.weight"), + "adapter.body.3.resnets.3.block1.bias": src_state.pop("body.3.body.3.block1.bias"), + "adapter.body.3.resnets.3.block2.weight": src_state.pop("body.3.body.3.block2.weight"), + "adapter.body.3.resnets.3.block2.bias": src_state.pop("body.3.body.3.block2.bias"), + # body.3.out_conv + "adapter.body.3.out_conv.weight": src_state.pop("body.3.out_conv.weight"), + "adapter.body.3.out_conv.bias": src_state.pop("body.3.out_conv.bias"), + } + + assert len(src_state) == 0 + + adapter = T2IAdapter(in_channels=3, channels=[320, 640, 1280], num_res_blocks=4, adapter_type="light_adapter") + + adapter.load_state_dict(res_state) + + return adapter + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--output_path", default=None, type=str, required=True, help="Path to the store the result checkpoint." + ) + parser.add_argument( + "--is_adapter_light", + action="store_true", + help="Is checkpoint come from Adapter-Light architecture. ex: color-adapter", + ) + parser.add_argument("--in_channels", required=False, type=int, help="Input channels for non-light adapter") + + args = parser.parse_args() + src_state = torch.load(args.checkpoint_path) + + if args.is_adapter_light: + adapter = convert_light_adapter(src_state) + else: + if args.in_channels is None: + raise ValueError("set `--in_channels=`") + adapter = convert_adapter(src_state, args.in_channels) + + adapter.save_pretrained(args.output_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_pixart_alpha_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_pixart_alpha_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..228b479df090961df6e6f20d028d041eeda094de --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_pixart_alpha_to_diffusers.py @@ -0,0 +1,198 @@ +import argparse +import os + +import torch +from transformers import T5EncoderModel, T5Tokenizer + +from diffusers import AutoencoderKL, DPMSolverMultistepScheduler, PixArtAlphaPipeline, Transformer2DModel + + +ckpt_id = "PixArt-alpha/PixArt-alpha" +# https://github.com/PixArt-alpha/PixArt-alpha/blob/0f55e922376d8b797edd44d25d0e7464b260dcab/scripts/inference.py#L125 +interpolation_scale = {256: 0.5, 512: 1, 1024: 2} + + +def main(args): + all_state_dict = torch.load(args.orig_ckpt_path, map_location="cpu") + state_dict = all_state_dict.pop("state_dict") + converted_state_dict = {} + + # Patch embeddings. + converted_state_dict["pos_embed.proj.weight"] = state_dict.pop("x_embedder.proj.weight") + converted_state_dict["pos_embed.proj.bias"] = state_dict.pop("x_embedder.proj.bias") + + # Caption projection. + converted_state_dict["caption_projection.linear_1.weight"] = state_dict.pop("y_embedder.y_proj.fc1.weight") + converted_state_dict["caption_projection.linear_1.bias"] = state_dict.pop("y_embedder.y_proj.fc1.bias") + converted_state_dict["caption_projection.linear_2.weight"] = state_dict.pop("y_embedder.y_proj.fc2.weight") + converted_state_dict["caption_projection.linear_2.bias"] = state_dict.pop("y_embedder.y_proj.fc2.bias") + + # AdaLN-single LN + converted_state_dict["adaln_single.emb.timestep_embedder.linear_1.weight"] = state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["adaln_single.emb.timestep_embedder.linear_1.bias"] = state_dict.pop("t_embedder.mlp.0.bias") + converted_state_dict["adaln_single.emb.timestep_embedder.linear_2.weight"] = state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["adaln_single.emb.timestep_embedder.linear_2.bias"] = state_dict.pop("t_embedder.mlp.2.bias") + + if args.image_size == 1024: + # Resolution. + converted_state_dict["adaln_single.emb.resolution_embedder.linear_1.weight"] = state_dict.pop( + "csize_embedder.mlp.0.weight" + ) + converted_state_dict["adaln_single.emb.resolution_embedder.linear_1.bias"] = state_dict.pop( + "csize_embedder.mlp.0.bias" + ) + converted_state_dict["adaln_single.emb.resolution_embedder.linear_2.weight"] = state_dict.pop( + "csize_embedder.mlp.2.weight" + ) + converted_state_dict["adaln_single.emb.resolution_embedder.linear_2.bias"] = state_dict.pop( + "csize_embedder.mlp.2.bias" + ) + # Aspect ratio. + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_1.weight"] = state_dict.pop( + "ar_embedder.mlp.0.weight" + ) + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_1.bias"] = state_dict.pop( + "ar_embedder.mlp.0.bias" + ) + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_2.weight"] = state_dict.pop( + "ar_embedder.mlp.2.weight" + ) + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_2.bias"] = state_dict.pop( + "ar_embedder.mlp.2.bias" + ) + # Shared norm. + converted_state_dict["adaln_single.linear.weight"] = state_dict.pop("t_block.1.weight") + converted_state_dict["adaln_single.linear.bias"] = state_dict.pop("t_block.1.bias") + + for depth in range(28): + # Transformer blocks. + converted_state_dict[f"transformer_blocks.{depth}.scale_shift_table"] = state_dict.pop( + f"blocks.{depth}.scale_shift_table" + ) + + # Attention is all you need 🤘 + + # Self attention. + q, k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.attn.qkv.weight"), 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(state_dict.pop(f"blocks.{depth}.attn.qkv.bias"), 3, dim=0) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.bias"] = v_bias + # Projection. + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.attn.proj.bias" + ) + + # Feed-forward. + converted_state_dict[f"transformer_blocks.{depth}.ff.net.0.proj.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.fc1.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.net.0.proj.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.fc1.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.net.2.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.fc2.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.net.2.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.fc2.bias" + ) + + # Cross-attention. + q = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.weight") + q_bias = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.bias") + k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.weight"), 2, dim=0) + k_bias, v_bias = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.bias"), 2, dim=0) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.bias"] = v_bias + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.bias" + ) + + # Final block. + converted_state_dict["proj_out.weight"] = state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = state_dict.pop("final_layer.linear.bias") + converted_state_dict["scale_shift_table"] = state_dict.pop("final_layer.scale_shift_table") + + # DiT XL/2 + transformer = Transformer2DModel( + sample_size=args.image_size // 8, + num_layers=28, + attention_head_dim=72, + in_channels=4, + out_channels=8, + patch_size=2, + attention_bias=True, + num_attention_heads=16, + cross_attention_dim=1152, + activation_fn="gelu-approximate", + num_embeds_ada_norm=1000, + norm_type="ada_norm_single", + norm_elementwise_affine=False, + norm_eps=1e-6, + caption_channels=4096, + ) + transformer.load_state_dict(converted_state_dict, strict=True) + + assert transformer.pos_embed.pos_embed is not None + state_dict.pop("pos_embed") + state_dict.pop("y_embedder.y_embedding") + assert len(state_dict) == 0, f"State dict is not empty, {state_dict.keys()}" + + num_model_params = sum(p.numel() for p in transformer.parameters()) + print(f"Total number of transformer parameters: {num_model_params}") + + if args.only_transformer: + transformer.save_pretrained(os.path.join(args.dump_path, "transformer")) + else: + scheduler = DPMSolverMultistepScheduler() + + vae = AutoencoderKL.from_pretrained(ckpt_id, subfolder="sd-vae-ft-ema") + + tokenizer = T5Tokenizer.from_pretrained(ckpt_id, subfolder="t5-v1_1-xxl") + text_encoder = T5EncoderModel.from_pretrained(ckpt_id, subfolder="t5-v1_1-xxl") + + pipeline = PixArtAlphaPipeline( + tokenizer=tokenizer, text_encoder=text_encoder, transformer=transformer, vae=vae, scheduler=scheduler + ) + + pipeline.save_pretrained(args.dump_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--orig_ckpt_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--image_size", + default=1024, + type=int, + choices=[256, 512, 1024], + required=False, + help="Image size of pretrained model, either 512 or 1024.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.") + parser.add_argument("--only_transformer", default=True, type=bool, required=True) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_pixart_sigma_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_pixart_sigma_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..9572a83c06441b36221ccbc88b343182f082dcf2 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_pixart_sigma_to_diffusers.py @@ -0,0 +1,223 @@ +import argparse +import os + +import torch +from transformers import T5EncoderModel, T5Tokenizer + +from diffusers import AutoencoderKL, DPMSolverMultistepScheduler, PixArtSigmaPipeline, Transformer2DModel + + +ckpt_id = "PixArt-alpha" +# https://github.com/PixArt-alpha/PixArt-sigma/blob/dd087141864e30ec44f12cb7448dd654be065e88/scripts/inference.py#L158 +interpolation_scale = {256: 0.5, 512: 1, 1024: 2, 2048: 4} + + +def main(args): + all_state_dict = torch.load(args.orig_ckpt_path) + state_dict = all_state_dict.pop("state_dict") + converted_state_dict = {} + + # Patch embeddings. + converted_state_dict["pos_embed.proj.weight"] = state_dict.pop("x_embedder.proj.weight") + converted_state_dict["pos_embed.proj.bias"] = state_dict.pop("x_embedder.proj.bias") + + # Caption projection. + converted_state_dict["caption_projection.linear_1.weight"] = state_dict.pop("y_embedder.y_proj.fc1.weight") + converted_state_dict["caption_projection.linear_1.bias"] = state_dict.pop("y_embedder.y_proj.fc1.bias") + converted_state_dict["caption_projection.linear_2.weight"] = state_dict.pop("y_embedder.y_proj.fc2.weight") + converted_state_dict["caption_projection.linear_2.bias"] = state_dict.pop("y_embedder.y_proj.fc2.bias") + + # AdaLN-single LN + converted_state_dict["adaln_single.emb.timestep_embedder.linear_1.weight"] = state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["adaln_single.emb.timestep_embedder.linear_1.bias"] = state_dict.pop("t_embedder.mlp.0.bias") + converted_state_dict["adaln_single.emb.timestep_embedder.linear_2.weight"] = state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["adaln_single.emb.timestep_embedder.linear_2.bias"] = state_dict.pop("t_embedder.mlp.2.bias") + + if args.micro_condition: + # Resolution. + converted_state_dict["adaln_single.emb.resolution_embedder.linear_1.weight"] = state_dict.pop( + "csize_embedder.mlp.0.weight" + ) + converted_state_dict["adaln_single.emb.resolution_embedder.linear_1.bias"] = state_dict.pop( + "csize_embedder.mlp.0.bias" + ) + converted_state_dict["adaln_single.emb.resolution_embedder.linear_2.weight"] = state_dict.pop( + "csize_embedder.mlp.2.weight" + ) + converted_state_dict["adaln_single.emb.resolution_embedder.linear_2.bias"] = state_dict.pop( + "csize_embedder.mlp.2.bias" + ) + # Aspect ratio. + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_1.weight"] = state_dict.pop( + "ar_embedder.mlp.0.weight" + ) + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_1.bias"] = state_dict.pop( + "ar_embedder.mlp.0.bias" + ) + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_2.weight"] = state_dict.pop( + "ar_embedder.mlp.2.weight" + ) + converted_state_dict["adaln_single.emb.aspect_ratio_embedder.linear_2.bias"] = state_dict.pop( + "ar_embedder.mlp.2.bias" + ) + # Shared norm. + converted_state_dict["adaln_single.linear.weight"] = state_dict.pop("t_block.1.weight") + converted_state_dict["adaln_single.linear.bias"] = state_dict.pop("t_block.1.bias") + + for depth in range(28): + # Transformer blocks. + converted_state_dict[f"transformer_blocks.{depth}.scale_shift_table"] = state_dict.pop( + f"blocks.{depth}.scale_shift_table" + ) + # Attention is all you need 🤘 + + # Self attention. + q, k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.attn.qkv.weight"), 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(state_dict.pop(f"blocks.{depth}.attn.qkv.bias"), 3, dim=0) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.bias"] = v_bias + # Projection. + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.attn.proj.bias" + ) + if args.qk_norm: + converted_state_dict[f"transformer_blocks.{depth}.attn1.q_norm.weight"] = state_dict.pop( + f"blocks.{depth}.attn.q_norm.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.q_norm.bias"] = state_dict.pop( + f"blocks.{depth}.attn.q_norm.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.k_norm.weight"] = state_dict.pop( + f"blocks.{depth}.attn.k_norm.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.k_norm.bias"] = state_dict.pop( + f"blocks.{depth}.attn.k_norm.bias" + ) + + # Feed-forward. + converted_state_dict[f"transformer_blocks.{depth}.ff.net.0.proj.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.fc1.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.net.0.proj.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.fc1.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.net.2.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.fc2.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.net.2.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.fc2.bias" + ) + + # Cross-attention. + q = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.weight") + q_bias = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.bias") + k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.weight"), 2, dim=0) + k_bias, v_bias = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.bias"), 2, dim=0) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.bias"] = v_bias + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.bias" + ) + + # Final block. + converted_state_dict["proj_out.weight"] = state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = state_dict.pop("final_layer.linear.bias") + converted_state_dict["scale_shift_table"] = state_dict.pop("final_layer.scale_shift_table") + + # PixArt XL/2 + transformer = Transformer2DModel( + sample_size=args.image_size // 8, + num_layers=28, + attention_head_dim=72, + in_channels=4, + out_channels=8, + patch_size=2, + attention_bias=True, + num_attention_heads=16, + cross_attention_dim=1152, + activation_fn="gelu-approximate", + num_embeds_ada_norm=1000, + norm_type="ada_norm_single", + norm_elementwise_affine=False, + norm_eps=1e-6, + caption_channels=4096, + interpolation_scale=interpolation_scale[args.image_size], + use_additional_conditions=args.micro_condition, + ) + transformer.load_state_dict(converted_state_dict, strict=True) + + assert transformer.pos_embed.pos_embed is not None + try: + state_dict.pop("y_embedder.y_embedding") + state_dict.pop("pos_embed") + except Exception as e: + print(f"Skipping {str(e)}") + pass + assert len(state_dict) == 0, f"State dict is not empty, {state_dict.keys()}" + + num_model_params = sum(p.numel() for p in transformer.parameters()) + print(f"Total number of transformer parameters: {num_model_params}") + + if args.only_transformer: + transformer.save_pretrained(os.path.join(args.dump_path, "transformer")) + else: + # pixart-Sigma vae link: https://huggingface.co/PixArt-alpha/pixart_sigma_sdxlvae_T5_diffusers/tree/main/vae + vae = AutoencoderKL.from_pretrained(f"{ckpt_id}/pixart_sigma_sdxlvae_T5_diffusers", subfolder="vae") + + scheduler = DPMSolverMultistepScheduler() + + tokenizer = T5Tokenizer.from_pretrained(f"{ckpt_id}/pixart_sigma_sdxlvae_T5_diffusers", subfolder="tokenizer") + text_encoder = T5EncoderModel.from_pretrained( + f"{ckpt_id}/pixart_sigma_sdxlvae_T5_diffusers", subfolder="text_encoder" + ) + + pipeline = PixArtSigmaPipeline( + tokenizer=tokenizer, text_encoder=text_encoder, transformer=transformer, vae=vae, scheduler=scheduler + ) + + pipeline.save_pretrained(args.dump_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--micro_condition", action="store_true", help="If use Micro-condition in PixArtMS structure during training." + ) + parser.add_argument("--qk_norm", action="store_true", help="If use qk norm during training.") + parser.add_argument( + "--orig_ckpt_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--image_size", + default=1024, + type=int, + choices=[256, 512, 1024, 2048], + required=False, + help="Image size of pretrained model, 256, 512, 1024, or 2048.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.") + parser.add_argument("--only_transformer", default=True, type=bool, required=True) + + args = parser.parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_prx_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_prx_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..d9bde2f34d56544a2aa012260e186a5a9662e6c3 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_prx_to_diffusers.py @@ -0,0 +1,345 @@ +#!/usr/bin/env python3 +""" +Script to convert PRX checkpoint from original codebase to diffusers format. +""" + +import argparse +import json +import os +import sys +from dataclasses import asdict, dataclass +from typing import Dict, Tuple + +import torch +from safetensors.torch import save_file + +from diffusers.models.transformers.transformer_prx import PRXTransformer2DModel +from diffusers.pipelines.prx import PRXPipeline + + +DEFAULT_RESOLUTION = 512 + + +@dataclass(frozen=True) +class PRXBase: + context_in_dim: int = 2304 + hidden_size: int = 1792 + mlp_ratio: float = 3.5 + num_heads: int = 28 + depth: int = 16 + axes_dim: Tuple[int, int] = (32, 32) + theta: int = 10_000 + time_factor: float = 1000.0 + time_max_period: int = 10_000 + + +@dataclass(frozen=True) +class PRXFlux(PRXBase): + in_channels: int = 16 + patch_size: int = 2 + + +@dataclass(frozen=True) +class PRXDCAE(PRXBase): + in_channels: int = 32 + patch_size: int = 1 + + +def build_config(vae_type: str) -> Tuple[dict, int]: + if vae_type == "flux": + cfg = PRXFlux() + elif vae_type == "dc-ae": + cfg = PRXDCAE() + else: + raise ValueError(f"Unsupported VAE type: {vae_type}. Use 'flux' or 'dc-ae'") + + config_dict = asdict(cfg) + config_dict["axes_dim"] = list(config_dict["axes_dim"]) # type: ignore[index] + return config_dict + + +def create_parameter_mapping(depth: int) -> dict: + """Create mapping from old parameter names to new diffusers names.""" + + # Key mappings for structural changes + mapping = {} + + # Map old structure (layers in PRXBlock) to new structure (layers in PRXAttention) + for i in range(depth): + # QKV projections moved to attention module + mapping[f"blocks.{i}.img_qkv_proj.weight"] = f"blocks.{i}.attention.img_qkv_proj.weight" + mapping[f"blocks.{i}.txt_kv_proj.weight"] = f"blocks.{i}.attention.txt_kv_proj.weight" + + # QK norm moved to attention module and renamed to match Attention's qk_norm structure + mapping[f"blocks.{i}.qk_norm.query_norm.scale"] = f"blocks.{i}.attention.norm_q.weight" + mapping[f"blocks.{i}.qk_norm.key_norm.scale"] = f"blocks.{i}.attention.norm_k.weight" + mapping[f"blocks.{i}.qk_norm.query_norm.weight"] = f"blocks.{i}.attention.norm_q.weight" + mapping[f"blocks.{i}.qk_norm.key_norm.weight"] = f"blocks.{i}.attention.norm_k.weight" + + # K norm for text tokens moved to attention module + mapping[f"blocks.{i}.k_norm.scale"] = f"blocks.{i}.attention.norm_added_k.weight" + mapping[f"blocks.{i}.k_norm.weight"] = f"blocks.{i}.attention.norm_added_k.weight" + + # Attention output projection + mapping[f"blocks.{i}.attn_out.weight"] = f"blocks.{i}.attention.to_out.0.weight" + + return mapping + + +def convert_checkpoint_parameters(old_state_dict: Dict[str, torch.Tensor], depth: int) -> Dict[str, torch.Tensor]: + """Convert old checkpoint parameters to new diffusers format.""" + + print("Converting checkpoint parameters...") + + mapping = create_parameter_mapping(depth) + converted_state_dict = {} + + for key, value in old_state_dict.items(): + new_key = key + + # Apply specific mappings if needed + if key in mapping: + new_key = mapping[key] + print(f" Mapped: {key} -> {new_key}") + + converted_state_dict[new_key] = value + + print(f"✓ Converted {len(converted_state_dict)} parameters") + return converted_state_dict + + +def create_transformer_from_checkpoint(checkpoint_path: str, config: dict) -> PRXTransformer2DModel: + """Create and load PRXTransformer2DModel from old checkpoint.""" + + print(f"Loading checkpoint from: {checkpoint_path}") + + # Load old checkpoint + if not os.path.exists(checkpoint_path): + raise FileNotFoundError(f"Checkpoint not found: {checkpoint_path}") + + old_checkpoint = torch.load(checkpoint_path, map_location="cpu") + + # Handle different checkpoint formats + if isinstance(old_checkpoint, dict): + if "model" in old_checkpoint: + state_dict = old_checkpoint["model"] + elif "state_dict" in old_checkpoint: + state_dict = old_checkpoint["state_dict"] + else: + state_dict = old_checkpoint + else: + state_dict = old_checkpoint + + print(f"✓ Loaded checkpoint with {len(state_dict)} parameters") + + # Convert parameter names if needed + model_depth = int(config.get("depth", 16)) + converted_state_dict = convert_checkpoint_parameters(state_dict, depth=model_depth) + + # Create transformer with config + print("Creating PRXTransformer2DModel...") + transformer = PRXTransformer2DModel(**config) + + # Load state dict + print("Loading converted parameters...") + missing_keys, unexpected_keys = transformer.load_state_dict(converted_state_dict, strict=False) + + if missing_keys: + print(f"⚠ Missing keys: {missing_keys}") + if unexpected_keys: + print(f"⚠ Unexpected keys: {unexpected_keys}") + + if not missing_keys and not unexpected_keys: + print("✓ All parameters loaded successfully!") + + return transformer + + +def create_scheduler_config(output_path: str, shift: float): + """Create FlowMatchEulerDiscreteScheduler config.""" + + scheduler_config = {"_class_name": "FlowMatchEulerDiscreteScheduler", "num_train_timesteps": 1000, "shift": shift} + + scheduler_path = os.path.join(output_path, "scheduler") + os.makedirs(scheduler_path, exist_ok=True) + + with open(os.path.join(scheduler_path, "scheduler_config.json"), "w") as f: + json.dump(scheduler_config, f, indent=2) + + print("✓ Created scheduler config") + + +def download_and_save_vae(vae_type: str, output_path: str): + """Download and save VAE to local directory.""" + from diffusers import AutoencoderDC, AutoencoderKL + + vae_path = os.path.join(output_path, "vae") + os.makedirs(vae_path, exist_ok=True) + + if vae_type == "flux": + print("Downloading FLUX VAE from black-forest-labs/FLUX.1-dev...") + vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae") + else: # dc-ae + print("Downloading DC-AE VAE from mit-han-lab/dc-ae-f32c32-sana-1.1-diffusers...") + vae = AutoencoderDC.from_pretrained("mit-han-lab/dc-ae-f32c32-sana-1.1-diffusers") + + vae.save_pretrained(vae_path) + print(f"✓ Saved VAE to {vae_path}") + + +def download_and_save_text_encoder(output_path: str): + """Download and save T5Gemma text encoder and tokenizer.""" + from transformers import GemmaTokenizerFast + from transformers.models.t5gemma.modeling_t5gemma import T5GemmaModel + + text_encoder_path = os.path.join(output_path, "text_encoder") + tokenizer_path = os.path.join(output_path, "tokenizer") + os.makedirs(text_encoder_path, exist_ok=True) + os.makedirs(tokenizer_path, exist_ok=True) + + print("Downloading T5Gemma model from google/t5gemma-2b-2b-ul2...") + t5gemma_model = T5GemmaModel.from_pretrained("google/t5gemma-2b-2b-ul2") + + # Extract and save only the encoder + t5gemma_encoder = t5gemma_model.encoder + t5gemma_encoder.save_pretrained(text_encoder_path) + print(f"✓ Saved T5GemmaEncoder to {text_encoder_path}") + + print("Downloading tokenizer from google/t5gemma-2b-2b-ul2...") + tokenizer = GemmaTokenizerFast.from_pretrained("google/t5gemma-2b-2b-ul2") + tokenizer.model_max_length = 256 + tokenizer.save_pretrained(tokenizer_path) + print(f"✓ Saved tokenizer to {tokenizer_path}") + + +def create_model_index(vae_type: str, default_image_size: int, output_path: str): + """Create model_index.json for the pipeline.""" + + if vae_type == "flux": + vae_class = "AutoencoderKL" + else: # dc-ae + vae_class = "AutoencoderDC" + + model_index = { + "_class_name": "PRXPipeline", + "_diffusers_version": "0.31.0.dev0", + "_name_or_path": os.path.basename(output_path), + "default_sample_size": default_image_size, + "scheduler": ["diffusers", "FlowMatchEulerDiscreteScheduler"], + "text_encoder": ["prx", "T5GemmaEncoder"], + "tokenizer": ["transformers", "GemmaTokenizerFast"], + "transformer": ["diffusers", "PRXTransformer2DModel"], + "vae": ["diffusers", vae_class], + } + + model_index_path = os.path.join(output_path, "model_index.json") + with open(model_index_path, "w") as f: + json.dump(model_index, f, indent=2) + + +def main(args): + # Validate inputs + if not os.path.exists(args.checkpoint_path): + raise FileNotFoundError(f"Checkpoint not found: {args.checkpoint_path}") + + config = build_config(args.vae_type) + + # Create output directory + os.makedirs(args.output_path, exist_ok=True) + print(f"✓ Output directory: {args.output_path}") + + # Create transformer from checkpoint + transformer = create_transformer_from_checkpoint(args.checkpoint_path, config) + + # Save transformer + transformer_path = os.path.join(args.output_path, "transformer") + os.makedirs(transformer_path, exist_ok=True) + + # Save config + with open(os.path.join(transformer_path, "config.json"), "w") as f: + json.dump(config, f, indent=2) + + # Save model weights as safetensors + state_dict = transformer.state_dict() + save_file(state_dict, os.path.join(transformer_path, "diffusion_pytorch_model.safetensors")) + print(f"✓ Saved transformer to {transformer_path}") + + # Create scheduler config + create_scheduler_config(args.output_path, args.shift) + + download_and_save_vae(args.vae_type, args.output_path) + download_and_save_text_encoder(args.output_path) + + # Create model_index.json + create_model_index(args.vae_type, args.resolution, args.output_path) + + # Verify the pipeline can be loaded + try: + pipeline = PRXPipeline.from_pretrained(args.output_path) + print("Pipeline loaded successfully!") + print(f"Transformer: {type(pipeline.transformer).__name__}") + print(f"VAE: {type(pipeline.vae).__name__}") + print(f"Text Encoder: {type(pipeline.text_encoder).__name__}") + print(f"Scheduler: {type(pipeline.scheduler).__name__}") + + # Display model info + num_params = sum(p.numel() for p in pipeline.transformer.parameters()) + print(f"✓ Transformer parameters: {num_params:,}") + + except Exception as e: + print(f"Pipeline verification failed: {e}") + return False + + print("Conversion completed successfully!") + print(f"Converted pipeline saved to: {args.output_path}") + print(f"VAE type: {args.vae_type}") + + return True + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Convert PRX checkpoint to diffusers format") + + parser.add_argument( + "--checkpoint_path", type=str, required=True, help="Path to the original PRX checkpoint (.pth file )" + ) + + parser.add_argument( + "--output_path", type=str, required=True, help="Output directory for the converted diffusers pipeline" + ) + + parser.add_argument( + "--vae_type", + type=str, + choices=["flux", "dc-ae"], + required=True, + help="VAE type to use: 'flux' for AutoencoderKL (16 channels) or 'dc-ae' for AutoencoderDC (32 channels)", + ) + + parser.add_argument( + "--resolution", + type=int, + choices=[256, 512, 1024], + default=DEFAULT_RESOLUTION, + help="Target resolution for the model (256, 512, or 1024). Affects the transformer's sample_size.", + ) + + parser.add_argument( + "--shift", + type=float, + default=3.0, + help="Shift for the scheduler", + ) + + args = parser.parse_args() + + try: + success = main(args) + if not success: + sys.exit(1) + except Exception as e: + print(f"Conversion failed: {e}") + import traceback + + traceback.print_exc() + sys.exit(1) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_controlnet_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_controlnet_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..f7fcd72525764eecc793ac92172bf291c4cff41e --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_controlnet_to_diffusers.py @@ -0,0 +1,216 @@ +#!/usr/bin/env python +from __future__ import annotations + +import argparse +from contextlib import nullcontext + +import torch +from accelerate import init_empty_weights + +from diffusers import ( + SanaControlNetModel, +) +from diffusers.models.model_loading_utils import load_model_dict_into_meta +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available else nullcontext + + +def main(args): + file_path = args.orig_ckpt_path + + all_state_dict = torch.load(file_path, weights_only=True) + state_dict = all_state_dict.pop("state_dict") + converted_state_dict = {} + + # Patch embeddings. + converted_state_dict["patch_embed.proj.weight"] = state_dict.pop("x_embedder.proj.weight") + converted_state_dict["patch_embed.proj.bias"] = state_dict.pop("x_embedder.proj.bias") + + # Caption projection. + converted_state_dict["caption_projection.linear_1.weight"] = state_dict.pop("y_embedder.y_proj.fc1.weight") + converted_state_dict["caption_projection.linear_1.bias"] = state_dict.pop("y_embedder.y_proj.fc1.bias") + converted_state_dict["caption_projection.linear_2.weight"] = state_dict.pop("y_embedder.y_proj.fc2.weight") + converted_state_dict["caption_projection.linear_2.bias"] = state_dict.pop("y_embedder.y_proj.fc2.bias") + + # AdaLN-single LN + converted_state_dict["time_embed.emb.timestep_embedder.linear_1.weight"] = state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_1.bias"] = state_dict.pop("t_embedder.mlp.0.bias") + converted_state_dict["time_embed.emb.timestep_embedder.linear_2.weight"] = state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_2.bias"] = state_dict.pop("t_embedder.mlp.2.bias") + + # Shared norm. + converted_state_dict["time_embed.linear.weight"] = state_dict.pop("t_block.1.weight") + converted_state_dict["time_embed.linear.bias"] = state_dict.pop("t_block.1.bias") + + # y norm + converted_state_dict["caption_norm.weight"] = state_dict.pop("attention_y_norm.weight") + + # Positional embedding interpolation scale. + interpolation_scale = {512: None, 1024: None, 2048: 1.0, 4096: 2.0} + + # ControlNet Input Projection. + converted_state_dict["input_block.weight"] = state_dict.pop("controlnet.0.before_proj.weight") + converted_state_dict["input_block.bias"] = state_dict.pop("controlnet.0.before_proj.bias") + + for depth in range(7): + # Transformer blocks. + converted_state_dict[f"transformer_blocks.{depth}.scale_shift_table"] = state_dict.pop( + f"controlnet.{depth}.copied_block.scale_shift_table" + ) + + # Linear Attention is all you need 🤘 + # Self attention. + q, k, v = torch.chunk(state_dict.pop(f"controlnet.{depth}.copied_block.attn.qkv.weight"), 3, dim=0) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.weight"] = v + # Projection. + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.weight"] = state_dict.pop( + f"controlnet.{depth}.copied_block.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.bias"] = state_dict.pop( + f"controlnet.{depth}.copied_block.attn.proj.bias" + ) + + # Feed-forward. + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_inverted.weight"] = state_dict.pop( + f"controlnet.{depth}.copied_block.mlp.inverted_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_inverted.bias"] = state_dict.pop( + f"controlnet.{depth}.copied_block.mlp.inverted_conv.conv.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_depth.weight"] = state_dict.pop( + f"controlnet.{depth}.copied_block.mlp.depth_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_depth.bias"] = state_dict.pop( + f"controlnet.{depth}.copied_block.mlp.depth_conv.conv.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_point.weight"] = state_dict.pop( + f"controlnet.{depth}.copied_block.mlp.point_conv.conv.weight" + ) + + # Cross-attention. + q = state_dict.pop(f"controlnet.{depth}.copied_block.cross_attn.q_linear.weight") + q_bias = state_dict.pop(f"controlnet.{depth}.copied_block.cross_attn.q_linear.bias") + k, v = torch.chunk(state_dict.pop(f"controlnet.{depth}.copied_block.cross_attn.kv_linear.weight"), 2, dim=0) + k_bias, v_bias = torch.chunk( + state_dict.pop(f"controlnet.{depth}.copied_block.cross_attn.kv_linear.bias"), 2, dim=0 + ) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.bias"] = v_bias + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.weight"] = state_dict.pop( + f"controlnet.{depth}.copied_block.cross_attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.bias"] = state_dict.pop( + f"controlnet.{depth}.copied_block.cross_attn.proj.bias" + ) + + # ControlNet After Projection + converted_state_dict[f"controlnet_blocks.{depth}.weight"] = state_dict.pop( + f"controlnet.{depth}.after_proj.weight" + ) + converted_state_dict[f"controlnet_blocks.{depth}.bias"] = state_dict.pop(f"controlnet.{depth}.after_proj.bias") + + # ControlNet + with CTX(): + controlnet = SanaControlNetModel( + num_attention_heads=model_kwargs[args.model_type]["num_attention_heads"], + attention_head_dim=model_kwargs[args.model_type]["attention_head_dim"], + num_layers=model_kwargs[args.model_type]["num_layers"], + num_cross_attention_heads=model_kwargs[args.model_type]["num_cross_attention_heads"], + cross_attention_head_dim=model_kwargs[args.model_type]["cross_attention_head_dim"], + cross_attention_dim=model_kwargs[args.model_type]["cross_attention_dim"], + caption_channels=2304, + sample_size=args.image_size // 32, + interpolation_scale=interpolation_scale[args.image_size], + ) + + if is_accelerate_available(): + load_model_dict_into_meta(controlnet, converted_state_dict) + else: + controlnet.load_state_dict(converted_state_dict, strict=True, assign=True) + + num_model_params = sum(p.numel() for p in controlnet.parameters()) + print(f"Total number of controlnet parameters: {num_model_params}") + + controlnet = controlnet.to(weight_dtype) + controlnet.load_state_dict(converted_state_dict, strict=True) + + print(f"Saving Sana ControlNet in Diffusers format in {args.dump_path}.") + controlnet.save_pretrained(args.dump_path) + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + +VARIANT_MAPPING = { + "fp32": None, + "fp16": "fp16", + "bf16": "bf16", +} + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--orig_ckpt_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--image_size", + default=1024, + type=int, + choices=[512, 1024, 2048, 4096], + required=False, + help="Image size of pretrained model, 512, 1024, 2048 or 4096.", + ) + parser.add_argument( + "--model_type", + default="SanaMS_1600M_P1_ControlNet_D7", + type=str, + choices=["SanaMS_1600M_P1_ControlNet_D7", "SanaMS_600M_P1_ControlNet_D7"], + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.") + parser.add_argument("--dtype", default="fp16", type=str, choices=["fp32", "fp16", "bf16"], help="Weight dtype.") + + args = parser.parse_args() + + model_kwargs = { + "SanaMS_1600M_P1_ControlNet_D7": { + "num_attention_heads": 70, + "attention_head_dim": 32, + "num_cross_attention_heads": 20, + "cross_attention_head_dim": 112, + "cross_attention_dim": 2240, + "num_layers": 7, + }, + "SanaMS_600M_P1_ControlNet_D7": { + "num_attention_heads": 36, + "attention_head_dim": 32, + "num_cross_attention_heads": 16, + "cross_attention_head_dim": 72, + "cross_attention_dim": 1152, + "num_layers": 7, + }, + } + + device = "cuda" if torch.cuda.is_available() else "cpu" + weight_dtype = DTYPE_MAPPING[args.dtype] + variant = VARIANT_MAPPING[args.dtype] + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..833e64ba75e7db07b1570334f747611fe6249a20 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_to_diffusers.py @@ -0,0 +1,456 @@ +#!/usr/bin/env python +from __future__ import annotations + +import argparse +import os +from contextlib import nullcontext + +import torch +from accelerate import init_empty_weights +from huggingface_hub import hf_hub_download, snapshot_download +from termcolor import colored +from transformers import AutoModelForCausalLM, AutoTokenizer + +from diffusers import ( + AutoencoderDC, + DPMSolverMultistepScheduler, + FlowMatchEulerDiscreteScheduler, + SanaPipeline, + SanaSprintPipeline, + SanaTransformer2DModel, + SCMScheduler, +) +from diffusers.models.model_loading_utils import load_model_dict_into_meta +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available else nullcontext + +ckpt_ids = [ + "Efficient-Large-Model/Sana_Sprint_0.6B_1024px/checkpoints/Sana_Sprint_0.6B_1024px.pth" + "Efficient-Large-Model/Sana_Sprint_1.6B_1024px/checkpoints/Sana_Sprint_1.6B_1024px.pth" + "Efficient-Large-Model/SANA1.5_4.8B_1024px/checkpoints/SANA1.5_4.8B_1024px.pth", + "Efficient-Large-Model/SANA1.5_1.6B_1024px/checkpoints/SANA1.5_1.6B_1024px.pth", + "Efficient-Large-Model/Sana_1600M_4Kpx_BF16/checkpoints/Sana_1600M_4Kpx_BF16.pth", + "Efficient-Large-Model/Sana_1600M_2Kpx_BF16/checkpoints/Sana_1600M_2Kpx_BF16.pth", + "Efficient-Large-Model/Sana_1600M_1024px_MultiLing/checkpoints/Sana_1600M_1024px_MultiLing.pth", + "Efficient-Large-Model/Sana_1600M_1024px_BF16/checkpoints/Sana_1600M_1024px_BF16.pth", + "Efficient-Large-Model/Sana_1600M_512px_MultiLing/checkpoints/Sana_1600M_512px_MultiLing.pth", + "Efficient-Large-Model/Sana_1600M_1024px/checkpoints/Sana_1600M_1024px.pth", + "Efficient-Large-Model/Sana_1600M_512px/checkpoints/Sana_1600M_512px.pth", + "Efficient-Large-Model/Sana_600M_1024px/checkpoints/Sana_600M_1024px_MultiLing.pth", + "Efficient-Large-Model/Sana_600M_512px/checkpoints/Sana_600M_512px_MultiLing.pth", +] +# https://github.com/NVlabs/Sana/blob/main/scripts/inference.py + + +def main(args): + cache_dir_path = os.path.expanduser("~/.cache/huggingface/hub") + + if args.orig_ckpt_path is None or args.orig_ckpt_path in ckpt_ids: + ckpt_id = args.orig_ckpt_path or ckpt_ids[0] + snapshot_download( + repo_id=f"{'/'.join(ckpt_id.split('/')[:2])}", + cache_dir=cache_dir_path, + repo_type="model", + ) + file_path = hf_hub_download( + repo_id=f"{'/'.join(ckpt_id.split('/')[:2])}", + filename=f"{'/'.join(ckpt_id.split('/')[2:])}", + cache_dir=cache_dir_path, + repo_type="model", + ) + else: + file_path = args.orig_ckpt_path + + print(colored(f"Loading checkpoint from {file_path}", "green", attrs=["bold"])) + all_state_dict = torch.load(file_path, weights_only=True) + state_dict = all_state_dict.pop("state_dict") + converted_state_dict = {} + + # Patch embeddings. + converted_state_dict["patch_embed.proj.weight"] = state_dict.pop("x_embedder.proj.weight") + converted_state_dict["patch_embed.proj.bias"] = state_dict.pop("x_embedder.proj.bias") + + # Caption projection. + converted_state_dict["caption_projection.linear_1.weight"] = state_dict.pop("y_embedder.y_proj.fc1.weight") + converted_state_dict["caption_projection.linear_1.bias"] = state_dict.pop("y_embedder.y_proj.fc1.bias") + converted_state_dict["caption_projection.linear_2.weight"] = state_dict.pop("y_embedder.y_proj.fc2.weight") + converted_state_dict["caption_projection.linear_2.bias"] = state_dict.pop("y_embedder.y_proj.fc2.bias") + + # Handle different time embedding structure based on model type + + if args.model_type in ["SanaSprint_1600M_P1_D20", "SanaSprint_600M_P1_D28"]: + # For Sana Sprint, the time embedding structure is different + converted_state_dict["time_embed.timestep_embedder.linear_1.weight"] = state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["time_embed.timestep_embedder.linear_1.bias"] = state_dict.pop("t_embedder.mlp.0.bias") + converted_state_dict["time_embed.timestep_embedder.linear_2.weight"] = state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["time_embed.timestep_embedder.linear_2.bias"] = state_dict.pop("t_embedder.mlp.2.bias") + + # Guidance embedder for Sana Sprint + converted_state_dict["time_embed.guidance_embedder.linear_1.weight"] = state_dict.pop( + "cfg_embedder.mlp.0.weight" + ) + converted_state_dict["time_embed.guidance_embedder.linear_1.bias"] = state_dict.pop("cfg_embedder.mlp.0.bias") + converted_state_dict["time_embed.guidance_embedder.linear_2.weight"] = state_dict.pop( + "cfg_embedder.mlp.2.weight" + ) + converted_state_dict["time_embed.guidance_embedder.linear_2.bias"] = state_dict.pop("cfg_embedder.mlp.2.bias") + else: + # Original Sana time embedding structure + converted_state_dict["time_embed.emb.timestep_embedder.linear_1.weight"] = state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_1.bias"] = state_dict.pop( + "t_embedder.mlp.0.bias" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_2.weight"] = state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_2.bias"] = state_dict.pop( + "t_embedder.mlp.2.bias" + ) + + # Shared norm. + converted_state_dict["time_embed.linear.weight"] = state_dict.pop("t_block.1.weight") + converted_state_dict["time_embed.linear.bias"] = state_dict.pop("t_block.1.bias") + + # y norm + converted_state_dict["caption_norm.weight"] = state_dict.pop("attention_y_norm.weight") + + # scheduler + if args.image_size == 4096: + flow_shift = 6.0 + else: + flow_shift = 3.0 + + # model config + if args.model_type in ["SanaMS_1600M_P1_D20", "SanaSprint_1600M_P1_D20", "SanaMS1.5_1600M_P1_D20"]: + layer_num = 20 + elif args.model_type in ["SanaMS_600M_P1_D28", "SanaSprint_600M_P1_D28"]: + layer_num = 28 + elif args.model_type == "SanaMS_4800M_P1_D60": + layer_num = 60 + else: + raise ValueError(f"{args.model_type} is not supported.") + # Positional embedding interpolation scale. + interpolation_scale = {512: None, 1024: None, 2048: 1.0, 4096: 2.0} + qk_norm = ( + "rms_norm_across_heads" + if args.model_type + in ["SanaMS1.5_1600M_P1_D20", "SanaMS1.5_4800M_P1_D60", "SanaSprint_600M_P1_D28", "SanaSprint_1600M_P1_D20"] + else None + ) + + for depth in range(layer_num): + # Transformer blocks. + converted_state_dict[f"transformer_blocks.{depth}.scale_shift_table"] = state_dict.pop( + f"blocks.{depth}.scale_shift_table" + ) + + # Linear Attention is all you need 🤘 + # Self attention. + q, k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.attn.qkv.weight"), 3, dim=0) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.weight"] = v + if qk_norm is not None: + # Add Q/K normalization for self-attention (attn1) - needed for Sana-Sprint and Sana-1.5 + converted_state_dict[f"transformer_blocks.{depth}.attn1.norm_q.weight"] = state_dict.pop( + f"blocks.{depth}.attn.q_norm.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.norm_k.weight"] = state_dict.pop( + f"blocks.{depth}.attn.k_norm.weight" + ) + # Projection. + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.attn.proj.bias" + ) + + # Feed-forward. + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_inverted.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.inverted_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_inverted.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.inverted_conv.conv.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_depth.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.depth_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_depth.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.depth_conv.conv.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_point.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.point_conv.conv.weight" + ) + + # Cross-attention. + q = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.weight") + q_bias = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.bias") + k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.weight"), 2, dim=0) + k_bias, v_bias = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.bias"), 2, dim=0) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.bias"] = v_bias + if qk_norm is not None: + # Add Q/K normalization for cross-attention (attn2) - needed for Sana-Sprint and Sana-1.5 + converted_state_dict[f"transformer_blocks.{depth}.attn2.norm_q.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.q_norm.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.norm_k.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.k_norm.weight" + ) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.bias" + ) + + # Final block. + converted_state_dict["proj_out.weight"] = state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = state_dict.pop("final_layer.linear.bias") + converted_state_dict["scale_shift_table"] = state_dict.pop("final_layer.scale_shift_table") + + # Transformer + with CTX(): + transformer_kwargs = { + "in_channels": 32, + "out_channels": 32, + "num_attention_heads": model_kwargs[args.model_type]["num_attention_heads"], + "attention_head_dim": model_kwargs[args.model_type]["attention_head_dim"], + "num_layers": model_kwargs[args.model_type]["num_layers"], + "num_cross_attention_heads": model_kwargs[args.model_type]["num_cross_attention_heads"], + "cross_attention_head_dim": model_kwargs[args.model_type]["cross_attention_head_dim"], + "cross_attention_dim": model_kwargs[args.model_type]["cross_attention_dim"], + "caption_channels": 2304, + "mlp_ratio": 2.5, + "attention_bias": False, + "sample_size": args.image_size // 32, + "patch_size": 1, + "norm_elementwise_affine": False, + "norm_eps": 1e-6, + "interpolation_scale": interpolation_scale[args.image_size], + } + + # Add qk_norm parameter for Sana Sprint + if args.model_type in [ + "SanaMS1.5_1600M_P1_D20", + "SanaMS1.5_4800M_P1_D60", + "SanaSprint_600M_P1_D28", + "SanaSprint_1600M_P1_D20", + ]: + transformer_kwargs["qk_norm"] = "rms_norm_across_heads" + if args.model_type in ["SanaSprint_1600M_P1_D20", "SanaSprint_600M_P1_D28"]: + transformer_kwargs["guidance_embeds"] = True + + transformer = SanaTransformer2DModel(**transformer_kwargs) + + if is_accelerate_available(): + load_model_dict_into_meta(transformer, converted_state_dict) + else: + transformer.load_state_dict(converted_state_dict, strict=True, assign=True) + + try: + state_dict.pop("y_embedder.y_embedding") + state_dict.pop("pos_embed") + state_dict.pop("logvar_linear.weight") + state_dict.pop("logvar_linear.bias") + except KeyError: + print("y_embedder.y_embedding or pos_embed not found in the state_dict") + + assert len(state_dict) == 0, f"State dict is not empty, {state_dict.keys()}" + + num_model_params = sum(p.numel() for p in transformer.parameters()) + print(f"Total number of transformer parameters: {num_model_params}") + + transformer = transformer.to(weight_dtype) + + if not args.save_full_pipeline: + print( + colored( + f"Only saving transformer model of {args.model_type}. " + f"Set --save_full_pipeline to save the whole Pipeline", + "green", + attrs=["bold"], + ) + ) + transformer.save_pretrained( + os.path.join(args.dump_path, "transformer"), safe_serialization=True, max_shard_size="5GB" + ) + else: + print(colored(f"Saving the whole Pipeline containing {args.model_type}", "green", attrs=["bold"])) + # VAE + ae = AutoencoderDC.from_pretrained("mit-han-lab/dc-ae-f32c32-sana-1.1-diffusers", torch_dtype=torch.float32) + + # Text Encoder + text_encoder_model_path = "Efficient-Large-Model/gemma-2-2b-it" + tokenizer = AutoTokenizer.from_pretrained(text_encoder_model_path) + tokenizer.padding_side = "right" + text_encoder = AutoModelForCausalLM.from_pretrained( + text_encoder_model_path, torch_dtype=torch.bfloat16 + ).get_decoder() + + # Choose the appropriate pipeline and scheduler based on model type + if args.model_type in ["SanaSprint_1600M_P1_D20", "SanaSprint_600M_P1_D28"]: + # Force SCM Scheduler for Sana Sprint regardless of scheduler_type + if args.scheduler_type != "scm": + print( + colored( + f"Warning: Overriding scheduler_type '{args.scheduler_type}' to 'scm' for SanaSprint model", + "yellow", + attrs=["bold"], + ) + ) + + # SCM Scheduler for Sana Sprint + scheduler_config = { + "prediction_type": "trigflow", + "sigma_data": 0.5, + } + scheduler = SCMScheduler(**scheduler_config) + pipe = SanaSprintPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + transformer=transformer, + vae=ae, + scheduler=scheduler, + ) + else: + # Original Sana scheduler + if args.scheduler_type == "flow-dpm_solver": + scheduler = DPMSolverMultistepScheduler( + flow_shift=flow_shift, + use_flow_sigmas=True, + prediction_type="flow_prediction", + ) + elif args.scheduler_type == "flow-euler": + scheduler = FlowMatchEulerDiscreteScheduler(shift=flow_shift) + else: + raise ValueError(f"Scheduler type {args.scheduler_type} is not supported") + + pipe = SanaPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + transformer=transformer, + vae=ae, + scheduler=scheduler, + ) + + pipe.save_pretrained(args.dump_path, safe_serialization=True, max_shard_size="5GB") + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--orig_ckpt_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--image_size", + default=1024, + type=int, + choices=[512, 1024, 2048, 4096], + required=False, + help="Image size of pretrained model, 512, 1024, 2048 or 4096.", + ) + parser.add_argument( + "--model_type", + default="SanaMS_1600M_P1_D20", + type=str, + choices=[ + "SanaMS_1600M_P1_D20", + "SanaMS_600M_P1_D28", + "SanaMS1.5_1600M_P1_D20", + "SanaMS1.5_4800M_P1_D60", + "SanaSprint_1600M_P1_D20", + "SanaSprint_600M_P1_D28", + ], + ) + parser.add_argument( + "--scheduler_type", + default="flow-dpm_solver", + type=str, + choices=["flow-dpm_solver", "flow-euler", "scm"], + help="Scheduler type to use. Use 'scm' for Sana Sprint models.", + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.") + parser.add_argument("--save_full_pipeline", action="store_true", help="save all the pipeline elements in one.") + parser.add_argument("--dtype", default="fp32", type=str, choices=["fp32", "fp16", "bf16"], help="Weight dtype.") + + args = parser.parse_args() + + model_kwargs = { + "SanaMS_1600M_P1_D20": { + "num_attention_heads": 70, + "attention_head_dim": 32, + "num_cross_attention_heads": 20, + "cross_attention_head_dim": 112, + "cross_attention_dim": 2240, + "num_layers": 20, + }, + "SanaMS_600M_P1_D28": { + "num_attention_heads": 36, + "attention_head_dim": 32, + "num_cross_attention_heads": 16, + "cross_attention_head_dim": 72, + "cross_attention_dim": 1152, + "num_layers": 28, + }, + "SanaMS1.5_1600M_P1_D20": { + "num_attention_heads": 70, + "attention_head_dim": 32, + "num_cross_attention_heads": 20, + "cross_attention_head_dim": 112, + "cross_attention_dim": 2240, + "num_layers": 20, + }, + "SanaMS1.5_4800M_P1_D60": { + "num_attention_heads": 70, + "attention_head_dim": 32, + "num_cross_attention_heads": 20, + "cross_attention_head_dim": 112, + "cross_attention_dim": 2240, + "num_layers": 60, + }, + "SanaSprint_600M_P1_D28": { + "num_attention_heads": 36, + "attention_head_dim": 32, + "num_cross_attention_heads": 16, + "cross_attention_head_dim": 72, + "cross_attention_dim": 1152, + "num_layers": 28, + }, + "SanaSprint_1600M_P1_D20": { + "num_attention_heads": 70, + "attention_head_dim": 32, + "num_cross_attention_heads": 20, + "cross_attention_head_dim": 112, + "cross_attention_dim": 2240, + "num_layers": 20, + }, + } + + device = "cuda" if torch.cuda.is_available() else "cpu" + weight_dtype = DTYPE_MAPPING[args.dtype] + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_video_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_video_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..a939a06cbd46982d39014fc319ab5cd93f0a4ad4 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sana_video_to_diffusers.py @@ -0,0 +1,327 @@ +#!/usr/bin/env python +from __future__ import annotations + +import argparse +import os +from contextlib import nullcontext + +import torch +from accelerate import init_empty_weights +from huggingface_hub import hf_hub_download, snapshot_download +from termcolor import colored +from transformers import AutoModelForCausalLM, AutoTokenizer + +from diffusers import ( + AutoencoderKLWan, + DPMSolverMultistepScheduler, + FlowMatchEulerDiscreteScheduler, + SanaVideoPipeline, + SanaVideoTransformer3DModel, + UniPCMultistepScheduler, +) +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available else nullcontext + +ckpt_ids = ["Efficient-Large-Model/SANA-Video_2B_480p/checkpoints/SANA_Video_2B_480p.pth"] +# https://github.com/NVlabs/Sana/blob/main/inference_video_scripts/inference_sana_video.py + + +def main(args): + cache_dir_path = os.path.expanduser("~/.cache/huggingface/hub") + + if args.orig_ckpt_path is None or args.orig_ckpt_path in ckpt_ids: + ckpt_id = args.orig_ckpt_path or ckpt_ids[0] + snapshot_download( + repo_id=f"{'/'.join(ckpt_id.split('/')[:2])}", + cache_dir=cache_dir_path, + repo_type="model", + ) + file_path = hf_hub_download( + repo_id=f"{'/'.join(ckpt_id.split('/')[:2])}", + filename=f"{'/'.join(ckpt_id.split('/')[2:])}", + cache_dir=cache_dir_path, + repo_type="model", + ) + else: + file_path = args.orig_ckpt_path + + print(colored(f"Loading checkpoint from {file_path}", "green", attrs=["bold"])) + all_state_dict = torch.load(file_path, weights_only=True) + state_dict = all_state_dict.pop("state_dict") + converted_state_dict = {} + + # Patch embeddings. + converted_state_dict["patch_embedding.weight"] = state_dict.pop("x_embedder.proj.weight") + converted_state_dict["patch_embedding.bias"] = state_dict.pop("x_embedder.proj.bias") + + # Caption projection. + converted_state_dict["caption_projection.linear_1.weight"] = state_dict.pop("y_embedder.y_proj.fc1.weight") + converted_state_dict["caption_projection.linear_1.bias"] = state_dict.pop("y_embedder.y_proj.fc1.bias") + converted_state_dict["caption_projection.linear_2.weight"] = state_dict.pop("y_embedder.y_proj.fc2.weight") + converted_state_dict["caption_projection.linear_2.bias"] = state_dict.pop("y_embedder.y_proj.fc2.bias") + + converted_state_dict["time_embed.emb.timestep_embedder.linear_1.weight"] = state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_1.bias"] = state_dict.pop("t_embedder.mlp.0.bias") + converted_state_dict["time_embed.emb.timestep_embedder.linear_2.weight"] = state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["time_embed.emb.timestep_embedder.linear_2.bias"] = state_dict.pop("t_embedder.mlp.2.bias") + + # Shared norm. + converted_state_dict["time_embed.linear.weight"] = state_dict.pop("t_block.1.weight") + converted_state_dict["time_embed.linear.bias"] = state_dict.pop("t_block.1.bias") + + # y norm + converted_state_dict["caption_norm.weight"] = state_dict.pop("attention_y_norm.weight") + + # scheduler + flow_shift = 8.0 + if args.task == "i2v": + assert args.scheduler_type == "flow-euler", "Scheduler type must be flow-euler for i2v task." + + # model config + layer_num = 20 + # Positional embedding interpolation scale. + qk_norm = True + + # sample size + if args.video_size == 480: + sample_size = 30 # Wan-VAE: 8xp2 downsample factor + patch_size = (1, 2, 2) + elif args.video_size == 720: + sample_size = 22 # Wan-VAE: 32xp1 downsample factor + patch_size = (1, 1, 1) + else: + raise ValueError(f"Video size {args.video_size} is not supported.") + + for depth in range(layer_num): + # Transformer blocks. + converted_state_dict[f"transformer_blocks.{depth}.scale_shift_table"] = state_dict.pop( + f"blocks.{depth}.scale_shift_table" + ) + + # Linear Attention is all you need 🤘 + # Self attention. + q, k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.attn.qkv.weight"), 3, dim=0) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_v.weight"] = v + if qk_norm is not None: + # Add Q/K normalization for self-attention (attn1) - needed for Sana-Sprint and Sana-1.5 + converted_state_dict[f"transformer_blocks.{depth}.attn1.norm_q.weight"] = state_dict.pop( + f"blocks.{depth}.attn.q_norm.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.norm_k.weight"] = state_dict.pop( + f"blocks.{depth}.attn.k_norm.weight" + ) + # Projection. + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn1.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.attn.proj.bias" + ) + + # Feed-forward. + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_inverted.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.inverted_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_inverted.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.inverted_conv.conv.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_depth.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.depth_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_depth.bias"] = state_dict.pop( + f"blocks.{depth}.mlp.depth_conv.conv.bias" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_point.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.point_conv.conv.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.ff.conv_temp.weight"] = state_dict.pop( + f"blocks.{depth}.mlp.t_conv.weight" + ) + + # Cross-attention. + q = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.weight") + q_bias = state_dict.pop(f"blocks.{depth}.cross_attn.q_linear.bias") + k, v = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.weight"), 2, dim=0) + k_bias, v_bias = torch.chunk(state_dict.pop(f"blocks.{depth}.cross_attn.kv_linear.bias"), 2, dim=0) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.weight"] = q + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_q.bias"] = q_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.weight"] = k + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_k.bias"] = k_bias + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.weight"] = v + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_v.bias"] = v_bias + if qk_norm is not None: + # Add Q/K normalization for cross-attention (attn2) - needed for Sana-Sprint and Sana-1.5 + converted_state_dict[f"transformer_blocks.{depth}.attn2.norm_q.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.q_norm.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.norm_k.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.k_norm.weight" + ) + + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.weight"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{depth}.attn2.to_out.0.bias"] = state_dict.pop( + f"blocks.{depth}.cross_attn.proj.bias" + ) + + # Final block. + converted_state_dict["proj_out.weight"] = state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = state_dict.pop("final_layer.linear.bias") + converted_state_dict["scale_shift_table"] = state_dict.pop("final_layer.scale_shift_table") + + # Transformer + with CTX(): + transformer_kwargs = { + "in_channels": 16, + "out_channels": 16, + "num_attention_heads": 20, + "attention_head_dim": 112, + "num_layers": 20, + "num_cross_attention_heads": 20, + "cross_attention_head_dim": 112, + "cross_attention_dim": 2240, + "caption_channels": 2304, + "mlp_ratio": 3.0, + "attention_bias": False, + "sample_size": sample_size, + "patch_size": patch_size, + "norm_elementwise_affine": False, + "norm_eps": 1e-6, + "qk_norm": "rms_norm_across_heads", + "rope_max_seq_len": 1024, + } + + transformer = SanaVideoTransformer3DModel(**transformer_kwargs) + + transformer.load_state_dict(converted_state_dict, strict=True, assign=True) + + try: + state_dict.pop("y_embedder.y_embedding") + state_dict.pop("pos_embed") + state_dict.pop("logvar_linear.weight") + state_dict.pop("logvar_linear.bias") + except KeyError: + print("y_embedder.y_embedding or pos_embed not found in the state_dict") + + assert len(state_dict) == 0, f"State dict is not empty, {state_dict.keys()}" + + num_model_params = sum(p.numel() for p in transformer.parameters()) + print(f"Total number of transformer parameters: {num_model_params}") + + transformer = transformer.to(weight_dtype) + + if not args.save_full_pipeline: + print( + colored( + f"Only saving transformer model of {args.model_type}. " + f"Set --save_full_pipeline to save the whole Pipeline", + "green", + attrs=["bold"], + ) + ) + transformer.save_pretrained( + os.path.join(args.dump_path, "transformer"), safe_serialization=True, max_shard_size="5GB" + ) + else: + print(colored(f"Saving the whole Pipeline containing {args.model_type}", "green", attrs=["bold"])) + # VAE + vae = AutoencoderKLWan.from_pretrained( + "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", subfolder="vae", torch_dtype=torch.float32 + ) + + # Text Encoder + text_encoder_model_path = "Efficient-Large-Model/gemma-2-2b-it" + tokenizer = AutoTokenizer.from_pretrained(text_encoder_model_path) + tokenizer.padding_side = "right" + text_encoder = AutoModelForCausalLM.from_pretrained( + text_encoder_model_path, torch_dtype=torch.bfloat16 + ).get_decoder() + + # Choose the appropriate pipeline and scheduler based on model type + # Original Sana scheduler + if args.scheduler_type == "flow-dpm_solver": + scheduler = DPMSolverMultistepScheduler( + flow_shift=flow_shift, + use_flow_sigmas=True, + prediction_type="flow_prediction", + ) + elif args.scheduler_type == "flow-euler": + scheduler = FlowMatchEulerDiscreteScheduler(shift=flow_shift) + elif args.scheduler_type == "uni-pc": + scheduler = UniPCMultistepScheduler( + prediction_type="flow_prediction", + use_flow_sigmas=True, + num_train_timesteps=1000, + flow_shift=flow_shift, + ) + else: + raise ValueError(f"Scheduler type {args.scheduler_type} is not supported") + + pipe = SanaVideoPipeline( + tokenizer=tokenizer, + text_encoder=text_encoder, + transformer=transformer, + vae=vae, + scheduler=scheduler, + ) + + pipe.save_pretrained(args.dump_path, safe_serialization=True, max_shard_size="5GB") + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--orig_ckpt_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--video_size", + default=480, + type=int, + choices=[480, 720], + required=False, + help="Video size of pretrained model, 480 or 720.", + ) + parser.add_argument( + "--model_type", + default="SanaVideo", + type=str, + choices=[ + "SanaVideo", + ], + ) + parser.add_argument( + "--scheduler_type", + default="flow-dpm_solver", + type=str, + choices=["flow-dpm_solver", "flow-euler", "uni-pc"], + help="Scheduler type to use.", + ) + parser.add_argument("--task", default="t2v", type=str, required=True, help="Task to convert, t2v or i2v.") + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output pipeline.") + parser.add_argument("--save_full_pipeline", action="store_true", help="save all the pipeline elements in one.") + parser.add_argument("--dtype", default="fp32", type=str, choices=["fp32", "fp16", "bf16"], help="Weight dtype.") + + args = parser.parse_args() + + device = "cuda" if torch.cuda.is_available() else "cpu" + weight_dtype = DTYPE_MAPPING[args.dtype] + + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sd3_controlnet_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sd3_controlnet_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..171f40a7aa06bd062aba85948f0fac33b1e6e736 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sd3_controlnet_to_diffusers.py @@ -0,0 +1,185 @@ +""" +A script to convert Stable Diffusion 3.5 ControlNet checkpoints to the Diffusers format. + +Example: + Convert a SD3.5 ControlNet checkpoint to Diffusers format using local file: + ```bash + python scripts/convert_sd3_controlnet_to_diffusers.py \ + --checkpoint_path "path/to/local/sd3.5_large_controlnet_canny.safetensors" \ + --output_path "output/sd35-controlnet-canny" \ + --dtype "fp16" # optional, defaults to fp32 + ``` + + Or download and convert from HuggingFace repository: + ```bash + python scripts/convert_sd3_controlnet_to_diffusers.py \ + --original_state_dict_repo_id "stabilityai/stable-diffusion-3.5-controlnets" \ + --filename "sd3.5_large_controlnet_canny.safetensors" \ + --output_path "/raid/yiyi/sd35-controlnet-canny-diffusers" \ + --dtype "fp32" # optional, defaults to fp32 + ``` + +Note: + The script supports the following ControlNet types from SD3.5: + - Canny edge detection + - Depth estimation + - Blur detection + + The checkpoint files can be downloaded from: + https://huggingface.co/stabilityai/stable-diffusion-3.5-controlnets +""" + +import argparse + +import safetensors.torch +import torch +from huggingface_hub import hf_hub_download + +from diffusers import SD3ControlNetModel + + +parser = argparse.ArgumentParser() +parser.add_argument("--checkpoint_path", type=str, default=None, help="Path to local checkpoint file") +parser.add_argument( + "--original_state_dict_repo_id", type=str, default=None, help="HuggingFace repo ID containing the checkpoint" +) +parser.add_argument("--filename", type=str, default=None, help="Filename of the checkpoint in the HF repo") +parser.add_argument("--output_path", type=str, required=True, help="Path to save the converted model") +parser.add_argument( + "--dtype", type=str, default="fp32", help="Data type for the converted model (fp16, bf16, or fp32)" +) + +args = parser.parse_args() + + +def load_original_checkpoint(args): + if args.original_state_dict_repo_id is not None: + if args.filename is None: + raise ValueError("When using `original_state_dict_repo_id`, `filename` must also be specified") + print(f"Downloading checkpoint from {args.original_state_dict_repo_id}/{args.filename}") + ckpt_path = hf_hub_download(repo_id=args.original_state_dict_repo_id, filename=args.filename) + elif args.checkpoint_path is not None: + print(f"Loading checkpoint from local path: {args.checkpoint_path}") + ckpt_path = args.checkpoint_path + else: + raise ValueError("Please provide either `original_state_dict_repo_id` or a local `checkpoint_path`") + + original_state_dict = safetensors.torch.load_file(ckpt_path) + return original_state_dict + + +def convert_sd3_controlnet_checkpoint_to_diffusers(original_state_dict): + converted_state_dict = {} + + # Direct mappings for controlnet blocks + for i in range(19): # 19 controlnet blocks + converted_state_dict[f"controlnet_blocks.{i}.weight"] = original_state_dict[f"controlnet_blocks.{i}.weight"] + converted_state_dict[f"controlnet_blocks.{i}.bias"] = original_state_dict[f"controlnet_blocks.{i}.bias"] + + # Positional embeddings + converted_state_dict["pos_embed_input.proj.weight"] = original_state_dict["pos_embed_input.proj.weight"] + converted_state_dict["pos_embed_input.proj.bias"] = original_state_dict["pos_embed_input.proj.bias"] + + # Time and text embeddings + time_text_mappings = { + "time_text_embed.timestep_embedder.linear_1.weight": "time_text_embed.timestep_embedder.linear_1.weight", + "time_text_embed.timestep_embedder.linear_1.bias": "time_text_embed.timestep_embedder.linear_1.bias", + "time_text_embed.timestep_embedder.linear_2.weight": "time_text_embed.timestep_embedder.linear_2.weight", + "time_text_embed.timestep_embedder.linear_2.bias": "time_text_embed.timestep_embedder.linear_2.bias", + "time_text_embed.text_embedder.linear_1.weight": "time_text_embed.text_embedder.linear_1.weight", + "time_text_embed.text_embedder.linear_1.bias": "time_text_embed.text_embedder.linear_1.bias", + "time_text_embed.text_embedder.linear_2.weight": "time_text_embed.text_embedder.linear_2.weight", + "time_text_embed.text_embedder.linear_2.bias": "time_text_embed.text_embedder.linear_2.bias", + } + + for new_key, old_key in time_text_mappings.items(): + if old_key in original_state_dict: + converted_state_dict[new_key] = original_state_dict[old_key] + + # Transformer blocks + for i in range(19): + # Split QKV into separate Q, K, V + qkv_weight = original_state_dict[f"transformer_blocks.{i}.attn.qkv.weight"] + qkv_bias = original_state_dict[f"transformer_blocks.{i}.attn.qkv.bias"] + q, k, v = torch.chunk(qkv_weight, 3, dim=0) + q_bias, k_bias, v_bias = torch.chunk(qkv_bias, 3, dim=0) + + block_mappings = { + f"transformer_blocks.{i}.attn.to_q.weight": q, + f"transformer_blocks.{i}.attn.to_q.bias": q_bias, + f"transformer_blocks.{i}.attn.to_k.weight": k, + f"transformer_blocks.{i}.attn.to_k.bias": k_bias, + f"transformer_blocks.{i}.attn.to_v.weight": v, + f"transformer_blocks.{i}.attn.to_v.bias": v_bias, + # Output projections + f"transformer_blocks.{i}.attn.to_out.0.weight": original_state_dict[ + f"transformer_blocks.{i}.attn.proj.weight" + ], + f"transformer_blocks.{i}.attn.to_out.0.bias": original_state_dict[ + f"transformer_blocks.{i}.attn.proj.bias" + ], + # Feed forward + f"transformer_blocks.{i}.ff.net.0.proj.weight": original_state_dict[ + f"transformer_blocks.{i}.mlp.fc1.weight" + ], + f"transformer_blocks.{i}.ff.net.0.proj.bias": original_state_dict[f"transformer_blocks.{i}.mlp.fc1.bias"], + f"transformer_blocks.{i}.ff.net.2.weight": original_state_dict[f"transformer_blocks.{i}.mlp.fc2.weight"], + f"transformer_blocks.{i}.ff.net.2.bias": original_state_dict[f"transformer_blocks.{i}.mlp.fc2.bias"], + # Norms + f"transformer_blocks.{i}.norm1.linear.weight": original_state_dict[ + f"transformer_blocks.{i}.adaLN_modulation.1.weight" + ], + f"transformer_blocks.{i}.norm1.linear.bias": original_state_dict[ + f"transformer_blocks.{i}.adaLN_modulation.1.bias" + ], + } + converted_state_dict.update(block_mappings) + + return converted_state_dict + + +def main(args): + original_ckpt = load_original_checkpoint(args) + original_dtype = next(iter(original_ckpt.values())).dtype + + # Initialize dtype with fp32 as default + if args.dtype == "fp16": + dtype = torch.float16 + elif args.dtype == "bf16": + dtype = torch.bfloat16 + elif args.dtype == "fp32": + dtype = torch.float32 + else: + raise ValueError(f"Unsupported dtype: {args.dtype}. Must be one of: fp16, bf16, fp32") + + if dtype != original_dtype: + print( + f"Converting checkpoint from {original_dtype} to {dtype}. This can lead to unexpected results, proceed with caution." + ) + + converted_controlnet_state_dict = convert_sd3_controlnet_checkpoint_to_diffusers(original_ckpt) + + controlnet = SD3ControlNetModel( + patch_size=2, + in_channels=16, + num_layers=19, + attention_head_dim=64, + num_attention_heads=38, + joint_attention_dim=None, + caption_projection_dim=2048, + pooled_projection_dim=2048, + out_channels=16, + pos_embed_max_size=None, + pos_embed_type=None, + use_pos_embed=False, + force_zeros_for_pooled_projection=False, + ) + + controlnet.load_state_dict(converted_controlnet_state_dict, strict=True) + + print(f"Saving SD3 ControlNet in Diffusers format in {args.output_path}.") + controlnet.to(dtype).save_pretrained(args.output_path) + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sd3_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sd3_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..83cb436e6e3236e4e95c5acd17f3612347225d20 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_sd3_to_diffusers.py @@ -0,0 +1,351 @@ +import argparse +from contextlib import nullcontext + +import safetensors.torch +import torch +from accelerate import init_empty_weights + +from diffusers import AutoencoderKL, SD3Transformer2DModel +from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint +from diffusers.models.model_loading_utils import load_model_dict_into_meta +from diffusers.utils.import_utils import is_accelerate_available + + +CTX = init_empty_weights if is_accelerate_available() else nullcontext + +parser = argparse.ArgumentParser() +parser.add_argument("--checkpoint_path", type=str) +parser.add_argument("--output_path", type=str) +parser.add_argument("--dtype", type=str) + +args = parser.parse_args() + + +def load_original_checkpoint(ckpt_path): + original_state_dict = safetensors.torch.load_file(ckpt_path) + keys = list(original_state_dict.keys()) + for k in keys: + if "model.diffusion_model." in k: + original_state_dict[k.replace("model.diffusion_model.", "")] = original_state_dict.pop(k) + + return original_state_dict + + +# in SD3 original implementation of AdaLayerNormContinuous, it split linear projection output into shift, scale; +# while in diffusers it split into scale, shift. Here we swap the linear projection weights in order to be able to use diffusers implementation +def swap_scale_shift(weight, dim): + shift, scale = weight.chunk(2, dim=0) + new_weight = torch.cat([scale, shift], dim=0) + return new_weight + + +def convert_sd3_transformer_checkpoint_to_diffusers( + original_state_dict, num_layers, caption_projection_dim, dual_attention_layers, has_qk_norm +): + converted_state_dict = {} + + # Positional and patch embeddings. + converted_state_dict["pos_embed.pos_embed"] = original_state_dict.pop("pos_embed") + converted_state_dict["pos_embed.proj.weight"] = original_state_dict.pop("x_embedder.proj.weight") + converted_state_dict["pos_embed.proj.bias"] = original_state_dict.pop("x_embedder.proj.bias") + + # Timestep embeddings. + converted_state_dict["time_text_embed.timestep_embedder.linear_1.weight"] = original_state_dict.pop( + "t_embedder.mlp.0.weight" + ) + converted_state_dict["time_text_embed.timestep_embedder.linear_1.bias"] = original_state_dict.pop( + "t_embedder.mlp.0.bias" + ) + converted_state_dict["time_text_embed.timestep_embedder.linear_2.weight"] = original_state_dict.pop( + "t_embedder.mlp.2.weight" + ) + converted_state_dict["time_text_embed.timestep_embedder.linear_2.bias"] = original_state_dict.pop( + "t_embedder.mlp.2.bias" + ) + + # Context projections. + converted_state_dict["context_embedder.weight"] = original_state_dict.pop("context_embedder.weight") + converted_state_dict["context_embedder.bias"] = original_state_dict.pop("context_embedder.bias") + + # Pooled context projection. + converted_state_dict["time_text_embed.text_embedder.linear_1.weight"] = original_state_dict.pop( + "y_embedder.mlp.0.weight" + ) + converted_state_dict["time_text_embed.text_embedder.linear_1.bias"] = original_state_dict.pop( + "y_embedder.mlp.0.bias" + ) + converted_state_dict["time_text_embed.text_embedder.linear_2.weight"] = original_state_dict.pop( + "y_embedder.mlp.2.weight" + ) + converted_state_dict["time_text_embed.text_embedder.linear_2.bias"] = original_state_dict.pop( + "y_embedder.mlp.2.bias" + ) + + # Transformer blocks 🎸. + for i in range(num_layers): + # Q, K, V + sample_q, sample_k, sample_v = torch.chunk( + original_state_dict.pop(f"joint_blocks.{i}.x_block.attn.qkv.weight"), 3, dim=0 + ) + context_q, context_k, context_v = torch.chunk( + original_state_dict.pop(f"joint_blocks.{i}.context_block.attn.qkv.weight"), 3, dim=0 + ) + sample_q_bias, sample_k_bias, sample_v_bias = torch.chunk( + original_state_dict.pop(f"joint_blocks.{i}.x_block.attn.qkv.bias"), 3, dim=0 + ) + context_q_bias, context_k_bias, context_v_bias = torch.chunk( + original_state_dict.pop(f"joint_blocks.{i}.context_block.attn.qkv.bias"), 3, dim=0 + ) + + converted_state_dict[f"transformer_blocks.{i}.attn.to_q.weight"] = torch.cat([sample_q]) + converted_state_dict[f"transformer_blocks.{i}.attn.to_q.bias"] = torch.cat([sample_q_bias]) + converted_state_dict[f"transformer_blocks.{i}.attn.to_k.weight"] = torch.cat([sample_k]) + converted_state_dict[f"transformer_blocks.{i}.attn.to_k.bias"] = torch.cat([sample_k_bias]) + converted_state_dict[f"transformer_blocks.{i}.attn.to_v.weight"] = torch.cat([sample_v]) + converted_state_dict[f"transformer_blocks.{i}.attn.to_v.bias"] = torch.cat([sample_v_bias]) + + converted_state_dict[f"transformer_blocks.{i}.attn.add_q_proj.weight"] = torch.cat([context_q]) + converted_state_dict[f"transformer_blocks.{i}.attn.add_q_proj.bias"] = torch.cat([context_q_bias]) + converted_state_dict[f"transformer_blocks.{i}.attn.add_k_proj.weight"] = torch.cat([context_k]) + converted_state_dict[f"transformer_blocks.{i}.attn.add_k_proj.bias"] = torch.cat([context_k_bias]) + converted_state_dict[f"transformer_blocks.{i}.attn.add_v_proj.weight"] = torch.cat([context_v]) + converted_state_dict[f"transformer_blocks.{i}.attn.add_v_proj.bias"] = torch.cat([context_v_bias]) + + # qk norm + if has_qk_norm: + converted_state_dict[f"transformer_blocks.{i}.attn.norm_q.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn.ln_q.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn.norm_k.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn.ln_k.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn.norm_added_q.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.attn.ln_q.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn.norm_added_k.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.attn.ln_k.weight" + ) + + # output projections. + converted_state_dict[f"transformer_blocks.{i}.attn.to_out.0.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn.to_out.0.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn.proj.bias" + ) + if not (i == num_layers - 1): + converted_state_dict[f"transformer_blocks.{i}.attn.to_add_out.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.attn.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn.to_add_out.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.attn.proj.bias" + ) + + # attn2 + if i in dual_attention_layers: + # Q, K, V + sample_q2, sample_k2, sample_v2 = torch.chunk( + original_state_dict.pop(f"joint_blocks.{i}.x_block.attn2.qkv.weight"), 3, dim=0 + ) + sample_q2_bias, sample_k2_bias, sample_v2_bias = torch.chunk( + original_state_dict.pop(f"joint_blocks.{i}.x_block.attn2.qkv.bias"), 3, dim=0 + ) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_q.weight"] = torch.cat([sample_q2]) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_q.bias"] = torch.cat([sample_q2_bias]) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_k.weight"] = torch.cat([sample_k2]) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_k.bias"] = torch.cat([sample_k2_bias]) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_v.weight"] = torch.cat([sample_v2]) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_v.bias"] = torch.cat([sample_v2_bias]) + + # qk norm + if has_qk_norm: + converted_state_dict[f"transformer_blocks.{i}.attn2.norm_q.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn2.ln_q.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn2.norm_k.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn2.ln_k.weight" + ) + + # output projections. + converted_state_dict[f"transformer_blocks.{i}.attn2.to_out.0.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn2.proj.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.attn2.to_out.0.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.attn2.proj.bias" + ) + + # norms. + converted_state_dict[f"transformer_blocks.{i}.norm1.linear.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.adaLN_modulation.1.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.norm1.linear.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.adaLN_modulation.1.bias" + ) + if not (i == num_layers - 1): + converted_state_dict[f"transformer_blocks.{i}.norm1_context.linear.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.adaLN_modulation.1.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.norm1_context.linear.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.adaLN_modulation.1.bias" + ) + else: + converted_state_dict[f"transformer_blocks.{i}.norm1_context.linear.weight"] = swap_scale_shift( + original_state_dict.pop(f"joint_blocks.{i}.context_block.adaLN_modulation.1.weight"), + dim=caption_projection_dim, + ) + converted_state_dict[f"transformer_blocks.{i}.norm1_context.linear.bias"] = swap_scale_shift( + original_state_dict.pop(f"joint_blocks.{i}.context_block.adaLN_modulation.1.bias"), + dim=caption_projection_dim, + ) + + # ffs. + converted_state_dict[f"transformer_blocks.{i}.ff.net.0.proj.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.mlp.fc1.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.ff.net.0.proj.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.mlp.fc1.bias" + ) + converted_state_dict[f"transformer_blocks.{i}.ff.net.2.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.mlp.fc2.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.ff.net.2.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.x_block.mlp.fc2.bias" + ) + if not (i == num_layers - 1): + converted_state_dict[f"transformer_blocks.{i}.ff_context.net.0.proj.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.mlp.fc1.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.ff_context.net.0.proj.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.mlp.fc1.bias" + ) + converted_state_dict[f"transformer_blocks.{i}.ff_context.net.2.weight"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.mlp.fc2.weight" + ) + converted_state_dict[f"transformer_blocks.{i}.ff_context.net.2.bias"] = original_state_dict.pop( + f"joint_blocks.{i}.context_block.mlp.fc2.bias" + ) + + # Final blocks. + converted_state_dict["proj_out.weight"] = original_state_dict.pop("final_layer.linear.weight") + converted_state_dict["proj_out.bias"] = original_state_dict.pop("final_layer.linear.bias") + converted_state_dict["norm_out.linear.weight"] = swap_scale_shift( + original_state_dict.pop("final_layer.adaLN_modulation.1.weight"), dim=caption_projection_dim + ) + converted_state_dict["norm_out.linear.bias"] = swap_scale_shift( + original_state_dict.pop("final_layer.adaLN_modulation.1.bias"), dim=caption_projection_dim + ) + + return converted_state_dict + + +def is_vae_in_checkpoint(original_state_dict): + return ("first_stage_model.decoder.conv_in.weight" in original_state_dict) and ( + "first_stage_model.encoder.conv_in.weight" in original_state_dict + ) + + +def get_attn2_layers(state_dict): + attn2_layers = [] + for key in state_dict.keys(): + if "attn2." in key: + # Extract the layer number from the key + layer_num = int(key.split(".")[1]) + attn2_layers.append(layer_num) + return tuple(sorted(set(attn2_layers))) + + +def get_pos_embed_max_size(state_dict): + num_patches = state_dict["pos_embed"].shape[1] + pos_embed_max_size = int(num_patches**0.5) + return pos_embed_max_size + + +def get_caption_projection_dim(state_dict): + caption_projection_dim = state_dict["context_embedder.weight"].shape[0] + return caption_projection_dim + + +def main(args): + original_ckpt = load_original_checkpoint(args.checkpoint_path) + original_dtype = next(iter(original_ckpt.values())).dtype + + # Initialize dtype with a default value + dtype = None + + if args.dtype is None: + dtype = original_dtype + elif args.dtype == "fp16": + dtype = torch.float16 + elif args.dtype == "bf16": + dtype = torch.bfloat16 + elif args.dtype == "fp32": + dtype = torch.float32 + else: + raise ValueError(f"Unsupported dtype: {args.dtype}") + + if dtype != original_dtype: + print( + f"Checkpoint dtype {original_dtype} does not match requested dtype {dtype}. This can lead to unexpected results, proceed with caution." + ) + + num_layers = list(set(int(k.split(".", 2)[1]) for k in original_ckpt if "joint_blocks" in k))[-1] + 1 # noqa: C401 + + caption_projection_dim = get_caption_projection_dim(original_ckpt) + + # () for sd3.0; (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) for sd3.5 + attn2_layers = get_attn2_layers(original_ckpt) + + # sd3.5 use qk norm("rms_norm") + has_qk_norm = any("ln_q" in key for key in original_ckpt.keys()) + + # sd3.5 2b use pox_embed_max_size=384 and sd3.0 and sd3.5 8b use 192 + pos_embed_max_size = get_pos_embed_max_size(original_ckpt) + + converted_transformer_state_dict = convert_sd3_transformer_checkpoint_to_diffusers( + original_ckpt, num_layers, caption_projection_dim, attn2_layers, has_qk_norm + ) + + with CTX(): + transformer = SD3Transformer2DModel( + sample_size=128, + patch_size=2, + in_channels=16, + joint_attention_dim=4096, + num_layers=num_layers, + caption_projection_dim=caption_projection_dim, + num_attention_heads=num_layers, + pos_embed_max_size=pos_embed_max_size, + qk_norm="rms_norm" if has_qk_norm else None, + dual_attention_layers=attn2_layers, + ) + if is_accelerate_available(): + load_model_dict_into_meta(transformer, converted_transformer_state_dict) + else: + transformer.load_state_dict(converted_transformer_state_dict, strict=True) + + print("Saving SD3 Transformer in Diffusers format.") + transformer.to(dtype).save_pretrained(f"{args.output_path}/transformer") + + if is_vae_in_checkpoint(original_ckpt): + with CTX(): + vae = AutoencoderKL.from_config( + "stabilityai/stable-diffusion-xl-base-1.0", + subfolder="vae", + latent_channels=16, + use_post_quant_conv=False, + use_quant_conv=False, + scaling_factor=1.5305, + shift_factor=0.0609, + ) + converted_vae_state_dict = convert_ldm_vae_checkpoint(original_ckpt, vae.config) + if is_accelerate_available(): + load_model_dict_into_meta(vae, converted_vae_state_dict) + else: + vae.load_state_dict(converted_vae_state_dict, strict=True) + + print("Saving SD3 Autoencoder in Diffusers format.") + vae.to(dtype).save_pretrained(f"{args.output_path}/vae") + + +if __name__ == "__main__": + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_shap_e_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_shap_e_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..ac6543667af9278b7bd19922b68696151dd98896 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_shap_e_to_diffusers.py @@ -0,0 +1,1080 @@ +import argparse +import tempfile + +import torch +from accelerate import load_checkpoint_and_dispatch + +from diffusers.models.transformers.prior_transformer import PriorTransformer +from diffusers.pipelines.shap_e import ShapERenderer + + +""" +Example - From the diffusers root directory: + +Download weights: +```sh +$ wget "https://openaipublic.azureedge.net/main/shap-e/text_cond.pt" +``` + +Convert the model: +```sh +$ python scripts/convert_shap_e_to_diffusers.py \ + --prior_checkpoint_path /home/yiyi_huggingface_co/shap-e/shap_e_model_cache/text_cond.pt \ + --prior_image_checkpoint_path /home/yiyi_huggingface_co/shap-e/shap_e_model_cache/image_cond.pt \ + --transmitter_checkpoint_path /home/yiyi_huggingface_co/shap-e/shap_e_model_cache/transmitter.pt\ + --dump_path /home/yiyi_huggingface_co/model_repo/shap-e-img2img/shap_e_renderer\ + --debug renderer +``` +""" + + +# prior + +PRIOR_ORIGINAL_PREFIX = "wrapped" + +PRIOR_CONFIG = { + "num_attention_heads": 16, + "attention_head_dim": 1024 // 16, + "num_layers": 24, + "embedding_dim": 1024, + "num_embeddings": 1024, + "additional_embeddings": 0, + "time_embed_act_fn": "gelu", + "norm_in_type": "layer", + "encoder_hid_proj_type": None, + "added_emb_type": None, + "time_embed_dim": 1024 * 4, + "embedding_proj_dim": 768, + "clip_embed_dim": 1024 * 2, +} + + +def prior_model_from_original_config(): + model = PriorTransformer(**PRIOR_CONFIG) + + return model + + +def prior_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # .time_embed.c_fc -> .time_embedding.linear_1 + diffusers_checkpoint.update( + { + "time_embedding.linear_1.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.c_fc.weight"], + "time_embedding.linear_1.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.c_fc.bias"], + } + ) + + # .time_embed.c_proj -> .time_embedding.linear_2 + diffusers_checkpoint.update( + { + "time_embedding.linear_2.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.c_proj.weight"], + "time_embedding.linear_2.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.time_embed.c_proj.bias"], + } + ) + + # .input_proj -> .proj_in + diffusers_checkpoint.update( + { + "proj_in.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.input_proj.weight"], + "proj_in.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.input_proj.bias"], + } + ) + + # .clip_emb -> .embedding_proj + diffusers_checkpoint.update( + { + "embedding_proj.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.clip_embed.weight"], + "embedding_proj.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.clip_embed.bias"], + } + ) + + # .pos_emb -> .positional_embedding + diffusers_checkpoint.update({"positional_embedding": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.pos_emb"][None, :]}) + + # .ln_pre -> .norm_in + diffusers_checkpoint.update( + { + "norm_in.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.ln_pre.weight"], + "norm_in.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.ln_pre.bias"], + } + ) + + # .backbone.resblocks. -> .transformer_blocks. + for idx in range(len(model.transformer_blocks)): + diffusers_transformer_prefix = f"transformer_blocks.{idx}" + original_transformer_prefix = f"{PRIOR_ORIGINAL_PREFIX}.backbone.resblocks.{idx}" + + # .attn -> .attn1 + diffusers_attention_prefix = f"{diffusers_transformer_prefix}.attn1" + original_attention_prefix = f"{original_transformer_prefix}.attn" + diffusers_checkpoint.update( + prior_attention_to_diffusers( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + original_attention_prefix=original_attention_prefix, + attention_head_dim=model.attention_head_dim, + ) + ) + + # .mlp -> .ff + diffusers_ff_prefix = f"{diffusers_transformer_prefix}.ff" + original_ff_prefix = f"{original_transformer_prefix}.mlp" + diffusers_checkpoint.update( + prior_ff_to_diffusers( + checkpoint, diffusers_ff_prefix=diffusers_ff_prefix, original_ff_prefix=original_ff_prefix + ) + ) + + # .ln_1 -> .norm1 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm1.weight": checkpoint[ + f"{original_transformer_prefix}.ln_1.weight" + ], + f"{diffusers_transformer_prefix}.norm1.bias": checkpoint[f"{original_transformer_prefix}.ln_1.bias"], + } + ) + + # .ln_2 -> .norm3 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm3.weight": checkpoint[ + f"{original_transformer_prefix}.ln_2.weight" + ], + f"{diffusers_transformer_prefix}.norm3.bias": checkpoint[f"{original_transformer_prefix}.ln_2.bias"], + } + ) + + # .ln_post -> .norm_out + diffusers_checkpoint.update( + { + "norm_out.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.ln_post.weight"], + "norm_out.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.ln_post.bias"], + } + ) + + # .output_proj -> .proj_to_clip_embeddings + diffusers_checkpoint.update( + { + "proj_to_clip_embeddings.weight": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.output_proj.weight"], + "proj_to_clip_embeddings.bias": checkpoint[f"{PRIOR_ORIGINAL_PREFIX}.output_proj.bias"], + } + ) + + return diffusers_checkpoint + + +def prior_attention_to_diffusers( + checkpoint, *, diffusers_attention_prefix, original_attention_prefix, attention_head_dim +): + diffusers_checkpoint = {} + + # .c_qkv -> .{to_q, to_k, to_v} + [q_weight, k_weight, v_weight], [q_bias, k_bias, v_bias] = split_attentions( + weight=checkpoint[f"{original_attention_prefix}.c_qkv.weight"], + bias=checkpoint[f"{original_attention_prefix}.c_qkv.bias"], + split=3, + chunk_size=attention_head_dim, + ) + + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_q.weight": q_weight, + f"{diffusers_attention_prefix}.to_q.bias": q_bias, + f"{diffusers_attention_prefix}.to_k.weight": k_weight, + f"{diffusers_attention_prefix}.to_k.bias": k_bias, + f"{diffusers_attention_prefix}.to_v.weight": v_weight, + f"{diffusers_attention_prefix}.to_v.bias": v_bias, + } + ) + + # .c_proj -> .to_out.0 + diffusers_checkpoint.update( + { + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{original_attention_prefix}.c_proj.weight"], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{original_attention_prefix}.c_proj.bias"], + } + ) + + return diffusers_checkpoint + + +def prior_ff_to_diffusers(checkpoint, *, diffusers_ff_prefix, original_ff_prefix): + diffusers_checkpoint = { + # .c_fc -> .net.0.proj + f"{diffusers_ff_prefix}.net.{0}.proj.weight": checkpoint[f"{original_ff_prefix}.c_fc.weight"], + f"{diffusers_ff_prefix}.net.{0}.proj.bias": checkpoint[f"{original_ff_prefix}.c_fc.bias"], + # .c_proj -> .net.2 + f"{diffusers_ff_prefix}.net.{2}.weight": checkpoint[f"{original_ff_prefix}.c_proj.weight"], + f"{diffusers_ff_prefix}.net.{2}.bias": checkpoint[f"{original_ff_prefix}.c_proj.bias"], + } + + return diffusers_checkpoint + + +# done prior + + +# prior_image (only slightly different from prior) + + +PRIOR_IMAGE_ORIGINAL_PREFIX = "wrapped" + +# Uses default arguments +PRIOR_IMAGE_CONFIG = { + "num_attention_heads": 8, + "attention_head_dim": 1024 // 8, + "num_layers": 24, + "embedding_dim": 1024, + "num_embeddings": 1024, + "additional_embeddings": 0, + "time_embed_act_fn": "gelu", + "norm_in_type": "layer", + "embedding_proj_norm_type": "layer", + "encoder_hid_proj_type": None, + "added_emb_type": None, + "time_embed_dim": 1024 * 4, + "embedding_proj_dim": 1024, + "clip_embed_dim": 1024 * 2, +} + + +def prior_image_model_from_original_config(): + model = PriorTransformer(**PRIOR_IMAGE_CONFIG) + + return model + + +def prior_image_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # .time_embed.c_fc -> .time_embedding.linear_1 + diffusers_checkpoint.update( + { + "time_embedding.linear_1.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.time_embed.c_fc.weight"], + "time_embedding.linear_1.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.time_embed.c_fc.bias"], + } + ) + + # .time_embed.c_proj -> .time_embedding.linear_2 + diffusers_checkpoint.update( + { + "time_embedding.linear_2.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.time_embed.c_proj.weight"], + "time_embedding.linear_2.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.time_embed.c_proj.bias"], + } + ) + + # .input_proj -> .proj_in + diffusers_checkpoint.update( + { + "proj_in.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.input_proj.weight"], + "proj_in.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.input_proj.bias"], + } + ) + + # .clip_embed.0 -> .embedding_proj_norm + diffusers_checkpoint.update( + { + "embedding_proj_norm.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.clip_embed.0.weight"], + "embedding_proj_norm.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.clip_embed.0.bias"], + } + ) + + # ..clip_embed.1 -> .embedding_proj + diffusers_checkpoint.update( + { + "embedding_proj.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.clip_embed.1.weight"], + "embedding_proj.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.clip_embed.1.bias"], + } + ) + + # .pos_emb -> .positional_embedding + diffusers_checkpoint.update( + {"positional_embedding": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.pos_emb"][None, :]} + ) + + # .ln_pre -> .norm_in + diffusers_checkpoint.update( + { + "norm_in.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.ln_pre.weight"], + "norm_in.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.ln_pre.bias"], + } + ) + + # .backbone.resblocks. -> .transformer_blocks. + for idx in range(len(model.transformer_blocks)): + diffusers_transformer_prefix = f"transformer_blocks.{idx}" + original_transformer_prefix = f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.backbone.resblocks.{idx}" + + # .attn -> .attn1 + diffusers_attention_prefix = f"{diffusers_transformer_prefix}.attn1" + original_attention_prefix = f"{original_transformer_prefix}.attn" + diffusers_checkpoint.update( + prior_attention_to_diffusers( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + original_attention_prefix=original_attention_prefix, + attention_head_dim=model.attention_head_dim, + ) + ) + + # .mlp -> .ff + diffusers_ff_prefix = f"{diffusers_transformer_prefix}.ff" + original_ff_prefix = f"{original_transformer_prefix}.mlp" + diffusers_checkpoint.update( + prior_ff_to_diffusers( + checkpoint, diffusers_ff_prefix=diffusers_ff_prefix, original_ff_prefix=original_ff_prefix + ) + ) + + # .ln_1 -> .norm1 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm1.weight": checkpoint[ + f"{original_transformer_prefix}.ln_1.weight" + ], + f"{diffusers_transformer_prefix}.norm1.bias": checkpoint[f"{original_transformer_prefix}.ln_1.bias"], + } + ) + + # .ln_2 -> .norm3 + diffusers_checkpoint.update( + { + f"{diffusers_transformer_prefix}.norm3.weight": checkpoint[ + f"{original_transformer_prefix}.ln_2.weight" + ], + f"{diffusers_transformer_prefix}.norm3.bias": checkpoint[f"{original_transformer_prefix}.ln_2.bias"], + } + ) + + # .ln_post -> .norm_out + diffusers_checkpoint.update( + { + "norm_out.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.ln_post.weight"], + "norm_out.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.ln_post.bias"], + } + ) + + # .output_proj -> .proj_to_clip_embeddings + diffusers_checkpoint.update( + { + "proj_to_clip_embeddings.weight": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.output_proj.weight"], + "proj_to_clip_embeddings.bias": checkpoint[f"{PRIOR_IMAGE_ORIGINAL_PREFIX}.output_proj.bias"], + } + ) + + return diffusers_checkpoint + + +# done prior_image + + +# renderer + +## create the lookup table for marching cubes method used in MeshDecoder + +MC_TABLE = [ + [], + [[0, 1, 0, 2, 0, 4]], + [[1, 0, 1, 5, 1, 3]], + [[0, 4, 1, 5, 0, 2], [1, 5, 1, 3, 0, 2]], + [[2, 0, 2, 3, 2, 6]], + [[0, 1, 2, 3, 0, 4], [2, 3, 2, 6, 0, 4]], + [[1, 0, 1, 5, 1, 3], [2, 6, 0, 2, 3, 2]], + [[3, 2, 2, 6, 3, 1], [3, 1, 2, 6, 1, 5], [1, 5, 2, 6, 0, 4]], + [[3, 1, 3, 7, 3, 2]], + [[0, 2, 0, 4, 0, 1], [3, 7, 2, 3, 1, 3]], + [[1, 5, 3, 7, 1, 0], [3, 7, 3, 2, 1, 0]], + [[2, 0, 0, 4, 2, 3], [2, 3, 0, 4, 3, 7], [3, 7, 0, 4, 1, 5]], + [[2, 0, 3, 1, 2, 6], [3, 1, 3, 7, 2, 6]], + [[1, 3, 3, 7, 1, 0], [1, 0, 3, 7, 0, 4], [0, 4, 3, 7, 2, 6]], + [[0, 1, 1, 5, 0, 2], [0, 2, 1, 5, 2, 6], [2, 6, 1, 5, 3, 7]], + [[0, 4, 1, 5, 3, 7], [0, 4, 3, 7, 2, 6]], + [[4, 0, 4, 6, 4, 5]], + [[0, 2, 4, 6, 0, 1], [4, 6, 4, 5, 0, 1]], + [[1, 5, 1, 3, 1, 0], [4, 6, 5, 4, 0, 4]], + [[5, 1, 1, 3, 5, 4], [5, 4, 1, 3, 4, 6], [4, 6, 1, 3, 0, 2]], + [[2, 0, 2, 3, 2, 6], [4, 5, 0, 4, 6, 4]], + [[6, 4, 4, 5, 6, 2], [6, 2, 4, 5, 2, 3], [2, 3, 4, 5, 0, 1]], + [[2, 6, 2, 0, 3, 2], [1, 0, 1, 5, 3, 1], [6, 4, 5, 4, 0, 4]], + [[1, 3, 5, 4, 1, 5], [1, 3, 4, 6, 5, 4], [1, 3, 3, 2, 4, 6], [3, 2, 2, 6, 4, 6]], + [[3, 1, 3, 7, 3, 2], [6, 4, 5, 4, 0, 4]], + [[4, 5, 0, 1, 4, 6], [0, 1, 0, 2, 4, 6], [7, 3, 2, 3, 1, 3]], + [[3, 2, 1, 0, 3, 7], [1, 0, 1, 5, 3, 7], [6, 4, 5, 4, 0, 4]], + [[3, 7, 3, 2, 1, 5], [3, 2, 6, 4, 1, 5], [1, 5, 6, 4, 5, 4], [3, 2, 2, 0, 6, 4]], + [[3, 7, 2, 6, 3, 1], [2, 6, 2, 0, 3, 1], [5, 4, 0, 4, 6, 4]], + [[1, 0, 1, 3, 5, 4], [1, 3, 2, 6, 5, 4], [1, 3, 3, 7, 2, 6], [5, 4, 2, 6, 4, 6]], + [[0, 1, 1, 5, 0, 2], [0, 2, 1, 5, 2, 6], [2, 6, 1, 5, 3, 7], [4, 5, 0, 4, 4, 6]], + [[6, 2, 4, 6, 4, 5], [4, 5, 5, 1, 6, 2], [6, 2, 5, 1, 7, 3]], + [[5, 1, 5, 4, 5, 7]], + [[0, 1, 0, 2, 0, 4], [5, 7, 1, 5, 4, 5]], + [[1, 0, 5, 4, 1, 3], [5, 4, 5, 7, 1, 3]], + [[4, 5, 5, 7, 4, 0], [4, 0, 5, 7, 0, 2], [0, 2, 5, 7, 1, 3]], + [[2, 0, 2, 3, 2, 6], [7, 5, 1, 5, 4, 5]], + [[2, 6, 0, 4, 2, 3], [0, 4, 0, 1, 2, 3], [7, 5, 1, 5, 4, 5]], + [[5, 7, 1, 3, 5, 4], [1, 3, 1, 0, 5, 4], [6, 2, 0, 2, 3, 2]], + [[3, 1, 3, 2, 7, 5], [3, 2, 0, 4, 7, 5], [3, 2, 2, 6, 0, 4], [7, 5, 0, 4, 5, 4]], + [[3, 7, 3, 2, 3, 1], [5, 4, 7, 5, 1, 5]], + [[0, 4, 0, 1, 2, 0], [3, 1, 3, 7, 2, 3], [4, 5, 7, 5, 1, 5]], + [[7, 3, 3, 2, 7, 5], [7, 5, 3, 2, 5, 4], [5, 4, 3, 2, 1, 0]], + [[0, 4, 2, 3, 0, 2], [0, 4, 3, 7, 2, 3], [0, 4, 4, 5, 3, 7], [4, 5, 5, 7, 3, 7]], + [[2, 0, 3, 1, 2, 6], [3, 1, 3, 7, 2, 6], [4, 5, 7, 5, 1, 5]], + [[1, 3, 3, 7, 1, 0], [1, 0, 3, 7, 0, 4], [0, 4, 3, 7, 2, 6], [5, 7, 1, 5, 5, 4]], + [[2, 6, 2, 0, 3, 7], [2, 0, 4, 5, 3, 7], [3, 7, 4, 5, 7, 5], [2, 0, 0, 1, 4, 5]], + [[4, 0, 5, 4, 5, 7], [5, 7, 7, 3, 4, 0], [4, 0, 7, 3, 6, 2]], + [[4, 6, 5, 7, 4, 0], [5, 7, 5, 1, 4, 0]], + [[1, 0, 0, 2, 1, 5], [1, 5, 0, 2, 5, 7], [5, 7, 0, 2, 4, 6]], + [[0, 4, 4, 6, 0, 1], [0, 1, 4, 6, 1, 3], [1, 3, 4, 6, 5, 7]], + [[0, 2, 4, 6, 5, 7], [0, 2, 5, 7, 1, 3]], + [[5, 1, 4, 0, 5, 7], [4, 0, 4, 6, 5, 7], [3, 2, 6, 2, 0, 2]], + [[2, 3, 2, 6, 0, 1], [2, 6, 7, 5, 0, 1], [0, 1, 7, 5, 1, 5], [2, 6, 6, 4, 7, 5]], + [[0, 4, 4, 6, 0, 1], [0, 1, 4, 6, 1, 3], [1, 3, 4, 6, 5, 7], [2, 6, 0, 2, 2, 3]], + [[3, 1, 2, 3, 2, 6], [2, 6, 6, 4, 3, 1], [3, 1, 6, 4, 7, 5]], + [[4, 6, 5, 7, 4, 0], [5, 7, 5, 1, 4, 0], [2, 3, 1, 3, 7, 3]], + [[1, 0, 0, 2, 1, 5], [1, 5, 0, 2, 5, 7], [5, 7, 0, 2, 4, 6], [3, 2, 1, 3, 3, 7]], + [[0, 1, 0, 4, 2, 3], [0, 4, 5, 7, 2, 3], [0, 4, 4, 6, 5, 7], [2, 3, 5, 7, 3, 7]], + [[7, 5, 3, 7, 3, 2], [3, 2, 2, 0, 7, 5], [7, 5, 2, 0, 6, 4]], + [[0, 4, 4, 6, 5, 7], [0, 4, 5, 7, 1, 5], [0, 2, 1, 3, 3, 7], [3, 7, 2, 6, 0, 2]], + [ + [3, 1, 7, 3, 6, 2], + [6, 2, 0, 1, 3, 1], + [6, 4, 0, 1, 6, 2], + [6, 4, 5, 1, 0, 1], + [6, 4, 7, 5, 5, 1], + ], + [ + [4, 0, 6, 4, 7, 5], + [7, 5, 1, 0, 4, 0], + [7, 3, 1, 0, 7, 5], + [7, 3, 2, 0, 1, 0], + [7, 3, 6, 2, 2, 0], + ], + [[7, 3, 6, 2, 6, 4], [7, 5, 7, 3, 6, 4]], + [[6, 2, 6, 7, 6, 4]], + [[0, 4, 0, 1, 0, 2], [6, 7, 4, 6, 2, 6]], + [[1, 0, 1, 5, 1, 3], [7, 6, 4, 6, 2, 6]], + [[1, 3, 0, 2, 1, 5], [0, 2, 0, 4, 1, 5], [7, 6, 4, 6, 2, 6]], + [[2, 3, 6, 7, 2, 0], [6, 7, 6, 4, 2, 0]], + [[4, 0, 0, 1, 4, 6], [4, 6, 0, 1, 6, 7], [6, 7, 0, 1, 2, 3]], + [[6, 4, 2, 0, 6, 7], [2, 0, 2, 3, 6, 7], [5, 1, 3, 1, 0, 1]], + [[1, 5, 1, 3, 0, 4], [1, 3, 7, 6, 0, 4], [0, 4, 7, 6, 4, 6], [1, 3, 3, 2, 7, 6]], + [[3, 2, 3, 1, 3, 7], [6, 4, 2, 6, 7, 6]], + [[3, 7, 3, 2, 1, 3], [0, 2, 0, 4, 1, 0], [7, 6, 4, 6, 2, 6]], + [[1, 5, 3, 7, 1, 0], [3, 7, 3, 2, 1, 0], [4, 6, 2, 6, 7, 6]], + [[2, 0, 0, 4, 2, 3], [2, 3, 0, 4, 3, 7], [3, 7, 0, 4, 1, 5], [6, 4, 2, 6, 6, 7]], + [[7, 6, 6, 4, 7, 3], [7, 3, 6, 4, 3, 1], [3, 1, 6, 4, 2, 0]], + [[0, 1, 4, 6, 0, 4], [0, 1, 6, 7, 4, 6], [0, 1, 1, 3, 6, 7], [1, 3, 3, 7, 6, 7]], + [[0, 2, 0, 1, 4, 6], [0, 1, 3, 7, 4, 6], [0, 1, 1, 5, 3, 7], [4, 6, 3, 7, 6, 7]], + [[7, 3, 6, 7, 6, 4], [6, 4, 4, 0, 7, 3], [7, 3, 4, 0, 5, 1]], + [[4, 0, 6, 2, 4, 5], [6, 2, 6, 7, 4, 5]], + [[2, 6, 6, 7, 2, 0], [2, 0, 6, 7, 0, 1], [0, 1, 6, 7, 4, 5]], + [[6, 7, 4, 5, 6, 2], [4, 5, 4, 0, 6, 2], [3, 1, 0, 1, 5, 1]], + [[2, 0, 2, 6, 3, 1], [2, 6, 4, 5, 3, 1], [2, 6, 6, 7, 4, 5], [3, 1, 4, 5, 1, 5]], + [[0, 2, 2, 3, 0, 4], [0, 4, 2, 3, 4, 5], [4, 5, 2, 3, 6, 7]], + [[0, 1, 2, 3, 6, 7], [0, 1, 6, 7, 4, 5]], + [[0, 2, 2, 3, 0, 4], [0, 4, 2, 3, 4, 5], [4, 5, 2, 3, 6, 7], [1, 3, 0, 1, 1, 5]], + [[5, 4, 1, 5, 1, 3], [1, 3, 3, 2, 5, 4], [5, 4, 3, 2, 7, 6]], + [[4, 0, 6, 2, 4, 5], [6, 2, 6, 7, 4, 5], [1, 3, 7, 3, 2, 3]], + [[2, 6, 6, 7, 2, 0], [2, 0, 6, 7, 0, 1], [0, 1, 6, 7, 4, 5], [3, 7, 2, 3, 3, 1]], + [[0, 1, 1, 5, 3, 7], [0, 1, 3, 7, 2, 3], [0, 4, 2, 6, 6, 7], [6, 7, 4, 5, 0, 4]], + [ + [6, 2, 7, 6, 5, 4], + [5, 4, 0, 2, 6, 2], + [5, 1, 0, 2, 5, 4], + [5, 1, 3, 2, 0, 2], + [5, 1, 7, 3, 3, 2], + ], + [[3, 1, 3, 7, 2, 0], [3, 7, 5, 4, 2, 0], [2, 0, 5, 4, 0, 4], [3, 7, 7, 6, 5, 4]], + [[1, 0, 3, 1, 3, 7], [3, 7, 7, 6, 1, 0], [1, 0, 7, 6, 5, 4]], + [ + [1, 0, 5, 1, 7, 3], + [7, 3, 2, 0, 1, 0], + [7, 6, 2, 0, 7, 3], + [7, 6, 4, 0, 2, 0], + [7, 6, 5, 4, 4, 0], + ], + [[7, 6, 5, 4, 5, 1], [7, 3, 7, 6, 5, 1]], + [[5, 7, 5, 1, 5, 4], [6, 2, 7, 6, 4, 6]], + [[0, 2, 0, 4, 1, 0], [5, 4, 5, 7, 1, 5], [2, 6, 7, 6, 4, 6]], + [[1, 0, 5, 4, 1, 3], [5, 4, 5, 7, 1, 3], [2, 6, 7, 6, 4, 6]], + [[4, 5, 5, 7, 4, 0], [4, 0, 5, 7, 0, 2], [0, 2, 5, 7, 1, 3], [6, 7, 4, 6, 6, 2]], + [[2, 3, 6, 7, 2, 0], [6, 7, 6, 4, 2, 0], [1, 5, 4, 5, 7, 5]], + [[4, 0, 0, 1, 4, 6], [4, 6, 0, 1, 6, 7], [6, 7, 0, 1, 2, 3], [5, 1, 4, 5, 5, 7]], + [[0, 2, 2, 3, 6, 7], [0, 2, 6, 7, 4, 6], [0, 1, 4, 5, 5, 7], [5, 7, 1, 3, 0, 1]], + [ + [5, 4, 7, 5, 3, 1], + [3, 1, 0, 4, 5, 4], + [3, 2, 0, 4, 3, 1], + [3, 2, 6, 4, 0, 4], + [3, 2, 7, 6, 6, 4], + ], + [[5, 4, 5, 7, 1, 5], [3, 7, 3, 2, 1, 3], [4, 6, 2, 6, 7, 6]], + [[1, 0, 0, 2, 0, 4], [1, 5, 5, 4, 5, 7], [3, 2, 1, 3, 3, 7], [2, 6, 7, 6, 4, 6]], + [[7, 3, 3, 2, 7, 5], [7, 5, 3, 2, 5, 4], [5, 4, 3, 2, 1, 0], [6, 2, 7, 6, 6, 4]], + [ + [0, 4, 2, 3, 0, 2], + [0, 4, 3, 7, 2, 3], + [0, 4, 4, 5, 3, 7], + [4, 5, 5, 7, 3, 7], + [6, 7, 4, 6, 2, 6], + ], + [[7, 6, 6, 4, 7, 3], [7, 3, 6, 4, 3, 1], [3, 1, 6, 4, 2, 0], [5, 4, 7, 5, 5, 1]], + [ + [0, 1, 4, 6, 0, 4], + [0, 1, 6, 7, 4, 6], + [0, 1, 1, 3, 6, 7], + [1, 3, 3, 7, 6, 7], + [5, 7, 1, 5, 4, 5], + ], + [ + [6, 7, 4, 6, 0, 2], + [0, 2, 3, 7, 6, 7], + [0, 1, 3, 7, 0, 2], + [0, 1, 5, 7, 3, 7], + [0, 1, 4, 5, 5, 7], + ], + [[4, 0, 6, 7, 4, 6], [4, 0, 7, 3, 6, 7], [4, 0, 5, 7, 7, 3], [4, 5, 5, 7, 4, 0]], + [[7, 5, 5, 1, 7, 6], [7, 6, 5, 1, 6, 2], [6, 2, 5, 1, 4, 0]], + [[0, 2, 1, 5, 0, 1], [0, 2, 5, 7, 1, 5], [0, 2, 2, 6, 5, 7], [2, 6, 6, 7, 5, 7]], + [[1, 3, 1, 0, 5, 7], [1, 0, 2, 6, 5, 7], [5, 7, 2, 6, 7, 6], [1, 0, 0, 4, 2, 6]], + [[2, 0, 6, 2, 6, 7], [6, 7, 7, 5, 2, 0], [2, 0, 7, 5, 3, 1]], + [[0, 4, 0, 2, 1, 5], [0, 2, 6, 7, 1, 5], [0, 2, 2, 3, 6, 7], [1, 5, 6, 7, 5, 7]], + [[7, 6, 5, 7, 5, 1], [5, 1, 1, 0, 7, 6], [7, 6, 1, 0, 3, 2]], + [ + [2, 0, 3, 2, 7, 6], + [7, 6, 4, 0, 2, 0], + [7, 5, 4, 0, 7, 6], + [7, 5, 1, 0, 4, 0], + [7, 5, 3, 1, 1, 0], + ], + [[7, 5, 3, 1, 3, 2], [7, 6, 7, 5, 3, 2]], + [[7, 5, 5, 1, 7, 6], [7, 6, 5, 1, 6, 2], [6, 2, 5, 1, 4, 0], [3, 1, 7, 3, 3, 2]], + [ + [0, 2, 1, 5, 0, 1], + [0, 2, 5, 7, 1, 5], + [0, 2, 2, 6, 5, 7], + [2, 6, 6, 7, 5, 7], + [3, 7, 2, 3, 1, 3], + ], + [ + [3, 7, 2, 3, 0, 1], + [0, 1, 5, 7, 3, 7], + [0, 4, 5, 7, 0, 1], + [0, 4, 6, 7, 5, 7], + [0, 4, 2, 6, 6, 7], + ], + [[2, 0, 3, 7, 2, 3], [2, 0, 7, 5, 3, 7], [2, 0, 6, 7, 7, 5], [2, 6, 6, 7, 2, 0]], + [ + [5, 7, 1, 5, 0, 4], + [0, 4, 6, 7, 5, 7], + [0, 2, 6, 7, 0, 4], + [0, 2, 3, 7, 6, 7], + [0, 2, 1, 3, 3, 7], + ], + [[1, 0, 5, 7, 1, 5], [1, 0, 7, 6, 5, 7], [1, 0, 3, 7, 7, 6], [1, 3, 3, 7, 1, 0]], + [[0, 2, 0, 1, 0, 4], [3, 7, 6, 7, 5, 7]], + [[7, 5, 7, 3, 7, 6]], + [[7, 3, 7, 5, 7, 6]], + [[0, 1, 0, 2, 0, 4], [6, 7, 3, 7, 5, 7]], + [[1, 3, 1, 0, 1, 5], [7, 6, 3, 7, 5, 7]], + [[0, 4, 1, 5, 0, 2], [1, 5, 1, 3, 0, 2], [6, 7, 3, 7, 5, 7]], + [[2, 6, 2, 0, 2, 3], [7, 5, 6, 7, 3, 7]], + [[0, 1, 2, 3, 0, 4], [2, 3, 2, 6, 0, 4], [5, 7, 6, 7, 3, 7]], + [[1, 5, 1, 3, 0, 1], [2, 3, 2, 6, 0, 2], [5, 7, 6, 7, 3, 7]], + [[3, 2, 2, 6, 3, 1], [3, 1, 2, 6, 1, 5], [1, 5, 2, 6, 0, 4], [7, 6, 3, 7, 7, 5]], + [[3, 1, 7, 5, 3, 2], [7, 5, 7, 6, 3, 2]], + [[7, 6, 3, 2, 7, 5], [3, 2, 3, 1, 7, 5], [4, 0, 1, 0, 2, 0]], + [[5, 7, 7, 6, 5, 1], [5, 1, 7, 6, 1, 0], [1, 0, 7, 6, 3, 2]], + [[2, 3, 2, 0, 6, 7], [2, 0, 1, 5, 6, 7], [2, 0, 0, 4, 1, 5], [6, 7, 1, 5, 7, 5]], + [[6, 2, 2, 0, 6, 7], [6, 7, 2, 0, 7, 5], [7, 5, 2, 0, 3, 1]], + [[0, 4, 0, 1, 2, 6], [0, 1, 5, 7, 2, 6], [2, 6, 5, 7, 6, 7], [0, 1, 1, 3, 5, 7]], + [[1, 5, 0, 2, 1, 0], [1, 5, 2, 6, 0, 2], [1, 5, 5, 7, 2, 6], [5, 7, 7, 6, 2, 6]], + [[5, 1, 7, 5, 7, 6], [7, 6, 6, 2, 5, 1], [5, 1, 6, 2, 4, 0]], + [[4, 5, 4, 0, 4, 6], [7, 3, 5, 7, 6, 7]], + [[0, 2, 4, 6, 0, 1], [4, 6, 4, 5, 0, 1], [3, 7, 5, 7, 6, 7]], + [[4, 6, 4, 5, 0, 4], [1, 5, 1, 3, 0, 1], [6, 7, 3, 7, 5, 7]], + [[5, 1, 1, 3, 5, 4], [5, 4, 1, 3, 4, 6], [4, 6, 1, 3, 0, 2], [7, 3, 5, 7, 7, 6]], + [[2, 3, 2, 6, 0, 2], [4, 6, 4, 5, 0, 4], [3, 7, 5, 7, 6, 7]], + [[6, 4, 4, 5, 6, 2], [6, 2, 4, 5, 2, 3], [2, 3, 4, 5, 0, 1], [7, 5, 6, 7, 7, 3]], + [[0, 1, 1, 5, 1, 3], [0, 2, 2, 3, 2, 6], [4, 5, 0, 4, 4, 6], [5, 7, 6, 7, 3, 7]], + [ + [1, 3, 5, 4, 1, 5], + [1, 3, 4, 6, 5, 4], + [1, 3, 3, 2, 4, 6], + [3, 2, 2, 6, 4, 6], + [7, 6, 3, 7, 5, 7], + ], + [[3, 1, 7, 5, 3, 2], [7, 5, 7, 6, 3, 2], [0, 4, 6, 4, 5, 4]], + [[1, 0, 0, 2, 4, 6], [1, 0, 4, 6, 5, 4], [1, 3, 5, 7, 7, 6], [7, 6, 3, 2, 1, 3]], + [[5, 7, 7, 6, 5, 1], [5, 1, 7, 6, 1, 0], [1, 0, 7, 6, 3, 2], [4, 6, 5, 4, 4, 0]], + [ + [7, 5, 6, 7, 2, 3], + [2, 3, 1, 5, 7, 5], + [2, 0, 1, 5, 2, 3], + [2, 0, 4, 5, 1, 5], + [2, 0, 6, 4, 4, 5], + ], + [[6, 2, 2, 0, 6, 7], [6, 7, 2, 0, 7, 5], [7, 5, 2, 0, 3, 1], [4, 0, 6, 4, 4, 5]], + [ + [4, 6, 5, 4, 1, 0], + [1, 0, 2, 6, 4, 6], + [1, 3, 2, 6, 1, 0], + [1, 3, 7, 6, 2, 6], + [1, 3, 5, 7, 7, 6], + ], + [ + [1, 5, 0, 2, 1, 0], + [1, 5, 2, 6, 0, 2], + [1, 5, 5, 7, 2, 6], + [5, 7, 7, 6, 2, 6], + [4, 6, 5, 4, 0, 4], + ], + [[5, 1, 4, 6, 5, 4], [5, 1, 6, 2, 4, 6], [5, 1, 7, 6, 6, 2], [5, 7, 7, 6, 5, 1]], + [[5, 4, 7, 6, 5, 1], [7, 6, 7, 3, 5, 1]], + [[7, 3, 5, 1, 7, 6], [5, 1, 5, 4, 7, 6], [2, 0, 4, 0, 1, 0]], + [[3, 1, 1, 0, 3, 7], [3, 7, 1, 0, 7, 6], [7, 6, 1, 0, 5, 4]], + [[0, 2, 0, 4, 1, 3], [0, 4, 6, 7, 1, 3], [1, 3, 6, 7, 3, 7], [0, 4, 4, 5, 6, 7]], + [[5, 4, 7, 6, 5, 1], [7, 6, 7, 3, 5, 1], [0, 2, 3, 2, 6, 2]], + [[1, 5, 5, 4, 7, 6], [1, 5, 7, 6, 3, 7], [1, 0, 3, 2, 2, 6], [2, 6, 0, 4, 1, 0]], + [[3, 1, 1, 0, 3, 7], [3, 7, 1, 0, 7, 6], [7, 6, 1, 0, 5, 4], [2, 0, 3, 2, 2, 6]], + [ + [2, 3, 6, 2, 4, 0], + [4, 0, 1, 3, 2, 3], + [4, 5, 1, 3, 4, 0], + [4, 5, 7, 3, 1, 3], + [4, 5, 6, 7, 7, 3], + ], + [[1, 5, 5, 4, 1, 3], [1, 3, 5, 4, 3, 2], [3, 2, 5, 4, 7, 6]], + [[1, 5, 5, 4, 1, 3], [1, 3, 5, 4, 3, 2], [3, 2, 5, 4, 7, 6], [0, 4, 1, 0, 0, 2]], + [[1, 0, 5, 4, 7, 6], [1, 0, 7, 6, 3, 2]], + [[2, 3, 0, 2, 0, 4], [0, 4, 4, 5, 2, 3], [2, 3, 4, 5, 6, 7]], + [[1, 3, 1, 5, 0, 2], [1, 5, 7, 6, 0, 2], [1, 5, 5, 4, 7, 6], [0, 2, 7, 6, 2, 6]], + [ + [5, 1, 4, 5, 6, 7], + [6, 7, 3, 1, 5, 1], + [6, 2, 3, 1, 6, 7], + [6, 2, 0, 1, 3, 1], + [6, 2, 4, 0, 0, 1], + ], + [[6, 7, 2, 6, 2, 0], [2, 0, 0, 1, 6, 7], [6, 7, 0, 1, 4, 5]], + [[6, 2, 4, 0, 4, 5], [6, 7, 6, 2, 4, 5]], + [[6, 7, 7, 3, 6, 4], [6, 4, 7, 3, 4, 0], [4, 0, 7, 3, 5, 1]], + [[1, 5, 1, 0, 3, 7], [1, 0, 4, 6, 3, 7], [1, 0, 0, 2, 4, 6], [3, 7, 4, 6, 7, 6]], + [[1, 0, 3, 7, 1, 3], [1, 0, 7, 6, 3, 7], [1, 0, 0, 4, 7, 6], [0, 4, 4, 6, 7, 6]], + [[6, 4, 7, 6, 7, 3], [7, 3, 3, 1, 6, 4], [6, 4, 3, 1, 2, 0]], + [[6, 7, 7, 3, 6, 4], [6, 4, 7, 3, 4, 0], [4, 0, 7, 3, 5, 1], [2, 3, 6, 2, 2, 0]], + [ + [7, 6, 3, 7, 1, 5], + [1, 5, 4, 6, 7, 6], + [1, 0, 4, 6, 1, 5], + [1, 0, 2, 6, 4, 6], + [1, 0, 3, 2, 2, 6], + ], + [ + [1, 0, 3, 7, 1, 3], + [1, 0, 7, 6, 3, 7], + [1, 0, 0, 4, 7, 6], + [0, 4, 4, 6, 7, 6], + [2, 6, 0, 2, 3, 2], + ], + [[3, 1, 7, 6, 3, 7], [3, 1, 6, 4, 7, 6], [3, 1, 2, 6, 6, 4], [3, 2, 2, 6, 3, 1]], + [[3, 2, 3, 1, 7, 6], [3, 1, 0, 4, 7, 6], [7, 6, 0, 4, 6, 4], [3, 1, 1, 5, 0, 4]], + [ + [0, 1, 2, 0, 6, 4], + [6, 4, 5, 1, 0, 1], + [6, 7, 5, 1, 6, 4], + [6, 7, 3, 1, 5, 1], + [6, 7, 2, 3, 3, 1], + ], + [[0, 1, 4, 0, 4, 6], [4, 6, 6, 7, 0, 1], [0, 1, 6, 7, 2, 3]], + [[6, 7, 2, 3, 2, 0], [6, 4, 6, 7, 2, 0]], + [ + [2, 6, 0, 2, 1, 3], + [1, 3, 7, 6, 2, 6], + [1, 5, 7, 6, 1, 3], + [1, 5, 4, 6, 7, 6], + [1, 5, 0, 4, 4, 6], + ], + [[1, 5, 1, 0, 1, 3], [4, 6, 7, 6, 2, 6]], + [[0, 1, 2, 6, 0, 2], [0, 1, 6, 7, 2, 6], [0, 1, 4, 6, 6, 7], [0, 4, 4, 6, 0, 1]], + [[6, 7, 6, 2, 6, 4]], + [[6, 2, 7, 3, 6, 4], [7, 3, 7, 5, 6, 4]], + [[7, 5, 6, 4, 7, 3], [6, 4, 6, 2, 7, 3], [1, 0, 2, 0, 4, 0]], + [[6, 2, 7, 3, 6, 4], [7, 3, 7, 5, 6, 4], [0, 1, 5, 1, 3, 1]], + [[2, 0, 0, 4, 1, 5], [2, 0, 1, 5, 3, 1], [2, 6, 3, 7, 7, 5], [7, 5, 6, 4, 2, 6]], + [[3, 7, 7, 5, 3, 2], [3, 2, 7, 5, 2, 0], [2, 0, 7, 5, 6, 4]], + [[3, 2, 3, 7, 1, 0], [3, 7, 6, 4, 1, 0], [3, 7, 7, 5, 6, 4], [1, 0, 6, 4, 0, 4]], + [[3, 7, 7, 5, 3, 2], [3, 2, 7, 5, 2, 0], [2, 0, 7, 5, 6, 4], [1, 5, 3, 1, 1, 0]], + [ + [7, 3, 5, 7, 4, 6], + [4, 6, 2, 3, 7, 3], + [4, 0, 2, 3, 4, 6], + [4, 0, 1, 3, 2, 3], + [4, 0, 5, 1, 1, 3], + ], + [[2, 3, 3, 1, 2, 6], [2, 6, 3, 1, 6, 4], [6, 4, 3, 1, 7, 5]], + [[2, 3, 3, 1, 2, 6], [2, 6, 3, 1, 6, 4], [6, 4, 3, 1, 7, 5], [0, 1, 2, 0, 0, 4]], + [[1, 0, 1, 5, 3, 2], [1, 5, 4, 6, 3, 2], [3, 2, 4, 6, 2, 6], [1, 5, 5, 7, 4, 6]], + [ + [0, 2, 4, 0, 5, 1], + [5, 1, 3, 2, 0, 2], + [5, 7, 3, 2, 5, 1], + [5, 7, 6, 2, 3, 2], + [5, 7, 4, 6, 6, 2], + ], + [[2, 0, 3, 1, 7, 5], [2, 0, 7, 5, 6, 4]], + [[4, 6, 0, 4, 0, 1], [0, 1, 1, 3, 4, 6], [4, 6, 1, 3, 5, 7]], + [[0, 2, 1, 0, 1, 5], [1, 5, 5, 7, 0, 2], [0, 2, 5, 7, 4, 6]], + [[5, 7, 4, 6, 4, 0], [5, 1, 5, 7, 4, 0]], + [[5, 4, 4, 0, 5, 7], [5, 7, 4, 0, 7, 3], [7, 3, 4, 0, 6, 2]], + [[0, 1, 0, 2, 4, 5], [0, 2, 3, 7, 4, 5], [4, 5, 3, 7, 5, 7], [0, 2, 2, 6, 3, 7]], + [[5, 4, 4, 0, 5, 7], [5, 7, 4, 0, 7, 3], [7, 3, 4, 0, 6, 2], [1, 0, 5, 1, 1, 3]], + [ + [1, 5, 3, 1, 2, 0], + [2, 0, 4, 5, 1, 5], + [2, 6, 4, 5, 2, 0], + [2, 6, 7, 5, 4, 5], + [2, 6, 3, 7, 7, 5], + ], + [[2, 3, 0, 4, 2, 0], [2, 3, 4, 5, 0, 4], [2, 3, 3, 7, 4, 5], [3, 7, 7, 5, 4, 5]], + [[3, 2, 7, 3, 7, 5], [7, 5, 5, 4, 3, 2], [3, 2, 5, 4, 1, 0]], + [ + [2, 3, 0, 4, 2, 0], + [2, 3, 4, 5, 0, 4], + [2, 3, 3, 7, 4, 5], + [3, 7, 7, 5, 4, 5], + [1, 5, 3, 1, 0, 1], + ], + [[3, 2, 1, 5, 3, 1], [3, 2, 5, 4, 1, 5], [3, 2, 7, 5, 5, 4], [3, 7, 7, 5, 3, 2]], + [[2, 6, 2, 3, 0, 4], [2, 3, 7, 5, 0, 4], [2, 3, 3, 1, 7, 5], [0, 4, 7, 5, 4, 5]], + [ + [3, 2, 1, 3, 5, 7], + [5, 7, 6, 2, 3, 2], + [5, 4, 6, 2, 5, 7], + [5, 4, 0, 2, 6, 2], + [5, 4, 1, 0, 0, 2], + ], + [ + [4, 5, 0, 4, 2, 6], + [2, 6, 7, 5, 4, 5], + [2, 3, 7, 5, 2, 6], + [2, 3, 1, 5, 7, 5], + [2, 3, 0, 1, 1, 5], + ], + [[2, 3, 2, 0, 2, 6], [1, 5, 7, 5, 4, 5]], + [[5, 7, 4, 5, 4, 0], [4, 0, 0, 2, 5, 7], [5, 7, 0, 2, 1, 3]], + [[5, 4, 1, 0, 1, 3], [5, 7, 5, 4, 1, 3]], + [[0, 2, 4, 5, 0, 4], [0, 2, 5, 7, 4, 5], [0, 2, 1, 5, 5, 7], [0, 1, 1, 5, 0, 2]], + [[5, 4, 5, 1, 5, 7]], + [[4, 6, 6, 2, 4, 5], [4, 5, 6, 2, 5, 1], [5, 1, 6, 2, 7, 3]], + [[4, 6, 6, 2, 4, 5], [4, 5, 6, 2, 5, 1], [5, 1, 6, 2, 7, 3], [0, 2, 4, 0, 0, 1]], + [[3, 7, 3, 1, 2, 6], [3, 1, 5, 4, 2, 6], [3, 1, 1, 0, 5, 4], [2, 6, 5, 4, 6, 4]], + [ + [6, 4, 2, 6, 3, 7], + [3, 7, 5, 4, 6, 4], + [3, 1, 5, 4, 3, 7], + [3, 1, 0, 4, 5, 4], + [3, 1, 2, 0, 0, 4], + ], + [[2, 0, 2, 3, 6, 4], [2, 3, 1, 5, 6, 4], [6, 4, 1, 5, 4, 5], [2, 3, 3, 7, 1, 5]], + [ + [0, 4, 1, 0, 3, 2], + [3, 2, 6, 4, 0, 4], + [3, 7, 6, 4, 3, 2], + [3, 7, 5, 4, 6, 4], + [3, 7, 1, 5, 5, 4], + ], + [ + [1, 3, 0, 1, 4, 5], + [4, 5, 7, 3, 1, 3], + [4, 6, 7, 3, 4, 5], + [4, 6, 2, 3, 7, 3], + [4, 6, 0, 2, 2, 3], + ], + [[3, 7, 3, 1, 3, 2], [5, 4, 6, 4, 0, 4]], + [[3, 1, 2, 6, 3, 2], [3, 1, 6, 4, 2, 6], [3, 1, 1, 5, 6, 4], [1, 5, 5, 4, 6, 4]], + [ + [3, 1, 2, 6, 3, 2], + [3, 1, 6, 4, 2, 6], + [3, 1, 1, 5, 6, 4], + [1, 5, 5, 4, 6, 4], + [0, 4, 1, 0, 2, 0], + ], + [[4, 5, 6, 4, 6, 2], [6, 2, 2, 3, 4, 5], [4, 5, 2, 3, 0, 1]], + [[2, 3, 6, 4, 2, 6], [2, 3, 4, 5, 6, 4], [2, 3, 0, 4, 4, 5], [2, 0, 0, 4, 2, 3]], + [[1, 3, 5, 1, 5, 4], [5, 4, 4, 6, 1, 3], [1, 3, 4, 6, 0, 2]], + [[1, 3, 0, 4, 1, 0], [1, 3, 4, 6, 0, 4], [1, 3, 5, 4, 4, 6], [1, 5, 5, 4, 1, 3]], + [[4, 6, 0, 2, 0, 1], [4, 5, 4, 6, 0, 1]], + [[4, 6, 4, 0, 4, 5]], + [[4, 0, 6, 2, 7, 3], [4, 0, 7, 3, 5, 1]], + [[1, 5, 0, 1, 0, 2], [0, 2, 2, 6, 1, 5], [1, 5, 2, 6, 3, 7]], + [[3, 7, 1, 3, 1, 0], [1, 0, 0, 4, 3, 7], [3, 7, 0, 4, 2, 6]], + [[3, 1, 2, 0, 2, 6], [3, 7, 3, 1, 2, 6]], + [[0, 4, 2, 0, 2, 3], [2, 3, 3, 7, 0, 4], [0, 4, 3, 7, 1, 5]], + [[3, 7, 1, 5, 1, 0], [3, 2, 3, 7, 1, 0]], + [[0, 4, 1, 3, 0, 1], [0, 4, 3, 7, 1, 3], [0, 4, 2, 3, 3, 7], [0, 2, 2, 3, 0, 4]], + [[3, 7, 3, 1, 3, 2]], + [[2, 6, 3, 2, 3, 1], [3, 1, 1, 5, 2, 6], [2, 6, 1, 5, 0, 4]], + [[1, 5, 3, 2, 1, 3], [1, 5, 2, 6, 3, 2], [1, 5, 0, 2, 2, 6], [1, 0, 0, 2, 1, 5]], + [[2, 3, 0, 1, 0, 4], [2, 6, 2, 3, 0, 4]], + [[2, 3, 2, 0, 2, 6]], + [[1, 5, 0, 4, 0, 2], [1, 3, 1, 5, 0, 2]], + [[1, 5, 1, 0, 1, 3]], + [[0, 2, 0, 1, 0, 4]], + [], +] + + +def create_mc_lookup_table(): + cases = torch.zeros(256, 5, 3, dtype=torch.long) + masks = torch.zeros(256, 5, dtype=torch.bool) + + edge_to_index = { + (0, 1): 0, + (2, 3): 1, + (4, 5): 2, + (6, 7): 3, + (0, 2): 4, + (1, 3): 5, + (4, 6): 6, + (5, 7): 7, + (0, 4): 8, + (1, 5): 9, + (2, 6): 10, + (3, 7): 11, + } + + for i, case in enumerate(MC_TABLE): + for j, tri in enumerate(case): + for k, (c1, c2) in enumerate(zip(tri[::2], tri[1::2])): + cases[i, j, k] = edge_to_index[(c1, c2) if c1 < c2 else (c2, c1)] + masks[i, j] = True + return cases, masks + + +RENDERER_CONFIG = {} + + +def renderer_model_from_original_config(): + model = ShapERenderer(**RENDERER_CONFIG) + + return model + + +RENDERER_MLP_ORIGINAL_PREFIX = "renderer.nerstf" + +RENDERER_PARAMS_PROJ_ORIGINAL_PREFIX = "encoder.params_proj" + + +def renderer_model_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + diffusers_checkpoint.update( + {f"mlp.{k}": checkpoint[f"{RENDERER_MLP_ORIGINAL_PREFIX}.{k}"] for k in model.mlp.state_dict().keys()} + ) + + diffusers_checkpoint.update( + { + f"params_proj.{k}": checkpoint[f"{RENDERER_PARAMS_PROJ_ORIGINAL_PREFIX}.{k}"] + for k in model.params_proj.state_dict().keys() + } + ) + + diffusers_checkpoint.update({"void.background": model.state_dict()["void.background"]}) + + cases, masks = create_mc_lookup_table() + + diffusers_checkpoint.update({"mesh_decoder.cases": cases}) + diffusers_checkpoint.update({"mesh_decoder.masks": masks}) + + return diffusers_checkpoint + + +# done renderer + + +# TODO maybe document and/or can do more efficiently (build indices in for loop and extract once for each split?) +def split_attentions(*, weight, bias, split, chunk_size): + weights = [None] * split + biases = [None] * split + + weights_biases_idx = 0 + + for starting_row_index in range(0, weight.shape[0], chunk_size): + row_indices = torch.arange(starting_row_index, starting_row_index + chunk_size) + + weight_rows = weight[row_indices, :] + bias_rows = bias[row_indices] + + if weights[weights_biases_idx] is None: + assert weights[weights_biases_idx] is None + weights[weights_biases_idx] = weight_rows + biases[weights_biases_idx] = bias_rows + else: + assert weights[weights_biases_idx] is not None + weights[weights_biases_idx] = torch.concat([weights[weights_biases_idx], weight_rows]) + biases[weights_biases_idx] = torch.concat([biases[weights_biases_idx], bias_rows]) + + weights_biases_idx = (weights_biases_idx + 1) % split + + return weights, biases + + +# done unet utils + + +# Driver functions + + +def prior(*, args, checkpoint_map_location): + print("loading prior") + + prior_checkpoint = torch.load(args.prior_checkpoint_path, map_location=checkpoint_map_location) + + prior_model = prior_model_from_original_config() + + prior_diffusers_checkpoint = prior_original_checkpoint_to_diffusers_checkpoint(prior_model, prior_checkpoint) + + del prior_checkpoint + + load_prior_checkpoint_to_model(prior_diffusers_checkpoint, prior_model) + + print("done loading prior") + + return prior_model + + +def prior_image(*, args, checkpoint_map_location): + print("loading prior_image") + + print(f"load checkpoint from {args.prior_image_checkpoint_path}") + prior_checkpoint = torch.load(args.prior_image_checkpoint_path, map_location=checkpoint_map_location) + + prior_model = prior_image_model_from_original_config() + + prior_diffusers_checkpoint = prior_image_original_checkpoint_to_diffusers_checkpoint(prior_model, prior_checkpoint) + + del prior_checkpoint + + load_prior_checkpoint_to_model(prior_diffusers_checkpoint, prior_model) + + print("done loading prior_image") + + return prior_model + + +def renderer(*, args, checkpoint_map_location): + print(" loading renderer") + + renderer_checkpoint = torch.load(args.transmitter_checkpoint_path, map_location=checkpoint_map_location) + + renderer_model = renderer_model_from_original_config() + + renderer_diffusers_checkpoint = renderer_model_original_checkpoint_to_diffusers_checkpoint( + renderer_model, renderer_checkpoint + ) + + del renderer_checkpoint + + load_checkpoint_to_model(renderer_diffusers_checkpoint, renderer_model, strict=True) + + print("done loading renderer") + + return renderer_model + + +# prior model will expect clip_mean and clip_std, which are missing from the state_dict +PRIOR_EXPECTED_MISSING_KEYS = ["clip_mean", "clip_std"] + + +def load_prior_checkpoint_to_model(checkpoint, model): + with tempfile.NamedTemporaryFile() as file: + torch.save(checkpoint, file.name) + del checkpoint + missing_keys, unexpected_keys = model.load_state_dict(torch.load(file.name), strict=False) + missing_keys = list(set(missing_keys) - set(PRIOR_EXPECTED_MISSING_KEYS)) + + if len(unexpected_keys) > 0: + raise ValueError(f"Unexpected keys when loading prior model: {unexpected_keys}") + if len(missing_keys) > 0: + raise ValueError(f"Missing keys when loading prior model: {missing_keys}") + + +def load_checkpoint_to_model(checkpoint, model, strict=False): + with tempfile.NamedTemporaryFile() as file: + torch.save(checkpoint, file.name) + del checkpoint + if strict: + model.load_state_dict(torch.load(file.name), strict=True) + else: + load_checkpoint_and_dispatch(model, file.name, device_map="auto") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--prior_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the prior checkpoint to convert.", + ) + + parser.add_argument( + "--prior_image_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the prior_image checkpoint to convert.", + ) + + parser.add_argument( + "--transmitter_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to the transmitter checkpoint to convert.", + ) + + parser.add_argument( + "--checkpoint_load_device", + default="cpu", + type=str, + required=False, + help="The device passed to `map_location` when loading checkpoints.", + ) + + parser.add_argument( + "--debug", + default=None, + type=str, + required=False, + help="Only run a specific stage of the convert script. Used for debugging", + ) + + args = parser.parse_args() + + print(f"loading checkpoints to {args.checkpoint_load_device}") + + checkpoint_map_location = torch.device(args.checkpoint_load_device) + + if args.debug is not None: + print(f"debug: only executing {args.debug}") + + if args.debug is None: + print("YiYi TO-DO") + elif args.debug == "prior": + prior_model = prior(args=args, checkpoint_map_location=checkpoint_map_location) + prior_model.save_pretrained(args.dump_path) + elif args.debug == "prior_image": + prior_model = prior_image(args=args, checkpoint_map_location=checkpoint_map_location) + prior_model.save_pretrained(args.dump_path) + elif args.debug == "renderer": + renderer_model = renderer(args=args, checkpoint_map_location=checkpoint_map_location) + renderer_model.save_pretrained(args.dump_path) + else: + raise ValueError(f"unknown debug value : {args.debug}") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_skyreelsv2_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_skyreelsv2_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..3bc3c435685b74041206441592fbb31b815253d0 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_skyreelsv2_to_diffusers.py @@ -0,0 +1,637 @@ +import argparse +import os +import pathlib +from typing import Any, Dict + +import torch +from accelerate import init_empty_weights +from huggingface_hub import hf_hub_download +from safetensors.torch import load_file +from transformers import AutoProcessor, AutoTokenizer, CLIPVisionModelWithProjection, UMT5EncoderModel + +from diffusers import ( + AutoencoderKLWan, + SkyReelsV2DiffusionForcingPipeline, + SkyReelsV2ImageToVideoPipeline, + SkyReelsV2Pipeline, + SkyReelsV2Transformer3DModel, + UniPCMultistepScheduler, +) + + +TRANSFORMER_KEYS_RENAME_DICT = { + "time_embedding.0": "condition_embedder.time_embedder.linear_1", + "time_embedding.2": "condition_embedder.time_embedder.linear_2", + "text_embedding.0": "condition_embedder.text_embedder.linear_1", + "text_embedding.2": "condition_embedder.text_embedder.linear_2", + "time_projection.1": "condition_embedder.time_proj", + "head.modulation": "scale_shift_table", + "head.head": "proj_out", + "modulation": "scale_shift_table", + "ffn.0": "ffn.net.0.proj", + "ffn.2": "ffn.net.2", + "fps_projection.0": "fps_projection.net.0.proj", + "fps_projection.2": "fps_projection.net.2", + # Hack to swap the layer names + # The original model calls the norms in following order: norm1, norm3, norm2 + # We convert it to: norm1, norm2, norm3 + "norm2": "norm__placeholder", + "norm3": "norm2", + "norm__placeholder": "norm3", + # For the I2V model + "img_emb.proj.0": "condition_embedder.image_embedder.norm1", + "img_emb.proj.1": "condition_embedder.image_embedder.ff.net.0.proj", + "img_emb.proj.3": "condition_embedder.image_embedder.ff.net.2", + "img_emb.proj.4": "condition_embedder.image_embedder.norm2", + # for the FLF2V model + "img_emb.emb_pos": "condition_embedder.image_embedder.pos_embed", + # Add attention component mappings + "self_attn.q": "attn1.to_q", + "self_attn.k": "attn1.to_k", + "self_attn.v": "attn1.to_v", + "self_attn.o": "attn1.to_out.0", + "self_attn.norm_q": "attn1.norm_q", + "self_attn.norm_k": "attn1.norm_k", + "cross_attn.q": "attn2.to_q", + "cross_attn.k": "attn2.to_k", + "cross_attn.v": "attn2.to_v", + "cross_attn.o": "attn2.to_out.0", + "cross_attn.norm_q": "attn2.norm_q", + "cross_attn.norm_k": "attn2.norm_k", + "attn2.to_k_img": "attn2.add_k_proj", + "attn2.to_v_img": "attn2.add_v_proj", + "attn2.norm_k_img": "attn2.norm_added_k", +} + +TRANSFORMER_SPECIAL_KEYS_REMAP = {} + + +def update_state_dict_(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def load_sharded_safetensors(dir: pathlib.Path): + if "720P" in str(dir): + file_paths = list(dir.glob("diffusion_pytorch_model*.safetensors")) + else: + file_paths = list(dir.glob("model*.safetensors")) + state_dict = {} + for path in file_paths: + state_dict.update(load_file(path)) + return state_dict + + +def get_transformer_config(model_type: str) -> Dict[str, Any]: + if model_type == "SkyReels-V2-DF-1.3B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-DF-1.3B-540P", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 8960, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 12, + "inject_sample_info": True, + "num_layers": 30, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + elif model_type == "SkyReels-V2-DF-14B-720P": + config = { + "model_id": "Skywork/SkyReels-V2-DF-14B-720P", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + elif model_type == "SkyReels-V2-DF-14B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-DF-14B-540P", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + elif model_type == "SkyReels-V2-T2V-14B-720P": + config = { + "model_id": "Skywork/SkyReels-V2-T2V-14B-720P", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + elif model_type == "SkyReels-V2-T2V-14B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-T2V-14B-540P", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + elif model_type == "SkyReels-V2-I2V-1.3B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-I2V-1.3B-540P", + "diffusers_config": { + "added_kv_proj_dim": 1536, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 8960, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 12, + "inject_sample_info": False, + "num_layers": 30, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "image_dim": 1280, + }, + } + elif model_type == "SkyReels-V2-I2V-14B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-I2V-14B-540P", + "diffusers_config": { + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "image_dim": 1280, + }, + } + elif model_type == "SkyReels-V2-I2V-14B-720P": + config = { + "model_id": "Skywork/SkyReels-V2-I2V-14B-720P", + "diffusers_config": { + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "image_dim": 1280, + }, + } + elif model_type == "SkyReels-V2-FLF2V-1.3B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-I2V-1.3B-540P", + "diffusers_config": { + "added_kv_proj_dim": 1536, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 8960, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 12, + "inject_sample_info": False, + "num_layers": 30, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "image_dim": 1280, + "pos_embed_seq_len": 514, + }, + } + elif model_type == "SkyReels-V2-FLF2V-14B-540P": + config = { + "model_id": "Skywork/SkyReels-V2-I2V-14B-540P", + "diffusers_config": { + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "image_dim": 1280, + "pos_embed_seq_len": 514, + }, + } + elif model_type == "SkyReels-V2-FLF2V-14B-720P": + config = { + "model_id": "Skywork/SkyReels-V2-I2V-14B-720P", + "diffusers_config": { + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "inject_sample_info": False, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "image_dim": 1280, + "pos_embed_seq_len": 514, + }, + } + return config + + +def convert_transformer(model_type: str): + config = get_transformer_config(model_type) + diffusers_config = config["diffusers_config"] + model_id = config["model_id"] + + if "1.3B" in model_type: + original_state_dict = load_file(hf_hub_download(model_id, "model.safetensors")) + else: + os.makedirs(model_type, exist_ok=True) + model_dir = pathlib.Path(model_type) + if "720P" in model_type: + top_shard = 7 if "I2V" in model_type else 6 + zeros = "0" * (4 if "I2V" or "T2V" in model_type else 3) + model_name = "diffusion_pytorch_model" + elif "540P" in model_type: + top_shard = 14 if "I2V" in model_type else 12 + model_name = "model" + + for i in range(1, top_shard + 1): + shard_path = f"{model_name}-{i:05d}-of-{zeros}{top_shard}.safetensors" + hf_hub_download(model_id, shard_path, local_dir=model_dir) + original_state_dict = load_sharded_safetensors(model_dir) + + with init_empty_weights(): + transformer = SkyReelsV2Transformer3DModel.from_config(diffusers_config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in TRANSFORMER_KEYS_RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in TRANSFORMER_SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + if "FLF2V" in model_type: + if ( + hasattr(transformer.condition_embedder, "image_embedder") + and hasattr(transformer.condition_embedder.image_embedder, "pos_embed") + and transformer.condition_embedder.image_embedder.pos_embed is not None + ): + pos_embed_shape = transformer.condition_embedder.image_embedder.pos_embed.shape + original_state_dict["condition_embedder.image_embedder.pos_embed"] = torch.zeros(pos_embed_shape) + + transformer.load_state_dict(original_state_dict, strict=True, assign=True) + return transformer + + +def convert_vae(): + vae_ckpt_path = hf_hub_download("Wan-AI/Wan2.1-T2V-14B", "Wan2.1_VAE.pth") + old_state_dict = torch.load(vae_ckpt_path, weights_only=True) + new_state_dict = {} + + # Create mappings for specific components + middle_key_mapping = { + # Encoder middle block + "encoder.middle.0.residual.0.gamma": "encoder.mid_block.resnets.0.norm1.gamma", + "encoder.middle.0.residual.2.bias": "encoder.mid_block.resnets.0.conv1.bias", + "encoder.middle.0.residual.2.weight": "encoder.mid_block.resnets.0.conv1.weight", + "encoder.middle.0.residual.3.gamma": "encoder.mid_block.resnets.0.norm2.gamma", + "encoder.middle.0.residual.6.bias": "encoder.mid_block.resnets.0.conv2.bias", + "encoder.middle.0.residual.6.weight": "encoder.mid_block.resnets.0.conv2.weight", + "encoder.middle.2.residual.0.gamma": "encoder.mid_block.resnets.1.norm1.gamma", + "encoder.middle.2.residual.2.bias": "encoder.mid_block.resnets.1.conv1.bias", + "encoder.middle.2.residual.2.weight": "encoder.mid_block.resnets.1.conv1.weight", + "encoder.middle.2.residual.3.gamma": "encoder.mid_block.resnets.1.norm2.gamma", + "encoder.middle.2.residual.6.bias": "encoder.mid_block.resnets.1.conv2.bias", + "encoder.middle.2.residual.6.weight": "encoder.mid_block.resnets.1.conv2.weight", + # Decoder middle block + "decoder.middle.0.residual.0.gamma": "decoder.mid_block.resnets.0.norm1.gamma", + "decoder.middle.0.residual.2.bias": "decoder.mid_block.resnets.0.conv1.bias", + "decoder.middle.0.residual.2.weight": "decoder.mid_block.resnets.0.conv1.weight", + "decoder.middle.0.residual.3.gamma": "decoder.mid_block.resnets.0.norm2.gamma", + "decoder.middle.0.residual.6.bias": "decoder.mid_block.resnets.0.conv2.bias", + "decoder.middle.0.residual.6.weight": "decoder.mid_block.resnets.0.conv2.weight", + "decoder.middle.2.residual.0.gamma": "decoder.mid_block.resnets.1.norm1.gamma", + "decoder.middle.2.residual.2.bias": "decoder.mid_block.resnets.1.conv1.bias", + "decoder.middle.2.residual.2.weight": "decoder.mid_block.resnets.1.conv1.weight", + "decoder.middle.2.residual.3.gamma": "decoder.mid_block.resnets.1.norm2.gamma", + "decoder.middle.2.residual.6.bias": "decoder.mid_block.resnets.1.conv2.bias", + "decoder.middle.2.residual.6.weight": "decoder.mid_block.resnets.1.conv2.weight", + } + + # Create a mapping for attention blocks + attention_mapping = { + # Encoder middle attention + "encoder.middle.1.norm.gamma": "encoder.mid_block.attentions.0.norm.gamma", + "encoder.middle.1.to_qkv.weight": "encoder.mid_block.attentions.0.to_qkv.weight", + "encoder.middle.1.to_qkv.bias": "encoder.mid_block.attentions.0.to_qkv.bias", + "encoder.middle.1.proj.weight": "encoder.mid_block.attentions.0.proj.weight", + "encoder.middle.1.proj.bias": "encoder.mid_block.attentions.0.proj.bias", + # Decoder middle attention + "decoder.middle.1.norm.gamma": "decoder.mid_block.attentions.0.norm.gamma", + "decoder.middle.1.to_qkv.weight": "decoder.mid_block.attentions.0.to_qkv.weight", + "decoder.middle.1.to_qkv.bias": "decoder.mid_block.attentions.0.to_qkv.bias", + "decoder.middle.1.proj.weight": "decoder.mid_block.attentions.0.proj.weight", + "decoder.middle.1.proj.bias": "decoder.mid_block.attentions.0.proj.bias", + } + + # Create a mapping for the head components + head_mapping = { + # Encoder head + "encoder.head.0.gamma": "encoder.norm_out.gamma", + "encoder.head.2.bias": "encoder.conv_out.bias", + "encoder.head.2.weight": "encoder.conv_out.weight", + # Decoder head + "decoder.head.0.gamma": "decoder.norm_out.gamma", + "decoder.head.2.bias": "decoder.conv_out.bias", + "decoder.head.2.weight": "decoder.conv_out.weight", + } + + # Create a mapping for the quant components + quant_mapping = { + "conv1.weight": "quant_conv.weight", + "conv1.bias": "quant_conv.bias", + "conv2.weight": "post_quant_conv.weight", + "conv2.bias": "post_quant_conv.bias", + } + + # Process each key in the state dict + for key, value in old_state_dict.items(): + # Handle middle block keys using the mapping + if key in middle_key_mapping: + new_key = middle_key_mapping[key] + new_state_dict[new_key] = value + # Handle attention blocks using the mapping + elif key in attention_mapping: + new_key = attention_mapping[key] + new_state_dict[new_key] = value + # Handle head keys using the mapping + elif key in head_mapping: + new_key = head_mapping[key] + new_state_dict[new_key] = value + # Handle quant keys using the mapping + elif key in quant_mapping: + new_key = quant_mapping[key] + new_state_dict[new_key] = value + # Handle encoder conv1 + elif key == "encoder.conv1.weight": + new_state_dict["encoder.conv_in.weight"] = value + elif key == "encoder.conv1.bias": + new_state_dict["encoder.conv_in.bias"] = value + # Handle decoder conv1 + elif key == "decoder.conv1.weight": + new_state_dict["decoder.conv_in.weight"] = value + elif key == "decoder.conv1.bias": + new_state_dict["decoder.conv_in.bias"] = value + # Handle encoder downsamples + elif key.startswith("encoder.downsamples."): + # Convert to down_blocks + new_key = key.replace("encoder.downsamples.", "encoder.down_blocks.") + + # Convert residual block naming but keep the original structure + if ".residual.0.gamma" in new_key: + new_key = new_key.replace(".residual.0.gamma", ".norm1.gamma") + elif ".residual.2.bias" in new_key: + new_key = new_key.replace(".residual.2.bias", ".conv1.bias") + elif ".residual.2.weight" in new_key: + new_key = new_key.replace(".residual.2.weight", ".conv1.weight") + elif ".residual.3.gamma" in new_key: + new_key = new_key.replace(".residual.3.gamma", ".norm2.gamma") + elif ".residual.6.bias" in new_key: + new_key = new_key.replace(".residual.6.bias", ".conv2.bias") + elif ".residual.6.weight" in new_key: + new_key = new_key.replace(".residual.6.weight", ".conv2.weight") + elif ".shortcut.bias" in new_key: + new_key = new_key.replace(".shortcut.bias", ".conv_shortcut.bias") + elif ".shortcut.weight" in new_key: + new_key = new_key.replace(".shortcut.weight", ".conv_shortcut.weight") + + new_state_dict[new_key] = value + + # Handle decoder upsamples + elif key.startswith("decoder.upsamples."): + # Convert to up_blocks + parts = key.split(".") + block_idx = int(parts[2]) + + # Group residual blocks + if "residual" in key: + if block_idx in [0, 1, 2]: + new_block_idx = 0 + resnet_idx = block_idx + elif block_idx in [4, 5, 6]: + new_block_idx = 1 + resnet_idx = block_idx - 4 + elif block_idx in [8, 9, 10]: + new_block_idx = 2 + resnet_idx = block_idx - 8 + elif block_idx in [12, 13, 14]: + new_block_idx = 3 + resnet_idx = block_idx - 12 + else: + # Keep as is for other blocks + new_state_dict[key] = value + continue + + # Convert residual block naming + if ".residual.0.gamma" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.norm1.gamma" + elif ".residual.2.bias" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv1.bias" + elif ".residual.2.weight" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv1.weight" + elif ".residual.3.gamma" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.norm2.gamma" + elif ".residual.6.bias" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv2.bias" + elif ".residual.6.weight" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv2.weight" + else: + new_key = key + + new_state_dict[new_key] = value + + # Handle shortcut connections + elif ".shortcut." in key: + if block_idx == 4: + new_key = key.replace(".shortcut.", ".resnets.0.conv_shortcut.") + new_key = new_key.replace("decoder.upsamples.4", "decoder.up_blocks.1") + else: + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + new_key = new_key.replace(".shortcut.", ".conv_shortcut.") + + new_state_dict[new_key] = value + + # Handle upsamplers + elif ".resample." in key or ".time_conv." in key: + if block_idx == 3: + new_key = key.replace(f"decoder.upsamples.{block_idx}", "decoder.up_blocks.0.upsamplers.0") + elif block_idx == 7: + new_key = key.replace(f"decoder.upsamples.{block_idx}", "decoder.up_blocks.1.upsamplers.0") + elif block_idx == 11: + new_key = key.replace(f"decoder.upsamples.{block_idx}", "decoder.up_blocks.2.upsamplers.0") + else: + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + + new_state_dict[new_key] = value + else: + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + new_state_dict[new_key] = value + else: + # Keep other keys unchanged + new_state_dict[key] = value + + with init_empty_weights(): + vae = AutoencoderKLWan() + vae.load_state_dict(new_state_dict, strict=True, assign=True) + return vae + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--model_type", type=str, default=None) + parser.add_argument("--output_path", type=str, required=True) + parser.add_argument("--dtype", default="fp32") + return parser.parse_args() + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + + +if __name__ == "__main__": + args = get_args() + + transformer = None + dtype = DTYPE_MAPPING[args.dtype] + + transformer = convert_transformer(args.model_type).to(dtype=dtype) + vae = convert_vae() + text_encoder = UMT5EncoderModel.from_pretrained("google/umt5-xxl") + tokenizer = AutoTokenizer.from_pretrained("google/umt5-xxl") + scheduler = UniPCMultistepScheduler( + prediction_type="flow_prediction", + num_train_timesteps=1000, + use_flow_sigmas=True, + ) + + if "I2V" in args.model_type or "FLF2V" in args.model_type: + image_encoder = CLIPVisionModelWithProjection.from_pretrained("laion/CLIP-ViT-H-14-laion2B-s32B-b79K") + image_processor = AutoProcessor.from_pretrained("laion/CLIP-ViT-H-14-laion2B-s32B-b79K") + pipe = SkyReelsV2ImageToVideoPipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + image_encoder=image_encoder, + image_processor=image_processor, + ) + elif "T2V" in args.model_type: + pipe = SkyReelsV2Pipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + ) + elif "DF" in args.model_type: + pipe = SkyReelsV2DiffusionForcingPipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + ) + + pipe.save_pretrained( + args.output_path, + safe_serialization=True, + max_shard_size="5GB", + # push_to_hub=True, + # repo_id=f"/{args.model_type}-Diffusers", + ) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_audio.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_audio.py new file mode 100644 index 0000000000000000000000000000000000000000..c3479fc6b2bb7184f8e42a65c55e7f4e783fc6f6 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_audio.py @@ -0,0 +1,279 @@ +# Run this script to convert the Stable Audio model weights to a diffusers pipeline. +import argparse +import json +import os +from contextlib import nullcontext + +import torch +from safetensors.torch import load_file +from transformers import ( + AutoTokenizer, + T5EncoderModel, +) + +from diffusers import ( + AutoencoderOobleck, + CosineDPMSolverMultistepScheduler, + StableAudioDiTModel, + StableAudioPipeline, + StableAudioProjectionModel, +) +from diffusers.models.model_loading_utils import load_model_dict_into_meta +from diffusers.utils import is_accelerate_available + + +if is_accelerate_available(): + from accelerate import init_empty_weights + + +def convert_stable_audio_state_dict_to_diffusers(state_dict, num_autoencoder_layers=5): + projection_model_state_dict = { + k.replace("conditioner.conditioners.", "").replace("embedder.embedding", "time_positional_embedding"): v + for (k, v) in state_dict.items() + if "conditioner.conditioners" in k + } + + # NOTE: we assume here that there's no projection layer from the text encoder to the latent space, script should be adapted a bit if there is. + for key, value in list(projection_model_state_dict.items()): + new_key = key.replace("seconds_start", "start_number_conditioner").replace( + "seconds_total", "end_number_conditioner" + ) + projection_model_state_dict[new_key] = projection_model_state_dict.pop(key) + + model_state_dict = {k.replace("model.model.", ""): v for (k, v) in state_dict.items() if "model.model." in k} + for key, value in list(model_state_dict.items()): + # attention layers + new_key = ( + key.replace("transformer.", "") + .replace("layers", "transformer_blocks") + .replace("self_attn", "attn1") + .replace("cross_attn", "attn2") + .replace("ff.ff", "ff.net") + ) + new_key = ( + new_key.replace("pre_norm", "norm1") + .replace("cross_attend_norm", "norm2") + .replace("ff_norm", "norm3") + .replace("to_out", "to_out.0") + ) + new_key = new_key.replace("gamma", "weight").replace("beta", "bias") # replace layernorm + + # other layers + new_key = ( + new_key.replace("project", "proj") + .replace("to_timestep_embed", "timestep_proj") + .replace("timestep_features", "time_proj") + .replace("to_global_embed", "global_proj") + .replace("to_cond_embed", "cross_attention_proj") + ) + + # we're using diffusers implementation of time_proj (GaussianFourierProjection) which creates a 1D tensor + if new_key == "time_proj.weight": + model_state_dict[key] = model_state_dict[key].squeeze(1) + + if "to_qkv" in new_key: + q, k, v = torch.chunk(model_state_dict.pop(key), 3, dim=0) + model_state_dict[new_key.replace("qkv", "q")] = q + model_state_dict[new_key.replace("qkv", "k")] = k + model_state_dict[new_key.replace("qkv", "v")] = v + elif "to_kv" in new_key: + k, v = torch.chunk(model_state_dict.pop(key), 2, dim=0) + model_state_dict[new_key.replace("kv", "k")] = k + model_state_dict[new_key.replace("kv", "v")] = v + else: + model_state_dict[new_key] = model_state_dict.pop(key) + + autoencoder_state_dict = { + k.replace("pretransform.model.", "").replace("coder.layers.0", "coder.conv1"): v + for (k, v) in state_dict.items() + if "pretransform.model." in k + } + + for key, _ in list(autoencoder_state_dict.items()): + new_key = key + if "coder.layers" in new_key: + # get idx of the layer + idx = int(new_key.split("coder.layers.")[1].split(".")[0]) + + new_key = new_key.replace(f"coder.layers.{idx}", f"coder.block.{idx - 1}") + + if "encoder" in new_key: + for i in range(3): + new_key = new_key.replace(f"block.{idx - 1}.layers.{i}", f"block.{idx - 1}.res_unit{i + 1}") + new_key = new_key.replace(f"block.{idx - 1}.layers.3", f"block.{idx - 1}.snake1") + new_key = new_key.replace(f"block.{idx - 1}.layers.4", f"block.{idx - 1}.conv1") + else: + for i in range(2, 5): + new_key = new_key.replace(f"block.{idx - 1}.layers.{i}", f"block.{idx - 1}.res_unit{i - 1}") + new_key = new_key.replace(f"block.{idx - 1}.layers.0", f"block.{idx - 1}.snake1") + new_key = new_key.replace(f"block.{idx - 1}.layers.1", f"block.{idx - 1}.conv_t1") + + new_key = new_key.replace("layers.0.beta", "snake1.beta") + new_key = new_key.replace("layers.0.alpha", "snake1.alpha") + new_key = new_key.replace("layers.2.beta", "snake2.beta") + new_key = new_key.replace("layers.2.alpha", "snake2.alpha") + new_key = new_key.replace("layers.1.bias", "conv1.bias") + new_key = new_key.replace("layers.1.weight_", "conv1.weight_") + new_key = new_key.replace("layers.3.bias", "conv2.bias") + new_key = new_key.replace("layers.3.weight_", "conv2.weight_") + + if idx == num_autoencoder_layers + 1: + new_key = new_key.replace(f"block.{idx - 1}", "snake1") + elif idx == num_autoencoder_layers + 2: + new_key = new_key.replace(f"block.{idx - 1}", "conv2") + + else: + new_key = new_key + + value = autoencoder_state_dict.pop(key) + if "snake" in new_key: + value = value.unsqueeze(0).unsqueeze(-1) + if new_key in autoencoder_state_dict: + raise ValueError(f"{new_key} already in state dict.") + autoencoder_state_dict[new_key] = value + + return model_state_dict, projection_model_state_dict, autoencoder_state_dict + + +parser = argparse.ArgumentParser(description="Convert Stable Audio 1.0 model weights to a diffusers pipeline") +parser.add_argument("--model_folder_path", type=str, help="Location of Stable Audio weights and config") +parser.add_argument("--use_safetensors", action="store_true", help="Use SafeTensors for conversion") +parser.add_argument( + "--save_directory", + type=str, + default="./tmp/stable-audio-1.0", + help="Directory to save a pipeline to. Will be created if it doesn't exist.", +) +parser.add_argument( + "--repo_id", + type=str, + default="stable-audio-1.0", + help="Hub organization to save the pipelines to", +) +parser.add_argument("--push_to_hub", action="store_true", help="Push to hub") +parser.add_argument("--variant", type=str, help="Set to bf16 to save bfloat16 weights") + +args = parser.parse_args() + +checkpoint_path = ( + os.path.join(args.model_folder_path, "model.safetensors") + if args.use_safetensors + else os.path.join(args.model_folder_path, "model.ckpt") +) +config_path = os.path.join(args.model_folder_path, "model_config.json") + +device = "cpu" +if args.variant == "bf16": + dtype = torch.bfloat16 +else: + dtype = torch.float32 + +with open(config_path) as f_in: + config_dict = json.load(f_in) + +conditioning_dict = { + conditioning["id"]: conditioning["config"] for conditioning in config_dict["model"]["conditioning"]["configs"] +} + +t5_model_config = conditioning_dict["prompt"] + +# T5 Text encoder +text_encoder = T5EncoderModel.from_pretrained(t5_model_config["t5_model_name"]) +tokenizer = AutoTokenizer.from_pretrained( + t5_model_config["t5_model_name"], truncation=True, model_max_length=t5_model_config["max_length"] +) + + +# scheduler +scheduler = CosineDPMSolverMultistepScheduler( + sigma_min=0.3, + sigma_max=500, + solver_order=2, + prediction_type="v_prediction", + sigma_data=1.0, + sigma_schedule="exponential", +) +ctx = init_empty_weights if is_accelerate_available() else nullcontext + + +if args.use_safetensors: + orig_state_dict = load_file(checkpoint_path, device=device) +else: + orig_state_dict = torch.load(checkpoint_path, map_location=device) + + +model_config = config_dict["model"]["diffusion"]["config"] + +model_state_dict, projection_model_state_dict, autoencoder_state_dict = convert_stable_audio_state_dict_to_diffusers( + orig_state_dict +) + + +with ctx(): + projection_model = StableAudioProjectionModel( + text_encoder_dim=text_encoder.config.d_model, + conditioning_dim=config_dict["model"]["conditioning"]["cond_dim"], + min_value=conditioning_dict["seconds_start"][ + "min_val" + ], # assume `seconds_start` and `seconds_total` have the same min / max values. + max_value=conditioning_dict["seconds_start"][ + "max_val" + ], # assume `seconds_start` and `seconds_total` have the same min / max values. + ) +if is_accelerate_available(): + load_model_dict_into_meta(projection_model, projection_model_state_dict) +else: + projection_model.load_state_dict(projection_model_state_dict) + +attention_head_dim = model_config["embed_dim"] // model_config["num_heads"] +with ctx(): + model = StableAudioDiTModel( + sample_size=int(config_dict["sample_size"]) + / int(config_dict["model"]["pretransform"]["config"]["downsampling_ratio"]), + in_channels=model_config["io_channels"], + num_layers=model_config["depth"], + attention_head_dim=attention_head_dim, + num_key_value_attention_heads=model_config["cond_token_dim"] // attention_head_dim, + num_attention_heads=model_config["num_heads"], + out_channels=model_config["io_channels"], + cross_attention_dim=model_config["cond_token_dim"], + time_proj_dim=256, + global_states_input_dim=model_config["global_cond_dim"], + cross_attention_input_dim=model_config["cond_token_dim"], + ) +if is_accelerate_available(): + load_model_dict_into_meta(model, model_state_dict) +else: + model.load_state_dict(model_state_dict) + + +autoencoder_config = config_dict["model"]["pretransform"]["config"] +with ctx(): + autoencoder = AutoencoderOobleck( + encoder_hidden_size=autoencoder_config["encoder"]["config"]["channels"], + downsampling_ratios=autoencoder_config["encoder"]["config"]["strides"], + decoder_channels=autoencoder_config["decoder"]["config"]["channels"], + decoder_input_channels=autoencoder_config["decoder"]["config"]["latent_dim"], + audio_channels=autoencoder_config["io_channels"], + channel_multiples=autoencoder_config["encoder"]["config"]["c_mults"], + sampling_rate=config_dict["sample_rate"], + ) + +if is_accelerate_available(): + load_model_dict_into_meta(autoencoder, autoencoder_state_dict) +else: + autoencoder.load_state_dict(autoencoder_state_dict) + + +# Prior pipeline +pipeline = StableAudioPipeline( + transformer=model, + tokenizer=tokenizer, + text_encoder=text_encoder, + scheduler=scheduler, + vae=autoencoder, + projection_model=projection_model, +) +pipeline.to(dtype).save_pretrained( + args.save_directory, repo_id=args.repo_id, push_to_hub=args.push_to_hub, variant=args.variant +) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_cascade.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_cascade.py new file mode 100644 index 0000000000000000000000000000000000000000..97ed18d9b4d4f3196ce3ebda43801641b3a75f30 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_cascade.py @@ -0,0 +1,218 @@ +# Run this script to convert the Stable Cascade model weights to a diffusers pipeline. +import argparse +from contextlib import nullcontext + +import torch +from safetensors.torch import load_file +from transformers import ( + AutoTokenizer, + CLIPConfig, + CLIPImageProcessor, + CLIPTextModelWithProjection, + CLIPVisionModelWithProjection, +) + +from diffusers import ( + DDPMWuerstchenScheduler, + StableCascadeCombinedPipeline, + StableCascadeDecoderPipeline, + StableCascadePriorPipeline, +) +from diffusers.loaders.single_file_utils import convert_stable_cascade_unet_single_file_to_diffusers +from diffusers.models import StableCascadeUNet +from diffusers.models.model_loading_utils import load_model_dict_into_meta +from diffusers.pipelines.wuerstchen import PaellaVQModel +from diffusers.utils import is_accelerate_available + + +if is_accelerate_available(): + from accelerate import init_empty_weights + +parser = argparse.ArgumentParser(description="Convert Stable Cascade model weights to a diffusers pipeline") +parser.add_argument("--model_path", type=str, help="Location of Stable Cascade weights") +parser.add_argument("--stage_c_name", type=str, default="stage_c.safetensors", help="Name of stage c checkpoint file") +parser.add_argument("--stage_b_name", type=str, default="stage_b.safetensors", help="Name of stage b checkpoint file") +parser.add_argument("--skip_stage_c", action="store_true", help="Skip converting stage c") +parser.add_argument("--skip_stage_b", action="store_true", help="Skip converting stage b") +parser.add_argument("--use_safetensors", action="store_true", help="Use SafeTensors for conversion") +parser.add_argument( + "--prior_output_path", default="stable-cascade-prior", type=str, help="Hub organization to save the pipelines to" +) +parser.add_argument( + "--decoder_output_path", + type=str, + default="stable-cascade-decoder", + help="Hub organization to save the pipelines to", +) +parser.add_argument( + "--combined_output_path", + type=str, + default="stable-cascade-combined", + help="Hub organization to save the pipelines to", +) +parser.add_argument("--save_combined", action="store_true") +parser.add_argument("--push_to_hub", action="store_true", help="Push to hub") +parser.add_argument("--variant", type=str, help="Set to bf16 to save bfloat16 weights") + +args = parser.parse_args() + +if args.skip_stage_b and args.skip_stage_c: + raise ValueError("At least one stage should be converted") +if (args.skip_stage_b or args.skip_stage_c) and args.save_combined: + raise ValueError("Cannot skip stages when creating a combined pipeline") + +model_path = args.model_path + +device = "cpu" +if args.variant == "bf16": + dtype = torch.bfloat16 +else: + dtype = torch.float32 + +# set paths to model weights +prior_checkpoint_path = f"{model_path}/{args.stage_c_name}" +decoder_checkpoint_path = f"{model_path}/{args.stage_b_name}" + +# Clip Text encoder and tokenizer +config = CLIPConfig.from_pretrained("laion/CLIP-ViT-bigG-14-laion2B-39B-b160k") +config.text_config.projection_dim = config.projection_dim +text_encoder = CLIPTextModelWithProjection.from_pretrained( + "laion/CLIP-ViT-bigG-14-laion2B-39B-b160k", config=config.text_config +) +tokenizer = AutoTokenizer.from_pretrained("laion/CLIP-ViT-bigG-14-laion2B-39B-b160k") + +# image processor +feature_extractor = CLIPImageProcessor() +image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") + +# scheduler for prior and decoder +scheduler = DDPMWuerstchenScheduler() +ctx = init_empty_weights if is_accelerate_available() else nullcontext + +if not args.skip_stage_c: + # Prior + if args.use_safetensors: + prior_orig_state_dict = load_file(prior_checkpoint_path, device=device) + else: + prior_orig_state_dict = torch.load(prior_checkpoint_path, map_location=device) + + prior_state_dict = convert_stable_cascade_unet_single_file_to_diffusers(prior_orig_state_dict) + + with ctx(): + prior_model = StableCascadeUNet( + in_channels=16, + out_channels=16, + timestep_ratio_embedding_dim=64, + patch_size=1, + conditioning_dim=2048, + block_out_channels=[2048, 2048], + num_attention_heads=[32, 32], + down_num_layers_per_block=[8, 24], + up_num_layers_per_block=[24, 8], + down_blocks_repeat_mappers=[1, 1], + up_blocks_repeat_mappers=[1, 1], + block_types_per_layer=[ + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ], + clip_text_in_channels=1280, + clip_text_pooled_in_channels=1280, + clip_image_in_channels=768, + clip_seq=4, + kernel_size=3, + dropout=[0.1, 0.1], + self_attn=True, + timestep_conditioning_type=["sca", "crp"], + switch_level=[False], + ) + if is_accelerate_available(): + load_model_dict_into_meta(prior_model, prior_state_dict) + else: + prior_model.load_state_dict(prior_state_dict) + + # Prior pipeline + prior_pipeline = StableCascadePriorPipeline( + prior=prior_model, + tokenizer=tokenizer, + text_encoder=text_encoder, + image_encoder=image_encoder, + scheduler=scheduler, + feature_extractor=feature_extractor, + ) + prior_pipeline.to(dtype).save_pretrained( + args.prior_output_path, push_to_hub=args.push_to_hub, variant=args.variant + ) + +if not args.skip_stage_b: + # Decoder + if args.use_safetensors: + decoder_orig_state_dict = load_file(decoder_checkpoint_path, device=device) + else: + decoder_orig_state_dict = torch.load(decoder_checkpoint_path, map_location=device) + + decoder_state_dict = convert_stable_cascade_unet_single_file_to_diffusers(decoder_orig_state_dict) + with ctx(): + decoder = StableCascadeUNet( + in_channels=4, + out_channels=4, + timestep_ratio_embedding_dim=64, + patch_size=2, + conditioning_dim=1280, + block_out_channels=[320, 640, 1280, 1280], + down_num_layers_per_block=[2, 6, 28, 6], + up_num_layers_per_block=[6, 28, 6, 2], + down_blocks_repeat_mappers=[1, 1, 1, 1], + up_blocks_repeat_mappers=[3, 3, 2, 2], + num_attention_heads=[0, 0, 20, 20], + block_types_per_layer=[ + ["SDCascadeResBlock", "SDCascadeTimestepBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ], + clip_text_pooled_in_channels=1280, + clip_seq=4, + effnet_in_channels=16, + pixel_mapper_in_channels=3, + kernel_size=3, + dropout=[0, 0, 0.1, 0.1], + self_attn=True, + timestep_conditioning_type=["sca"], + ) + + if is_accelerate_available(): + load_model_dict_into_meta(decoder, decoder_state_dict) + else: + decoder.load_state_dict(decoder_state_dict) + + # VQGAN from Wuerstchen-V2 + vqmodel = PaellaVQModel.from_pretrained("warp-ai/wuerstchen", subfolder="vqgan") + + # Decoder pipeline + decoder_pipeline = StableCascadeDecoderPipeline( + decoder=decoder, text_encoder=text_encoder, tokenizer=tokenizer, vqgan=vqmodel, scheduler=scheduler + ) + decoder_pipeline.to(dtype).save_pretrained( + args.decoder_output_path, push_to_hub=args.push_to_hub, variant=args.variant + ) + +if args.save_combined: + # Stable Cascade combined pipeline + stable_cascade_pipeline = StableCascadeCombinedPipeline( + # Decoder + text_encoder=text_encoder, + tokenizer=tokenizer, + decoder=decoder, + scheduler=scheduler, + vqgan=vqmodel, + # Prior + prior_text_encoder=text_encoder, + prior_tokenizer=tokenizer, + prior_prior=prior_model, + prior_scheduler=scheduler, + prior_image_encoder=image_encoder, + prior_feature_extractor=feature_extractor, + ) + stable_cascade_pipeline.to(dtype).save_pretrained( + args.combined_output_path, push_to_hub=args.push_to_hub, variant=args.variant + ) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_cascade_lite.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_cascade_lite.py new file mode 100644 index 0000000000000000000000000000000000000000..5f4804e30f74836f3ce57d8125e4bb278f419437 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_cascade_lite.py @@ -0,0 +1,226 @@ +# Run this script to convert the Stable Cascade model weights to a diffusers pipeline. +import argparse +from contextlib import nullcontext + +import torch +from safetensors.torch import load_file +from transformers import ( + AutoTokenizer, + CLIPConfig, + CLIPImageProcessor, + CLIPTextModelWithProjection, + CLIPVisionModelWithProjection, +) + +from diffusers import ( + DDPMWuerstchenScheduler, + StableCascadeCombinedPipeline, + StableCascadeDecoderPipeline, + StableCascadePriorPipeline, +) +from diffusers.loaders.single_file_utils import convert_stable_cascade_unet_single_file_to_diffusers +from diffusers.models import StableCascadeUNet +from diffusers.models.model_loading_utils import load_model_dict_into_meta +from diffusers.pipelines.wuerstchen import PaellaVQModel +from diffusers.utils import is_accelerate_available + + +if is_accelerate_available(): + from accelerate import init_empty_weights + +parser = argparse.ArgumentParser(description="Convert Stable Cascade model weights to a diffusers pipeline") +parser.add_argument("--model_path", type=str, help="Location of Stable Cascade weights") +parser.add_argument( + "--stage_c_name", type=str, default="stage_c_lite.safetensors", help="Name of stage c checkpoint file" +) +parser.add_argument( + "--stage_b_name", type=str, default="stage_b_lite.safetensors", help="Name of stage b checkpoint file" +) +parser.add_argument("--skip_stage_c", action="store_true", help="Skip converting stage c") +parser.add_argument("--skip_stage_b", action="store_true", help="Skip converting stage b") +parser.add_argument("--use_safetensors", action="store_true", help="Use SafeTensors for conversion") +parser.add_argument( + "--prior_output_path", + default="stable-cascade-prior-lite", + type=str, + help="Hub organization to save the pipelines to", +) +parser.add_argument( + "--decoder_output_path", + type=str, + default="stable-cascade-decoder-lite", + help="Hub organization to save the pipelines to", +) +parser.add_argument( + "--combined_output_path", + type=str, + default="stable-cascade-combined-lite", + help="Hub organization to save the pipelines to", +) +parser.add_argument("--save_combined", action="store_true") +parser.add_argument("--push_to_hub", action="store_true", help="Push to hub") +parser.add_argument("--variant", type=str, help="Set to bf16 to save bfloat16 weights") + +args = parser.parse_args() + +if args.skip_stage_b and args.skip_stage_c: + raise ValueError("At least one stage should be converted") +if (args.skip_stage_b or args.skip_stage_c) and args.save_combined: + raise ValueError("Cannot skip stages when creating a combined pipeline") + +model_path = args.model_path + +device = "cpu" +if args.variant == "bf16": + dtype = torch.bfloat16 +else: + dtype = torch.float32 + +# set paths to model weights +prior_checkpoint_path = f"{model_path}/{args.stage_c_name}" +decoder_checkpoint_path = f"{model_path}/{args.stage_b_name}" + +# Clip Text encoder and tokenizer +config = CLIPConfig.from_pretrained("laion/CLIP-ViT-bigG-14-laion2B-39B-b160k") +config.text_config.projection_dim = config.projection_dim +text_encoder = CLIPTextModelWithProjection.from_pretrained( + "laion/CLIP-ViT-bigG-14-laion2B-39B-b160k", config=config.text_config +) +tokenizer = AutoTokenizer.from_pretrained("laion/CLIP-ViT-bigG-14-laion2B-39B-b160k") + +# image processor +feature_extractor = CLIPImageProcessor() +image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") +# scheduler for prior and decoder +scheduler = DDPMWuerstchenScheduler() + +ctx = init_empty_weights if is_accelerate_available() else nullcontext + +if not args.skip_stage_c: + # Prior + if args.use_safetensors: + prior_orig_state_dict = load_file(prior_checkpoint_path, device=device) + else: + prior_orig_state_dict = torch.load(prior_checkpoint_path, map_location=device) + + prior_state_dict = convert_stable_cascade_unet_single_file_to_diffusers(prior_orig_state_dict) + with ctx(): + prior_model = StableCascadeUNet( + in_channels=16, + out_channels=16, + timestep_ratio_embedding_dim=64, + patch_size=1, + conditioning_dim=1536, + block_out_channels=[1536, 1536], + num_attention_heads=[24, 24], + down_num_layers_per_block=[4, 12], + up_num_layers_per_block=[12, 4], + down_blocks_repeat_mappers=[1, 1], + up_blocks_repeat_mappers=[1, 1], + block_types_per_layer=[ + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ], + clip_text_in_channels=1280, + clip_text_pooled_in_channels=1280, + clip_image_in_channels=768, + clip_seq=4, + kernel_size=3, + dropout=[0.1, 0.1], + self_attn=True, + timestep_conditioning_type=["sca", "crp"], + switch_level=[False], + ) + + if is_accelerate_available(): + load_model_dict_into_meta(prior_model, prior_state_dict) + else: + prior_model.load_state_dict(prior_state_dict) + + # Prior pipeline + prior_pipeline = StableCascadePriorPipeline( + prior=prior_model, + tokenizer=tokenizer, + text_encoder=text_encoder, + image_encoder=image_encoder, + scheduler=scheduler, + feature_extractor=feature_extractor, + ) + prior_pipeline.to(dtype).save_pretrained( + args.prior_output_path, push_to_hub=args.push_to_hub, variant=args.variant + ) + +if not args.skip_stage_b: + # Decoder + if args.use_safetensors: + decoder_orig_state_dict = load_file(decoder_checkpoint_path, device=device) + else: + decoder_orig_state_dict = torch.load(decoder_checkpoint_path, map_location=device) + + decoder_state_dict = convert_stable_cascade_unet_single_file_to_diffusers(decoder_orig_state_dict) + + with ctx(): + decoder = StableCascadeUNet( + in_channels=4, + out_channels=4, + timestep_ratio_embedding_dim=64, + patch_size=2, + conditioning_dim=1280, + block_out_channels=[320, 576, 1152, 1152], + down_num_layers_per_block=[2, 4, 14, 4], + up_num_layers_per_block=[4, 14, 4, 2], + down_blocks_repeat_mappers=[1, 1, 1, 1], + up_blocks_repeat_mappers=[2, 2, 2, 2], + num_attention_heads=[0, 9, 18, 18], + block_types_per_layer=[ + ["SDCascadeResBlock", "SDCascadeTimestepBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ["SDCascadeResBlock", "SDCascadeTimestepBlock", "SDCascadeAttnBlock"], + ], + clip_text_pooled_in_channels=1280, + clip_seq=4, + effnet_in_channels=16, + pixel_mapper_in_channels=3, + kernel_size=3, + dropout=[0, 0, 0.1, 0.1], + self_attn=True, + timestep_conditioning_type=["sca"], + ) + + if is_accelerate_available(): + load_model_dict_into_meta(decoder, decoder_state_dict) + else: + decoder.load_state_dict(decoder_state_dict) + + # VQGAN from Wuerstchen-V2 + vqmodel = PaellaVQModel.from_pretrained("warp-ai/wuerstchen", subfolder="vqgan") + + # Decoder pipeline + decoder_pipeline = StableCascadeDecoderPipeline( + decoder=decoder, text_encoder=text_encoder, tokenizer=tokenizer, vqgan=vqmodel, scheduler=scheduler + ) + decoder_pipeline.to(dtype).save_pretrained( + args.decoder_output_path, push_to_hub=args.push_to_hub, variant=args.variant + ) + +if args.save_combined: + # Stable Cascade combined pipeline + stable_cascade_pipeline = StableCascadeCombinedPipeline( + # Decoder + text_encoder=text_encoder, + tokenizer=tokenizer, + decoder=decoder, + scheduler=scheduler, + vqgan=vqmodel, + # Prior + prior_text_encoder=text_encoder, + prior_tokenizer=tokenizer, + prior_prior=prior_model, + prior_scheduler=scheduler, + prior_image_encoder=image_encoder, + prior_feature_extractor=feature_extractor, + ) + stable_cascade_pipeline.to(dtype).save_pretrained( + args.combined_output_path, push_to_hub=args.push_to_hub, variant=args.variant + ) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_checkpoint_to_onnx.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_checkpoint_to_onnx.py new file mode 100644 index 0000000000000000000000000000000000000000..1fb9f8d35bae3cd2a3f8ba2983e2742e99ea2f8e --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_checkpoint_to_onnx.py @@ -0,0 +1,265 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import os +import shutil +from pathlib import Path + +import onnx +import torch +from packaging import version +from torch.onnx import export + +from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline + + +is_torch_less_than_1_11 = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") + + +def onnx_export( + model, + model_args: tuple, + output_path: Path, + ordered_input_names, + output_names, + dynamic_axes, + opset, + use_external_data_format=False, +): + output_path.parent.mkdir(parents=True, exist_ok=True) + # PyTorch deprecated the `enable_onnx_checker` and `use_external_data_format` arguments in v1.11, + # so we check the torch version for backwards compatibility + if is_torch_less_than_1_11: + export( + model, + model_args, + f=output_path.as_posix(), + input_names=ordered_input_names, + output_names=output_names, + dynamic_axes=dynamic_axes, + do_constant_folding=True, + use_external_data_format=use_external_data_format, + enable_onnx_checker=True, + opset_version=opset, + ) + else: + export( + model, + model_args, + f=output_path.as_posix(), + input_names=ordered_input_names, + output_names=output_names, + dynamic_axes=dynamic_axes, + do_constant_folding=True, + opset_version=opset, + ) + + +@torch.no_grad() +def convert_models(model_path: str, output_path: str, opset: int, fp16: bool = False): + dtype = torch.float16 if fp16 else torch.float32 + if fp16 and torch.cuda.is_available(): + device = "cuda" + elif fp16 and not torch.cuda.is_available(): + raise ValueError("`float16` model export is only supported on GPUs with CUDA") + else: + device = "cpu" + pipeline = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=dtype).to(device) + output_path = Path(output_path) + + # TEXT ENCODER + num_tokens = pipeline.text_encoder.config.max_position_embeddings + text_hidden_size = pipeline.text_encoder.config.hidden_size + text_input = pipeline.tokenizer( + "A sample prompt", + padding="max_length", + max_length=pipeline.tokenizer.model_max_length, + truncation=True, + return_tensors="pt", + ) + onnx_export( + pipeline.text_encoder, + # casting to torch.int32 until the CLIP fix is released: https://github.com/huggingface/transformers/pull/18515/files + model_args=(text_input.input_ids.to(device=device, dtype=torch.int32)), + output_path=output_path / "text_encoder" / "model.onnx", + ordered_input_names=["input_ids"], + output_names=["last_hidden_state", "pooler_output"], + dynamic_axes={ + "input_ids": {0: "batch", 1: "sequence"}, + }, + opset=opset, + ) + del pipeline.text_encoder + + # UNET + unet_in_channels = pipeline.unet.config.in_channels + unet_sample_size = pipeline.unet.config.sample_size + unet_path = output_path / "unet" / "model.onnx" + onnx_export( + pipeline.unet, + model_args=( + torch.randn(2, unet_in_channels, unet_sample_size, unet_sample_size).to(device=device, dtype=dtype), + torch.randn(2).to(device=device, dtype=dtype), + torch.randn(2, num_tokens, text_hidden_size).to(device=device, dtype=dtype), + False, + ), + output_path=unet_path, + ordered_input_names=["sample", "timestep", "encoder_hidden_states", "return_dict"], + output_names=["out_sample"], # has to be different from "sample" for correct tracing + dynamic_axes={ + "sample": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + "timestep": {0: "batch"}, + "encoder_hidden_states": {0: "batch", 1: "sequence"}, + }, + opset=opset, + use_external_data_format=True, # UNet is > 2GB, so the weights need to be split + ) + unet_model_path = str(unet_path.absolute().as_posix()) + unet_dir = os.path.dirname(unet_model_path) + unet = onnx.load(unet_model_path) + # clean up existing tensor files + shutil.rmtree(unet_dir) + os.mkdir(unet_dir) + # collate external tensor files into one + onnx.save_model( + unet, + unet_model_path, + save_as_external_data=True, + all_tensors_to_one_file=True, + location="weights.pb", + convert_attribute=False, + ) + del pipeline.unet + + # VAE ENCODER + vae_encoder = pipeline.vae + vae_in_channels = vae_encoder.config.in_channels + vae_sample_size = vae_encoder.config.sample_size + # need to get the raw tensor output (sample) from the encoder + vae_encoder.forward = lambda sample, return_dict: vae_encoder.encode(sample, return_dict)[0].sample() + onnx_export( + vae_encoder, + model_args=( + torch.randn(1, vae_in_channels, vae_sample_size, vae_sample_size).to(device=device, dtype=dtype), + False, + ), + output_path=output_path / "vae_encoder" / "model.onnx", + ordered_input_names=["sample", "return_dict"], + output_names=["latent_sample"], + dynamic_axes={ + "sample": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + }, + opset=opset, + ) + + # VAE DECODER + vae_decoder = pipeline.vae + vae_latent_channels = vae_decoder.config.latent_channels + vae_out_channels = vae_decoder.config.out_channels + # forward only through the decoder part + vae_decoder.forward = vae_encoder.decode + onnx_export( + vae_decoder, + model_args=( + torch.randn(1, vae_latent_channels, unet_sample_size, unet_sample_size).to(device=device, dtype=dtype), + False, + ), + output_path=output_path / "vae_decoder" / "model.onnx", + ordered_input_names=["latent_sample", "return_dict"], + output_names=["sample"], + dynamic_axes={ + "latent_sample": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + }, + opset=opset, + ) + del pipeline.vae + + # SAFETY CHECKER + if pipeline.safety_checker is not None: + safety_checker = pipeline.safety_checker + clip_num_channels = safety_checker.config.vision_config.num_channels + clip_image_size = safety_checker.config.vision_config.image_size + safety_checker.forward = safety_checker.forward_onnx + onnx_export( + pipeline.safety_checker, + model_args=( + torch.randn( + 1, + clip_num_channels, + clip_image_size, + clip_image_size, + ).to(device=device, dtype=dtype), + torch.randn(1, vae_sample_size, vae_sample_size, vae_out_channels).to(device=device, dtype=dtype), + ), + output_path=output_path / "safety_checker" / "model.onnx", + ordered_input_names=["clip_input", "images"], + output_names=["out_images", "has_nsfw_concepts"], + dynamic_axes={ + "clip_input": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + "images": {0: "batch", 1: "height", 2: "width", 3: "channels"}, + }, + opset=opset, + ) + del pipeline.safety_checker + safety_checker = OnnxRuntimeModel.from_pretrained(output_path / "safety_checker") + feature_extractor = pipeline.feature_extractor + else: + safety_checker = None + feature_extractor = None + + onnx_pipeline = OnnxStableDiffusionPipeline( + vae_encoder=OnnxRuntimeModel.from_pretrained(output_path / "vae_encoder"), + vae_decoder=OnnxRuntimeModel.from_pretrained(output_path / "vae_decoder"), + text_encoder=OnnxRuntimeModel.from_pretrained(output_path / "text_encoder"), + tokenizer=pipeline.tokenizer, + unet=OnnxRuntimeModel.from_pretrained(output_path / "unet"), + scheduler=pipeline.scheduler, + safety_checker=safety_checker, + feature_extractor=feature_extractor, + requires_safety_checker=safety_checker is not None, + ) + + onnx_pipeline.save_pretrained(output_path) + print("ONNX pipeline saved to", output_path) + + del pipeline + del onnx_pipeline + _ = OnnxStableDiffusionPipeline.from_pretrained(output_path, provider="CPUExecutionProvider") + print("ONNX pipeline is loadable") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--model_path", + type=str, + required=True, + help="Path to the `diffusers` checkpoint to convert (either a local directory or on the Hub).", + ) + + parser.add_argument("--output_path", type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--opset", + default=14, + type=int, + help="The version of the ONNX operator set to use.", + ) + parser.add_argument("--fp16", action="store_true", default=False, help="Export the models in `float16` mode") + + args = parser.parse_args() + + convert_models(args.model_path, args.output_path, args.opset, args.fp16) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_controlnet_to_onnx.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_controlnet_to_onnx.py new file mode 100644 index 0000000000000000000000000000000000000000..4af39b28783681c9e6626cd2c003f2b8635224a5 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_controlnet_to_onnx.py @@ -0,0 +1,505 @@ +import argparse +import os +import shutil +from pathlib import Path + +import onnx +import onnx_graphsurgeon as gs +import torch +from onnx import shape_inference +from packaging import version +from polygraphy.backend.onnx.loader import fold_constants +from torch.onnx import export + +from diffusers import ( + ControlNetModel, + StableDiffusionControlNetImg2ImgPipeline, +) +from diffusers.models.attention_processor import AttnProcessor +from diffusers.pipelines.controlnet.pipeline_controlnet_sd_xl import StableDiffusionXLControlNetPipeline + + +is_torch_less_than_1_11 = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") +is_torch_2_0_1 = version.parse(version.parse(torch.__version__).base_version) == version.parse("2.0.1") + + +class Optimizer: + def __init__(self, onnx_graph, verbose=False): + self.graph = gs.import_onnx(onnx_graph) + self.verbose = verbose + + def info(self, prefix): + if self.verbose: + print( + f"{prefix} .. {len(self.graph.nodes)} nodes, {len(self.graph.tensors().keys())} tensors, {len(self.graph.inputs)} inputs, {len(self.graph.outputs)} outputs" + ) + + def cleanup(self, return_onnx=False): + self.graph.cleanup().toposort() + if return_onnx: + return gs.export_onnx(self.graph) + + def select_outputs(self, keep, names=None): + self.graph.outputs = [self.graph.outputs[o] for o in keep] + if names: + for i, name in enumerate(names): + self.graph.outputs[i].name = name + + def fold_constants(self, return_onnx=False): + onnx_graph = fold_constants(gs.export_onnx(self.graph), allow_onnxruntime_shape_inference=True) + self.graph = gs.import_onnx(onnx_graph) + if return_onnx: + return onnx_graph + + def infer_shapes(self, return_onnx=False): + onnx_graph = gs.export_onnx(self.graph) + if onnx_graph.ByteSize() > 2147483648: + raise TypeError("ERROR: model size exceeds supported 2GB limit") + else: + onnx_graph = shape_inference.infer_shapes(onnx_graph) + + self.graph = gs.import_onnx(onnx_graph) + if return_onnx: + return onnx_graph + + +def optimize(onnx_graph, name, verbose): + opt = Optimizer(onnx_graph, verbose=verbose) + opt.info(name + ": original") + opt.cleanup() + opt.info(name + ": cleanup") + opt.fold_constants() + opt.info(name + ": fold constants") + # opt.infer_shapes() + # opt.info(name + ': shape inference') + onnx_opt_graph = opt.cleanup(return_onnx=True) + opt.info(name + ": finished") + return onnx_opt_graph + + +class UNet2DConditionControlNetModel(torch.nn.Module): + def __init__( + self, + unet, + controlnets: ControlNetModel, + ): + super().__init__() + self.unet = unet + self.controlnets = controlnets + + def forward( + self, + sample, + timestep, + encoder_hidden_states, + controlnet_conds, + controlnet_scales, + ): + for i, (controlnet_cond, conditioning_scale, controlnet) in enumerate( + zip(controlnet_conds, controlnet_scales, self.controlnets) + ): + down_samples, mid_sample = controlnet( + sample, + timestep, + encoder_hidden_states=encoder_hidden_states, + controlnet_cond=controlnet_cond, + conditioning_scale=conditioning_scale, + return_dict=False, + ) + + # merge samples + if i == 0: + down_block_res_samples, mid_block_res_sample = down_samples, mid_sample + else: + down_block_res_samples = [ + samples_prev + samples_curr + for samples_prev, samples_curr in zip(down_block_res_samples, down_samples) + ] + mid_block_res_sample += mid_sample + + noise_pred = self.unet( + sample, + timestep, + encoder_hidden_states=encoder_hidden_states, + down_block_additional_residuals=down_block_res_samples, + mid_block_additional_residual=mid_block_res_sample, + return_dict=False, + )[0] + return noise_pred + + +class UNet2DConditionXLControlNetModel(torch.nn.Module): + def __init__( + self, + unet, + controlnets: ControlNetModel, + ): + super().__init__() + self.unet = unet + self.controlnets = controlnets + + def forward( + self, + sample, + timestep, + encoder_hidden_states, + controlnet_conds, + controlnet_scales, + text_embeds, + time_ids, + ): + added_cond_kwargs = {"text_embeds": text_embeds, "time_ids": time_ids} + for i, (controlnet_cond, conditioning_scale, controlnet) in enumerate( + zip(controlnet_conds, controlnet_scales, self.controlnets) + ): + down_samples, mid_sample = controlnet( + sample, + timestep, + encoder_hidden_states=encoder_hidden_states, + controlnet_cond=controlnet_cond, + conditioning_scale=conditioning_scale, + added_cond_kwargs=added_cond_kwargs, + return_dict=False, + ) + + # merge samples + if i == 0: + down_block_res_samples, mid_block_res_sample = down_samples, mid_sample + else: + down_block_res_samples = [ + samples_prev + samples_curr + for samples_prev, samples_curr in zip(down_block_res_samples, down_samples) + ] + mid_block_res_sample += mid_sample + + noise_pred = self.unet( + sample, + timestep, + encoder_hidden_states=encoder_hidden_states, + down_block_additional_residuals=down_block_res_samples, + mid_block_additional_residual=mid_block_res_sample, + added_cond_kwargs=added_cond_kwargs, + return_dict=False, + )[0] + return noise_pred + + +def onnx_export( + model, + model_args: tuple, + output_path: Path, + ordered_input_names, + output_names, + dynamic_axes, + opset, + use_external_data_format=False, +): + output_path.parent.mkdir(parents=True, exist_ok=True) + # PyTorch deprecated the `enable_onnx_checker` and `use_external_data_format` arguments in v1.11, + # so we check the torch version for backwards compatibility + with torch.inference_mode(), torch.autocast("cuda"): + if is_torch_less_than_1_11: + export( + model, + model_args, + f=output_path.as_posix(), + input_names=ordered_input_names, + output_names=output_names, + dynamic_axes=dynamic_axes, + do_constant_folding=True, + use_external_data_format=use_external_data_format, + enable_onnx_checker=True, + opset_version=opset, + ) + else: + export( + model, + model_args, + f=output_path.as_posix(), + input_names=ordered_input_names, + output_names=output_names, + dynamic_axes=dynamic_axes, + do_constant_folding=True, + opset_version=opset, + ) + + +@torch.no_grad() +def convert_models( + model_path: str, controlnet_path: list, output_path: str, opset: int, fp16: bool = False, sd_xl: bool = False +): + """ + Function to convert models in stable diffusion controlnet pipeline into ONNX format + + Example: + python convert_stable_diffusion_controlnet_to_onnx.py + --model_path danbrown/RevAnimated-v1-2-2 + --controlnet_path lllyasviel/control_v11f1e_sd15_tile ioclab/brightness-controlnet + --output_path path-to-models-stable_diffusion/RevAnimated-v1-2-2 + --fp16 + + Example for SD XL: + python convert_stable_diffusion_controlnet_to_onnx.py + --model_path stabilityai/stable-diffusion-xl-base-1.0 + --controlnet_path SargeZT/sdxl-controlnet-seg + --output_path path-to-models-stable_diffusion/stable-diffusion-xl-base-1.0 + --fp16 + --sd_xl + + Returns: + create 4 onnx models in output path + text_encoder/model.onnx + unet/model.onnx + unet/weights.pb + vae_encoder/model.onnx + vae_decoder/model.onnx + + run test script in diffusers/examples/community + python test_onnx_controlnet.py + --sd_model danbrown/RevAnimated-v1-2-2 + --onnx_model_dir path-to-models-stable_diffusion/RevAnimated-v1-2-2 + --qr_img_path path-to-qr-code-image + """ + dtype = torch.float16 if fp16 else torch.float32 + if fp16 and torch.cuda.is_available(): + device = "cuda" + elif fp16 and not torch.cuda.is_available(): + raise ValueError("`float16` model export is only supported on GPUs with CUDA") + else: + device = "cpu" + + # init controlnet + controlnets = [] + for path in controlnet_path: + controlnet = ControlNetModel.from_pretrained(path, torch_dtype=dtype).to(device) + if is_torch_2_0_1: + controlnet.set_attn_processor(AttnProcessor()) + controlnets.append(controlnet) + + if sd_xl: + if len(controlnets) == 1: + controlnet = controlnets[0] + else: + raise ValueError("MultiControlNet is not yet supported.") + pipeline = StableDiffusionXLControlNetPipeline.from_pretrained( + model_path, controlnet=controlnet, torch_dtype=dtype, variant="fp16", use_safetensors=True + ).to(device) + else: + pipeline = StableDiffusionControlNetImg2ImgPipeline.from_pretrained( + model_path, controlnet=controlnets, torch_dtype=dtype + ).to(device) + + output_path = Path(output_path) + if is_torch_2_0_1: + pipeline.unet.set_attn_processor(AttnProcessor()) + pipeline.vae.set_attn_processor(AttnProcessor()) + + # # TEXT ENCODER + num_tokens = pipeline.text_encoder.config.max_position_embeddings + text_hidden_size = pipeline.text_encoder.config.hidden_size + text_input = pipeline.tokenizer( + "A sample prompt", + padding="max_length", + max_length=pipeline.tokenizer.model_max_length, + truncation=True, + return_tensors="pt", + ) + onnx_export( + pipeline.text_encoder, + # casting to torch.int32 until the CLIP fix is released: https://github.com/huggingface/transformers/pull/18515/files + model_args=(text_input.input_ids.to(device=device, dtype=torch.int32)), + output_path=output_path / "text_encoder" / "model.onnx", + ordered_input_names=["input_ids"], + output_names=["last_hidden_state", "pooler_output"], + dynamic_axes={ + "input_ids": {0: "batch", 1: "sequence"}, + }, + opset=opset, + ) + del pipeline.text_encoder + + # # UNET + if sd_xl: + controlnets = torch.nn.ModuleList(controlnets) + unet_controlnet = UNet2DConditionXLControlNetModel(pipeline.unet, controlnets) + unet_in_channels = pipeline.unet.config.in_channels + unet_sample_size = pipeline.unet.config.sample_size + text_hidden_size = 2048 + img_size = 8 * unet_sample_size + unet_path = output_path / "unet" / "model.onnx" + + onnx_export( + unet_controlnet, + model_args=( + torch.randn(2, unet_in_channels, unet_sample_size, unet_sample_size).to(device=device, dtype=dtype), + torch.tensor([1.0]).to(device=device, dtype=dtype), + torch.randn(2, num_tokens, text_hidden_size).to(device=device, dtype=dtype), + torch.randn(len(controlnets), 2, 3, img_size, img_size).to(device=device, dtype=dtype), + torch.randn(len(controlnets), 1).to(device=device, dtype=dtype), + torch.randn(2, 1280).to(device=device, dtype=dtype), + torch.rand(2, 6).to(device=device, dtype=dtype), + ), + output_path=unet_path, + ordered_input_names=[ + "sample", + "timestep", + "encoder_hidden_states", + "controlnet_conds", + "conditioning_scales", + "text_embeds", + "time_ids", + ], + output_names=["noise_pred"], # has to be different from "sample" for correct tracing + dynamic_axes={ + "sample": {0: "2B", 2: "H", 3: "W"}, + "encoder_hidden_states": {0: "2B"}, + "controlnet_conds": {1: "2B", 3: "8H", 4: "8W"}, + "text_embeds": {0: "2B"}, + "time_ids": {0: "2B"}, + }, + opset=opset, + use_external_data_format=True, # UNet is > 2GB, so the weights need to be split + ) + unet_model_path = str(unet_path.absolute().as_posix()) + unet_dir = os.path.dirname(unet_model_path) + # optimize onnx + shape_inference.infer_shapes_path(unet_model_path, unet_model_path) + unet_opt_graph = optimize(onnx.load(unet_model_path), name="Unet", verbose=True) + # clean up existing tensor files + shutil.rmtree(unet_dir) + os.mkdir(unet_dir) + # collate external tensor files into one + onnx.save_model( + unet_opt_graph, + unet_model_path, + save_as_external_data=True, + all_tensors_to_one_file=True, + location="weights.pb", + convert_attribute=False, + ) + del pipeline.unet + else: + controlnets = torch.nn.ModuleList(controlnets) + unet_controlnet = UNet2DConditionControlNetModel(pipeline.unet, controlnets) + unet_in_channels = pipeline.unet.config.in_channels + unet_sample_size = pipeline.unet.config.sample_size + img_size = 8 * unet_sample_size + unet_path = output_path / "unet" / "model.onnx" + + onnx_export( + unet_controlnet, + model_args=( + torch.randn(2, unet_in_channels, unet_sample_size, unet_sample_size).to(device=device, dtype=dtype), + torch.tensor([1.0]).to(device=device, dtype=dtype), + torch.randn(2, num_tokens, text_hidden_size).to(device=device, dtype=dtype), + torch.randn(len(controlnets), 2, 3, img_size, img_size).to(device=device, dtype=dtype), + torch.randn(len(controlnets), 1).to(device=device, dtype=dtype), + ), + output_path=unet_path, + ordered_input_names=[ + "sample", + "timestep", + "encoder_hidden_states", + "controlnet_conds", + "conditioning_scales", + ], + output_names=["noise_pred"], # has to be different from "sample" for correct tracing + dynamic_axes={ + "sample": {0: "2B", 2: "H", 3: "W"}, + "encoder_hidden_states": {0: "2B"}, + "controlnet_conds": {1: "2B", 3: "8H", 4: "8W"}, + }, + opset=opset, + use_external_data_format=True, # UNet is > 2GB, so the weights need to be split + ) + unet_model_path = str(unet_path.absolute().as_posix()) + unet_dir = os.path.dirname(unet_model_path) + # optimize onnx + shape_inference.infer_shapes_path(unet_model_path, unet_model_path) + unet_opt_graph = optimize(onnx.load(unet_model_path), name="Unet", verbose=True) + # clean up existing tensor files + shutil.rmtree(unet_dir) + os.mkdir(unet_dir) + # collate external tensor files into one + onnx.save_model( + unet_opt_graph, + unet_model_path, + save_as_external_data=True, + all_tensors_to_one_file=True, + location="weights.pb", + convert_attribute=False, + ) + del pipeline.unet + + # VAE ENCODER + vae_encoder = pipeline.vae + vae_in_channels = vae_encoder.config.in_channels + vae_sample_size = vae_encoder.config.sample_size + # need to get the raw tensor output (sample) from the encoder + vae_encoder.forward = lambda sample: vae_encoder.encode(sample).latent_dist.sample() + onnx_export( + vae_encoder, + model_args=(torch.randn(1, vae_in_channels, vae_sample_size, vae_sample_size).to(device=device, dtype=dtype),), + output_path=output_path / "vae_encoder" / "model.onnx", + ordered_input_names=["sample"], + output_names=["latent_sample"], + dynamic_axes={ + "sample": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + }, + opset=opset, + ) + + # VAE DECODER + vae_decoder = pipeline.vae + vae_latent_channels = vae_decoder.config.latent_channels + # forward only through the decoder part + vae_decoder.forward = vae_encoder.decode + onnx_export( + vae_decoder, + model_args=( + torch.randn(1, vae_latent_channels, unet_sample_size, unet_sample_size).to(device=device, dtype=dtype), + ), + output_path=output_path / "vae_decoder" / "model.onnx", + ordered_input_names=["latent_sample"], + output_names=["sample"], + dynamic_axes={ + "latent_sample": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + }, + opset=opset, + ) + del pipeline.vae + + del pipeline + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--sd_xl", action="store_true", default=False, help="SD XL pipeline") + + parser.add_argument( + "--model_path", + type=str, + required=True, + help="Path to the `diffusers` checkpoint to convert (either a local directory or on the Hub).", + ) + + parser.add_argument( + "--controlnet_path", + nargs="+", + required=True, + help="Path to the `controlnet` checkpoint to convert (either a local directory or on the Hub).", + ) + + parser.add_argument("--output_path", type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--opset", + default=14, + type=int, + help="The version of the ONNX operator set to use.", + ) + parser.add_argument("--fp16", action="store_true", default=False, help="Export the models in `float16` mode") + + args = parser.parse_args() + + convert_models(args.model_path, args.controlnet_path, args.output_path, args.opset, args.fp16, args.sd_xl) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_controlnet_to_tensorrt.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_controlnet_to_tensorrt.py new file mode 100644 index 0000000000000000000000000000000000000000..52ab02c221e91c655df9c1698afc49cdb5bdb91a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_stable_diffusion_controlnet_to_tensorrt.py @@ -0,0 +1,121 @@ +import argparse +import sys + +import tensorrt as trt + + +def convert_models(onnx_path: str, num_controlnet: int, output_path: str, fp16: bool = False, sd_xl: bool = False): + """ + Function to convert models in stable diffusion controlnet pipeline into TensorRT format + + Example: + python convert_stable_diffusion_controlnet_to_tensorrt.py + --onnx_path path-to-models-stable_diffusion/RevAnimated-v1-2-2/unet/model.onnx + --output_path path-to-models-stable_diffusion/RevAnimated-v1-2-2/unet/model.engine + --fp16 + --num_controlnet 2 + + Example for SD XL: + python convert_stable_diffusion_controlnet_to_tensorrt.py + --onnx_path path-to-models-stable_diffusion/stable-diffusion-xl-base-1.0/unet/model.onnx + --output_path path-to-models-stable_diffusion/stable-diffusion-xl-base-1.0/unet/model.engine + --fp16 + --num_controlnet 1 + --sd_xl + + Returns: + unet/model.engine + + run test script in diffusers/examples/community + python test_onnx_controlnet.py + --sd_model danbrown/RevAnimated-v1-2-2 + --onnx_model_dir path-to-models-stable_diffusion/RevAnimated-v1-2-2 + --unet_engine_path path-to-models-stable_diffusion/stable-diffusion-xl-base-1.0/unet/model.engine + --qr_img_path path-to-qr-code-image + """ + # UNET + if sd_xl: + batch_size = 1 + unet_in_channels = 4 + unet_sample_size = 64 + num_tokens = 77 + text_hidden_size = 2048 + img_size = 512 + + text_embeds_shape = (2 * batch_size, 1280) + time_ids_shape = (2 * batch_size, 6) + else: + batch_size = 1 + unet_in_channels = 4 + unet_sample_size = 64 + num_tokens = 77 + text_hidden_size = 768 + img_size = 512 + batch_size = 1 + + latents_shape = (2 * batch_size, unet_in_channels, unet_sample_size, unet_sample_size) + embed_shape = (2 * batch_size, num_tokens, text_hidden_size) + controlnet_conds_shape = (num_controlnet, 2 * batch_size, 3, img_size, img_size) + + TRT_LOGGER = trt.Logger(trt.Logger.VERBOSE) + TRT_BUILDER = trt.Builder(TRT_LOGGER) + TRT_RUNTIME = trt.Runtime(TRT_LOGGER) + + network = TRT_BUILDER.create_network(1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)) + onnx_parser = trt.OnnxParser(network, TRT_LOGGER) + + parse_success = onnx_parser.parse_from_file(onnx_path) + for idx in range(onnx_parser.num_errors): + print(onnx_parser.get_error(idx)) + if not parse_success: + sys.exit("ONNX model parsing failed") + print("Load Onnx model done") + + profile = TRT_BUILDER.create_optimization_profile() + + profile.set_shape("sample", latents_shape, latents_shape, latents_shape) + profile.set_shape("encoder_hidden_states", embed_shape, embed_shape, embed_shape) + profile.set_shape("controlnet_conds", controlnet_conds_shape, controlnet_conds_shape, controlnet_conds_shape) + if sd_xl: + profile.set_shape("text_embeds", text_embeds_shape, text_embeds_shape, text_embeds_shape) + profile.set_shape("time_ids", time_ids_shape, time_ids_shape, time_ids_shape) + + config = TRT_BUILDER.create_builder_config() + config.add_optimization_profile(profile) + config.set_preview_feature(trt.PreviewFeature.DISABLE_EXTERNAL_TACTIC_SOURCES_FOR_CORE_0805, True) + if fp16: + config.set_flag(trt.BuilderFlag.FP16) + + plan = TRT_BUILDER.build_serialized_network(network, config) + if plan is None: + sys.exit("Failed building engine") + print("Succeeded building engine") + + engine = TRT_RUNTIME.deserialize_cuda_engine(plan) + + ## save TRT engine + with open(output_path, "wb") as f: + f.write(engine.serialize()) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--sd_xl", action="store_true", default=False, help="SD XL pipeline") + + parser.add_argument( + "--onnx_path", + type=str, + required=True, + help="Path to the onnx checkpoint to convert", + ) + + parser.add_argument("--num_controlnet", type=int) + + parser.add_argument("--output_path", type=str, required=True, help="Path to the output model.") + + parser.add_argument("--fp16", action="store_true", default=False, help="Export the models in `float16` mode") + + args = parser.parse_args() + + convert_models(args.onnx_path, args.num_controlnet, args.output_path, args.fp16, args.sd_xl) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_svd_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_svd_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..e46410ccb3bdcc10d84f488fd692acfa189e8c34 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_svd_to_diffusers.py @@ -0,0 +1,730 @@ +from diffusers.utils import is_accelerate_available, logging + + +if is_accelerate_available(): + pass + +logger = logging.get_logger(__name__) # pylint: disable=invalid-name + + +def create_unet_diffusers_config(original_config, image_size: int, controlnet=False): + """ + Creates a config for the diffusers based on the config of the LDM model. + """ + if controlnet: + unet_params = original_config.model.params.control_stage_config.params + else: + if "unet_config" in original_config.model.params and original_config.model.params.unet_config is not None: + unet_params = original_config.model.params.unet_config.params + else: + unet_params = original_config.model.params.network_config.params + + vae_params = original_config.model.params.first_stage_config.params.encoder_config.params + + block_out_channels = [unet_params.model_channels * mult for mult in unet_params.channel_mult] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = ( + "CrossAttnDownBlockSpatioTemporal" + if resolution in unet_params.attention_resolutions + else "DownBlockSpatioTemporal" + ) + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = ( + "CrossAttnUpBlockSpatioTemporal" + if resolution in unet_params.attention_resolutions + else "UpBlockSpatioTemporal" + ) + up_block_types.append(block_type) + resolution //= 2 + + if unet_params.transformer_depth is not None: + transformer_layers_per_block = ( + unet_params.transformer_depth + if isinstance(unet_params.transformer_depth, int) + else list(unet_params.transformer_depth) + ) + else: + transformer_layers_per_block = 1 + + vae_scale_factor = 2 ** (len(vae_params.ch_mult) - 1) + + head_dim = unet_params.num_heads if "num_heads" in unet_params else None + use_linear_projection = ( + unet_params.use_linear_in_transformer if "use_linear_in_transformer" in unet_params else False + ) + if use_linear_projection: + # stable diffusion 2-base-512 and 2-768 + if head_dim is None: + head_dim_mult = unet_params.model_channels // unet_params.num_head_channels + head_dim = [head_dim_mult * c for c in list(unet_params.channel_mult)] + + class_embed_type = None + addition_embed_type = None + addition_time_embed_dim = None + projection_class_embeddings_input_dim = None + context_dim = None + + if unet_params.context_dim is not None: + context_dim = ( + unet_params.context_dim if isinstance(unet_params.context_dim, int) else unet_params.context_dim[0] + ) + + if "num_classes" in unet_params: + if unet_params.num_classes == "sequential": + addition_time_embed_dim = 256 + assert "adm_in_channels" in unet_params + projection_class_embeddings_input_dim = unet_params.adm_in_channels + + config = { + "sample_size": image_size // vae_scale_factor, + "in_channels": unet_params.in_channels, + "down_block_types": tuple(down_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params.num_res_blocks, + "cross_attention_dim": context_dim, + "attention_head_dim": head_dim, + "use_linear_projection": use_linear_projection, + "class_embed_type": class_embed_type, + "addition_embed_type": addition_embed_type, + "addition_time_embed_dim": addition_time_embed_dim, + "projection_class_embeddings_input_dim": projection_class_embeddings_input_dim, + "transformer_layers_per_block": transformer_layers_per_block, + } + + if "disable_self_attentions" in unet_params: + config["only_cross_attention"] = unet_params.disable_self_attentions + + if "num_classes" in unet_params and isinstance(unet_params.num_classes, int): + config["num_class_embeds"] = unet_params.num_classes + + if controlnet: + config["conditioning_channels"] = unet_params.hint_channels + else: + config["out_channels"] = unet_params.out_channels + config["up_block_types"] = tuple(up_block_types) + + return config + + +def assign_to_checkpoint( + paths, + checkpoint, + old_checkpoint, + attention_paths_to_split=None, + additional_replacements=None, + config=None, + mid_block_suffix="", +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + if mid_block_suffix is not None: + mid_block_suffix = f".{mid_block_suffix}" + else: + mid_block_suffix = "" + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", f"mid_block.resnets.0{mid_block_suffix}") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", f"mid_block.resnets.1{mid_block_suffix}") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + if new_path == "mid_block.resnets.0.spatial_res_block.norm1.weight": + print("yeyy") + + # proj_attn.weight has to be converted from conv 1D to linear + is_attn_weight = "proj_attn.weight" in new_path or ("attentions" in new_path and "to_" in new_path) + shape = old_checkpoint[path["old"]].shape + if is_attn_weight and len(shape) == 3: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + elif is_attn_weight and len(shape) == 4: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + new_item = new_item.replace("time_stack", "temporal_transformer_blocks") + + new_item = new_item.replace("time_pos_embed.0.bias", "time_pos_embed.linear_1.bias") + new_item = new_item.replace("time_pos_embed.0.weight", "time_pos_embed.linear_1.weight") + new_item = new_item.replace("time_pos_embed.2.bias", "time_pos_embed.linear_2.bias") + new_item = new_item.replace("time_pos_embed.2.weight", "time_pos_embed.linear_2.weight") + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = new_item.replace("time_stack.", "") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def convert_ldm_unet_checkpoint( + checkpoint, config, path=None, extract_ema=False, controlnet=False, skip_extract_state_dict=False +): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + + if skip_extract_state_dict: + unet_state_dict = checkpoint + else: + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + unet_key = "model.diffusion_model." + + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + logger.warning(f"Checkpoint {path} has both EMA and non-EMA weights.") + logger.warning( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + logger.warning( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + if config["class_embed_type"] is None: + # No parameters to port + ... + elif config["class_embed_type"] == "timestep" or config["class_embed_type"] == "projection": + new_checkpoint["class_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["class_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["class_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["class_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + else: + raise NotImplementedError(f"Not implemented `class_embed_type`: {config['class_embed_type']}") + + # if config["addition_embed_type"] == "text_time": + new_checkpoint["add_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["add_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["add_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["add_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + spatial_resnets = [ + key + for key in input_blocks[i] + if f"input_blocks.{i}.0" in key + and ( + f"input_blocks.{i}.0.op" not in key + and f"input_blocks.{i}.0.time_stack" not in key + and f"input_blocks.{i}.0.time_mixer" not in key + ) + ] + temporal_resnets = [key for key in input_blocks[i] if f"input_blocks.{i}.0.time_stack" in key] + # import ipdb; ipdb.set_trace() + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(spatial_resnets) + meta_path = { + "old": f"input_blocks.{i}.0", + "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}.spatial_res_block", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + paths = renew_resnet_paths(temporal_resnets) + meta_path = { + "old": f"input_blocks.{i}.0", + "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}.temporal_res_block", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + # TODO resnet time_mixer.mix_factor + if f"input_blocks.{i}.0.time_mixer.mix_factor" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.resnets.{layer_in_block_id}.time_mixer.mix_factor"] = ( + unet_state_dict[f"input_blocks.{i}.0.time_mixer.mix_factor"] + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + # import ipdb; ipdb.set_trace() + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_spatial = [key for key in resnet_0 if "time_stack" not in key and "time_mixer" not in key] + resnet_0_paths = renew_resnet_paths(resnet_0_spatial) + # import ipdb; ipdb.set_trace() + assign_to_checkpoint( + resnet_0_paths, new_checkpoint, unet_state_dict, config=config, mid_block_suffix="spatial_res_block" + ) + + resnet_0_temporal = [key for key in resnet_0 if "time_stack" in key and "time_mixer" not in key] + resnet_0_paths = renew_resnet_paths(resnet_0_temporal) + assign_to_checkpoint( + resnet_0_paths, new_checkpoint, unet_state_dict, config=config, mid_block_suffix="temporal_res_block" + ) + + resnet_1_spatial = [key for key in resnet_1 if "time_stack" not in key and "time_mixer" not in key] + resnet_1_paths = renew_resnet_paths(resnet_1_spatial) + assign_to_checkpoint( + resnet_1_paths, new_checkpoint, unet_state_dict, config=config, mid_block_suffix="spatial_res_block" + ) + + resnet_1_temporal = [key for key in resnet_1 if "time_stack" in key and "time_mixer" not in key] + resnet_1_paths = renew_resnet_paths(resnet_1_temporal) + assign_to_checkpoint( + resnet_1_paths, new_checkpoint, unet_state_dict, config=config, mid_block_suffix="temporal_res_block" + ) + + new_checkpoint["mid_block.resnets.0.time_mixer.mix_factor"] = unet_state_dict[ + "middle_block.0.time_mixer.mix_factor" + ] + new_checkpoint["mid_block.resnets.1.time_mixer.mix_factor"] = unet_state_dict[ + "middle_block.2.time_mixer.mix_factor" + ] + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + spatial_resnets = [ + key + for key in output_blocks[i] + if f"output_blocks.{i}.0" in key + and (f"output_blocks.{i}.0.time_stack" not in key and "time_mixer" not in key) + ] + # import ipdb; ipdb.set_trace() + + temporal_resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0.time_stack" in key] + + paths = renew_resnet_paths(spatial_resnets) + meta_path = { + "old": f"output_blocks.{i}.0", + "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}.spatial_res_block", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + paths = renew_resnet_paths(temporal_resnets) + meta_path = { + "old": f"output_blocks.{i}.0", + "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}.temporal_res_block", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if f"output_blocks.{i}.0.time_mixer.mix_factor" in unet_state_dict: + new_checkpoint[f"up_blocks.{block_id}.resnets.{layer_in_block_id}.time_mixer.mix_factor"] = ( + unet_state_dict[f"output_blocks.{i}.0.time_mixer.mix_factor"] + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key and "conv" not in key] + if len(attentions): + paths = renew_attention_paths(attentions) + # import ipdb; ipdb.set_trace() + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + spatial_layers = [ + layer for layer in output_block_layers if "time_stack" not in layer and "time_mixer" not in layer + ] + resnet_0_paths = renew_resnet_paths(spatial_layers, n_shave_prefix_segments=1) + # import ipdb; ipdb.set_trace() + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join( + ["up_blocks", str(block_id), "resnets", str(layer_in_block_id), "spatial_res_block", path["new"]] + ) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + temporal_layers = [ + layer for layer in output_block_layers if "time_stack" in layer and "time_mixer" not in key + ] + resnet_0_paths = renew_resnet_paths(temporal_layers, n_shave_prefix_segments=1) + # import ipdb; ipdb.set_trace() + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join( + ["up_blocks", str(block_id), "resnets", str(layer_in_block_id), "temporal_res_block", path["new"]] + ) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + new_checkpoint["up_blocks.0.resnets.0.time_mixer.mix_factor"] = unet_state_dict[ + f"output_blocks.{str(i)}.0.time_mixer.mix_factor" + ] + + return new_checkpoint + + +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["to_q.weight", "to_k.weight", "to_v.weight"] + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0, 0] + elif "proj_attn.weight" in key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0] + + +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0, is_temporal=False): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # Temporal resnet + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = new_item.replace("time_stack.", "temporal_res_block.") + + # Spatial resnet + new_item = new_item.replace("conv1", "spatial_res_block.conv1") + new_item = new_item.replace("norm1", "spatial_res_block.norm1") + + new_item = new_item.replace("conv2", "spatial_res_block.conv2") + new_item = new_item.replace("norm2", "spatial_res_block.norm2") + + new_item = new_item.replace("nin_shortcut", "spatial_res_block.conv_shortcut") + + new_item = new_item.replace("mix_factor", "spatial_res_block.time_mixer.mix_factor") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "to_q.weight") + new_item = new_item.replace("q.bias", "to_q.bias") + + new_item = new_item.replace("k.weight", "to_k.weight") + new_item = new_item.replace("k.bias", "to_k.bias") + + new_item = new_item.replace("v.weight", "to_v.weight") + new_item = new_item.replace("v.bias", "to_v.bias") + + new_item = new_item.replace("proj_out.weight", "to_out.0.weight") + new_item = new_item.replace("proj_out.bias", "to_out.0.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def convert_ldm_vae_checkpoint(checkpoint, config): + # extract state dict for VAE + vae_state_dict = {} + keys = list(checkpoint.keys()) + vae_key = "first_stage_model." if any(k.startswith("first_stage_model.") for k in keys) else "" + for key in keys: + if key.startswith(vae_key): + vae_state_dict[key.replace(vae_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + new_checkpoint["decoder.time_conv_out.weight"] = vae_state_dict["decoder.time_mix_conv.weight"] + new_checkpoint["decoder.time_conv_out.bias"] = vae_state_dict["decoder.time_mix_conv.bias"] + + # new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + # new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + # new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + # new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_tiny_autoencoder_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_tiny_autoencoder_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..9bb2df98a77a62400cfcea024d1d1ddd2b3f3368 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_tiny_autoencoder_to_diffusers.py @@ -0,0 +1,71 @@ +import argparse + +import safetensors.torch + +from diffusers import AutoencoderTiny + + +""" +Example - From the diffusers root directory: + +Download the weights: +```sh +$ wget -q https://huggingface.co/madebyollin/taesd/resolve/main/taesd_encoder.safetensors +$ wget -q https://huggingface.co/madebyollin/taesd/resolve/main/taesd_decoder.safetensors +``` + +Convert the model: +```sh +$ python scripts/convert_tiny_autoencoder_to_diffusers.py \ + --encoder_ckpt_path taesd_encoder.safetensors \ + --decoder_ckpt_path taesd_decoder.safetensors \ + --dump_path taesd-diffusers +``` +""" + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument( + "--encoder_ckpt_path", + default=None, + type=str, + required=True, + help="Path to the encoder ckpt.", + ) + parser.add_argument( + "--decoder_ckpt_path", + default=None, + type=str, + required=True, + help="Path to the decoder ckpt.", + ) + parser.add_argument( + "--use_safetensors", action="store_true", help="Whether to serialize in the safetensors format." + ) + args = parser.parse_args() + + print("Loading the original state_dicts of the encoder and the decoder...") + encoder_state_dict = safetensors.torch.load_file(args.encoder_ckpt_path) + decoder_state_dict = safetensors.torch.load_file(args.decoder_ckpt_path) + + print("Populating the state_dicts in the diffusers format...") + tiny_autoencoder = AutoencoderTiny() + new_state_dict = {} + + # Modify the encoder state dict. + for k in encoder_state_dict: + new_state_dict.update({f"encoder.layers.{k}": encoder_state_dict[k]}) + + # Modify the decoder state dict. + for k in decoder_state_dict: + layer_id = int(k.split(".")[0]) - 1 + new_k = str(layer_id) + "." + ".".join(k.split(".")[1:]) + new_state_dict.update({f"decoder.layers.{new_k}": decoder_state_dict[k]}) + + # Assertion tests with the original implementation can be found here: + # https://gist.github.com/sayakpaul/337b0988f08bd2cf2b248206f760e28f + tiny_autoencoder.load_state_dict(new_state_dict) + print("Population successful, serializing...") + tiny_autoencoder.save_pretrained(args.dump_path, safe_serialization=args.use_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_unclip_txt2img_to_image_variation.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_unclip_txt2img_to_image_variation.py new file mode 100644 index 0000000000000000000000000000000000000000..07f8ebf2a3d012600a533dcfa642b609c31a3d8c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_unclip_txt2img_to_image_variation.py @@ -0,0 +1,41 @@ +import argparse + +from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection + +from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--txt2img_unclip", + default="kakaobrain/karlo-v1-alpha", + type=str, + required=False, + help="The pretrained txt2img unclip.", + ) + + args = parser.parse_args() + + txt2img = UnCLIPPipeline.from_pretrained(args.txt2img_unclip) + + feature_extractor = CLIPImageProcessor() + image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") + + img2img = UnCLIPImageVariationPipeline( + decoder=txt2img.decoder, + text_encoder=txt2img.text_encoder, + tokenizer=txt2img.tokenizer, + text_proj=txt2img.text_proj, + feature_extractor=feature_extractor, + image_encoder=image_encoder, + super_res_first=txt2img.super_res_first, + super_res_last=txt2img.super_res_last, + decoder_scheduler=txt2img.decoder_scheduler, + super_res_scheduler=txt2img.super_res_scheduler, + ) + + img2img.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_unidiffuser_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_unidiffuser_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..4c38172754f6645111b8eeed75cf1cd85dbeb30f --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_unidiffuser_to_diffusers.py @@ -0,0 +1,786 @@ +# Convert the original UniDiffuser checkpoints into diffusers equivalents. + +import argparse +from argparse import Namespace + +import torch +from transformers import ( + CLIPImageProcessor, + CLIPTextConfig, + CLIPTextModel, + CLIPTokenizer, + CLIPVisionConfig, + CLIPVisionModelWithProjection, + GPT2Tokenizer, +) + +from diffusers import ( + AutoencoderKL, + DPMSolverMultistepScheduler, + UniDiffuserModel, + UniDiffuserPipeline, + UniDiffuserTextDecoder, +) + + +SCHEDULER_CONFIG = Namespace( + **{ + "beta_start": 0.00085, + "beta_end": 0.012, + "beta_schedule": "scaled_linear", + "solver_order": 3, + } +) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.shave_segments +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_resnet_paths +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_attention_paths +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "to_q.weight") + new_item = new_item.replace("q.bias", "to_q.bias") + + new_item = new_item.replace("k.weight", "to_k.weight") + new_item = new_item.replace("k.bias", "to_k.bias") + + new_item = new_item.replace("v.weight", "to_v.weight") + new_item = new_item.replace("v.bias", "to_v.bias") + + new_item = new_item.replace("proj_out.weight", "to_out.0.weight") + new_item = new_item.replace("proj_out.bias", "to_out.0.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.conv_attn_to_linear +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["query.weight", "key.weight", "value.weight"] + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0, 0] + elif "proj_attn.weight" in key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0] + + +# Modified from diffusers.pipelines.stable_diffusion.convert_from_ckpt.assign_to_checkpoint +# config.num_head_channels => num_head_channels +def assign_to_checkpoint( + paths, + checkpoint, + old_checkpoint, + attention_paths_to_split=None, + additional_replacements=None, + num_head_channels=1, +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // num_head_channels // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + is_attn_weight = "proj_attn.weight" in new_path or ("attentions" in new_path and "to_" in new_path) + shape = old_checkpoint[path["old"]].shape + if is_attn_weight and len(shape) == 3: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + elif is_attn_weight and len(shape) == 4: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def create_vae_diffusers_config(config_type): + # Hardcoded for now + if args.config_type == "test": + vae_config = create_vae_diffusers_config_test() + elif args.config_type == "big": + vae_config = create_vae_diffusers_config_big() + else: + raise NotImplementedError( + f"Config type {config_type} is not implemented, currently only config types" + " 'test' and 'big' are available." + ) + return vae_config + + +def create_unidiffuser_unet_config(config_type, version): + # Hardcoded for now + if args.config_type == "test": + unet_config = create_unidiffuser_unet_config_test() + elif args.config_type == "big": + unet_config = create_unidiffuser_unet_config_big() + else: + raise NotImplementedError( + f"Config type {config_type} is not implemented, currently only config types" + " 'test' and 'big' are available." + ) + # Unidiffuser-v1 uses data type embeddings + if version == 1: + unet_config["use_data_type_embedding"] = True + return unet_config + + +def create_text_decoder_config(config_type): + # Hardcoded for now + if args.config_type == "test": + text_decoder_config = create_text_decoder_config_test() + elif args.config_type == "big": + text_decoder_config = create_text_decoder_config_big() + else: + raise NotImplementedError( + f"Config type {config_type} is not implemented, currently only config types" + " 'test' and 'big' are available." + ) + return text_decoder_config + + +# Hardcoded configs for test versions of the UniDiffuser models, corresponding to those in the fast default tests. +def create_vae_diffusers_config_test(): + vae_config = { + "sample_size": 32, + "in_channels": 3, + "out_channels": 3, + "down_block_types": ["DownEncoderBlock2D", "DownEncoderBlock2D"], + "up_block_types": ["UpDecoderBlock2D", "UpDecoderBlock2D"], + "block_out_channels": [32, 64], + "latent_channels": 4, + "layers_per_block": 1, + } + return vae_config + + +def create_unidiffuser_unet_config_test(): + unet_config = { + "text_dim": 32, + "clip_img_dim": 32, + "num_text_tokens": 77, + "num_attention_heads": 2, + "attention_head_dim": 8, + "in_channels": 4, + "out_channels": 4, + "num_layers": 2, + "dropout": 0.0, + "norm_num_groups": 32, + "attention_bias": False, + "sample_size": 16, + "patch_size": 2, + "activation_fn": "gelu", + "num_embeds_ada_norm": 1000, + "norm_type": "layer_norm", + "block_type": "unidiffuser", + "pre_layer_norm": False, + "use_timestep_embedding": False, + "norm_elementwise_affine": True, + "use_patch_pos_embed": False, + "ff_final_dropout": True, + "use_data_type_embedding": False, + } + return unet_config + + +def create_text_decoder_config_test(): + text_decoder_config = { + "prefix_length": 77, + "prefix_inner_dim": 32, + "prefix_hidden_dim": 32, + "vocab_size": 1025, # 1024 + 1 for new EOS token + "n_positions": 1024, + "n_embd": 32, + "n_layer": 5, + "n_head": 4, + "n_inner": 37, + "activation_function": "gelu", + "resid_pdrop": 0.1, + "embd_pdrop": 0.1, + "attn_pdrop": 0.1, + "layer_norm_epsilon": 1e-5, + "initializer_range": 0.02, + } + return text_decoder_config + + +# Hardcoded configs for the UniDiffuser V1 model at https://huggingface.co/thu-ml/unidiffuser-v1 +# See also https://github.com/thu-ml/unidiffuser/blob/main/configs/sample_unidiffuser_v1.py +def create_vae_diffusers_config_big(): + vae_config = { + "sample_size": 256, + "in_channels": 3, + "out_channels": 3, + "down_block_types": ["DownEncoderBlock2D", "DownEncoderBlock2D", "DownEncoderBlock2D", "DownEncoderBlock2D"], + "up_block_types": ["UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D"], + "block_out_channels": [128, 256, 512, 512], + "latent_channels": 4, + "layers_per_block": 2, + } + return vae_config + + +def create_unidiffuser_unet_config_big(): + unet_config = { + "text_dim": 64, + "clip_img_dim": 512, + "num_text_tokens": 77, + "num_attention_heads": 24, + "attention_head_dim": 64, + "in_channels": 4, + "out_channels": 4, + "num_layers": 30, + "dropout": 0.0, + "norm_num_groups": 32, + "attention_bias": False, + "sample_size": 64, + "patch_size": 2, + "activation_fn": "gelu", + "num_embeds_ada_norm": 1000, + "norm_type": "layer_norm", + "block_type": "unidiffuser", + "pre_layer_norm": False, + "use_timestep_embedding": False, + "norm_elementwise_affine": True, + "use_patch_pos_embed": False, + "ff_final_dropout": True, + "use_data_type_embedding": False, + } + return unet_config + + +# From https://huggingface.co/gpt2/blob/main/config.json, the GPT2 checkpoint used by UniDiffuser +def create_text_decoder_config_big(): + text_decoder_config = { + "prefix_length": 77, + "prefix_inner_dim": 768, + "prefix_hidden_dim": 64, + "vocab_size": 50258, # 50257 + 1 for new EOS token + "n_positions": 1024, + "n_embd": 768, + "n_layer": 12, + "n_head": 12, + "n_inner": 3072, + "activation_function": "gelu", + "resid_pdrop": 0.1, + "embd_pdrop": 0.1, + "attn_pdrop": 0.1, + "layer_norm_epsilon": 1e-5, + "initializer_range": 0.02, + } + return text_decoder_config + + +# Based on diffusers.pipelines.stable_diffusion.convert_from_ckpt.convert_ldm_vae_checkpoint +def convert_vae_to_diffusers(ckpt, diffusers_model, num_head_channels=1): + """ + Converts a UniDiffuser autoencoder_kl.pth checkpoint to a diffusers AutoencoderKL. + """ + # autoencoder_kl.pth ckpt is a torch state dict + vae_state_dict = torch.load(ckpt, map_location="cpu") + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint( + paths, + new_checkpoint, + vae_state_dict, + additional_replacements=[meta_path], + num_head_channels=num_head_channels, # not used in vae + ) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint( + paths, + new_checkpoint, + vae_state_dict, + additional_replacements=[meta_path], + num_head_channels=num_head_channels, # not used in vae + ) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + paths, + new_checkpoint, + vae_state_dict, + additional_replacements=[meta_path], + num_head_channels=num_head_channels, # not used in vae + ) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint( + paths, + new_checkpoint, + vae_state_dict, + additional_replacements=[meta_path], + num_head_channels=num_head_channels, # not used in vae + ) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint( + paths, + new_checkpoint, + vae_state_dict, + additional_replacements=[meta_path], + num_head_channels=num_head_channels, # not used in vae + ) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + paths, + new_checkpoint, + vae_state_dict, + additional_replacements=[meta_path], + num_head_channels=num_head_channels, # not used in vae + ) + conv_attn_to_linear(new_checkpoint) + + missing_keys, unexpected_keys = diffusers_model.load_state_dict(new_checkpoint) + for missing_key in missing_keys: + print(f"Missing key: {missing_key}") + for unexpected_key in unexpected_keys: + print(f"Unexpected key: {unexpected_key}") + + return diffusers_model + + +def convert_uvit_block_to_diffusers_block( + uvit_state_dict, + new_state_dict, + block_prefix, + new_prefix="transformer.transformer_", + skip_connection=False, +): + """ + Maps the keys in a UniDiffuser transformer block (`Block`) to the keys in a diffusers transformer block + (`UTransformerBlock`/`UniDiffuserBlock`). + """ + prefix = new_prefix + block_prefix + if skip_connection: + new_state_dict[prefix + ".skip.skip_linear.weight"] = uvit_state_dict[block_prefix + ".skip_linear.weight"] + new_state_dict[prefix + ".skip.skip_linear.bias"] = uvit_state_dict[block_prefix + ".skip_linear.bias"] + new_state_dict[prefix + ".skip.norm.weight"] = uvit_state_dict[block_prefix + ".norm1.weight"] + new_state_dict[prefix + ".skip.norm.bias"] = uvit_state_dict[block_prefix + ".norm1.bias"] + + # Create the prefix string for out_blocks. + prefix += ".block" + + # Split up attention qkv.weight into to_q.weight, to_k.weight, to_v.weight + qkv = uvit_state_dict[block_prefix + ".attn.qkv.weight"] + new_attn_keys = [".attn1.to_q.weight", ".attn1.to_k.weight", ".attn1.to_v.weight"] + new_attn_keys = [prefix + key for key in new_attn_keys] + shape = qkv.shape[0] // len(new_attn_keys) + for i, attn_key in enumerate(new_attn_keys): + new_state_dict[attn_key] = qkv[i * shape : (i + 1) * shape] + + new_state_dict[prefix + ".attn1.to_out.0.weight"] = uvit_state_dict[block_prefix + ".attn.proj.weight"] + new_state_dict[prefix + ".attn1.to_out.0.bias"] = uvit_state_dict[block_prefix + ".attn.proj.bias"] + new_state_dict[prefix + ".norm1.weight"] = uvit_state_dict[block_prefix + ".norm2.weight"] + new_state_dict[prefix + ".norm1.bias"] = uvit_state_dict[block_prefix + ".norm2.bias"] + new_state_dict[prefix + ".ff.net.0.proj.weight"] = uvit_state_dict[block_prefix + ".mlp.fc1.weight"] + new_state_dict[prefix + ".ff.net.0.proj.bias"] = uvit_state_dict[block_prefix + ".mlp.fc1.bias"] + new_state_dict[prefix + ".ff.net.2.weight"] = uvit_state_dict[block_prefix + ".mlp.fc2.weight"] + new_state_dict[prefix + ".ff.net.2.bias"] = uvit_state_dict[block_prefix + ".mlp.fc2.bias"] + new_state_dict[prefix + ".norm3.weight"] = uvit_state_dict[block_prefix + ".norm3.weight"] + new_state_dict[prefix + ".norm3.bias"] = uvit_state_dict[block_prefix + ".norm3.bias"] + + return uvit_state_dict, new_state_dict + + +def convert_uvit_to_diffusers(ckpt, diffusers_model): + """ + Converts a UniDiffuser uvit_v*.pth checkpoint to a diffusers UniDiffusersModel. + """ + # uvit_v*.pth ckpt is a torch state dict + uvit_state_dict = torch.load(ckpt, map_location="cpu") + + new_state_dict = {} + + # Input layers + new_state_dict["vae_img_in.proj.weight"] = uvit_state_dict["patch_embed.proj.weight"] + new_state_dict["vae_img_in.proj.bias"] = uvit_state_dict["patch_embed.proj.bias"] + new_state_dict["clip_img_in.weight"] = uvit_state_dict["clip_img_embed.weight"] + new_state_dict["clip_img_in.bias"] = uvit_state_dict["clip_img_embed.bias"] + new_state_dict["text_in.weight"] = uvit_state_dict["text_embed.weight"] + new_state_dict["text_in.bias"] = uvit_state_dict["text_embed.bias"] + + new_state_dict["pos_embed"] = uvit_state_dict["pos_embed"] + + # Handle data type token embeddings for UniDiffuser-v1 + if "token_embedding.weight" in uvit_state_dict and diffusers_model.use_data_type_embedding: + new_state_dict["data_type_pos_embed_token"] = uvit_state_dict["pos_embed_token"] + new_state_dict["data_type_token_embedding.weight"] = uvit_state_dict["token_embedding.weight"] + + # Also initialize the PatchEmbedding in UTransformer2DModel with the PatchEmbedding from the checkpoint. + # This isn't used in the current implementation, so might want to remove. + new_state_dict["transformer.pos_embed.proj.weight"] = uvit_state_dict["patch_embed.proj.weight"] + new_state_dict["transformer.pos_embed.proj.bias"] = uvit_state_dict["patch_embed.proj.bias"] + + # Output layers + new_state_dict["transformer.norm_out.weight"] = uvit_state_dict["norm.weight"] + new_state_dict["transformer.norm_out.bias"] = uvit_state_dict["norm.bias"] + + new_state_dict["vae_img_out.weight"] = uvit_state_dict["decoder_pred.weight"] + new_state_dict["vae_img_out.bias"] = uvit_state_dict["decoder_pred.bias"] + new_state_dict["clip_img_out.weight"] = uvit_state_dict["clip_img_out.weight"] + new_state_dict["clip_img_out.bias"] = uvit_state_dict["clip_img_out.bias"] + new_state_dict["text_out.weight"] = uvit_state_dict["text_out.weight"] + new_state_dict["text_out.bias"] = uvit_state_dict["text_out.bias"] + + # in_blocks + in_blocks_prefixes = {".".join(layer.split(".")[:2]) for layer in uvit_state_dict if "in_blocks" in layer} + for in_block_prefix in list(in_blocks_prefixes): + convert_uvit_block_to_diffusers_block(uvit_state_dict, new_state_dict, in_block_prefix) + + # mid_block + # Assume there's only one mid block + convert_uvit_block_to_diffusers_block(uvit_state_dict, new_state_dict, "mid_block") + + # out_blocks + out_blocks_prefixes = {".".join(layer.split(".")[:2]) for layer in uvit_state_dict if "out_blocks" in layer} + for out_block_prefix in list(out_blocks_prefixes): + convert_uvit_block_to_diffusers_block(uvit_state_dict, new_state_dict, out_block_prefix, skip_connection=True) + + missing_keys, unexpected_keys = diffusers_model.load_state_dict(new_state_dict) + for missing_key in missing_keys: + print(f"Missing key: {missing_key}") + for unexpected_key in unexpected_keys: + print(f"Unexpected key: {unexpected_key}") + + return diffusers_model + + +def convert_caption_decoder_to_diffusers(ckpt, diffusers_model): + """ + Converts a UniDiffuser caption_decoder.pth checkpoint to a diffusers UniDiffuserTextDecoder. + """ + # caption_decoder.pth ckpt is a torch state dict + checkpoint_state_dict = torch.load(ckpt, map_location="cpu") + decoder_state_dict = {} + # Remove the "module." prefix, if necessary + caption_decoder_key = "module." + for key in checkpoint_state_dict: + if key.startswith(caption_decoder_key): + decoder_state_dict[key.replace(caption_decoder_key, "")] = checkpoint_state_dict.get(key) + else: + decoder_state_dict[key] = checkpoint_state_dict.get(key) + + new_state_dict = {} + + # Encoder and Decoder + new_state_dict["encode_prefix.weight"] = decoder_state_dict["encode_prefix.weight"] + new_state_dict["encode_prefix.bias"] = decoder_state_dict["encode_prefix.bias"] + new_state_dict["decode_prefix.weight"] = decoder_state_dict["decode_prefix.weight"] + new_state_dict["decode_prefix.bias"] = decoder_state_dict["decode_prefix.bias"] + + # Internal GPT2LMHeadModel transformer model + for key, val in decoder_state_dict.items(): + if key.startswith("gpt"): + suffix = key[len("gpt") :] + new_state_dict["transformer" + suffix] = val + + missing_keys, unexpected_keys = diffusers_model.load_state_dict(new_state_dict) + for missing_key in missing_keys: + print(f"Missing key: {missing_key}") + for unexpected_key in unexpected_keys: + print(f"Unexpected key: {unexpected_key}") + + return diffusers_model + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--caption_decoder_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to caption decoder checkpoint to convert.", + ) + parser.add_argument( + "--uvit_checkpoint_path", default=None, type=str, required=False, help="Path to U-ViT checkpoint to convert." + ) + parser.add_argument( + "--vae_checkpoint_path", + default=None, + type=str, + required=False, + help="Path to VAE checkpoint to convert.", + ) + parser.add_argument( + "--pipeline_output_path", + default=None, + type=str, + required=True, + help="Path to save the output pipeline to.", + ) + parser.add_argument( + "--config_type", + default="test", + type=str, + help=( + "Config type to use. Should be 'test' to create small models for testing or 'big' to convert a full" + " checkpoint." + ), + ) + parser.add_argument( + "--version", + default=0, + type=int, + help="The UniDiffuser model type to convert to. Should be 0 for UniDiffuser-v0 and 1 for UniDiffuser-v1.", + ) + parser.add_argument( + "--safe_serialization", + action="store_true", + help="Whether to use safetensors/safe seialization when saving the pipeline.", + ) + + args = parser.parse_args() + + # Convert the VAE model. + if args.vae_checkpoint_path is not None: + vae_config = create_vae_diffusers_config(args.config_type) + vae = AutoencoderKL(**vae_config) + vae = convert_vae_to_diffusers(args.vae_checkpoint_path, vae) + + # Convert the U-ViT ("unet") model. + if args.uvit_checkpoint_path is not None: + unet_config = create_unidiffuser_unet_config(args.config_type, args.version) + unet = UniDiffuserModel(**unet_config) + unet = convert_uvit_to_diffusers(args.uvit_checkpoint_path, unet) + + # Convert the caption decoder ("text_decoder") model. + if args.caption_decoder_checkpoint_path is not None: + text_decoder_config = create_text_decoder_config(args.config_type) + text_decoder = UniDiffuserTextDecoder(**text_decoder_config) + text_decoder = convert_caption_decoder_to_diffusers(args.caption_decoder_checkpoint_path, text_decoder) + + # Scheduler is the same for both the test and big models. + scheduler_config = SCHEDULER_CONFIG + scheduler = DPMSolverMultistepScheduler( + beta_start=scheduler_config.beta_start, + beta_end=scheduler_config.beta_end, + beta_schedule=scheduler_config.beta_schedule, + solver_order=scheduler_config.solver_order, + ) + + if args.config_type == "test": + # Make a small random CLIPTextModel + torch.manual_seed(0) + clip_text_encoder_config = CLIPTextConfig( + bos_token_id=0, + eos_token_id=2, + hidden_size=32, + intermediate_size=37, + layer_norm_eps=1e-05, + num_attention_heads=4, + num_hidden_layers=5, + pad_token_id=1, + vocab_size=1000, + ) + text_encoder = CLIPTextModel(clip_text_encoder_config) + clip_tokenizer = CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip") + + # Make a small random CLIPVisionModel and accompanying CLIPImageProcessor + torch.manual_seed(0) + clip_image_encoder_config = CLIPVisionConfig( + image_size=32, + patch_size=2, + num_channels=3, + hidden_size=32, + projection_dim=32, + num_hidden_layers=5, + num_attention_heads=4, + intermediate_size=37, + dropout=0.1, + attention_dropout=0.1, + initializer_range=0.02, + ) + image_encoder = CLIPVisionModelWithProjection(clip_image_encoder_config) + image_processor = CLIPImageProcessor(crop_size=32, size=32) + + # Note that the text_decoder should already have its token embeddings resized. + text_tokenizer = GPT2Tokenizer.from_pretrained("hf-internal-testing/tiny-random-GPT2Model") + eos = "<|EOS|>" + special_tokens_dict = {"eos_token": eos} + text_tokenizer.add_special_tokens(special_tokens_dict) + elif args.config_type == "big": + text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14") + clip_tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14") + + image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-base-patch32") + image_processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-base-patch32") + + # Note that the text_decoder should already have its token embeddings resized. + text_tokenizer = GPT2Tokenizer.from_pretrained("gpt2") + eos = "<|EOS|>" + special_tokens_dict = {"eos_token": eos} + text_tokenizer.add_special_tokens(special_tokens_dict) + else: + raise NotImplementedError( + f"Config type {args.config_type} is not implemented, currently only config types" + " 'test' and 'big' are available." + ) + + pipeline = UniDiffuserPipeline( + vae=vae, + text_encoder=text_encoder, + image_encoder=image_encoder, + clip_image_processor=image_processor, + clip_tokenizer=clip_tokenizer, + text_decoder=text_decoder, + text_tokenizer=text_tokenizer, + unet=unet, + scheduler=scheduler, + ) + pipeline.save_pretrained(args.pipeline_output_path, safe_serialization=args.safe_serialization) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vae_diff_to_onnx.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vae_diff_to_onnx.py new file mode 100644 index 0000000000000000000000000000000000000000..e023e04b94973f26ff6a93b6fa3e2b7b3661b829 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vae_diff_to_onnx.py @@ -0,0 +1,122 @@ +# Copyright 2022 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +from pathlib import Path + +import torch +from packaging import version +from torch.onnx import export + +from diffusers import AutoencoderKL + + +is_torch_less_than_1_11 = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") + + +def onnx_export( + model, + model_args: tuple, + output_path: Path, + ordered_input_names, + output_names, + dynamic_axes, + opset, + use_external_data_format=False, +): + output_path.parent.mkdir(parents=True, exist_ok=True) + # PyTorch deprecated the `enable_onnx_checker` and `use_external_data_format` arguments in v1.11, + # so we check the torch version for backwards compatibility + if is_torch_less_than_1_11: + export( + model, + model_args, + f=output_path.as_posix(), + input_names=ordered_input_names, + output_names=output_names, + dynamic_axes=dynamic_axes, + do_constant_folding=True, + use_external_data_format=use_external_data_format, + enable_onnx_checker=True, + opset_version=opset, + ) + else: + export( + model, + model_args, + f=output_path.as_posix(), + input_names=ordered_input_names, + output_names=output_names, + dynamic_axes=dynamic_axes, + do_constant_folding=True, + opset_version=opset, + ) + + +@torch.no_grad() +def convert_models(model_path: str, output_path: str, opset: int, fp16: bool = False): + dtype = torch.float16 if fp16 else torch.float32 + if fp16 and torch.cuda.is_available(): + device = "cuda" + elif fp16 and not torch.cuda.is_available(): + raise ValueError("`float16` model export is only supported on GPUs with CUDA") + else: + device = "cpu" + output_path = Path(output_path) + + # VAE DECODER + vae_decoder = AutoencoderKL.from_pretrained(model_path + "/vae") + vae_latent_channels = vae_decoder.config.latent_channels + # forward only through the decoder part + vae_decoder.forward = vae_decoder.decode + onnx_export( + vae_decoder, + model_args=( + torch.randn(1, vae_latent_channels, 25, 25).to(device=device, dtype=dtype), + False, + ), + output_path=output_path / "vae_decoder" / "model.onnx", + ordered_input_names=["latent_sample", "return_dict"], + output_names=["sample"], + dynamic_axes={ + "latent_sample": {0: "batch", 1: "channels", 2: "height", 3: "width"}, + }, + opset=opset, + ) + del vae_decoder + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--model_path", + type=str, + required=True, + help="Path to the `diffusers` checkpoint to convert (either a local directory or on the Hub).", + ) + + parser.add_argument("--output_path", type=str, required=True, help="Path to the output model.") + parser.add_argument( + "--opset", + default=14, + type=int, + help="The version of the ONNX operator set to use.", + ) + parser.add_argument("--fp16", action="store_true", default=False, help="Export the models in `float16` mode") + + args = parser.parse_args() + print(args.output_path) + convert_models(args.model_path, args.output_path, args.opset, args.fp16) + print("SD: Done: ONNX") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vae_pt_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vae_pt_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..8c7dc71ddfd82dc6e6aa584850ea7f9e9a31e813 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vae_pt_to_diffusers.py @@ -0,0 +1,177 @@ +import argparse +import io + +import requests +import torch +import yaml + +from diffusers import AutoencoderKL +from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( + assign_to_checkpoint, + conv_attn_to_linear, + create_vae_diffusers_config, + renew_vae_attention_paths, + renew_vae_resnet_paths, +) +from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT + + +def custom_convert_ldm_vae_checkpoint(checkpoint, config): + vae_state_dict = checkpoint + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [ + key + for key in down_blocks[i] + if f"down.{i}" in key and f"down.{i}.downsample" not in key and "attn" not in key + ] + attentions = [key for key in down_blocks[i] if f"down.{i}.attn" in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + paths = renew_vae_attention_paths(attentions) + meta_path = {"old": f"down.{i}.attn", "new": f"down_blocks.{i}.attentions"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key + for key in up_blocks[block_id] + if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key and "attn" not in key + ] + attentions = [key for key in up_blocks[block_id] if f"up.{block_id}.attn" in key] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + paths = renew_vae_attention_paths(attentions) + meta_path = {"old": f"up.{block_id}.attn", "new": f"up_blocks.{i}.attentions"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint + + +def vae_pt_to_vae_diffuser( + checkpoint_path: str, + output_path: str, +): + # Only support V1 + r = requests.get( + " https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml", + timeout=DIFFUSERS_REQUEST_TIMEOUT, + ) + io_obj = io.BytesIO(r.content) + + original_config = yaml.safe_load(io_obj) + image_size = 512 + device = "cuda" if torch.cuda.is_available() else "cpu" + if checkpoint_path.endswith("safetensors"): + from safetensors import safe_open + + checkpoint = {} + with safe_open(checkpoint_path, framework="pt", device="cpu") as f: + for key in f.keys(): + checkpoint[key] = f.get_tensor(key) + else: + checkpoint = torch.load(checkpoint_path, map_location=device)["state_dict"] + + # Convert the VAE model. + vae_config = create_vae_diffusers_config(original_config, image_size=image_size) + converted_vae_checkpoint = custom_convert_ldm_vae_checkpoint(checkpoint, vae_config) + + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_checkpoint) + vae.save_pretrained(output_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--vae_pt_path", default=None, type=str, required=True, help="Path to the VAE.pt to convert.") + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the VAE.pt to convert.") + + args = parser.parse_args() + + vae_pt_to_vae_diffuser(args.vae_pt_path, args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_versatile_diffusion_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_versatile_diffusion_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..ce68bb4c2e8ca1a93ca0d2157d2c81ede69258e8 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_versatile_diffusion_to_diffusers.py @@ -0,0 +1,791 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Conversion script for the Versatile Stable Diffusion checkpoints.""" + +import argparse +from argparse import Namespace + +import torch +from transformers import ( + CLIPImageProcessor, + CLIPTextModelWithProjection, + CLIPTokenizer, + CLIPVisionModelWithProjection, +) + +from diffusers import ( + AutoencoderKL, + DDIMScheduler, + DPMSolverMultistepScheduler, + EulerAncestralDiscreteScheduler, + EulerDiscreteScheduler, + LMSDiscreteScheduler, + PNDMScheduler, + UNet2DConditionModel, + VersatileDiffusionPipeline, +) +from diffusers.pipelines.versatile_diffusion.modeling_text_unet import UNetFlatConditionModel + + +SCHEDULER_CONFIG = Namespace( + **{ + "beta_linear_start": 0.00085, + "beta_linear_end": 0.012, + "timesteps": 1000, + "scale_factor": 0.18215, + } +) + +IMAGE_UNET_CONFIG = Namespace( + **{ + "input_channels": 4, + "model_channels": 320, + "output_channels": 4, + "num_noattn_blocks": [2, 2, 2, 2], + "channel_mult": [1, 2, 4, 4], + "with_attn": [True, True, True, False], + "num_heads": 8, + "context_dim": 768, + "use_checkpoint": True, + } +) + +TEXT_UNET_CONFIG = Namespace( + **{ + "input_channels": 768, + "model_channels": 320, + "output_channels": 768, + "num_noattn_blocks": [2, 2, 2, 2], + "channel_mult": [1, 2, 4, 4], + "second_dim": [4, 4, 4, 4], + "with_attn": [True, True, True, False], + "num_heads": 8, + "context_dim": 768, + "use_checkpoint": True, + } +) + +AUTOENCODER_CONFIG = Namespace( + **{ + "double_z": True, + "z_channels": 4, + "resolution": 256, + "in_channels": 3, + "out_ch": 3, + "ch": 128, + "ch_mult": [1, 2, 4, 4], + "num_res_blocks": 2, + "attn_resolutions": [], + "dropout": 0.0, + } +) + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "query.weight") + new_item = new_item.replace("q.bias", "query.bias") + + new_item = new_item.replace("k.weight", "key.weight") + new_item = new_item.replace("k.bias", "key.bias") + + new_item = new_item.replace("v.weight", "value.weight") + new_item = new_item.replace("v.bias", "value.bias") + + new_item = new_item.replace("proj_out.weight", "proj_attn.weight") + new_item = new_item.replace("proj_out.bias", "proj_attn.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming + to them. It splits attention layers, and takes into account additional replacements + that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + if "proj_attn.weight" in new_path: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + elif path["old"] in old_checkpoint: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["query.weight", "key.weight", "value.weight"] + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0, 0] + elif "proj_attn.weight" in key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0] + + +def create_image_unet_diffusers_config(unet_params): + """ + Creates a config for the diffusers based on the config of the VD model. + """ + + block_out_channels = [unet_params.model_channels * mult for mult in unet_params.channel_mult] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlock2D" if unet_params.with_attn[i] else "DownBlock2D" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlock2D" if unet_params.with_attn[-i - 1] else "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + if not all(n == unet_params.num_noattn_blocks[0] for n in unet_params.num_noattn_blocks): + raise ValueError("Not all num_res_blocks are equal, which is not supported in this script.") + + config = { + "sample_size": None, + "in_channels": unet_params.input_channels, + "out_channels": unet_params.output_channels, + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params.num_noattn_blocks[0], + "cross_attention_dim": unet_params.context_dim, + "attention_head_dim": unet_params.num_heads, + } + + return config + + +def create_text_unet_diffusers_config(unet_params): + """ + Creates a config for the diffusers based on the config of the VD model. + """ + + block_out_channels = [unet_params.model_channels * mult for mult in unet_params.channel_mult] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlockFlat" if unet_params.with_attn[i] else "DownBlockFlat" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlockFlat" if unet_params.with_attn[-i - 1] else "UpBlockFlat" + up_block_types.append(block_type) + resolution //= 2 + + if not all(n == unet_params.num_noattn_blocks[0] for n in unet_params.num_noattn_blocks): + raise ValueError("Not all num_res_blocks are equal, which is not supported in this script.") + + config = { + "sample_size": None, + "in_channels": (unet_params.input_channels, 1, 1), + "out_channels": (unet_params.output_channels, 1, 1), + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params.num_noattn_blocks[0], + "cross_attention_dim": unet_params.context_dim, + "attention_head_dim": unet_params.num_heads, + } + + return config + + +def create_vae_diffusers_config(vae_params): + """ + Creates a config for the diffusers based on the config of the VD model. + """ + + block_out_channels = [vae_params.ch * mult for mult in vae_params.ch_mult] + down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) + up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) + + config = { + "sample_size": vae_params.resolution, + "in_channels": vae_params.in_channels, + "out_channels": vae_params.out_ch, + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "latent_channels": vae_params.z_channels, + "layers_per_block": vae_params.num_res_blocks, + } + return config + + +def create_diffusers_scheduler(original_config): + schedular = DDIMScheduler( + num_train_timesteps=original_config.model.params.timesteps, + beta_start=original_config.model.params.linear_start, + beta_end=original_config.model.params.linear_end, + beta_schedule="scaled_linear", + ) + return schedular + + +def convert_vd_unet_checkpoint(checkpoint, config, unet_key, extract_ema=False): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100: + print("Checkpoint has both EMA and non-EMA weights.") + if extract_ema: + print( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(flat_ema_key) + else: + print( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = checkpoint.pop(key) + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = checkpoint["model.diffusion_model.time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = checkpoint["model.diffusion_model.time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = checkpoint["model.diffusion_model.time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = checkpoint["model.diffusion_model.time_embed.2.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + elif f"input_blocks.{i}.0.weight" in unet_state_dict: + # text_unet uses linear layers in place of downsamplers + shape = unet_state_dict[f"input_blocks.{i}.0.weight"].shape + if shape[0] != shape[1]: + continue + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if ["conv.weight", "conv.bias"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.weight", "conv.bias"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + elif f"output_blocks.{i}.1.weight" in unet_state_dict: + # text_unet uses linear layers in place of upsamplers + shape = unet_state_dict[f"output_blocks.{i}.1.weight"].shape + if shape[0] != shape[1]: + continue + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.weight"] = unet_state_dict.pop( + f"output_blocks.{i}.1.weight" + ) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.bias"] = unet_state_dict.pop( + f"output_blocks.{i}.1.bias" + ) + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + elif f"output_blocks.{i}.2.weight" in unet_state_dict: + # text_unet uses linear layers in place of upsamplers + shape = unet_state_dict[f"output_blocks.{i}.2.weight"].shape + if shape[0] != shape[1]: + continue + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.weight"] = unet_state_dict.pop( + f"output_blocks.{i}.2.weight" + ) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.bias"] = unet_state_dict.pop( + f"output_blocks.{i}.2.bias" + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + return new_checkpoint + + +def convert_vd_vae_checkpoint(checkpoint, config): + # extract state dict for VAE + vae_state_dict = {} + keys = list(checkpoint.keys()) + for key in keys: + vae_state_dict[key] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--unet_checkpoint_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--vae_checkpoint_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--optimus_checkpoint_path", default=None, type=str, required=False, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--scheduler_type", + default="pndm", + type=str, + help="Type of scheduler to use. Should be one of ['pndm', 'lms', 'ddim', 'euler', 'euler-ancestral', 'dpm']", + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + args = parser.parse_args() + + scheduler_config = SCHEDULER_CONFIG + + num_train_timesteps = scheduler_config.timesteps + beta_start = scheduler_config.beta_linear_start + beta_end = scheduler_config.beta_linear_end + if args.scheduler_type == "pndm": + scheduler = PNDMScheduler( + beta_end=beta_end, + beta_schedule="scaled_linear", + beta_start=beta_start, + num_train_timesteps=num_train_timesteps, + skip_prk_steps=True, + steps_offset=1, + ) + elif args.scheduler_type == "lms": + scheduler = LMSDiscreteScheduler(beta_start=beta_start, beta_end=beta_end, beta_schedule="scaled_linear") + elif args.scheduler_type == "euler": + scheduler = EulerDiscreteScheduler(beta_start=beta_start, beta_end=beta_end, beta_schedule="scaled_linear") + elif args.scheduler_type == "euler-ancestral": + scheduler = EulerAncestralDiscreteScheduler( + beta_start=beta_start, beta_end=beta_end, beta_schedule="scaled_linear" + ) + elif args.scheduler_type == "dpm": + scheduler = DPMSolverMultistepScheduler( + beta_start=beta_start, beta_end=beta_end, beta_schedule="scaled_linear" + ) + elif args.scheduler_type == "ddim": + scheduler = DDIMScheduler( + beta_start=beta_start, + beta_end=beta_end, + beta_schedule="scaled_linear", + clip_sample=False, + set_alpha_to_one=False, + steps_offset=1, + ) + else: + raise ValueError(f"Scheduler of type {args.scheduler_type} doesn't exist!") + + # Convert the UNet2DConditionModel models. + if args.unet_checkpoint_path is not None: + # image UNet + image_unet_config = create_image_unet_diffusers_config(IMAGE_UNET_CONFIG) + checkpoint = torch.load(args.unet_checkpoint_path) + converted_image_unet_checkpoint = convert_vd_unet_checkpoint( + checkpoint, image_unet_config, unet_key="model.diffusion_model.unet_image.", extract_ema=args.extract_ema + ) + image_unet = UNet2DConditionModel(**image_unet_config) + image_unet.load_state_dict(converted_image_unet_checkpoint) + + # text UNet + text_unet_config = create_text_unet_diffusers_config(TEXT_UNET_CONFIG) + converted_text_unet_checkpoint = convert_vd_unet_checkpoint( + checkpoint, text_unet_config, unet_key="model.diffusion_model.unet_text.", extract_ema=args.extract_ema + ) + text_unet = UNetFlatConditionModel(**text_unet_config) + text_unet.load_state_dict(converted_text_unet_checkpoint) + + # Convert the VAE model. + if args.vae_checkpoint_path is not None: + vae_config = create_vae_diffusers_config(AUTOENCODER_CONFIG) + checkpoint = torch.load(args.vae_checkpoint_path) + converted_vae_checkpoint = convert_vd_vae_checkpoint(checkpoint, vae_config) + + vae = AutoencoderKL(**vae_config) + vae.load_state_dict(converted_vae_checkpoint) + + tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14") + image_feature_extractor = CLIPImageProcessor.from_pretrained("openai/clip-vit-large-patch14") + text_encoder = CLIPTextModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") + image_encoder = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-large-patch14") + + pipe = VersatileDiffusionPipeline( + scheduler=scheduler, + tokenizer=tokenizer, + image_feature_extractor=image_feature_extractor, + text_encoder=text_encoder, + image_encoder=image_encoder, + image_unet=image_unet, + text_unet=text_unet, + vae=vae, + ) + pipe.save_pretrained(args.dump_path) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vq_diffusion_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vq_diffusion_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..fe62d18faff01e5f1815b049a8d98330b72b739b --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_vq_diffusion_to_diffusers.py @@ -0,0 +1,916 @@ +""" +This script ports models from VQ-diffusion (https://github.com/microsoft/VQ-Diffusion) to diffusers. + +It currently only supports porting the ITHQ dataset. + +ITHQ dataset: +```sh +# From the root directory of diffusers. + +# Download the VQVAE checkpoint +$ wget https://facevcstandard.blob.core.windows.net/v-zhictang/Improved-VQ-Diffusion_model_release/ithq_vqvae.pth?sv=2020-10-02&st=2022-05-30T15%3A17%3A18Z&se=2030-05-31T15%3A17%3A00Z&sr=b&sp=r&sig=1jVavHFPpUjDs%2FTO1V3PTezaNbPp2Nx8MxiWI7y6fEY%3D -O ithq_vqvae.pth + +# Download the VQVAE config +# NOTE that in VQ-diffusion the documented file is `configs/ithq.yaml` but the target class +# `image_synthesis.modeling.codecs.image_codec.ema_vqvae.PatchVQVAE` +# loads `OUTPUT/pretrained_model/taming_dvae/config.yaml` +$ wget https://raw.githubusercontent.com/microsoft/VQ-Diffusion/main/OUTPUT/pretrained_model/taming_dvae/config.yaml -O ithq_vqvae.yaml + +# Download the main model checkpoint +$ wget https://facevcstandard.blob.core.windows.net/v-zhictang/Improved-VQ-Diffusion_model_release/ithq_learnable.pth?sv=2020-10-02&st=2022-05-30T10%3A22%3A06Z&se=2030-05-31T10%3A22%3A00Z&sr=b&sp=r&sig=GOE%2Bza02%2FPnGxYVOOPtwrTR4RA3%2F5NVgMxdW4kjaEZ8%3D -O ithq_learnable.pth + +# Download the main model config +$ wget https://raw.githubusercontent.com/microsoft/VQ-Diffusion/main/configs/ithq.yaml -O ithq.yaml + +# run the convert script +$ python ./scripts/convert_vq_diffusion_to_diffusers.py \ + --checkpoint_path ./ithq_learnable.pth \ + --original_config_file ./ithq.yaml \ + --vqvae_checkpoint_path ./ithq_vqvae.pth \ + --vqvae_original_config_file ./ithq_vqvae.yaml \ + --dump_path +``` +""" + +import argparse +import tempfile + +import torch +import yaml +from accelerate import init_empty_weights, load_checkpoint_and_dispatch +from transformers import CLIPTextModel, CLIPTokenizer +from yaml.loader import FullLoader + +from diffusers import Transformer2DModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel +from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings + + +# vqvae model + +PORTED_VQVAES = ["image_synthesis.modeling.codecs.image_codec.patch_vqgan.PatchVQGAN"] + + +def vqvae_model_from_original_config(original_config): + assert original_config["target"] in PORTED_VQVAES, ( + f"{original_config['target']} has not yet been ported to diffusers." + ) + + original_config = original_config["params"] + + original_encoder_config = original_config["encoder_config"]["params"] + original_decoder_config = original_config["decoder_config"]["params"] + + in_channels = original_encoder_config["in_channels"] + out_channels = original_decoder_config["out_ch"] + + down_block_types = get_down_block_types(original_encoder_config) + up_block_types = get_up_block_types(original_decoder_config) + + assert original_encoder_config["ch"] == original_decoder_config["ch"] + assert original_encoder_config["ch_mult"] == original_decoder_config["ch_mult"] + block_out_channels = tuple( + [original_encoder_config["ch"] * a_ch_mult for a_ch_mult in original_encoder_config["ch_mult"]] + ) + + assert original_encoder_config["num_res_blocks"] == original_decoder_config["num_res_blocks"] + layers_per_block = original_encoder_config["num_res_blocks"] + + assert original_encoder_config["z_channels"] == original_decoder_config["z_channels"] + latent_channels = original_encoder_config["z_channels"] + + num_vq_embeddings = original_config["n_embed"] + + # Hard coded value for ResnetBlock.GoupNorm(num_groups) in VQ-diffusion + norm_num_groups = 32 + + e_dim = original_config["embed_dim"] + + model = VQModel( + in_channels=in_channels, + out_channels=out_channels, + down_block_types=down_block_types, + up_block_types=up_block_types, + block_out_channels=block_out_channels, + layers_per_block=layers_per_block, + latent_channels=latent_channels, + num_vq_embeddings=num_vq_embeddings, + norm_num_groups=norm_num_groups, + vq_embed_dim=e_dim, + ) + + return model + + +def get_down_block_types(original_encoder_config): + attn_resolutions = coerce_attn_resolutions(original_encoder_config["attn_resolutions"]) + num_resolutions = len(original_encoder_config["ch_mult"]) + resolution = coerce_resolution(original_encoder_config["resolution"]) + + curr_res = resolution + down_block_types = [] + + for _ in range(num_resolutions): + if curr_res in attn_resolutions: + down_block_type = "AttnDownEncoderBlock2D" + else: + down_block_type = "DownEncoderBlock2D" + + down_block_types.append(down_block_type) + + curr_res = [r // 2 for r in curr_res] + + return down_block_types + + +def get_up_block_types(original_decoder_config): + attn_resolutions = coerce_attn_resolutions(original_decoder_config["attn_resolutions"]) + num_resolutions = len(original_decoder_config["ch_mult"]) + resolution = coerce_resolution(original_decoder_config["resolution"]) + + curr_res = [r // 2 ** (num_resolutions - 1) for r in resolution] + up_block_types = [] + + for _ in reversed(range(num_resolutions)): + if curr_res in attn_resolutions: + up_block_type = "AttnUpDecoderBlock2D" + else: + up_block_type = "UpDecoderBlock2D" + + up_block_types.append(up_block_type) + + curr_res = [r * 2 for r in curr_res] + + return up_block_types + + +def coerce_attn_resolutions(attn_resolutions): + attn_resolutions = list(attn_resolutions) + attn_resolutions_ = [] + for ar in attn_resolutions: + if isinstance(ar, (list, tuple)): + attn_resolutions_.append(list(ar)) + else: + attn_resolutions_.append([ar, ar]) + return attn_resolutions_ + + +def coerce_resolution(resolution): + if isinstance(resolution, int): + resolution = [resolution, resolution] # H, W + elif isinstance(resolution, (tuple, list)): + resolution = list(resolution) + else: + raise ValueError("Unknown type of resolution:", resolution) + return resolution + + +# done vqvae model + +# vqvae checkpoint + + +def vqvae_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + diffusers_checkpoint.update(vqvae_encoder_to_diffusers_checkpoint(model, checkpoint)) + + # quant_conv + + diffusers_checkpoint.update( + { + "quant_conv.weight": checkpoint["quant_conv.weight"], + "quant_conv.bias": checkpoint["quant_conv.bias"], + } + ) + + # quantize + diffusers_checkpoint.update({"quantize.embedding.weight": checkpoint["quantize.embedding"]}) + + # post_quant_conv + diffusers_checkpoint.update( + { + "post_quant_conv.weight": checkpoint["post_quant_conv.weight"], + "post_quant_conv.bias": checkpoint["post_quant_conv.bias"], + } + ) + + # decoder + diffusers_checkpoint.update(vqvae_decoder_to_diffusers_checkpoint(model, checkpoint)) + + return diffusers_checkpoint + + +def vqvae_encoder_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # conv_in + diffusers_checkpoint.update( + { + "encoder.conv_in.weight": checkpoint["encoder.conv_in.weight"], + "encoder.conv_in.bias": checkpoint["encoder.conv_in.bias"], + } + ) + + # down_blocks + for down_block_idx, down_block in enumerate(model.encoder.down_blocks): + diffusers_down_block_prefix = f"encoder.down_blocks.{down_block_idx}" + down_block_prefix = f"encoder.down.{down_block_idx}" + + # resnets + for resnet_idx, resnet in enumerate(down_block.resnets): + diffusers_resnet_prefix = f"{diffusers_down_block_prefix}.resnets.{resnet_idx}" + resnet_prefix = f"{down_block_prefix}.block.{resnet_idx}" + + diffusers_checkpoint.update( + vqvae_resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + # downsample + + # do not include the downsample when on the last down block + # There is no downsample on the last down block + if down_block_idx != len(model.encoder.down_blocks) - 1: + # There's a single downsample in the original checkpoint but a list of downsamples + # in the diffusers model. + diffusers_downsample_prefix = f"{diffusers_down_block_prefix}.downsamplers.0.conv" + downsample_prefix = f"{down_block_prefix}.downsample.conv" + diffusers_checkpoint.update( + { + f"{diffusers_downsample_prefix}.weight": checkpoint[f"{downsample_prefix}.weight"], + f"{diffusers_downsample_prefix}.bias": checkpoint[f"{downsample_prefix}.bias"], + } + ) + + # attentions + + if hasattr(down_block, "attentions"): + for attention_idx, _ in enumerate(down_block.attentions): + diffusers_attention_prefix = f"{diffusers_down_block_prefix}.attentions.{attention_idx}" + attention_prefix = f"{down_block_prefix}.attn.{attention_idx}" + diffusers_checkpoint.update( + vqvae_attention_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + attention_prefix=attention_prefix, + ) + ) + + # mid block + + # mid block attentions + + # There is a single hardcoded attention block in the middle of the VQ-diffusion encoder + diffusers_attention_prefix = "encoder.mid_block.attentions.0" + attention_prefix = "encoder.mid.attn_1" + diffusers_checkpoint.update( + vqvae_attention_to_diffusers_checkpoint( + checkpoint, diffusers_attention_prefix=diffusers_attention_prefix, attention_prefix=attention_prefix + ) + ) + + # mid block resnets + + for diffusers_resnet_idx, resnet in enumerate(model.encoder.mid_block.resnets): + diffusers_resnet_prefix = f"encoder.mid_block.resnets.{diffusers_resnet_idx}" + + # the hardcoded prefixes to `block_` are 1 and 2 + orig_resnet_idx = diffusers_resnet_idx + 1 + # There are two hardcoded resnets in the middle of the VQ-diffusion encoder + resnet_prefix = f"encoder.mid.block_{orig_resnet_idx}" + + diffusers_checkpoint.update( + vqvae_resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + diffusers_checkpoint.update( + { + # conv_norm_out + "encoder.conv_norm_out.weight": checkpoint["encoder.norm_out.weight"], + "encoder.conv_norm_out.bias": checkpoint["encoder.norm_out.bias"], + # conv_out + "encoder.conv_out.weight": checkpoint["encoder.conv_out.weight"], + "encoder.conv_out.bias": checkpoint["encoder.conv_out.bias"], + } + ) + + return diffusers_checkpoint + + +def vqvae_decoder_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + # conv in + diffusers_checkpoint.update( + { + "decoder.conv_in.weight": checkpoint["decoder.conv_in.weight"], + "decoder.conv_in.bias": checkpoint["decoder.conv_in.bias"], + } + ) + + # up_blocks + + for diffusers_up_block_idx, up_block in enumerate(model.decoder.up_blocks): + # up_blocks are stored in reverse order in the VQ-diffusion checkpoint + orig_up_block_idx = len(model.decoder.up_blocks) - 1 - diffusers_up_block_idx + + diffusers_up_block_prefix = f"decoder.up_blocks.{diffusers_up_block_idx}" + up_block_prefix = f"decoder.up.{orig_up_block_idx}" + + # resnets + for resnet_idx, resnet in enumerate(up_block.resnets): + diffusers_resnet_prefix = f"{diffusers_up_block_prefix}.resnets.{resnet_idx}" + resnet_prefix = f"{up_block_prefix}.block.{resnet_idx}" + + diffusers_checkpoint.update( + vqvae_resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + # upsample + + # there is no up sample on the last up block + if diffusers_up_block_idx != len(model.decoder.up_blocks) - 1: + # There's a single upsample in the VQ-diffusion checkpoint but a list of downsamples + # in the diffusers model. + diffusers_downsample_prefix = f"{diffusers_up_block_prefix}.upsamplers.0.conv" + downsample_prefix = f"{up_block_prefix}.upsample.conv" + diffusers_checkpoint.update( + { + f"{diffusers_downsample_prefix}.weight": checkpoint[f"{downsample_prefix}.weight"], + f"{diffusers_downsample_prefix}.bias": checkpoint[f"{downsample_prefix}.bias"], + } + ) + + # attentions + + if hasattr(up_block, "attentions"): + for attention_idx, _ in enumerate(up_block.attentions): + diffusers_attention_prefix = f"{diffusers_up_block_prefix}.attentions.{attention_idx}" + attention_prefix = f"{up_block_prefix}.attn.{attention_idx}" + diffusers_checkpoint.update( + vqvae_attention_to_diffusers_checkpoint( + checkpoint, + diffusers_attention_prefix=diffusers_attention_prefix, + attention_prefix=attention_prefix, + ) + ) + + # mid block + + # mid block attentions + + # There is a single hardcoded attention block in the middle of the VQ-diffusion decoder + diffusers_attention_prefix = "decoder.mid_block.attentions.0" + attention_prefix = "decoder.mid.attn_1" + diffusers_checkpoint.update( + vqvae_attention_to_diffusers_checkpoint( + checkpoint, diffusers_attention_prefix=diffusers_attention_prefix, attention_prefix=attention_prefix + ) + ) + + # mid block resnets + + for diffusers_resnet_idx, resnet in enumerate(model.encoder.mid_block.resnets): + diffusers_resnet_prefix = f"decoder.mid_block.resnets.{diffusers_resnet_idx}" + + # the hardcoded prefixes to `block_` are 1 and 2 + orig_resnet_idx = diffusers_resnet_idx + 1 + # There are two hardcoded resnets in the middle of the VQ-diffusion decoder + resnet_prefix = f"decoder.mid.block_{orig_resnet_idx}" + + diffusers_checkpoint.update( + vqvae_resnet_to_diffusers_checkpoint( + resnet, checkpoint, diffusers_resnet_prefix=diffusers_resnet_prefix, resnet_prefix=resnet_prefix + ) + ) + + diffusers_checkpoint.update( + { + # conv_norm_out + "decoder.conv_norm_out.weight": checkpoint["decoder.norm_out.weight"], + "decoder.conv_norm_out.bias": checkpoint["decoder.norm_out.bias"], + # conv_out + "decoder.conv_out.weight": checkpoint["decoder.conv_out.weight"], + "decoder.conv_out.bias": checkpoint["decoder.conv_out.bias"], + } + ) + + return diffusers_checkpoint + + +def vqvae_resnet_to_diffusers_checkpoint(resnet, checkpoint, *, diffusers_resnet_prefix, resnet_prefix): + rv = { + # norm1 + f"{diffusers_resnet_prefix}.norm1.weight": checkpoint[f"{resnet_prefix}.norm1.weight"], + f"{diffusers_resnet_prefix}.norm1.bias": checkpoint[f"{resnet_prefix}.norm1.bias"], + # conv1 + f"{diffusers_resnet_prefix}.conv1.weight": checkpoint[f"{resnet_prefix}.conv1.weight"], + f"{diffusers_resnet_prefix}.conv1.bias": checkpoint[f"{resnet_prefix}.conv1.bias"], + # norm2 + f"{diffusers_resnet_prefix}.norm2.weight": checkpoint[f"{resnet_prefix}.norm2.weight"], + f"{diffusers_resnet_prefix}.norm2.bias": checkpoint[f"{resnet_prefix}.norm2.bias"], + # conv2 + f"{diffusers_resnet_prefix}.conv2.weight": checkpoint[f"{resnet_prefix}.conv2.weight"], + f"{diffusers_resnet_prefix}.conv2.bias": checkpoint[f"{resnet_prefix}.conv2.bias"], + } + + if resnet.conv_shortcut is not None: + rv.update( + { + f"{diffusers_resnet_prefix}.conv_shortcut.weight": checkpoint[f"{resnet_prefix}.nin_shortcut.weight"], + f"{diffusers_resnet_prefix}.conv_shortcut.bias": checkpoint[f"{resnet_prefix}.nin_shortcut.bias"], + } + ) + + return rv + + +def vqvae_attention_to_diffusers_checkpoint(checkpoint, *, diffusers_attention_prefix, attention_prefix): + return { + # group_norm + f"{diffusers_attention_prefix}.group_norm.weight": checkpoint[f"{attention_prefix}.norm.weight"], + f"{diffusers_attention_prefix}.group_norm.bias": checkpoint[f"{attention_prefix}.norm.bias"], + # query + f"{diffusers_attention_prefix}.query.weight": checkpoint[f"{attention_prefix}.q.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.query.bias": checkpoint[f"{attention_prefix}.q.bias"], + # key + f"{diffusers_attention_prefix}.key.weight": checkpoint[f"{attention_prefix}.k.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.key.bias": checkpoint[f"{attention_prefix}.k.bias"], + # value + f"{diffusers_attention_prefix}.value.weight": checkpoint[f"{attention_prefix}.v.weight"][:, :, 0, 0], + f"{diffusers_attention_prefix}.value.bias": checkpoint[f"{attention_prefix}.v.bias"], + # proj_attn + f"{diffusers_attention_prefix}.proj_attn.weight": checkpoint[f"{attention_prefix}.proj_out.weight"][ + :, :, 0, 0 + ], + f"{diffusers_attention_prefix}.proj_attn.bias": checkpoint[f"{attention_prefix}.proj_out.bias"], + } + + +# done vqvae checkpoint + +# transformer model + +PORTED_DIFFUSIONS = ["image_synthesis.modeling.transformers.diffusion_transformer.DiffusionTransformer"] +PORTED_TRANSFORMERS = ["image_synthesis.modeling.transformers.transformer_utils.Text2ImageTransformer"] +PORTED_CONTENT_EMBEDDINGS = ["image_synthesis.modeling.embeddings.dalle_mask_image_embedding.DalleMaskImageEmbedding"] + + +def transformer_model_from_original_config( + original_diffusion_config, original_transformer_config, original_content_embedding_config +): + assert original_diffusion_config["target"] in PORTED_DIFFUSIONS, ( + f"{original_diffusion_config['target']} has not yet been ported to diffusers." + ) + assert original_transformer_config["target"] in PORTED_TRANSFORMERS, ( + f"{original_transformer_config['target']} has not yet been ported to diffusers." + ) + assert original_content_embedding_config["target"] in PORTED_CONTENT_EMBEDDINGS, ( + f"{original_content_embedding_config['target']} has not yet been ported to diffusers." + ) + + original_diffusion_config = original_diffusion_config["params"] + original_transformer_config = original_transformer_config["params"] + original_content_embedding_config = original_content_embedding_config["params"] + + inner_dim = original_transformer_config["n_embd"] + + n_heads = original_transformer_config["n_head"] + + # VQ-Diffusion gives dimension of the multi-headed attention layers as the + # number of attention heads times the sequence length (the dimension) of a + # single head. We want to specify our attention blocks with those values + # specified separately + assert inner_dim % n_heads == 0 + d_head = inner_dim // n_heads + + depth = original_transformer_config["n_layer"] + context_dim = original_transformer_config["condition_dim"] + + num_embed = original_content_embedding_config["num_embed"] + # the number of embeddings in the transformer includes the mask embedding. + # the content embedding (the vqvae) does not include the mask embedding. + num_embed = num_embed + 1 + + height = original_transformer_config["content_spatial_size"][0] + width = original_transformer_config["content_spatial_size"][1] + + assert width == height, "width has to be equal to height" + dropout = original_transformer_config["resid_pdrop"] + num_embeds_ada_norm = original_diffusion_config["diffusion_step"] + + model_kwargs = { + "attention_bias": True, + "cross_attention_dim": context_dim, + "attention_head_dim": d_head, + "num_layers": depth, + "dropout": dropout, + "num_attention_heads": n_heads, + "num_vector_embeds": num_embed, + "num_embeds_ada_norm": num_embeds_ada_norm, + "norm_num_groups": 32, + "sample_size": width, + "activation_fn": "geglu-approximate", + } + + model = Transformer2DModel(**model_kwargs) + return model + + +# done transformer model + +# transformer checkpoint + + +def transformer_original_checkpoint_to_diffusers_checkpoint(model, checkpoint): + diffusers_checkpoint = {} + + transformer_prefix = "transformer.transformer" + + diffusers_latent_image_embedding_prefix = "latent_image_embedding" + latent_image_embedding_prefix = f"{transformer_prefix}.content_emb" + + # DalleMaskImageEmbedding + diffusers_checkpoint.update( + { + f"{diffusers_latent_image_embedding_prefix}.emb.weight": checkpoint[ + f"{latent_image_embedding_prefix}.emb.weight" + ], + f"{diffusers_latent_image_embedding_prefix}.height_emb.weight": checkpoint[ + f"{latent_image_embedding_prefix}.height_emb.weight" + ], + f"{diffusers_latent_image_embedding_prefix}.width_emb.weight": checkpoint[ + f"{latent_image_embedding_prefix}.width_emb.weight" + ], + } + ) + + # transformer blocks + for transformer_block_idx, transformer_block in enumerate(model.transformer_blocks): + diffusers_transformer_block_prefix = f"transformer_blocks.{transformer_block_idx}" + transformer_block_prefix = f"{transformer_prefix}.blocks.{transformer_block_idx}" + + # ada norm block + diffusers_ada_norm_prefix = f"{diffusers_transformer_block_prefix}.norm1" + ada_norm_prefix = f"{transformer_block_prefix}.ln1" + + diffusers_checkpoint.update( + transformer_ada_norm_to_diffusers_checkpoint( + checkpoint, diffusers_ada_norm_prefix=diffusers_ada_norm_prefix, ada_norm_prefix=ada_norm_prefix + ) + ) + + # attention block + diffusers_attention_prefix = f"{diffusers_transformer_block_prefix}.attn1" + attention_prefix = f"{transformer_block_prefix}.attn1" + + diffusers_checkpoint.update( + transformer_attention_to_diffusers_checkpoint( + checkpoint, diffusers_attention_prefix=diffusers_attention_prefix, attention_prefix=attention_prefix + ) + ) + + # ada norm block + diffusers_ada_norm_prefix = f"{diffusers_transformer_block_prefix}.norm2" + ada_norm_prefix = f"{transformer_block_prefix}.ln1_1" + + diffusers_checkpoint.update( + transformer_ada_norm_to_diffusers_checkpoint( + checkpoint, diffusers_ada_norm_prefix=diffusers_ada_norm_prefix, ada_norm_prefix=ada_norm_prefix + ) + ) + + # attention block + diffusers_attention_prefix = f"{diffusers_transformer_block_prefix}.attn2" + attention_prefix = f"{transformer_block_prefix}.attn2" + + diffusers_checkpoint.update( + transformer_attention_to_diffusers_checkpoint( + checkpoint, diffusers_attention_prefix=diffusers_attention_prefix, attention_prefix=attention_prefix + ) + ) + + # norm block + diffusers_norm_block_prefix = f"{diffusers_transformer_block_prefix}.norm3" + norm_block_prefix = f"{transformer_block_prefix}.ln2" + + diffusers_checkpoint.update( + { + f"{diffusers_norm_block_prefix}.weight": checkpoint[f"{norm_block_prefix}.weight"], + f"{diffusers_norm_block_prefix}.bias": checkpoint[f"{norm_block_prefix}.bias"], + } + ) + + # feedforward block + diffusers_feedforward_prefix = f"{diffusers_transformer_block_prefix}.ff" + feedforward_prefix = f"{transformer_block_prefix}.mlp" + + diffusers_checkpoint.update( + transformer_feedforward_to_diffusers_checkpoint( + checkpoint, + diffusers_feedforward_prefix=diffusers_feedforward_prefix, + feedforward_prefix=feedforward_prefix, + ) + ) + + # to logits + + diffusers_norm_out_prefix = "norm_out" + norm_out_prefix = f"{transformer_prefix}.to_logits.0" + + diffusers_checkpoint.update( + { + f"{diffusers_norm_out_prefix}.weight": checkpoint[f"{norm_out_prefix}.weight"], + f"{diffusers_norm_out_prefix}.bias": checkpoint[f"{norm_out_prefix}.bias"], + } + ) + + diffusers_out_prefix = "out" + out_prefix = f"{transformer_prefix}.to_logits.1" + + diffusers_checkpoint.update( + { + f"{diffusers_out_prefix}.weight": checkpoint[f"{out_prefix}.weight"], + f"{diffusers_out_prefix}.bias": checkpoint[f"{out_prefix}.bias"], + } + ) + + return diffusers_checkpoint + + +def transformer_ada_norm_to_diffusers_checkpoint(checkpoint, *, diffusers_ada_norm_prefix, ada_norm_prefix): + return { + f"{diffusers_ada_norm_prefix}.emb.weight": checkpoint[f"{ada_norm_prefix}.emb.weight"], + f"{diffusers_ada_norm_prefix}.linear.weight": checkpoint[f"{ada_norm_prefix}.linear.weight"], + f"{diffusers_ada_norm_prefix}.linear.bias": checkpoint[f"{ada_norm_prefix}.linear.bias"], + } + + +def transformer_attention_to_diffusers_checkpoint(checkpoint, *, diffusers_attention_prefix, attention_prefix): + return { + # key + f"{diffusers_attention_prefix}.to_k.weight": checkpoint[f"{attention_prefix}.key.weight"], + f"{diffusers_attention_prefix}.to_k.bias": checkpoint[f"{attention_prefix}.key.bias"], + # query + f"{diffusers_attention_prefix}.to_q.weight": checkpoint[f"{attention_prefix}.query.weight"], + f"{diffusers_attention_prefix}.to_q.bias": checkpoint[f"{attention_prefix}.query.bias"], + # value + f"{diffusers_attention_prefix}.to_v.weight": checkpoint[f"{attention_prefix}.value.weight"], + f"{diffusers_attention_prefix}.to_v.bias": checkpoint[f"{attention_prefix}.value.bias"], + # linear out + f"{diffusers_attention_prefix}.to_out.0.weight": checkpoint[f"{attention_prefix}.proj.weight"], + f"{diffusers_attention_prefix}.to_out.0.bias": checkpoint[f"{attention_prefix}.proj.bias"], + } + + +def transformer_feedforward_to_diffusers_checkpoint(checkpoint, *, diffusers_feedforward_prefix, feedforward_prefix): + return { + f"{diffusers_feedforward_prefix}.net.0.proj.weight": checkpoint[f"{feedforward_prefix}.0.weight"], + f"{diffusers_feedforward_prefix}.net.0.proj.bias": checkpoint[f"{feedforward_prefix}.0.bias"], + f"{diffusers_feedforward_prefix}.net.2.weight": checkpoint[f"{feedforward_prefix}.2.weight"], + f"{diffusers_feedforward_prefix}.net.2.bias": checkpoint[f"{feedforward_prefix}.2.bias"], + } + + +# done transformer checkpoint + + +def read_config_file(filename): + # The yaml file contains annotations that certain values should + # loaded as tuples. + with open(filename) as f: + original_config = yaml.load(f, FullLoader) + + return original_config + + +# We take separate arguments for the vqvae because the ITHQ vqvae config file +# is separate from the config file for the rest of the model. +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--vqvae_checkpoint_path", + default=None, + type=str, + required=True, + help="Path to the vqvae checkpoint to convert.", + ) + + parser.add_argument( + "--vqvae_original_config_file", + default=None, + type=str, + required=True, + help="The YAML config file corresponding to the original architecture for the vqvae.", + ) + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + + parser.add_argument( + "--original_config_file", + default=None, + type=str, + required=True, + help="The YAML config file corresponding to the original architecture.", + ) + + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + + parser.add_argument( + "--checkpoint_load_device", + default="cpu", + type=str, + required=False, + help="The device passed to `map_location` when loading checkpoints.", + ) + + # See link for how ema weights are always selected + # https://github.com/microsoft/VQ-Diffusion/blob/3c98e77f721db7c787b76304fa2c96a36c7b00af/inference_VQ_Diffusion.py#L65 + parser.add_argument( + "--no_use_ema", + action="store_true", + required=False, + help=( + "Set to not use the ema weights from the original VQ-Diffusion checkpoint. You probably do not want to set" + " it as the original VQ-Diffusion always uses the ema weights when loading models." + ), + ) + + args = parser.parse_args() + + use_ema = not args.no_use_ema + + print(f"loading checkpoints to {args.checkpoint_load_device}") + + checkpoint_map_location = torch.device(args.checkpoint_load_device) + + # vqvae_model + + print(f"loading vqvae, config: {args.vqvae_original_config_file}, checkpoint: {args.vqvae_checkpoint_path}") + + vqvae_original_config = read_config_file(args.vqvae_original_config_file).model + vqvae_checkpoint = torch.load(args.vqvae_checkpoint_path, map_location=checkpoint_map_location)["model"] + + with init_empty_weights(): + vqvae_model = vqvae_model_from_original_config(vqvae_original_config) + + vqvae_diffusers_checkpoint = vqvae_original_checkpoint_to_diffusers_checkpoint(vqvae_model, vqvae_checkpoint) + + with tempfile.NamedTemporaryFile() as vqvae_diffusers_checkpoint_file: + torch.save(vqvae_diffusers_checkpoint, vqvae_diffusers_checkpoint_file.name) + del vqvae_diffusers_checkpoint + del vqvae_checkpoint + load_checkpoint_and_dispatch(vqvae_model, vqvae_diffusers_checkpoint_file.name, device_map="auto") + + print("done loading vqvae") + + # done vqvae_model + + # transformer_model + + print( + f"loading transformer, config: {args.original_config_file}, checkpoint: {args.checkpoint_path}, use ema:" + f" {use_ema}" + ) + + original_config = read_config_file(args.original_config_file).model + + diffusion_config = original_config["params"]["diffusion_config"] + transformer_config = original_config["params"]["diffusion_config"]["params"]["transformer_config"] + content_embedding_config = original_config["params"]["diffusion_config"]["params"]["content_emb_config"] + + pre_checkpoint = torch.load(args.checkpoint_path, map_location=checkpoint_map_location) + + if use_ema: + if "ema" in pre_checkpoint: + checkpoint = {} + for k, v in pre_checkpoint["model"].items(): + checkpoint[k] = v + + for k, v in pre_checkpoint["ema"].items(): + # The ema weights are only used on the transformer. To mimic their key as if they came + # from the state_dict for the top level model, we prefix with an additional "transformer." + # See the source linked in the args.use_ema config for more information. + checkpoint[f"transformer.{k}"] = v + else: + print("attempted to load ema weights but no ema weights are specified in the loaded checkpoint.") + checkpoint = pre_checkpoint["model"] + else: + checkpoint = pre_checkpoint["model"] + + del pre_checkpoint + + with init_empty_weights(): + transformer_model = transformer_model_from_original_config( + diffusion_config, transformer_config, content_embedding_config + ) + + diffusers_transformer_checkpoint = transformer_original_checkpoint_to_diffusers_checkpoint( + transformer_model, checkpoint + ) + + # classifier free sampling embeddings interlude + + # The learned embeddings are stored on the transformer in the original VQ-diffusion. We store them on a separate + # model, so we pull them off the checkpoint before the checkpoint is deleted. + + learnable_classifier_free_sampling_embeddings = diffusion_config["params"].learnable_cf + + if learnable_classifier_free_sampling_embeddings: + learned_classifier_free_sampling_embeddings_embeddings = checkpoint["transformer.empty_text_embed"] + else: + learned_classifier_free_sampling_embeddings_embeddings = None + + # done classifier free sampling embeddings interlude + + with tempfile.NamedTemporaryFile() as diffusers_transformer_checkpoint_file: + torch.save(diffusers_transformer_checkpoint, diffusers_transformer_checkpoint_file.name) + del diffusers_transformer_checkpoint + del checkpoint + load_checkpoint_and_dispatch(transformer_model, diffusers_transformer_checkpoint_file.name, device_map="auto") + + print("done loading transformer") + + # done transformer_model + + # text encoder + + print("loading CLIP text encoder") + + clip_name = "openai/clip-vit-base-patch32" + + # The original VQ-Diffusion specifies the pad value by the int used in the + # returned tokens. Each model uses `0` as the pad value. The transformers clip api + # specifies the pad value via the token before it has been tokenized. The `!` pad + # token is the same as padding with the `0` pad value. + pad_token = "!" + + tokenizer_model = CLIPTokenizer.from_pretrained(clip_name, pad_token=pad_token, device_map="auto") + + assert tokenizer_model.convert_tokens_to_ids(pad_token) == 0 + + text_encoder_model = CLIPTextModel.from_pretrained( + clip_name, + # `CLIPTextModel` does not support device_map="auto" + # device_map="auto" + ) + + print("done loading CLIP text encoder") + + # done text encoder + + # scheduler + + scheduler_model = VQDiffusionScheduler( + # the scheduler has the same number of embeddings as the transformer + num_vec_classes=transformer_model.num_vector_embeds + ) + + # done scheduler + + # learned classifier free sampling embeddings + + with init_empty_weights(): + learned_classifier_free_sampling_embeddings_model = LearnedClassifierFreeSamplingEmbeddings( + learnable_classifier_free_sampling_embeddings, + hidden_size=text_encoder_model.config.hidden_size, + length=tokenizer_model.model_max_length, + ) + + learned_classifier_free_sampling_checkpoint = { + "embeddings": learned_classifier_free_sampling_embeddings_embeddings.float() + } + + with tempfile.NamedTemporaryFile() as learned_classifier_free_sampling_checkpoint_file: + torch.save(learned_classifier_free_sampling_checkpoint, learned_classifier_free_sampling_checkpoint_file.name) + del learned_classifier_free_sampling_checkpoint + del learned_classifier_free_sampling_embeddings_embeddings + load_checkpoint_and_dispatch( + learned_classifier_free_sampling_embeddings_model, + learned_classifier_free_sampling_checkpoint_file.name, + device_map="auto", + ) + + # done learned classifier free sampling embeddings + + print(f"saving VQ diffusion model, path: {args.dump_path}") + + pipe = VQDiffusionPipeline( + vqvae=vqvae_model, + transformer=transformer_model, + tokenizer=tokenizer_model, + text_encoder=text_encoder_model, + learned_classifier_free_sampling_embeddings=learned_classifier_free_sampling_embeddings_model, + scheduler=scheduler_model, + ) + pipe.save_pretrained(args.dump_path) + + print("done writing VQ diffusion model") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_wan_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_wan_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..06f87409262ae0ddaf748af76a1a44c38196efdf --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_wan_to_diffusers.py @@ -0,0 +1,1287 @@ +import argparse +import pathlib +from typing import Any, Dict, Tuple + +import torch +from accelerate import init_empty_weights +from huggingface_hub import hf_hub_download, snapshot_download +from safetensors.torch import load_file +from transformers import ( + AutoProcessor, + AutoTokenizer, + CLIPImageProcessor, + CLIPVisionModel, + CLIPVisionModelWithProjection, + UMT5EncoderModel, +) + +from diffusers import ( + AutoencoderKLWan, + UniPCMultistepScheduler, + WanAnimatePipeline, + WanAnimateTransformer3DModel, + WanImageToVideoPipeline, + WanPipeline, + WanTransformer3DModel, + WanVACEPipeline, + WanVACETransformer3DModel, +) + + +TRANSFORMER_KEYS_RENAME_DICT = { + "time_embedding.0": "condition_embedder.time_embedder.linear_1", + "time_embedding.2": "condition_embedder.time_embedder.linear_2", + "text_embedding.0": "condition_embedder.text_embedder.linear_1", + "text_embedding.2": "condition_embedder.text_embedder.linear_2", + "time_projection.1": "condition_embedder.time_proj", + "head.modulation": "scale_shift_table", + "head.head": "proj_out", + "modulation": "scale_shift_table", + "ffn.0": "ffn.net.0.proj", + "ffn.2": "ffn.net.2", + # Hack to swap the layer names + # The original model calls the norms in following order: norm1, norm3, norm2 + # We convert it to: norm1, norm2, norm3 + "norm2": "norm__placeholder", + "norm3": "norm2", + "norm__placeholder": "norm3", + # For the I2V model + "img_emb.proj.0": "condition_embedder.image_embedder.norm1", + "img_emb.proj.1": "condition_embedder.image_embedder.ff.net.0.proj", + "img_emb.proj.3": "condition_embedder.image_embedder.ff.net.2", + "img_emb.proj.4": "condition_embedder.image_embedder.norm2", + # for the FLF2V model + "img_emb.emb_pos": "condition_embedder.image_embedder.pos_embed", + # Add attention component mappings + "self_attn.q": "attn1.to_q", + "self_attn.k": "attn1.to_k", + "self_attn.v": "attn1.to_v", + "self_attn.o": "attn1.to_out.0", + "self_attn.norm_q": "attn1.norm_q", + "self_attn.norm_k": "attn1.norm_k", + "cross_attn.q": "attn2.to_q", + "cross_attn.k": "attn2.to_k", + "cross_attn.v": "attn2.to_v", + "cross_attn.o": "attn2.to_out.0", + "cross_attn.norm_q": "attn2.norm_q", + "cross_attn.norm_k": "attn2.norm_k", + "attn2.to_k_img": "attn2.add_k_proj", + "attn2.to_v_img": "attn2.add_v_proj", + "attn2.norm_k_img": "attn2.norm_added_k", +} + +VACE_TRANSFORMER_KEYS_RENAME_DICT = { + "time_embedding.0": "condition_embedder.time_embedder.linear_1", + "time_embedding.2": "condition_embedder.time_embedder.linear_2", + "text_embedding.0": "condition_embedder.text_embedder.linear_1", + "text_embedding.2": "condition_embedder.text_embedder.linear_2", + "time_projection.1": "condition_embedder.time_proj", + "head.modulation": "scale_shift_table", + "head.head": "proj_out", + "modulation": "scale_shift_table", + "ffn.0": "ffn.net.0.proj", + "ffn.2": "ffn.net.2", + # Hack to swap the layer names + # The original model calls the norms in following order: norm1, norm3, norm2 + # We convert it to: norm1, norm2, norm3 + "norm2": "norm__placeholder", + "norm3": "norm2", + "norm__placeholder": "norm3", + # # For the I2V model + # "img_emb.proj.0": "condition_embedder.image_embedder.norm1", + # "img_emb.proj.1": "condition_embedder.image_embedder.ff.net.0.proj", + # "img_emb.proj.3": "condition_embedder.image_embedder.ff.net.2", + # "img_emb.proj.4": "condition_embedder.image_embedder.norm2", + # # for the FLF2V model + # "img_emb.emb_pos": "condition_embedder.image_embedder.pos_embed", + # Add attention component mappings + "self_attn.q": "attn1.to_q", + "self_attn.k": "attn1.to_k", + "self_attn.v": "attn1.to_v", + "self_attn.o": "attn1.to_out.0", + "self_attn.norm_q": "attn1.norm_q", + "self_attn.norm_k": "attn1.norm_k", + "cross_attn.q": "attn2.to_q", + "cross_attn.k": "attn2.to_k", + "cross_attn.v": "attn2.to_v", + "cross_attn.o": "attn2.to_out.0", + "cross_attn.norm_q": "attn2.norm_q", + "cross_attn.norm_k": "attn2.norm_k", + "attn2.to_k_img": "attn2.add_k_proj", + "attn2.to_v_img": "attn2.add_v_proj", + "attn2.norm_k_img": "attn2.norm_added_k", + "before_proj": "proj_in", + "after_proj": "proj_out", +} + +ANIMATE_TRANSFORMER_KEYS_RENAME_DICT = { + "time_embedding.0": "condition_embedder.time_embedder.linear_1", + "time_embedding.2": "condition_embedder.time_embedder.linear_2", + "text_embedding.0": "condition_embedder.text_embedder.linear_1", + "text_embedding.2": "condition_embedder.text_embedder.linear_2", + "time_projection.1": "condition_embedder.time_proj", + "head.modulation": "scale_shift_table", + "head.head": "proj_out", + "modulation": "scale_shift_table", + "ffn.0": "ffn.net.0.proj", + "ffn.2": "ffn.net.2", + # Hack to swap the layer names + # The original model calls the norms in following order: norm1, norm3, norm2 + # We convert it to: norm1, norm2, norm3 + "norm2": "norm__placeholder", + "norm3": "norm2", + "norm__placeholder": "norm3", + "img_emb.proj.0": "condition_embedder.image_embedder.norm1", + "img_emb.proj.1": "condition_embedder.image_embedder.ff.net.0.proj", + "img_emb.proj.3": "condition_embedder.image_embedder.ff.net.2", + "img_emb.proj.4": "condition_embedder.image_embedder.norm2", + # Add attention component mappings + "self_attn.q": "attn1.to_q", + "self_attn.k": "attn1.to_k", + "self_attn.v": "attn1.to_v", + "self_attn.o": "attn1.to_out.0", + "self_attn.norm_q": "attn1.norm_q", + "self_attn.norm_k": "attn1.norm_k", + "cross_attn.q": "attn2.to_q", + "cross_attn.k": "attn2.to_k", + "cross_attn.v": "attn2.to_v", + "cross_attn.o": "attn2.to_out.0", + "cross_attn.norm_q": "attn2.norm_q", + "cross_attn.norm_k": "attn2.norm_k", + "cross_attn.k_img": "attn2.to_k_img", + "cross_attn.v_img": "attn2.to_v_img", + "cross_attn.norm_k_img": "attn2.norm_k_img", + # After cross_attn -> attn2 rename, we need to rename the img keys + "attn2.to_k_img": "attn2.add_k_proj", + "attn2.to_v_img": "attn2.add_v_proj", + "attn2.norm_k_img": "attn2.norm_added_k", + # Wan Animate-specific mappings (motion encoder, face encoder, face adapter) + # Motion encoder mappings + # The name mapping is complicated for the convolutional part so we handle that in its own function + "motion_encoder.enc.fc": "motion_encoder.motion_network", + "motion_encoder.dec.direction.weight": "motion_encoder.motion_synthesis_weight", + # Face encoder mappings - CausalConv1d has a .conv submodule that we need to flatten + "face_encoder.conv1_local.conv": "face_encoder.conv1_local", + "face_encoder.conv2.conv": "face_encoder.conv2", + "face_encoder.conv3.conv": "face_encoder.conv3", + # Face adapter mappings are handled in a separate function +} + + +# TODO: Verify this and simplify if possible. +def convert_animate_motion_encoder_weights(key: str, state_dict: Dict[str, Any], final_conv_idx: int = 8) -> None: + """ + Convert all motion encoder weights for Animate model. + + In the original model: + - All Linear layers in fc use EqualLinear + - All Conv2d layers in convs use EqualConv2d (except blur_conv which is initialized separately) + - Blur kernels are stored as buffers in Sequential modules + - ConvLayer is nn.Sequential with indices: [Blur (optional), EqualConv2d, FusedLeakyReLU (optional)] + + Conversion strategy: + 1. Drop .kernel buffers (blur kernels) + 2. Rename sequential indices to named components (e.g., 0 -> conv2d, 1 -> bias_leaky_relu) + """ + # Skip if not a weight, bias, or kernel + if ".weight" not in key and ".bias" not in key and ".kernel" not in key: + return + + # Handle Blur kernel buffers from original implementation. + # After renaming, these appear under: motion_encoder.res_blocks.*.conv{2,skip}.blur_kernel + # Diffusers constructs blur kernels as a non-persistent buffer so we must drop these keys + if ".kernel" in key and "motion_encoder" in key: + # Remove unexpected blur kernel buffers to avoid strict load errors + state_dict.pop(key, None) + return + + # Rename Sequential indices to named components in ConvLayer and ResBlock + if ".enc.net_app.convs." in key and (".weight" in key or ".bias" in key): + parts = key.split(".") + + # Find the sequential index (digit) after convs or after conv1/conv2/skip + # Examples: + # - enc.net_app.convs.0.0.weight -> conv_in.weight (initial conv layer weight) + # - enc.net_app.convs.0.1.bias -> conv_in.act_fn.bias (initial conv layer bias) + # - enc.net_app.convs.{n:1-7}.conv1.0.weight -> res_blocks.{(n-1):0-6}.conv1.weight (conv1 weight) + # - e.g. enc.net_app.convs.1.conv1.0.weight -> res_blocks.0.conv1.weight + # - enc.net_app.convs.{n:1-7}.conv1.1.bias -> res_blocks.{(n-1):0-6}.conv1.act_fn.bias (conv1 bias) + # - e.g. enc.net_app.convs.1.conv1.1.bias -> res_blocks.0.conv1.act_fn.bias + # - enc.net_app.convs.{n:1-7}.conv2.1.weight -> res_blocks.{(n-1):0-6}.conv2.weight (conv2 weight) + # - enc.net_app.convs.1.conv2.2.bias -> res_blocks.0.conv2.act_fn.bias (conv2 bias) + # - enc.net_app.convs.{n:1-7}.skip.1.weight -> res_blocks.{(n-1):0-6}.conv_skip.weight (skip conv weight) + # - enc.net_app.convs.8 -> conv_out (final conv layer) + + convs_idx = parts.index("convs") if "convs" in parts else -1 + if convs_idx >= 0 and len(parts) - convs_idx >= 2: + bias = False + # The nn.Sequential index will always follow convs + sequential_idx = int(parts[convs_idx + 1]) + if sequential_idx == 0: + if key.endswith(".weight"): + new_key = "motion_encoder.conv_in.weight" + elif key.endswith(".bias"): + new_key = "motion_encoder.conv_in.act_fn.bias" + bias = True + elif sequential_idx == final_conv_idx: + if key.endswith(".weight"): + new_key = "motion_encoder.conv_out.weight" + else: + # Intermediate .convs. layers, which get mapped to .res_blocks. + prefix = "motion_encoder.res_blocks." + + layer_name = parts[convs_idx + 2] + if layer_name == "skip": + layer_name = "conv_skip" + + if key.endswith(".weight"): + param_name = "weight" + elif key.endswith(".bias"): + param_name = "act_fn.bias" + bias = True + + suffix_parts = [str(sequential_idx - 1), layer_name, param_name] + suffix = ".".join(suffix_parts) + new_key = prefix + suffix + + param = state_dict.pop(key) + if bias: + param = param.squeeze() + state_dict[new_key] = param + return + return + return + + +def convert_animate_face_adapter_weights(key: str, state_dict: Dict[str, Any]) -> None: + """ + Convert face adapter weights for the Animate model. + + The original model uses a fused KV projection but the diffusers models uses separate K and V projections. + """ + # Skip if not a weight or bias + if ".weight" not in key and ".bias" not in key: + return + + prefix = "face_adapter." + if ".fuser_blocks." in key: + parts = key.split(".") + + module_list_idx = parts.index("fuser_blocks") if "fuser_blocks" in parts else -1 + if module_list_idx >= 0 and (len(parts) - 1) - module_list_idx == 3: + block_idx = parts[module_list_idx + 1] + layer_name = parts[module_list_idx + 2] + param_name = parts[module_list_idx + 3] + + if layer_name == "linear1_kv": + layer_name_k = "to_k" + layer_name_v = "to_v" + + suffix_k = ".".join([block_idx, layer_name_k, param_name]) + suffix_v = ".".join([block_idx, layer_name_v, param_name]) + new_key_k = prefix + suffix_k + new_key_v = prefix + suffix_v + + kv_proj = state_dict.pop(key) + k_proj, v_proj = torch.chunk(kv_proj, 2, dim=0) + state_dict[new_key_k] = k_proj + state_dict[new_key_v] = v_proj + return + else: + if layer_name == "q_norm": + new_layer_name = "norm_q" + elif layer_name == "k_norm": + new_layer_name = "norm_k" + elif layer_name == "linear1_q": + new_layer_name = "to_q" + elif layer_name == "linear2": + new_layer_name = "to_out" + + suffix_parts = [block_idx, new_layer_name, param_name] + suffix = ".".join(suffix_parts) + new_key = prefix + suffix + state_dict[new_key] = state_dict.pop(key) + return + return + + +TRANSFORMER_SPECIAL_KEYS_REMAP = {} +VACE_TRANSFORMER_SPECIAL_KEYS_REMAP = {} +ANIMATE_TRANSFORMER_SPECIAL_KEYS_REMAP = { + "motion_encoder": convert_animate_motion_encoder_weights, + "face_adapter": convert_animate_face_adapter_weights, +} + + +def update_state_dict_(state_dict: Dict[str, Any], old_key: str, new_key: str) -> Dict[str, Any]: + state_dict[new_key] = state_dict.pop(old_key) + + +def load_sharded_safetensors(dir: pathlib.Path): + file_paths = list(dir.glob("diffusion_pytorch_model*.safetensors")) + state_dict = {} + for path in file_paths: + state_dict.update(load_file(path)) + return state_dict + + +def get_transformer_config(model_type: str) -> Tuple[Dict[str, Any], ...]: + if model_type == "Wan-T2V-1.3B": + config = { + "model_id": "StevenZhang/Wan2.1-T2V-1.3B-Diff", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 8960, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 12, + "num_layers": 30, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan-T2V-14B": + config = { + "model_id": "StevenZhang/Wan2.1-T2V-14B-Diff", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan-I2V-14B-480p": + config = { + "model_id": "StevenZhang/Wan2.1-I2V-14B-480P-Diff", + "diffusers_config": { + "image_dim": 1280, + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan-I2V-14B-720p": + config = { + "model_id": "StevenZhang/Wan2.1-I2V-14B-720P-Diff", + "diffusers_config": { + "image_dim": 1280, + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan-FLF2V-14B-720P": + config = { + "model_id": "ypyp/Wan2.1-FLF2V-14B-720P", # This is just a placeholder + "diffusers_config": { + "image_dim": 1280, + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "rope_max_seq_len": 1024, + "pos_embed_seq_len": 257 * 2, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan-VACE-1.3B": + config = { + "model_id": "Wan-AI/Wan2.1-VACE-1.3B", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 8960, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 12, + "num_layers": 30, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "vace_layers": [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28], + "vace_in_channels": 96, + }, + } + RENAME_DICT = VACE_TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = VACE_TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan-VACE-14B": + config = { + "model_id": "Wan-AI/Wan2.1-VACE-14B", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "vace_layers": [0, 5, 10, 15, 20, 25, 30, 35], + "vace_in_channels": 96, + }, + } + RENAME_DICT = VACE_TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = VACE_TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan2.2-VACE-Fun-14B": + config = { + "model_id": "alibaba-pai/Wan2.2-VACE-Fun-A14B", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "vace_layers": [0, 5, 10, 15, 20, 25, 30, 35], + "vace_in_channels": 96, + }, + } + RENAME_DICT = VACE_TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = VACE_TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan2.2-I2V-14B-720p": + config = { + "model_id": "Wan-AI/Wan2.2-I2V-A14B", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan2.2-T2V-A14B": + config = { + "model_id": "Wan-AI/Wan2.2-T2V-A14B", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 16, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan2.2-TI2V-5B": + config = { + "model_id": "Wan-AI/Wan2.2-TI2V-5B", + "diffusers_config": { + "added_kv_proj_dim": None, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 14336, + "freq_dim": 256, + "in_channels": 48, + "num_attention_heads": 24, + "num_layers": 30, + "out_channels": 48, + "patch_size": [1, 2, 2], + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + }, + } + RENAME_DICT = TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = TRANSFORMER_SPECIAL_KEYS_REMAP + elif model_type == "Wan2.2-Animate-14B": + config = { + "model_id": "Wan-AI/Wan2.2-Animate-14B", + "diffusers_config": { + "image_dim": 1280, + "added_kv_proj_dim": 5120, + "attention_head_dim": 128, + "cross_attn_norm": True, + "eps": 1e-06, + "ffn_dim": 13824, + "freq_dim": 256, + "in_channels": 36, + "num_attention_heads": 40, + "num_layers": 40, + "out_channels": 16, + "patch_size": (1, 2, 2), + "qk_norm": "rms_norm_across_heads", + "text_dim": 4096, + "rope_max_seq_len": 1024, + "pos_embed_seq_len": None, + "motion_encoder_size": 512, # Start of Wan Animate-specific configs + "motion_style_dim": 512, + "motion_dim": 20, + "motion_encoder_dim": 512, + "face_encoder_hidden_dim": 1024, + "face_encoder_num_heads": 4, + "inject_face_latents_blocks": 5, + }, + } + RENAME_DICT = ANIMATE_TRANSFORMER_KEYS_RENAME_DICT + SPECIAL_KEYS_REMAP = ANIMATE_TRANSFORMER_SPECIAL_KEYS_REMAP + return config, RENAME_DICT, SPECIAL_KEYS_REMAP + + +def convert_transformer(model_type: str, stage: str = None): + config, RENAME_DICT, SPECIAL_KEYS_REMAP = get_transformer_config(model_type) + + diffusers_config = config["diffusers_config"] + model_id = config["model_id"] + model_dir = pathlib.Path(snapshot_download(model_id, repo_type="model")) + + if stage is not None: + model_dir = model_dir / stage + + original_state_dict = load_sharded_safetensors(model_dir) + + with init_empty_weights(): + if "Animate" in model_type: + transformer = WanAnimateTransformer3DModel.from_config(diffusers_config) + elif "VACE" in model_type: + transformer = WanVACETransformer3DModel.from_config(diffusers_config) + else: + transformer = WanTransformer3DModel.from_config(diffusers_config) + + for key in list(original_state_dict.keys()): + new_key = key[:] + for replace_key, rename_key in RENAME_DICT.items(): + new_key = new_key.replace(replace_key, rename_key) + update_state_dict_(original_state_dict, key, new_key) + + for key in list(original_state_dict.keys()): + for special_key, handler_fn_inplace in SPECIAL_KEYS_REMAP.items(): + if special_key not in key: + continue + handler_fn_inplace(key, original_state_dict) + + # Load state dict into the meta model, which will materialize the tensors + transformer.load_state_dict(original_state_dict, strict=True, assign=True) + + # Move to CPU to ensure all tensors are materialized + transformer = transformer.to("cpu") + + return transformer + + +def convert_vae(): + vae_ckpt_path = hf_hub_download("Wan-AI/Wan2.1-T2V-14B", "Wan2.1_VAE.pth") + old_state_dict = torch.load(vae_ckpt_path, weights_only=True) + new_state_dict = {} + + # Create mappings for specific components + middle_key_mapping = { + # Encoder middle block + "encoder.middle.0.residual.0.gamma": "encoder.mid_block.resnets.0.norm1.gamma", + "encoder.middle.0.residual.2.bias": "encoder.mid_block.resnets.0.conv1.bias", + "encoder.middle.0.residual.2.weight": "encoder.mid_block.resnets.0.conv1.weight", + "encoder.middle.0.residual.3.gamma": "encoder.mid_block.resnets.0.norm2.gamma", + "encoder.middle.0.residual.6.bias": "encoder.mid_block.resnets.0.conv2.bias", + "encoder.middle.0.residual.6.weight": "encoder.mid_block.resnets.0.conv2.weight", + "encoder.middle.2.residual.0.gamma": "encoder.mid_block.resnets.1.norm1.gamma", + "encoder.middle.2.residual.2.bias": "encoder.mid_block.resnets.1.conv1.bias", + "encoder.middle.2.residual.2.weight": "encoder.mid_block.resnets.1.conv1.weight", + "encoder.middle.2.residual.3.gamma": "encoder.mid_block.resnets.1.norm2.gamma", + "encoder.middle.2.residual.6.bias": "encoder.mid_block.resnets.1.conv2.bias", + "encoder.middle.2.residual.6.weight": "encoder.mid_block.resnets.1.conv2.weight", + # Decoder middle block + "decoder.middle.0.residual.0.gamma": "decoder.mid_block.resnets.0.norm1.gamma", + "decoder.middle.0.residual.2.bias": "decoder.mid_block.resnets.0.conv1.bias", + "decoder.middle.0.residual.2.weight": "decoder.mid_block.resnets.0.conv1.weight", + "decoder.middle.0.residual.3.gamma": "decoder.mid_block.resnets.0.norm2.gamma", + "decoder.middle.0.residual.6.bias": "decoder.mid_block.resnets.0.conv2.bias", + "decoder.middle.0.residual.6.weight": "decoder.mid_block.resnets.0.conv2.weight", + "decoder.middle.2.residual.0.gamma": "decoder.mid_block.resnets.1.norm1.gamma", + "decoder.middle.2.residual.2.bias": "decoder.mid_block.resnets.1.conv1.bias", + "decoder.middle.2.residual.2.weight": "decoder.mid_block.resnets.1.conv1.weight", + "decoder.middle.2.residual.3.gamma": "decoder.mid_block.resnets.1.norm2.gamma", + "decoder.middle.2.residual.6.bias": "decoder.mid_block.resnets.1.conv2.bias", + "decoder.middle.2.residual.6.weight": "decoder.mid_block.resnets.1.conv2.weight", + } + + # Create a mapping for attention blocks + attention_mapping = { + # Encoder middle attention + "encoder.middle.1.norm.gamma": "encoder.mid_block.attentions.0.norm.gamma", + "encoder.middle.1.to_qkv.weight": "encoder.mid_block.attentions.0.to_qkv.weight", + "encoder.middle.1.to_qkv.bias": "encoder.mid_block.attentions.0.to_qkv.bias", + "encoder.middle.1.proj.weight": "encoder.mid_block.attentions.0.proj.weight", + "encoder.middle.1.proj.bias": "encoder.mid_block.attentions.0.proj.bias", + # Decoder middle attention + "decoder.middle.1.norm.gamma": "decoder.mid_block.attentions.0.norm.gamma", + "decoder.middle.1.to_qkv.weight": "decoder.mid_block.attentions.0.to_qkv.weight", + "decoder.middle.1.to_qkv.bias": "decoder.mid_block.attentions.0.to_qkv.bias", + "decoder.middle.1.proj.weight": "decoder.mid_block.attentions.0.proj.weight", + "decoder.middle.1.proj.bias": "decoder.mid_block.attentions.0.proj.bias", + } + + # Create a mapping for the head components + head_mapping = { + # Encoder head + "encoder.head.0.gamma": "encoder.norm_out.gamma", + "encoder.head.2.bias": "encoder.conv_out.bias", + "encoder.head.2.weight": "encoder.conv_out.weight", + # Decoder head + "decoder.head.0.gamma": "decoder.norm_out.gamma", + "decoder.head.2.bias": "decoder.conv_out.bias", + "decoder.head.2.weight": "decoder.conv_out.weight", + } + + # Create a mapping for the quant components + quant_mapping = { + "conv1.weight": "quant_conv.weight", + "conv1.bias": "quant_conv.bias", + "conv2.weight": "post_quant_conv.weight", + "conv2.bias": "post_quant_conv.bias", + } + + # Process each key in the state dict + for key, value in old_state_dict.items(): + # Handle middle block keys using the mapping + if key in middle_key_mapping: + new_key = middle_key_mapping[key] + new_state_dict[new_key] = value + # Handle attention blocks using the mapping + elif key in attention_mapping: + new_key = attention_mapping[key] + new_state_dict[new_key] = value + # Handle head keys using the mapping + elif key in head_mapping: + new_key = head_mapping[key] + new_state_dict[new_key] = value + # Handle quant keys using the mapping + elif key in quant_mapping: + new_key = quant_mapping[key] + new_state_dict[new_key] = value + # Handle encoder conv1 + elif key == "encoder.conv1.weight": + new_state_dict["encoder.conv_in.weight"] = value + elif key == "encoder.conv1.bias": + new_state_dict["encoder.conv_in.bias"] = value + # Handle decoder conv1 + elif key == "decoder.conv1.weight": + new_state_dict["decoder.conv_in.weight"] = value + elif key == "decoder.conv1.bias": + new_state_dict["decoder.conv_in.bias"] = value + # Handle encoder downsamples + elif key.startswith("encoder.downsamples."): + # Convert to down_blocks + new_key = key.replace("encoder.downsamples.", "encoder.down_blocks.") + + # Convert residual block naming but keep the original structure + if ".residual.0.gamma" in new_key: + new_key = new_key.replace(".residual.0.gamma", ".norm1.gamma") + elif ".residual.2.bias" in new_key: + new_key = new_key.replace(".residual.2.bias", ".conv1.bias") + elif ".residual.2.weight" in new_key: + new_key = new_key.replace(".residual.2.weight", ".conv1.weight") + elif ".residual.3.gamma" in new_key: + new_key = new_key.replace(".residual.3.gamma", ".norm2.gamma") + elif ".residual.6.bias" in new_key: + new_key = new_key.replace(".residual.6.bias", ".conv2.bias") + elif ".residual.6.weight" in new_key: + new_key = new_key.replace(".residual.6.weight", ".conv2.weight") + elif ".shortcut.bias" in new_key: + new_key = new_key.replace(".shortcut.bias", ".conv_shortcut.bias") + elif ".shortcut.weight" in new_key: + new_key = new_key.replace(".shortcut.weight", ".conv_shortcut.weight") + + new_state_dict[new_key] = value + + # Handle decoder upsamples + elif key.startswith("decoder.upsamples."): + # Convert to up_blocks + parts = key.split(".") + block_idx = int(parts[2]) + + # Group residual blocks + if "residual" in key: + if block_idx in [0, 1, 2]: + new_block_idx = 0 + resnet_idx = block_idx + elif block_idx in [4, 5, 6]: + new_block_idx = 1 + resnet_idx = block_idx - 4 + elif block_idx in [8, 9, 10]: + new_block_idx = 2 + resnet_idx = block_idx - 8 + elif block_idx in [12, 13, 14]: + new_block_idx = 3 + resnet_idx = block_idx - 12 + else: + # Keep as is for other blocks + new_state_dict[key] = value + continue + + # Convert residual block naming + if ".residual.0.gamma" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.norm1.gamma" + elif ".residual.2.bias" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv1.bias" + elif ".residual.2.weight" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv1.weight" + elif ".residual.3.gamma" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.norm2.gamma" + elif ".residual.6.bias" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv2.bias" + elif ".residual.6.weight" in key: + new_key = f"decoder.up_blocks.{new_block_idx}.resnets.{resnet_idx}.conv2.weight" + else: + new_key = key + + new_state_dict[new_key] = value + + # Handle shortcut connections + elif ".shortcut." in key: + if block_idx == 4: + new_key = key.replace(".shortcut.", ".resnets.0.conv_shortcut.") + new_key = new_key.replace("decoder.upsamples.4", "decoder.up_blocks.1") + else: + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + new_key = new_key.replace(".shortcut.", ".conv_shortcut.") + + new_state_dict[new_key] = value + + # Handle upsamplers + elif ".resample." in key or ".time_conv." in key: + if block_idx == 3: + new_key = key.replace(f"decoder.upsamples.{block_idx}", "decoder.up_blocks.0.upsamplers.0") + elif block_idx == 7: + new_key = key.replace(f"decoder.upsamples.{block_idx}", "decoder.up_blocks.1.upsamplers.0") + elif block_idx == 11: + new_key = key.replace(f"decoder.upsamples.{block_idx}", "decoder.up_blocks.2.upsamplers.0") + else: + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + + new_state_dict[new_key] = value + else: + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + new_state_dict[new_key] = value + else: + # Keep other keys unchanged + new_state_dict[key] = value + + with init_empty_weights(): + vae = AutoencoderKLWan() + vae.load_state_dict(new_state_dict, strict=True, assign=True) + return vae + + +vae22_diffusers_config = { + "base_dim": 160, + "z_dim": 48, + "is_residual": True, + "in_channels": 12, + "out_channels": 12, + "decoder_base_dim": 256, + "scale_factor_temporal": 4, + "scale_factor_spatial": 16, + "patch_size": 2, + "latents_mean": [ + -0.2289, + -0.0052, + -0.1323, + -0.2339, + -0.2799, + 0.0174, + 0.1838, + 0.1557, + -0.1382, + 0.0542, + 0.2813, + 0.0891, + 0.1570, + -0.0098, + 0.0375, + -0.1825, + -0.2246, + -0.1207, + -0.0698, + 0.5109, + 0.2665, + -0.2108, + -0.2158, + 0.2502, + -0.2055, + -0.0322, + 0.1109, + 0.1567, + -0.0729, + 0.0899, + -0.2799, + -0.1230, + -0.0313, + -0.1649, + 0.0117, + 0.0723, + -0.2839, + -0.2083, + -0.0520, + 0.3748, + 0.0152, + 0.1957, + 0.1433, + -0.2944, + 0.3573, + -0.0548, + -0.1681, + -0.0667, + ], + "latents_std": [ + 0.4765, + 1.0364, + 0.4514, + 1.1677, + 0.5313, + 0.4990, + 0.4818, + 0.5013, + 0.8158, + 1.0344, + 0.5894, + 1.0901, + 0.6885, + 0.6165, + 0.8454, + 0.4978, + 0.5759, + 0.3523, + 0.7135, + 0.6804, + 0.5833, + 1.4146, + 0.8986, + 0.5659, + 0.7069, + 0.5338, + 0.4889, + 0.4917, + 0.4069, + 0.4999, + 0.6866, + 0.4093, + 0.5709, + 0.6065, + 0.6415, + 0.4944, + 0.5726, + 1.2042, + 0.5458, + 1.6887, + 0.3971, + 1.0600, + 0.3943, + 0.5537, + 0.5444, + 0.4089, + 0.7468, + 0.7744, + ], + "clip_output": False, +} + + +def convert_vae_22(): + vae_ckpt_path = hf_hub_download("Wan-AI/Wan2.2-TI2V-5B", "Wan2.2_VAE.pth") + old_state_dict = torch.load(vae_ckpt_path, weights_only=True) + new_state_dict = {} + + # Create mappings for specific components + middle_key_mapping = { + # Encoder middle block + "encoder.middle.0.residual.0.gamma": "encoder.mid_block.resnets.0.norm1.gamma", + "encoder.middle.0.residual.2.bias": "encoder.mid_block.resnets.0.conv1.bias", + "encoder.middle.0.residual.2.weight": "encoder.mid_block.resnets.0.conv1.weight", + "encoder.middle.0.residual.3.gamma": "encoder.mid_block.resnets.0.norm2.gamma", + "encoder.middle.0.residual.6.bias": "encoder.mid_block.resnets.0.conv2.bias", + "encoder.middle.0.residual.6.weight": "encoder.mid_block.resnets.0.conv2.weight", + "encoder.middle.2.residual.0.gamma": "encoder.mid_block.resnets.1.norm1.gamma", + "encoder.middle.2.residual.2.bias": "encoder.mid_block.resnets.1.conv1.bias", + "encoder.middle.2.residual.2.weight": "encoder.mid_block.resnets.1.conv1.weight", + "encoder.middle.2.residual.3.gamma": "encoder.mid_block.resnets.1.norm2.gamma", + "encoder.middle.2.residual.6.bias": "encoder.mid_block.resnets.1.conv2.bias", + "encoder.middle.2.residual.6.weight": "encoder.mid_block.resnets.1.conv2.weight", + # Decoder middle block + "decoder.middle.0.residual.0.gamma": "decoder.mid_block.resnets.0.norm1.gamma", + "decoder.middle.0.residual.2.bias": "decoder.mid_block.resnets.0.conv1.bias", + "decoder.middle.0.residual.2.weight": "decoder.mid_block.resnets.0.conv1.weight", + "decoder.middle.0.residual.3.gamma": "decoder.mid_block.resnets.0.norm2.gamma", + "decoder.middle.0.residual.6.bias": "decoder.mid_block.resnets.0.conv2.bias", + "decoder.middle.0.residual.6.weight": "decoder.mid_block.resnets.0.conv2.weight", + "decoder.middle.2.residual.0.gamma": "decoder.mid_block.resnets.1.norm1.gamma", + "decoder.middle.2.residual.2.bias": "decoder.mid_block.resnets.1.conv1.bias", + "decoder.middle.2.residual.2.weight": "decoder.mid_block.resnets.1.conv1.weight", + "decoder.middle.2.residual.3.gamma": "decoder.mid_block.resnets.1.norm2.gamma", + "decoder.middle.2.residual.6.bias": "decoder.mid_block.resnets.1.conv2.bias", + "decoder.middle.2.residual.6.weight": "decoder.mid_block.resnets.1.conv2.weight", + } + + # Create a mapping for attention blocks + attention_mapping = { + # Encoder middle attention + "encoder.middle.1.norm.gamma": "encoder.mid_block.attentions.0.norm.gamma", + "encoder.middle.1.to_qkv.weight": "encoder.mid_block.attentions.0.to_qkv.weight", + "encoder.middle.1.to_qkv.bias": "encoder.mid_block.attentions.0.to_qkv.bias", + "encoder.middle.1.proj.weight": "encoder.mid_block.attentions.0.proj.weight", + "encoder.middle.1.proj.bias": "encoder.mid_block.attentions.0.proj.bias", + # Decoder middle attention + "decoder.middle.1.norm.gamma": "decoder.mid_block.attentions.0.norm.gamma", + "decoder.middle.1.to_qkv.weight": "decoder.mid_block.attentions.0.to_qkv.weight", + "decoder.middle.1.to_qkv.bias": "decoder.mid_block.attentions.0.to_qkv.bias", + "decoder.middle.1.proj.weight": "decoder.mid_block.attentions.0.proj.weight", + "decoder.middle.1.proj.bias": "decoder.mid_block.attentions.0.proj.bias", + } + + # Create a mapping for the head components + head_mapping = { + # Encoder head + "encoder.head.0.gamma": "encoder.norm_out.gamma", + "encoder.head.2.bias": "encoder.conv_out.bias", + "encoder.head.2.weight": "encoder.conv_out.weight", + # Decoder head + "decoder.head.0.gamma": "decoder.norm_out.gamma", + "decoder.head.2.bias": "decoder.conv_out.bias", + "decoder.head.2.weight": "decoder.conv_out.weight", + } + + # Create a mapping for the quant components + quant_mapping = { + "conv1.weight": "quant_conv.weight", + "conv1.bias": "quant_conv.bias", + "conv2.weight": "post_quant_conv.weight", + "conv2.bias": "post_quant_conv.bias", + } + + # Process each key in the state dict + for key, value in old_state_dict.items(): + # Handle middle block keys using the mapping + if key in middle_key_mapping: + new_key = middle_key_mapping[key] + new_state_dict[new_key] = value + # Handle attention blocks using the mapping + elif key in attention_mapping: + new_key = attention_mapping[key] + new_state_dict[new_key] = value + # Handle head keys using the mapping + elif key in head_mapping: + new_key = head_mapping[key] + new_state_dict[new_key] = value + # Handle quant keys using the mapping + elif key in quant_mapping: + new_key = quant_mapping[key] + new_state_dict[new_key] = value + # Handle encoder conv1 + elif key == "encoder.conv1.weight": + new_state_dict["encoder.conv_in.weight"] = value + elif key == "encoder.conv1.bias": + new_state_dict["encoder.conv_in.bias"] = value + # Handle decoder conv1 + elif key == "decoder.conv1.weight": + new_state_dict["decoder.conv_in.weight"] = value + elif key == "decoder.conv1.bias": + new_state_dict["decoder.conv_in.bias"] = value + # Handle encoder downsamples + elif key.startswith("encoder.downsamples."): + # Change encoder.downsamples to encoder.down_blocks + new_key = key.replace("encoder.downsamples.", "encoder.down_blocks.") + + # Handle residual blocks - change downsamples to resnets and rename components + if "residual" in new_key or "shortcut" in new_key: + # Change the second downsamples to resnets + new_key = new_key.replace(".downsamples.", ".resnets.") + + # Rename residual components + if ".residual.0.gamma" in new_key: + new_key = new_key.replace(".residual.0.gamma", ".norm1.gamma") + elif ".residual.2.weight" in new_key: + new_key = new_key.replace(".residual.2.weight", ".conv1.weight") + elif ".residual.2.bias" in new_key: + new_key = new_key.replace(".residual.2.bias", ".conv1.bias") + elif ".residual.3.gamma" in new_key: + new_key = new_key.replace(".residual.3.gamma", ".norm2.gamma") + elif ".residual.6.weight" in new_key: + new_key = new_key.replace(".residual.6.weight", ".conv2.weight") + elif ".residual.6.bias" in new_key: + new_key = new_key.replace(".residual.6.bias", ".conv2.bias") + elif ".shortcut.weight" in new_key: + new_key = new_key.replace(".shortcut.weight", ".conv_shortcut.weight") + elif ".shortcut.bias" in new_key: + new_key = new_key.replace(".shortcut.bias", ".conv_shortcut.bias") + + # Handle resample blocks - change downsamples to downsampler and remove index + elif "resample" in new_key or "time_conv" in new_key: + # Change the second downsamples to downsampler and remove the index + parts = new_key.split(".") + # Find the pattern: encoder.down_blocks.X.downsamples.Y.resample... + # We want to change it to: encoder.down_blocks.X.downsampler.resample... + if len(parts) >= 4 and parts[3] == "downsamples": + # Remove the index (parts[4]) and change downsamples to downsampler + new_parts = parts[:3] + ["downsampler"] + parts[5:] + new_key = ".".join(new_parts) + + new_state_dict[new_key] = value + + # Handle decoder upsamples + elif key.startswith("decoder.upsamples."): + # Change decoder.upsamples to decoder.up_blocks + new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.") + + # Handle residual blocks - change upsamples to resnets and rename components + if "residual" in new_key or "shortcut" in new_key: + # Change the second upsamples to resnets + new_key = new_key.replace(".upsamples.", ".resnets.") + + # Rename residual components + if ".residual.0.gamma" in new_key: + new_key = new_key.replace(".residual.0.gamma", ".norm1.gamma") + elif ".residual.2.weight" in new_key: + new_key = new_key.replace(".residual.2.weight", ".conv1.weight") + elif ".residual.2.bias" in new_key: + new_key = new_key.replace(".residual.2.bias", ".conv1.bias") + elif ".residual.3.gamma" in new_key: + new_key = new_key.replace(".residual.3.gamma", ".norm2.gamma") + elif ".residual.6.weight" in new_key: + new_key = new_key.replace(".residual.6.weight", ".conv2.weight") + elif ".residual.6.bias" in new_key: + new_key = new_key.replace(".residual.6.bias", ".conv2.bias") + elif ".shortcut.weight" in new_key: + new_key = new_key.replace(".shortcut.weight", ".conv_shortcut.weight") + elif ".shortcut.bias" in new_key: + new_key = new_key.replace(".shortcut.bias", ".conv_shortcut.bias") + + # Handle resample blocks - change upsamples to upsampler and remove index + elif "resample" in new_key or "time_conv" in new_key: + # Change the second upsamples to upsampler and remove the index + parts = new_key.split(".") + # Find the pattern: encoder.down_blocks.X.downsamples.Y.resample... + # We want to change it to: encoder.down_blocks.X.downsampler.resample... + if len(parts) >= 4 and parts[3] == "upsamples": + # Remove the index (parts[4]) and change upsamples to upsampler + new_parts = parts[:3] + ["upsampler"] + parts[5:] + new_key = ".".join(new_parts) + + new_state_dict[new_key] = value + else: + # Keep other keys unchanged + new_state_dict[key] = value + + with init_empty_weights(): + vae = AutoencoderKLWan(**vae22_diffusers_config) + vae.load_state_dict(new_state_dict, strict=True, assign=True) + return vae + + +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--model_type", type=str, default=None) + parser.add_argument("--output_path", type=str, required=True) + parser.add_argument("--dtype", default="fp32", choices=["fp32", "fp16", "bf16", "none"]) + return parser.parse_args() + + +DTYPE_MAPPING = { + "fp32": torch.float32, + "fp16": torch.float16, + "bf16": torch.bfloat16, +} + + +if __name__ == "__main__": + args = get_args() + + if "Wan2.2" in args.model_type and "TI2V" not in args.model_type and "Animate" not in args.model_type: + transformer = convert_transformer(args.model_type, stage="high_noise_model") + transformer_2 = convert_transformer(args.model_type, stage="low_noise_model") + else: + transformer = convert_transformer(args.model_type) + transformer_2 = None + + if "Wan2.2" in args.model_type and "TI2V" in args.model_type: + vae = convert_vae_22() + else: + vae = convert_vae() + + text_encoder = UMT5EncoderModel.from_pretrained("google/umt5-xxl", torch_dtype=torch.bfloat16) + tokenizer = AutoTokenizer.from_pretrained("google/umt5-xxl") + if "FLF2V" in args.model_type: + flow_shift = 16.0 + elif "TI2V" in args.model_type or "Animate" in args.model_type: + flow_shift = 5.0 + else: + flow_shift = 3.0 + scheduler = UniPCMultistepScheduler( + prediction_type="flow_prediction", use_flow_sigmas=True, num_train_timesteps=1000, flow_shift=flow_shift + ) + + # If user has specified "none", we keep the original dtypes of the state dict without any conversion + if args.dtype != "none": + dtype = DTYPE_MAPPING[args.dtype] + transformer.to(dtype) + if transformer_2 is not None: + transformer_2.to(dtype) + + if "Wan2.2" and "I2V" in args.model_type and "TI2V" not in args.model_type: + pipe = WanImageToVideoPipeline( + transformer=transformer, + transformer_2=transformer_2, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + boundary_ratio=0.9, + ) + elif "Wan2.2" and "T2V" in args.model_type: + pipe = WanPipeline( + transformer=transformer, + transformer_2=transformer_2, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + boundary_ratio=0.875, + ) + elif "Wan2.2" and "TI2V" in args.model_type: + pipe = WanPipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + expand_timesteps=True, + ) + elif "I2V" in args.model_type or "FLF2V" in args.model_type: + image_encoder = CLIPVisionModelWithProjection.from_pretrained( + "laion/CLIP-ViT-H-14-laion2B-s32B-b79K", torch_dtype=torch.bfloat16 + ) + image_processor = AutoProcessor.from_pretrained("laion/CLIP-ViT-H-14-laion2B-s32B-b79K") + pipe = WanImageToVideoPipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + image_encoder=image_encoder, + image_processor=image_processor, + ) + elif "Wan2.2-VACE" in args.model_type: + pipe = WanVACEPipeline( + transformer=transformer, + transformer_2=transformer_2, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + boundary_ratio=0.875, + ) + elif "Wan-VACE" in args.model_type: + pipe = WanVACEPipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + ) + elif "Animate" in args.model_type: + image_encoder = CLIPVisionModel.from_pretrained( + "laion/CLIP-ViT-H-14-laion2B-s32B-b79K", torch_dtype=torch.bfloat16 + ) + image_processor = CLIPImageProcessor.from_pretrained("laion/CLIP-ViT-H-14-laion2B-s32B-b79K") + + pipe = WanAnimatePipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + image_encoder=image_encoder, + image_processor=image_processor, + ) + else: + pipe = WanPipeline( + transformer=transformer, + text_encoder=text_encoder, + tokenizer=tokenizer, + vae=vae, + scheduler=scheduler, + ) + + pipe.save_pretrained(args.output_path, safe_serialization=True, max_shard_size="5GB") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_wuerstchen.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_wuerstchen.py new file mode 100644 index 0000000000000000000000000000000000000000..826b9b20818154852a11709d9b2b207a5aa24ffc --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_wuerstchen.py @@ -0,0 +1,115 @@ +# Run inside root directory of official source code: https://github.com/dome272/wuerstchen/ +import os + +import torch +from transformers import AutoTokenizer, CLIPTextModel +from vqgan import VQModel + +from diffusers import ( + DDPMWuerstchenScheduler, + WuerstchenCombinedPipeline, + WuerstchenDecoderPipeline, + WuerstchenPriorPipeline, +) +from diffusers.pipelines.wuerstchen import PaellaVQModel, WuerstchenDiffNeXt, WuerstchenPrior + + +model_path = "models/" +device = "cpu" + +paella_vqmodel = VQModel() +state_dict = torch.load(os.path.join(model_path, "vqgan_f4_v1_500k.pt"), map_location=device)["state_dict"] +paella_vqmodel.load_state_dict(state_dict) + +state_dict["vquantizer.embedding.weight"] = state_dict["vquantizer.codebook.weight"] +state_dict.pop("vquantizer.codebook.weight") +vqmodel = PaellaVQModel(num_vq_embeddings=paella_vqmodel.codebook_size, latent_channels=paella_vqmodel.c_latent) +vqmodel.load_state_dict(state_dict) + +# Clip Text encoder and tokenizer +text_encoder = CLIPTextModel.from_pretrained("laion/CLIP-ViT-bigG-14-laion2B-39B-b160k") +tokenizer = AutoTokenizer.from_pretrained("laion/CLIP-ViT-bigG-14-laion2B-39B-b160k") + +# Generator +gen_text_encoder = CLIPTextModel.from_pretrained("laion/CLIP-ViT-H-14-laion2B-s32B-b79K").to("cpu") +gen_tokenizer = AutoTokenizer.from_pretrained("laion/CLIP-ViT-H-14-laion2B-s32B-b79K") + +orig_state_dict = torch.load(os.path.join(model_path, "model_v2_stage_b.pt"), map_location=device)["state_dict"] +state_dict = {} +for key in orig_state_dict.keys(): + if key.endswith("in_proj_weight"): + weights = orig_state_dict[key].chunk(3, 0) + state_dict[key.replace("attn.in_proj_weight", "to_q.weight")] = weights[0] + state_dict[key.replace("attn.in_proj_weight", "to_k.weight")] = weights[1] + state_dict[key.replace("attn.in_proj_weight", "to_v.weight")] = weights[2] + elif key.endswith("in_proj_bias"): + weights = orig_state_dict[key].chunk(3, 0) + state_dict[key.replace("attn.in_proj_bias", "to_q.bias")] = weights[0] + state_dict[key.replace("attn.in_proj_bias", "to_k.bias")] = weights[1] + state_dict[key.replace("attn.in_proj_bias", "to_v.bias")] = weights[2] + elif key.endswith("out_proj.weight"): + weights = orig_state_dict[key] + state_dict[key.replace("attn.out_proj.weight", "to_out.0.weight")] = weights + elif key.endswith("out_proj.bias"): + weights = orig_state_dict[key] + state_dict[key.replace("attn.out_proj.bias", "to_out.0.bias")] = weights + else: + state_dict[key] = orig_state_dict[key] +decoder = WuerstchenDiffNeXt() +decoder.load_state_dict(state_dict) + +# Prior +orig_state_dict = torch.load(os.path.join(model_path, "model_v3_stage_c.pt"), map_location=device)["ema_state_dict"] +state_dict = {} +for key in orig_state_dict.keys(): + if key.endswith("in_proj_weight"): + weights = orig_state_dict[key].chunk(3, 0) + state_dict[key.replace("attn.in_proj_weight", "to_q.weight")] = weights[0] + state_dict[key.replace("attn.in_proj_weight", "to_k.weight")] = weights[1] + state_dict[key.replace("attn.in_proj_weight", "to_v.weight")] = weights[2] + elif key.endswith("in_proj_bias"): + weights = orig_state_dict[key].chunk(3, 0) + state_dict[key.replace("attn.in_proj_bias", "to_q.bias")] = weights[0] + state_dict[key.replace("attn.in_proj_bias", "to_k.bias")] = weights[1] + state_dict[key.replace("attn.in_proj_bias", "to_v.bias")] = weights[2] + elif key.endswith("out_proj.weight"): + weights = orig_state_dict[key] + state_dict[key.replace("attn.out_proj.weight", "to_out.0.weight")] = weights + elif key.endswith("out_proj.bias"): + weights = orig_state_dict[key] + state_dict[key.replace("attn.out_proj.bias", "to_out.0.bias")] = weights + else: + state_dict[key] = orig_state_dict[key] +prior_model = WuerstchenPrior(c_in=16, c=1536, c_cond=1280, c_r=64, depth=32, nhead=24).to(device) +prior_model.load_state_dict(state_dict) + +# scheduler +scheduler = DDPMWuerstchenScheduler() + +# Prior pipeline +prior_pipeline = WuerstchenPriorPipeline( + prior=prior_model, text_encoder=text_encoder, tokenizer=tokenizer, scheduler=scheduler +) + +prior_pipeline.save_pretrained("warp-ai/wuerstchen-prior") + +decoder_pipeline = WuerstchenDecoderPipeline( + text_encoder=gen_text_encoder, tokenizer=gen_tokenizer, vqgan=vqmodel, decoder=decoder, scheduler=scheduler +) +decoder_pipeline.save_pretrained("warp-ai/wuerstchen") + +# Wuerstchen pipeline +wuerstchen_pipeline = WuerstchenCombinedPipeline( + # Decoder + text_encoder=gen_text_encoder, + tokenizer=gen_tokenizer, + decoder=decoder, + scheduler=scheduler, + vqgan=vqmodel, + # Prior + prior_tokenizer=tokenizer, + prior_text_encoder=text_encoder, + prior=prior_model, + prior_scheduler=scheduler, +) +wuerstchen_pipeline.save_pretrained("warp-ai/WuerstchenCombinedPipeline") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_zero123_to_diffusers.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_zero123_to_diffusers.py new file mode 100644 index 0000000000000000000000000000000000000000..b46633fae7ff878d74223c6b4a9d0dabc7a08182 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/convert_zero123_to_diffusers.py @@ -0,0 +1,807 @@ +""" +This script modified from +https://github.com/huggingface/diffusers/blob/bc691231360a4cbc7d19a58742ebb8ed0f05e027/scripts/convert_original_stable_diffusion_to_diffusers.py + +Convert original Zero1to3 checkpoint to diffusers checkpoint. + +# run the convert script +$ python convert_zero123_to_diffusers.py \ + --checkpoint_path /path/zero123/105000.ckpt \ + --dump_path ./zero1to3 \ + --original_config_file /path/zero123/configs/sd-objaverse-finetune-c_concat-256.yaml +``` +""" + +import argparse + +import torch +import yaml +from accelerate import init_empty_weights +from accelerate.utils import set_module_tensor_to_device +from pipeline_zero1to3 import CCProjection, Zero1to3StableDiffusionPipeline +from transformers import ( + CLIPImageProcessor, + CLIPVisionModelWithProjection, +) + +from diffusers.models import ( + AutoencoderKL, + UNet2DConditionModel, +) +from diffusers.schedulers import DDIMScheduler +from diffusers.utils import logging + + +logger = logging.get_logger(__name__) + + +def create_unet_diffusers_config(original_config, image_size: int, controlnet=False): + """ + Creates a config for the diffusers based on the config of the LDM model. + """ + if controlnet: + unet_params = original_config["model"]["params"]["control_stage_config"]["params"] + else: + if ( + "unet_config" in original_config["model"]["params"] + and original_config["model"]["params"]["unet_config"] is not None + ): + unet_params = original_config["model"]["params"]["unet_config"]["params"] + else: + unet_params = original_config["model"]["params"]["network_config"]["params"] + + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + + block_out_channels = [unet_params["model_channels"] * mult for mult in unet_params["channel_mult"]] + + down_block_types = [] + resolution = 1 + for i in range(len(block_out_channels)): + block_type = "CrossAttnDownBlock2D" if resolution in unet_params["attention_resolutions"] else "DownBlock2D" + down_block_types.append(block_type) + if i != len(block_out_channels) - 1: + resolution *= 2 + + up_block_types = [] + for i in range(len(block_out_channels)): + block_type = "CrossAttnUpBlock2D" if resolution in unet_params["attention_resolutions"] else "UpBlock2D" + up_block_types.append(block_type) + resolution //= 2 + + if unet_params["transformer_depth"] is not None: + transformer_layers_per_block = ( + unet_params["transformer_depth"] + if isinstance(unet_params["transformer_depth"], int) + else list(unet_params["transformer_depth"]) + ) + else: + transformer_layers_per_block = 1 + + vae_scale_factor = 2 ** (len(vae_params["ch_mult"]) - 1) + + head_dim = unet_params["num_heads"] if "num_heads" in unet_params else None + use_linear_projection = ( + unet_params["use_linear_in_transformer"] if "use_linear_in_transformer" in unet_params else False + ) + if use_linear_projection: + # stable diffusion 2-base-512 and 2-768 + if head_dim is None: + head_dim_mult = unet_params["model_channels"] // unet_params["num_head_channels"] + head_dim = [head_dim_mult * c for c in list(unet_params["channel_mult"])] + + class_embed_type = None + addition_embed_type = None + addition_time_embed_dim = None + projection_class_embeddings_input_dim = None + context_dim = None + + if unet_params["context_dim"] is not None: + context_dim = ( + unet_params["context_dim"] + if isinstance(unet_params["context_dim"], int) + else unet_params["context_dim"][0] + ) + + if "num_classes" in unet_params: + if unet_params["num_classes"] == "sequential": + if context_dim in [2048, 1280]: + # SDXL + addition_embed_type = "text_time" + addition_time_embed_dim = 256 + else: + class_embed_type = "projection" + assert "adm_in_channels" in unet_params + projection_class_embeddings_input_dim = unet_params["adm_in_channels"] + else: + raise NotImplementedError(f"Unknown conditional unet num_classes config: {unet_params['num_classes']}") + + config = { + "sample_size": image_size // vae_scale_factor, + "in_channels": unet_params["in_channels"], + "down_block_types": tuple(down_block_types), + "block_out_channels": tuple(block_out_channels), + "layers_per_block": unet_params["num_res_blocks"], + "cross_attention_dim": context_dim, + "attention_head_dim": head_dim, + "use_linear_projection": use_linear_projection, + "class_embed_type": class_embed_type, + "addition_embed_type": addition_embed_type, + "addition_time_embed_dim": addition_time_embed_dim, + "projection_class_embeddings_input_dim": projection_class_embeddings_input_dim, + "transformer_layers_per_block": transformer_layers_per_block, + } + + if controlnet: + config["conditioning_channels"] = unet_params["hint_channels"] + else: + config["out_channels"] = unet_params["out_channels"] + config["up_block_types"] = tuple(up_block_types) + + return config + + +def assign_to_checkpoint( + paths, checkpoint, old_checkpoint, attention_paths_to_split=None, additional_replacements=None, config=None +): + """ + This does the final conversion step: take locally converted weights and apply a global renaming to them. It splits + attention layers, and takes into account additional replacements that may arise. + + Assigns the weights to the new checkpoint. + """ + assert isinstance(paths, list), "Paths should be a list of dicts containing 'old' and 'new' keys." + + # Splits the attention layers into three variables. + if attention_paths_to_split is not None: + for path, path_map in attention_paths_to_split.items(): + old_tensor = old_checkpoint[path] + channels = old_tensor.shape[0] // 3 + + target_shape = (-1, channels) if len(old_tensor.shape) == 3 else (-1) + + num_heads = old_tensor.shape[0] // config["num_head_channels"] // 3 + + old_tensor = old_tensor.reshape((num_heads, 3 * channels // num_heads) + old_tensor.shape[1:]) + query, key, value = old_tensor.split(channels // num_heads, dim=1) + + checkpoint[path_map["query"]] = query.reshape(target_shape) + checkpoint[path_map["key"]] = key.reshape(target_shape) + checkpoint[path_map["value"]] = value.reshape(target_shape) + + for path in paths: + new_path = path["new"] + + # These have already been assigned + if attention_paths_to_split is not None and new_path in attention_paths_to_split: + continue + + # Global renaming happens here + new_path = new_path.replace("middle_block.0", "mid_block.resnets.0") + new_path = new_path.replace("middle_block.1", "mid_block.attentions.0") + new_path = new_path.replace("middle_block.2", "mid_block.resnets.1") + + if additional_replacements is not None: + for replacement in additional_replacements: + new_path = new_path.replace(replacement["old"], replacement["new"]) + + # proj_attn.weight has to be converted from conv 1D to linear + is_attn_weight = "proj_attn.weight" in new_path or ("attentions" in new_path and "to_" in new_path) + shape = old_checkpoint[path["old"]].shape + if is_attn_weight and len(shape) == 3: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0] + elif is_attn_weight and len(shape) == 4: + checkpoint[new_path] = old_checkpoint[path["old"]][:, :, 0, 0] + else: + checkpoint[new_path] = old_checkpoint[path["old"]] + + +def shave_segments(path, n_shave_prefix_segments=1): + """ + Removes segments. Positive values shave the first segments, negative shave the last segments. + """ + if n_shave_prefix_segments >= 0: + return ".".join(path.split(".")[n_shave_prefix_segments:]) + else: + return ".".join(path.split(".")[:n_shave_prefix_segments]) + + +def renew_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item.replace("in_layers.0", "norm1") + new_item = new_item.replace("in_layers.2", "conv1") + + new_item = new_item.replace("out_layers.0", "norm2") + new_item = new_item.replace("out_layers.3", "conv2") + + new_item = new_item.replace("emb_layers.1", "time_emb_proj") + new_item = new_item.replace("skip_connection", "conv_shortcut") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + # new_item = new_item.replace('norm.weight', 'group_norm.weight') + # new_item = new_item.replace('norm.bias', 'group_norm.bias') + + # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight') + # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias') + + # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def convert_ldm_unet_checkpoint( + checkpoint, config, path=None, extract_ema=False, controlnet=False, skip_extract_state_dict=False +): + """ + Takes a state dict and a config, and returns a converted checkpoint. + """ + + if skip_extract_state_dict: + unet_state_dict = checkpoint + else: + # extract state_dict for UNet + unet_state_dict = {} + keys = list(checkpoint.keys()) + + if controlnet: + unet_key = "control_model." + else: + unet_key = "model.diffusion_model." + + # at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA + if sum(k.startswith("model_ema") for k in keys) > 100 and extract_ema: + logger.warning(f"Checkpoint {path} has both EMA and non-EMA weights.") + logger.warning( + "In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA" + " weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag." + ) + for key in keys: + if key.startswith("model.diffusion_model"): + flat_ema_key = "model_ema." + "".join(key.split(".")[1:]) + unet_state_dict[key.replace(unet_key, "")] = checkpoint[flat_ema_key] + else: + if sum(k.startswith("model_ema") for k in keys) > 100: + logger.warning( + "In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA" + " weights (usually better for inference), please make sure to add the `--extract_ema` flag." + ) + + for key in keys: + if key.startswith(unet_key): + unet_state_dict[key.replace(unet_key, "")] = checkpoint[key] + + new_checkpoint = {} + + new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] + new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] + new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"] + new_checkpoint["time_embedding.linear_2.bias"] = unet_state_dict["time_embed.2.bias"] + + if config["class_embed_type"] is None: + # No parameters to port + ... + elif config["class_embed_type"] == "timestep" or config["class_embed_type"] == "projection": + new_checkpoint["class_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["class_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["class_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["class_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + else: + raise NotImplementedError(f"Not implemented `class_embed_type`: {config['class_embed_type']}") + + if config["addition_embed_type"] == "text_time": + new_checkpoint["add_embedding.linear_1.weight"] = unet_state_dict["label_emb.0.0.weight"] + new_checkpoint["add_embedding.linear_1.bias"] = unet_state_dict["label_emb.0.0.bias"] + new_checkpoint["add_embedding.linear_2.weight"] = unet_state_dict["label_emb.0.2.weight"] + new_checkpoint["add_embedding.linear_2.bias"] = unet_state_dict["label_emb.0.2.bias"] + + new_checkpoint["conv_in.weight"] = unet_state_dict["input_blocks.0.0.weight"] + new_checkpoint["conv_in.bias"] = unet_state_dict["input_blocks.0.0.bias"] + + if not controlnet: + new_checkpoint["conv_norm_out.weight"] = unet_state_dict["out.0.weight"] + new_checkpoint["conv_norm_out.bias"] = unet_state_dict["out.0.bias"] + new_checkpoint["conv_out.weight"] = unet_state_dict["out.2.weight"] + new_checkpoint["conv_out.bias"] = unet_state_dict["out.2.bias"] + + # Retrieves the keys for the input blocks only + num_input_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "input_blocks" in layer}) + input_blocks = { + layer_id: [key for key in unet_state_dict if f"input_blocks.{layer_id}" in key] + for layer_id in range(num_input_blocks) + } + + # Retrieves the keys for the middle blocks only + num_middle_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "middle_block" in layer}) + middle_blocks = { + layer_id: [key for key in unet_state_dict if f"middle_block.{layer_id}" in key] + for layer_id in range(num_middle_blocks) + } + + # Retrieves the keys for the output blocks only + num_output_blocks = len({".".join(layer.split(".")[:2]) for layer in unet_state_dict if "output_blocks" in layer}) + output_blocks = { + layer_id: [key for key in unet_state_dict if f"output_blocks.{layer_id}" in key] + for layer_id in range(num_output_blocks) + } + + for i in range(1, num_input_blocks): + block_id = (i - 1) // (config["layers_per_block"] + 1) + layer_in_block_id = (i - 1) % (config["layers_per_block"] + 1) + + resnets = [ + key for key in input_blocks[i] if f"input_blocks.{i}.0" in key and f"input_blocks.{i}.0.op" not in key + ] + attentions = [key for key in input_blocks[i] if f"input_blocks.{i}.1" in key] + + if f"input_blocks.{i}.0.op.weight" in unet_state_dict: + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.weight"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.weight" + ) + new_checkpoint[f"down_blocks.{block_id}.downsamplers.0.conv.bias"] = unet_state_dict.pop( + f"input_blocks.{i}.0.op.bias" + ) + + paths = renew_resnet_paths(resnets) + meta_path = {"old": f"input_blocks.{i}.0", "new": f"down_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = {"old": f"input_blocks.{i}.1", "new": f"down_blocks.{block_id}.attentions.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + resnet_0 = middle_blocks[0] + attentions = middle_blocks[1] + resnet_1 = middle_blocks[2] + + resnet_0_paths = renew_resnet_paths(resnet_0) + assign_to_checkpoint(resnet_0_paths, new_checkpoint, unet_state_dict, config=config) + + resnet_1_paths = renew_resnet_paths(resnet_1) + assign_to_checkpoint(resnet_1_paths, new_checkpoint, unet_state_dict, config=config) + + attentions_paths = renew_attention_paths(attentions) + meta_path = {"old": "middle_block.1", "new": "mid_block.attentions.0"} + assign_to_checkpoint( + attentions_paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + for i in range(num_output_blocks): + block_id = i // (config["layers_per_block"] + 1) + layer_in_block_id = i % (config["layers_per_block"] + 1) + output_block_layers = [shave_segments(name, 2) for name in output_blocks[i]] + output_block_list = {} + + for layer in output_block_layers: + layer_id, layer_name = layer.split(".")[0], shave_segments(layer, 1) + if layer_id in output_block_list: + output_block_list[layer_id].append(layer_name) + else: + output_block_list[layer_id] = [layer_name] + + if len(output_block_list) > 1: + resnets = [key for key in output_blocks[i] if f"output_blocks.{i}.0" in key] + attentions = [key for key in output_blocks[i] if f"output_blocks.{i}.1" in key] + + resnet_0_paths = renew_resnet_paths(resnets) + paths = renew_resnet_paths(resnets) + + meta_path = {"old": f"output_blocks.{i}.0", "new": f"up_blocks.{block_id}.resnets.{layer_in_block_id}"} + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + + output_block_list = {k: sorted(v) for k, v in output_block_list.items()} + if ["conv.bias", "conv.weight"] in output_block_list.values(): + index = list(output_block_list.values()).index(["conv.bias", "conv.weight"]) + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.weight"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.weight" + ] + new_checkpoint[f"up_blocks.{block_id}.upsamplers.0.conv.bias"] = unet_state_dict[ + f"output_blocks.{i}.{index}.conv.bias" + ] + + # Clear attentions as they have been attributed above. + if len(attentions) == 2: + attentions = [] + + if len(attentions): + paths = renew_attention_paths(attentions) + meta_path = { + "old": f"output_blocks.{i}.1", + "new": f"up_blocks.{block_id}.attentions.{layer_in_block_id}", + } + assign_to_checkpoint( + paths, new_checkpoint, unet_state_dict, additional_replacements=[meta_path], config=config + ) + else: + resnet_0_paths = renew_resnet_paths(output_block_layers, n_shave_prefix_segments=1) + for path in resnet_0_paths: + old_path = ".".join(["output_blocks", str(i), path["old"]]) + new_path = ".".join(["up_blocks", str(block_id), "resnets", str(layer_in_block_id), path["new"]]) + + new_checkpoint[new_path] = unet_state_dict[old_path] + + if controlnet: + # conditioning embedding + + orig_index = 0 + + new_checkpoint["controlnet_cond_embedding.conv_in.weight"] = unet_state_dict.pop( + f"input_hint_block.{orig_index}.weight" + ) + new_checkpoint["controlnet_cond_embedding.conv_in.bias"] = unet_state_dict.pop( + f"input_hint_block.{orig_index}.bias" + ) + + orig_index += 2 + + diffusers_index = 0 + + while diffusers_index < 6: + new_checkpoint[f"controlnet_cond_embedding.blocks.{diffusers_index}.weight"] = unet_state_dict.pop( + f"input_hint_block.{orig_index}.weight" + ) + new_checkpoint[f"controlnet_cond_embedding.blocks.{diffusers_index}.bias"] = unet_state_dict.pop( + f"input_hint_block.{orig_index}.bias" + ) + diffusers_index += 1 + orig_index += 2 + + new_checkpoint["controlnet_cond_embedding.conv_out.weight"] = unet_state_dict.pop( + f"input_hint_block.{orig_index}.weight" + ) + new_checkpoint["controlnet_cond_embedding.conv_out.bias"] = unet_state_dict.pop( + f"input_hint_block.{orig_index}.bias" + ) + + # down blocks + for i in range(num_input_blocks): + new_checkpoint[f"controlnet_down_blocks.{i}.weight"] = unet_state_dict.pop(f"zero_convs.{i}.0.weight") + new_checkpoint[f"controlnet_down_blocks.{i}.bias"] = unet_state_dict.pop(f"zero_convs.{i}.0.bias") + + # mid block + new_checkpoint["controlnet_mid_block.weight"] = unet_state_dict.pop("middle_block_out.0.weight") + new_checkpoint["controlnet_mid_block.bias"] = unet_state_dict.pop("middle_block_out.0.bias") + + return new_checkpoint + + +def create_vae_diffusers_config(original_config, image_size: int): + """ + Creates a config for the diffusers based on the config of the LDM model. + """ + vae_params = original_config["model"]["params"]["first_stage_config"]["params"]["ddconfig"] + _ = original_config["model"]["params"]["first_stage_config"]["params"]["embed_dim"] + + block_out_channels = [vae_params["ch"] * mult for mult in vae_params["ch_mult"]] + down_block_types = ["DownEncoderBlock2D"] * len(block_out_channels) + up_block_types = ["UpDecoderBlock2D"] * len(block_out_channels) + + config = { + "sample_size": image_size, + "in_channels": vae_params["in_channels"], + "out_channels": vae_params["out_ch"], + "down_block_types": tuple(down_block_types), + "up_block_types": tuple(up_block_types), + "block_out_channels": tuple(block_out_channels), + "latent_channels": vae_params["z_channels"], + "layers_per_block": vae_params["num_res_blocks"], + } + return config + + +def convert_ldm_vae_checkpoint(checkpoint, config): + # extract state dict for VAE + vae_state_dict = {} + vae_key = "first_stage_model." + keys = list(checkpoint.keys()) + for key in keys: + if key.startswith(vae_key): + vae_state_dict[key.replace(vae_key, "")] = checkpoint.get(key) + + new_checkpoint = {} + + new_checkpoint["encoder.conv_in.weight"] = vae_state_dict["encoder.conv_in.weight"] + new_checkpoint["encoder.conv_in.bias"] = vae_state_dict["encoder.conv_in.bias"] + new_checkpoint["encoder.conv_out.weight"] = vae_state_dict["encoder.conv_out.weight"] + new_checkpoint["encoder.conv_out.bias"] = vae_state_dict["encoder.conv_out.bias"] + new_checkpoint["encoder.conv_norm_out.weight"] = vae_state_dict["encoder.norm_out.weight"] + new_checkpoint["encoder.conv_norm_out.bias"] = vae_state_dict["encoder.norm_out.bias"] + + new_checkpoint["decoder.conv_in.weight"] = vae_state_dict["decoder.conv_in.weight"] + new_checkpoint["decoder.conv_in.bias"] = vae_state_dict["decoder.conv_in.bias"] + new_checkpoint["decoder.conv_out.weight"] = vae_state_dict["decoder.conv_out.weight"] + new_checkpoint["decoder.conv_out.bias"] = vae_state_dict["decoder.conv_out.bias"] + new_checkpoint["decoder.conv_norm_out.weight"] = vae_state_dict["decoder.norm_out.weight"] + new_checkpoint["decoder.conv_norm_out.bias"] = vae_state_dict["decoder.norm_out.bias"] + + new_checkpoint["quant_conv.weight"] = vae_state_dict["quant_conv.weight"] + new_checkpoint["quant_conv.bias"] = vae_state_dict["quant_conv.bias"] + new_checkpoint["post_quant_conv.weight"] = vae_state_dict["post_quant_conv.weight"] + new_checkpoint["post_quant_conv.bias"] = vae_state_dict["post_quant_conv.bias"] + + # Retrieves the keys for the encoder down blocks only + num_down_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "encoder.down" in layer}) + down_blocks = { + layer_id: [key for key in vae_state_dict if f"down.{layer_id}" in key] for layer_id in range(num_down_blocks) + } + + # Retrieves the keys for the decoder up blocks only + num_up_blocks = len({".".join(layer.split(".")[:3]) for layer in vae_state_dict if "decoder.up" in layer}) + up_blocks = { + layer_id: [key for key in vae_state_dict if f"up.{layer_id}" in key] for layer_id in range(num_up_blocks) + } + + for i in range(num_down_blocks): + resnets = [key for key in down_blocks[i] if f"down.{i}" in key and f"down.{i}.downsample" not in key] + + if f"encoder.down.{i}.downsample.conv.weight" in vae_state_dict: + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.weight"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.weight" + ) + new_checkpoint[f"encoder.down_blocks.{i}.downsamplers.0.conv.bias"] = vae_state_dict.pop( + f"encoder.down.{i}.downsample.conv.bias" + ) + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"down.{i}.block", "new": f"down_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "encoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"encoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "encoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + + for i in range(num_up_blocks): + block_id = num_up_blocks - 1 - i + resnets = [ + key for key in up_blocks[block_id] if f"up.{block_id}" in key and f"up.{block_id}.upsample" not in key + ] + + if f"decoder.up.{block_id}.upsample.conv.weight" in vae_state_dict: + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.weight"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.weight" + ] + new_checkpoint[f"decoder.up_blocks.{i}.upsamplers.0.conv.bias"] = vae_state_dict[ + f"decoder.up.{block_id}.upsample.conv.bias" + ] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"up.{block_id}.block", "new": f"up_blocks.{i}.resnets"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_resnets = [key for key in vae_state_dict if "decoder.mid.block" in key] + num_mid_res_blocks = 2 + for i in range(1, num_mid_res_blocks + 1): + resnets = [key for key in mid_resnets if f"decoder.mid.block_{i}" in key] + + paths = renew_vae_resnet_paths(resnets) + meta_path = {"old": f"mid.block_{i}", "new": f"mid_block.resnets.{i - 1}"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + + mid_attentions = [key for key in vae_state_dict if "decoder.mid.attn" in key] + paths = renew_vae_attention_paths(mid_attentions) + meta_path = {"old": "mid.attn_1", "new": "mid_block.attentions.0"} + assign_to_checkpoint(paths, new_checkpoint, vae_state_dict, additional_replacements=[meta_path], config=config) + conv_attn_to_linear(new_checkpoint) + return new_checkpoint + + +def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside resnets to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("nin_shortcut", "conv_shortcut") + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): + """ + Updates paths inside attentions to the new naming scheme (local renaming) + """ + mapping = [] + for old_item in old_list: + new_item = old_item + + new_item = new_item.replace("norm.weight", "group_norm.weight") + new_item = new_item.replace("norm.bias", "group_norm.bias") + + new_item = new_item.replace("q.weight", "to_q.weight") + new_item = new_item.replace("q.bias", "to_q.bias") + + new_item = new_item.replace("k.weight", "to_k.weight") + new_item = new_item.replace("k.bias", "to_k.bias") + + new_item = new_item.replace("v.weight", "to_v.weight") + new_item = new_item.replace("v.bias", "to_v.bias") + + new_item = new_item.replace("proj_out.weight", "to_out.0.weight") + new_item = new_item.replace("proj_out.bias", "to_out.0.bias") + + new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) + + mapping.append({"old": old_item, "new": new_item}) + + return mapping + + +def conv_attn_to_linear(checkpoint): + keys = list(checkpoint.keys()) + attn_keys = ["query.weight", "key.weight", "value.weight"] + for key in keys: + if ".".join(key.split(".")[-2:]) in attn_keys: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0, 0] + elif "proj_attn.weight" in key: + if checkpoint[key].ndim > 2: + checkpoint[key] = checkpoint[key][:, :, 0] + + +def convert_from_original_zero123_ckpt(checkpoint_path, original_config_file, extract_ema, device): + ckpt = torch.load(checkpoint_path, map_location=device) + ckpt["global_step"] + checkpoint = ckpt["state_dict"] + del ckpt + torch.cuda.empty_cache() + + original_config = yaml.safe_load(original_config_file) + original_config["model"]["params"]["cond_stage_config"]["target"].split(".")[-1] + num_in_channels = 8 + original_config["model"]["params"]["unet_config"]["params"]["in_channels"] = num_in_channels + prediction_type = "epsilon" + image_size = 256 + num_train_timesteps = getattr(original_config["model"]["params"], "timesteps", None) or 1000 + + beta_start = getattr(original_config["model"]["params"], "linear_start", None) or 0.02 + beta_end = getattr(original_config["model"]["params"], "linear_end", None) or 0.085 + scheduler = DDIMScheduler( + beta_end=beta_end, + beta_schedule="scaled_linear", + beta_start=beta_start, + num_train_timesteps=num_train_timesteps, + steps_offset=1, + clip_sample=False, + set_alpha_to_one=False, + prediction_type=prediction_type, + ) + scheduler.register_to_config(clip_sample=False) + + # Convert the UNet2DConditionModel model. + upcast_attention = None + unet_config = create_unet_diffusers_config(original_config, image_size=image_size) + unet_config["upcast_attention"] = upcast_attention + with init_empty_weights(): + unet = UNet2DConditionModel(**unet_config) + converted_unet_checkpoint = convert_ldm_unet_checkpoint( + checkpoint, unet_config, path=None, extract_ema=extract_ema + ) + for param_name, param in converted_unet_checkpoint.items(): + set_module_tensor_to_device(unet, param_name, "cpu", value=param) + + # Convert the VAE model. + vae_config = create_vae_diffusers_config(original_config, image_size=image_size) + converted_vae_checkpoint = convert_ldm_vae_checkpoint(checkpoint, vae_config) + + if ( + "model" in original_config + and "params" in original_config["model"] + and "scale_factor" in original_config["model"]["params"] + ): + vae_scaling_factor = original_config["model"]["params"]["scale_factor"] + else: + vae_scaling_factor = 0.18215 # default SD scaling factor + + vae_config["scaling_factor"] = vae_scaling_factor + + with init_empty_weights(): + vae = AutoencoderKL(**vae_config) + + for param_name, param in converted_vae_checkpoint.items(): + set_module_tensor_to_device(vae, param_name, "cpu", value=param) + + feature_extractor = CLIPImageProcessor.from_pretrained( + "lambdalabs/sd-image-variations-diffusers", subfolder="feature_extractor" + ) + image_encoder = CLIPVisionModelWithProjection.from_pretrained( + "lambdalabs/sd-image-variations-diffusers", subfolder="image_encoder" + ) + + cc_projection = CCProjection() + cc_projection.load_state_dict( + { + "projection.weight": checkpoint["cc_projection.weight"].cpu(), + "projection.bias": checkpoint["cc_projection.bias"].cpu(), + } + ) + + pipe = Zero1to3StableDiffusionPipeline( + vae, image_encoder, unet, scheduler, None, feature_extractor, cc_projection, requires_safety_checker=False + ) + + return pipe + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--checkpoint_path", default=None, type=str, required=True, help="Path to the checkpoint to convert." + ) + parser.add_argument( + "--original_config_file", + default=None, + type=str, + help="The YAML config file corresponding to the original architecture.", + ) + parser.add_argument( + "--extract_ema", + action="store_true", + help=( + "Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights" + " or not. Defaults to `False`. Add `--extract_ema` to extract the EMA weights. EMA weights usually yield" + " higher quality images for inference. Non-EMA weights are usually better to continue fine-tuning." + ), + ) + parser.add_argument( + "--to_safetensors", + action="store_true", + help="Whether to store pipeline in safetensors format or not.", + ) + parser.add_argument("--half", action="store_true", help="Save weights in half precision.") + parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") + args = parser.parse_args() + + pipe = convert_from_original_zero123_ckpt( + checkpoint_path=args.checkpoint_path, + original_config_file=args.original_config_file, + extract_ema=args.extract_ema, + device=args.device, + ) + + if args.half: + pipe.to(dtype=torch.float16) + + pipe.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/extract_lora_from_model.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/extract_lora_from_model.py new file mode 100644 index 0000000000000000000000000000000000000000..0e01ddea47f9751f89309b24fc7cbf08c93e6f3e --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/extract_lora_from_model.py @@ -0,0 +1,151 @@ +""" +This script demonstrates how to extract a LoRA checkpoint from a fully finetuned model with the CogVideoX model. + +To make it work for other models: + +* Change the model class. Here we use `CogVideoXTransformer3DModel`. For Flux, it would be `FluxTransformer2DModel`, +for example. (TODO: more reason to add `AutoModel`). +* Spply path to the base checkpoint via `base_ckpt_path`. +* Supply path to the fully fine-tuned checkpoint via `--finetune_ckpt_path`. +* Change the `--rank` as needed. + +Example usage: + +```bash +python extract_lora_from_model.py \ + --base_ckpt_path=THUDM/CogVideoX-5b \ + --finetune_ckpt_path=finetrainers/cakeify-v0 \ + --lora_out_path=cakeify_lora.safetensors +``` + +Script is adapted from +https://github.com/Stability-AI/stability-ComfyUI-nodes/blob/001154622564b17223ce0191803c5fff7b87146c/control_lora_create.py +""" + +import argparse + +import torch +from safetensors.torch import save_file +from tqdm.auto import tqdm + +from diffusers import CogVideoXTransformer3DModel + + +RANK = 64 +CLAMP_QUANTILE = 0.99 + + +# Comes from +# https://github.com/Stability-AI/stability-ComfyUI-nodes/blob/001154622564b17223ce0191803c5fff7b87146c/control_lora_create.py#L9 +def extract_lora(diff, rank): + # Important to use CUDA otherwise, very slow! + if torch.cuda.is_available(): + diff = diff.to("cuda") + + is_conv2d = len(diff.shape) == 4 + kernel_size = None if not is_conv2d else diff.size()[2:4] + is_conv2d_3x3 = is_conv2d and kernel_size != (1, 1) + out_dim, in_dim = diff.size()[0:2] + rank = min(rank, in_dim, out_dim) + + if is_conv2d: + if is_conv2d_3x3: + diff = diff.flatten(start_dim=1) + else: + diff = diff.squeeze() + + U, S, Vh = torch.linalg.svd(diff.float()) + U = U[:, :rank] + S = S[:rank] + U = U @ torch.diag(S) + Vh = Vh[:rank, :] + + dist = torch.cat([U.flatten(), Vh.flatten()]) + hi_val = torch.quantile(dist, CLAMP_QUANTILE) + low_val = -hi_val + + U = U.clamp(low_val, hi_val) + Vh = Vh.clamp(low_val, hi_val) + if is_conv2d: + U = U.reshape(out_dim, rank, 1, 1) + Vh = Vh.reshape(rank, in_dim, kernel_size[0], kernel_size[1]) + return (U.cpu(), Vh.cpu()) + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--base_ckpt_path", + default=None, + type=str, + required=True, + help="Base checkpoint path from which the model was finetuned. Can be a model ID on the Hub.", + ) + parser.add_argument( + "--base_subfolder", + default="transformer", + type=str, + help="subfolder to load the base checkpoint from if any.", + ) + parser.add_argument( + "--finetune_ckpt_path", + default=None, + type=str, + required=True, + help="Fully fine-tuned checkpoint path. Can be a model ID on the Hub.", + ) + parser.add_argument( + "--finetune_subfolder", + default=None, + type=str, + help="subfolder to load the fulle finetuned checkpoint from if any.", + ) + parser.add_argument("--rank", default=64, type=int) + parser.add_argument("--lora_out_path", default=None, type=str, required=True) + args = parser.parse_args() + + if not args.lora_out_path.endswith(".safetensors"): + raise ValueError("`lora_out_path` must end with `.safetensors`.") + + return args + + +@torch.no_grad() +def main(args): + model_finetuned = CogVideoXTransformer3DModel.from_pretrained( + args.finetune_ckpt_path, subfolder=args.finetune_subfolder, torch_dtype=torch.bfloat16 + ) + state_dict_ft = model_finetuned.state_dict() + + # Change the `subfolder` as needed. + base_model = CogVideoXTransformer3DModel.from_pretrained( + args.base_ckpt_path, subfolder=args.base_subfolder, torch_dtype=torch.bfloat16 + ) + state_dict = base_model.state_dict() + output_dict = {} + + for k in tqdm(state_dict, desc="Extracting LoRA..."): + original_param = state_dict[k] + finetuned_param = state_dict_ft[k] + if len(original_param.shape) >= 2: + diff = finetuned_param.float() - original_param.float() + out = extract_lora(diff, RANK) + name = k + + if name.endswith(".weight"): + name = name[: -len(".weight")] + down_key = "{}.lora_A.weight".format(name) + up_key = "{}.lora_B.weight".format(name) + + output_dict[up_key] = out[0].contiguous().to(finetuned_param.dtype) + output_dict[down_key] = out[1].contiguous().to(finetuned_param.dtype) + + prefix = "transformer" if "transformer" in base_model.__class__.__name__.lower() else "unet" + output_dict = {f"{prefix}.{k}": v for k, v in output_dict.items()} + save_file(output_dict, args.lora_out_path) + print(f"LoRA saved and it contains {len(output_dict)} keys.") + + +if __name__ == "__main__": + args = parse_args() + main(args) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/generate_logits.py b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/generate_logits.py new file mode 100644 index 0000000000000000000000000000000000000000..99d46d6628a61c7e6cc0cb662ea382716a43843f --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/scripts/generate_logits.py @@ -0,0 +1,127 @@ +import random + +import torch +from huggingface_hub import HfApi + +from diffusers import UNet2DModel + + +api = HfApi() + +results = {} +# fmt: off +results["google_ddpm_cifar10_32"] = torch.tensor([ + -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, + 1.2342, -2.2485, 0.4636, 0.8076, -0.7991, 0.3969, 0.8498, 0.9189, + -1.8887, -3.3522, 0.7639, 0.2040, 0.6271, -2.7148, -1.6316, 3.0839, + 0.3186, 0.2721, -0.9759, -1.2461, 2.6257, 1.3557 +]) +results["google_ddpm_ema_bedroom_256"] = torch.tensor([ + -2.3639, -2.5344, 0.0054, -0.6674, 1.5990, 1.0158, 0.3124, -2.1436, + 1.8795, -2.5429, -0.1566, -0.3973, 1.2490, 2.6447, 1.2283, -0.5208, + -2.8154, -3.5119, 2.3838, 1.2033, 1.7201, -2.1256, -1.4576, 2.7948, + 2.4204, -0.9752, -1.2546, 0.8027, 3.2758, 3.1365 +]) +results["CompVis_ldm_celebahq_256"] = torch.tensor([ + -0.6531, -0.6891, -0.3172, -0.5375, -0.9140, -0.5367, -0.1175, -0.7869, + -0.3808, -0.4513, -0.2098, -0.0083, 0.3183, 0.5140, 0.2247, -0.1304, + -0.1302, -0.2802, -0.2084, -0.2025, -0.4967, -0.4873, -0.0861, 0.6925, + 0.0250, 0.1290, -0.1543, 0.6316, 1.0460, 1.4943 +]) +results["google_ncsnpp_ffhq_1024"] = torch.tensor([ + 0.0911, 0.1107, 0.0182, 0.0435, -0.0805, -0.0608, 0.0381, 0.2172, + -0.0280, 0.1327, -0.0299, -0.0255, -0.0050, -0.1170, -0.1046, 0.0309, + 0.1367, 0.1728, -0.0533, -0.0748, -0.0534, 0.1624, 0.0384, -0.1805, + -0.0707, 0.0642, 0.0220, -0.0134, -0.1333, -0.1505 +]) +results["google_ncsnpp_bedroom_256"] = torch.tensor([ + 0.1321, 0.1337, 0.0440, 0.0622, -0.0591, -0.0370, 0.0503, 0.2133, + -0.0177, 0.1415, -0.0116, -0.0112, 0.0044, -0.0980, -0.0789, 0.0395, + 0.1502, 0.1785, -0.0488, -0.0514, -0.0404, 0.1539, 0.0454, -0.1559, + -0.0665, 0.0659, 0.0383, -0.0005, -0.1266, -0.1386 +]) +results["google_ncsnpp_celebahq_256"] = torch.tensor([ + 0.1154, 0.1218, 0.0307, 0.0526, -0.0711, -0.0541, 0.0366, 0.2078, + -0.0267, 0.1317, -0.0226, -0.0193, -0.0014, -0.1055, -0.0902, 0.0330, + 0.1391, 0.1709, -0.0562, -0.0693, -0.0560, 0.1482, 0.0381, -0.1683, + -0.0681, 0.0661, 0.0331, -0.0046, -0.1268, -0.1431 +]) +results["google_ncsnpp_church_256"] = torch.tensor([ + 0.1192, 0.1240, 0.0414, 0.0606, -0.0557, -0.0412, 0.0430, 0.2042, + -0.0200, 0.1385, -0.0115, -0.0132, 0.0017, -0.0965, -0.0802, 0.0398, + 0.1433, 0.1747, -0.0458, -0.0533, -0.0407, 0.1545, 0.0419, -0.1574, + -0.0645, 0.0626, 0.0341, -0.0010, -0.1199, -0.1390 +]) +results["google_ncsnpp_ffhq_256"] = torch.tensor([ + 0.1075, 0.1074, 0.0205, 0.0431, -0.0774, -0.0607, 0.0298, 0.2042, + -0.0320, 0.1267, -0.0281, -0.0250, -0.0064, -0.1091, -0.0946, 0.0290, + 0.1328, 0.1650, -0.0580, -0.0738, -0.0586, 0.1440, 0.0337, -0.1746, + -0.0712, 0.0605, 0.0250, -0.0099, -0.1316, -0.1473 +]) +results["google_ddpm_cat_256"] = torch.tensor([ + -1.4572, -2.0481, -0.0414, -0.6005, 1.4136, 0.5848, 0.4028, -2.7330, + 1.2212, -2.1228, 0.2155, 0.4039, 0.7662, 2.0535, 0.7477, -0.3243, + -2.1758, -2.7648, 1.6947, 0.7026, 1.2338, -1.6078, -0.8682, 2.2810, + 1.8574, -0.5718, -0.5586, -0.0186, 2.3415, 2.1251]) +results["google_ddpm_celebahq_256"] = torch.tensor([ + -1.3690, -1.9720, -0.4090, -0.6966, 1.4660, 0.9938, -0.1385, -2.7324, + 0.7736, -1.8917, 0.2923, 0.4293, 0.1693, 1.4112, 1.1887, -0.3181, + -2.2160, -2.6381, 1.3170, 0.8163, 0.9240, -1.6544, -0.6099, 2.5259, + 1.6430, -0.9090, -0.9392, -0.0126, 2.4268, 2.3266 +]) +results["google_ddpm_ema_celebahq_256"] = torch.tensor([ + -1.3525, -1.9628, -0.3956, -0.6860, 1.4664, 1.0014, -0.1259, -2.7212, + 0.7772, -1.8811, 0.2996, 0.4388, 0.1704, 1.4029, 1.1701, -0.3027, + -2.2053, -2.6287, 1.3350, 0.8131, 0.9274, -1.6292, -0.6098, 2.5131, + 1.6505, -0.8958, -0.9298, -0.0151, 2.4257, 2.3355 +]) +results["google_ddpm_church_256"] = torch.tensor([ + -2.0585, -2.7897, -0.2850, -0.8940, 1.9052, 0.5702, 0.6345, -3.8959, + 1.5932, -3.2319, 0.1974, 0.0287, 1.7566, 2.6543, 0.8387, -0.5351, + -3.2736, -4.3375, 2.9029, 1.6390, 1.4640, -2.1701, -1.9013, 2.9341, + 3.4981, -0.6255, -1.1644, -0.1591, 3.7097, 3.2066 +]) +results["google_ddpm_bedroom_256"] = torch.tensor([ + -2.3139, -2.5594, -0.0197, -0.6785, 1.7001, 1.1606, 0.3075, -2.1740, + 1.8071, -2.5630, -0.0926, -0.3811, 1.2116, 2.6246, 1.2731, -0.5398, + -2.8153, -3.6140, 2.3893, 1.3262, 1.6258, -2.1856, -1.3267, 2.8395, + 2.3779, -1.0623, -1.2468, 0.8959, 3.3367, 3.2243 +]) +results["google_ddpm_ema_church_256"] = torch.tensor([ + -2.0628, -2.7667, -0.2089, -0.8263, 2.0539, 0.5992, 0.6495, -3.8336, + 1.6025, -3.2817, 0.1721, -0.0633, 1.7516, 2.7039, 0.8100, -0.5908, + -3.2113, -4.4343, 2.9257, 1.3632, 1.5562, -2.1489, -1.9894, 3.0560, + 3.3396, -0.7328, -1.0417, 0.0383, 3.7093, 3.2343 +]) +results["google_ddpm_ema_cat_256"] = torch.tensor([ + -1.4574, -2.0569, -0.0473, -0.6117, 1.4018, 0.5769, 0.4129, -2.7344, + 1.2241, -2.1397, 0.2000, 0.3937, 0.7616, 2.0453, 0.7324, -0.3391, + -2.1746, -2.7744, 1.6963, 0.6921, 1.2187, -1.6172, -0.8877, 2.2439, + 1.8471, -0.5839, -0.5605, -0.0464, 2.3250, 2.1219 +]) +# fmt: on + +models = api.list_models(filter="diffusers") +for mod in models: + if "google" in mod.author or mod.id == "CompVis/ldm-celebahq-256": + local_checkpoint = "/home/patrick/google_checkpoints/" + mod.id.split("/")[-1] + + print(f"Started running {mod.id}!!!") + + if mod.id.startswith("CompVis"): + model = UNet2DModel.from_pretrained(local_checkpoint, subfolder="unet") + else: + model = UNet2DModel.from_pretrained(local_checkpoint) + + torch.manual_seed(0) + random.seed(0) + + noise = torch.randn(1, model.config.in_channels, model.config.sample_size, model.config.sample_size) + time_step = torch.tensor([10] * noise.shape[0]) + with torch.no_grad(): + logits = model(noise, time_step).sample + + assert torch.allclose( + logits[0, 0, 0, :30], results["_".join("_".join(mod.id.split("/")).split("-"))], atol=1e-3 + ) + print(f"{mod.id} has passed successfully!!!") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/setup.py b/tasks/tasksmith-1c5704b1f07f/environment/source/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..8d346ddfeccae1c999fa454a1a6cd8b5eb77b732 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/setup.py @@ -0,0 +1,306 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/main/setup.py + +To create the package for PyPI. + +1. Run `make pre-release` (or `make pre-patch` for a patch release) then run `make fix-copies` to fix the index of the + documentation. + + If releasing on a special branch, copy the updated README.md on the main branch for the commit you will make + for the post-release and run `make fix-copies` on the main branch as well. + +2. Unpin specific versions from setup.py that use a git install. + +3. Checkout the release branch (v-release, for example v4.19-release), and commit these changes with the + message: "Release: " and push. + +4. Manually trigger the "Nightly and release tests on main/release branch" workflow from the release branch. Wait for + the tests to complete. We can safely ignore the known test failures. + +5. Wait for the tests on main to be completed and be green (otherwise revert and fix bugs). + +6. Add a tag in git to mark the release: "git tag v -m 'Adds tag v for PyPI'" + Push the tag to git: git push --tags origin v-release + +7. Build both the sources and the wheel. Do not change anything in setup.py between + creating the wheel and the source distribution (obviously). + + For the wheel, run: "python setup.py bdist_wheel" in the top level directory + (This will build a wheel for the Python version you use to build it). + + For the sources, run: "python setup.py sdist" + You should now have a /dist directory with both .whl and .tar.gz source versions. + + Long story cut short, you need to run both before you can upload the distribution to the + test PyPI and the actual PyPI servers: + + python setup.py bdist_wheel && python setup.py sdist + +8. Check that everything looks correct by uploading the package to the PyPI test server: + + twine upload dist/* -r pypitest + (pypi suggests using twine as other methods upload files via plaintext.) + You may have to specify the repository url, use the following command then: + twine upload dist/* -r pypitest --repository-url=https://test.pypi.org/legacy/ + + Check that you can install it in a virtualenv by running: + pip install -i https://testpypi.python.org/pypi diffusers + + If you are testing from a Colab Notebook, for instance, then do: + pip install diffusers && pip uninstall diffusers + pip install -i https://testpypi.python.org/pypi diffusers + + Check you can run the following commands: + python -c "from diffusers import __version__; print(__version__)" + python -c "from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained('fusing/unet-ldm-dummy-update'); pipe()" + python -c "from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained('hf-internal-testing/tiny-stable-diffusion-pipe', safety_checker=None); pipe('ah suh du')" + python -c "from diffusers import *" + +9. Upload the final version to the actual PyPI: + twine upload dist/* -r pypi + +10. Prepare the release notes and publish them on GitHub once everything is looking hunky-dory. You can use the following + Space to fetch all the commits applicable for the release: https://huggingface.co/spaces/sayakpaul/auto-release-notes-diffusers. + It automatically fetches the correct tag and branch but also provides the option to configure them. + `tag` should be the previous release tag (v0.26.1, for example), and `branch` should be + the latest release branch (v0.27.0-release, for example). It denotes all commits that have happened on branch + v0.27.0-release after the tag v0.26.1 was created. + +11. Run `make post-release` (or, for a patch release, `make post-patch`). If you were on a branch for the release, + you need to go back to main before executing this. +""" + +import os +import re +import sys + +from setuptools import Command, find_packages, setup + + +# IMPORTANT: +# 1. all dependencies should be listed here with their version requirements if any +# 2. once modified, run: `make deps_table_update` to update src/diffusers/dependency_versions_table.py +_deps = [ + "Pillow", # keep the PIL.Image.Resampling deprecation away + "accelerate>=0.31.0", + "compel==0.1.8", + "datasets", + "filelock", + "flax>=0.4.1", + "hf-doc-builder>=0.3.0", + "httpx<1.0.0", + "huggingface-hub>=0.34.0,<2.0", + "requests-mock==1.10.0", + "importlib_metadata", + "invisible-watermark>=0.2.0", + "isort>=5.5.4", + "jax>=0.4.1", + "jaxlib>=0.4.1", + "Jinja2", + "k-diffusion==0.0.12", + "torchsde", + "note_seq", + "librosa", + "numpy", + "parameterized", + "peft>=0.17.0", + "protobuf>=3.20.3,<4", + "pytest", + "pytest-timeout", + "pytest-xdist", + "python>=3.8.0", + "ruff==0.9.10", + "safetensors>=0.3.1", + "sentencepiece>=0.1.91,!=0.1.92", + "GitPython<3.1.19", + "scipy", + "onnx", + "optimum_quanto>=0.2.6", + "gguf>=0.10.0", + "torchao>=0.7.0", + "bitsandbytes>=0.43.3", + "nvidia_modelopt[hf]>=0.33.1", + "regex!=2019.12.17", + "requests", + "tensorboard", + "tiktoken>=0.7.0", + "torch>=1.4", + "torchvision", + "transformers>=4.41.2", + "urllib3<=2.0.0", + "black", + "phonemizer", + "opencv-python", + "timm", +] + +# this is a lookup table with items like: +# +# tokenizers: "huggingface-hub==0.8.0" +# packaging: "packaging" +# +# some of the values are versioned whereas others aren't. +deps = {b: a for a, b in (re.findall(r"^(([^!=<>~]+)(?:[!=<>~].*)?$)", x)[0] for x in _deps)} + +# since we save this data in src/diffusers/dependency_versions_table.py it can be easily accessed from +# anywhere. If you need to quickly access the data from this table in a shell, you can do so easily with: +# +# python -c 'import sys; from diffusers.dependency_versions_table import deps; \ +# print(" ".join([deps[x] for x in sys.argv[1:]]))' tokenizers datasets +# +# Just pass the desired package names to that script as it's shown with 2 packages above. +# +# If diffusers is not yet installed and the work is done from the cloned repo remember to add `PYTHONPATH=src` to the script above +# +# You can then feed this for example to `pip`: +# +# pip install -U $(python -c 'import sys; from diffusers.dependency_versions_table import deps; \ +# print(" ".join([deps[x] for x in sys.argv[1:]]))' tokenizers datasets) +# + + +def deps_list(*pkgs): + return [deps[pkg] for pkg in pkgs] + + +class DepsTableUpdateCommand(Command): + """ + A custom command that updates the dependency table. + usage: python setup.py deps_table_update + """ + + description = "build runtime dependency table" + user_options = [ + # format: (long option, short option, description). + ( + "dep-table-update", + None, + "updates src/diffusers/dependency_versions_table.py", + ), + ] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + entries = "\n".join([f' "{k}": "{v}",' for k, v in deps.items()]) + content = [ + "# THIS FILE HAS BEEN AUTOGENERATED. To update:", + "# 1. modify the `_deps` dict in setup.py", + "# 2. run `make deps_table_update`", + "deps = {", + entries, + "}", + "", + ] + target = "src/diffusers/dependency_versions_table.py" + print(f"updating {target}") + with open(target, "w", encoding="utf-8", newline="\n") as f: + f.write("\n".join(content)) + + +extras = {} +extras["quality"] = deps_list("urllib3", "isort", "ruff", "hf-doc-builder") +extras["docs"] = deps_list("hf-doc-builder") +extras["training"] = deps_list("accelerate", "datasets", "protobuf", "tensorboard", "Jinja2", "peft", "timm") +extras["test"] = deps_list( + "compel", + "GitPython", + "datasets", + "Jinja2", + "invisible-watermark", + "k-diffusion", + "librosa", + "parameterized", + "pytest", + "pytest-timeout", + "pytest-xdist", + "requests-mock", + "safetensors", + "sentencepiece", + "scipy", + "tiktoken", + "torchvision", + "transformers", + "phonemizer", +) +extras["torch"] = deps_list("torch", "accelerate") + +extras["bitsandbytes"] = deps_list("bitsandbytes", "accelerate") +extras["gguf"] = deps_list("gguf", "accelerate") +extras["optimum_quanto"] = deps_list("optimum_quanto", "accelerate") +extras["torchao"] = deps_list("torchao", "accelerate") +extras["nvidia_modelopt"] = deps_list("nvidia_modelopt[hf]") + +if os.name == "nt": # windows + extras["flax"] = [] # jax is not supported on windows +else: + extras["flax"] = deps_list("jax", "jaxlib", "flax") + +extras["dev"] = ( + extras["quality"] + extras["test"] + extras["training"] + extras["docs"] + extras["torch"] + extras["flax"] +) + +install_requires = [ + deps["importlib_metadata"], + deps["filelock"], + deps["httpx"], + deps["huggingface-hub"], + deps["numpy"], + deps["regex"], + deps["requests"], + deps["safetensors"], + deps["Pillow"], +] + +version_range_max = max(sys.version_info[1], 10) + 1 + +setup( + name="diffusers", + version="0.36.0.dev0", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots) + description="State-of-the-art diffusion in PyTorch and JAX.", + long_description=open("README.md", "r", encoding="utf-8").read(), + long_description_content_type="text/markdown", + keywords="deep learning diffusion jax pytorch stable diffusion audioldm", + license="Apache 2.0 License", + author="The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/diffusers/graphs/contributors)", + author_email="diffusers@huggingface.co", + url="https://github.com/huggingface/diffusers", + package_dir={"": "src"}, + packages=find_packages("src"), + package_data={"diffusers": ["py.typed"]}, + include_package_data=True, + python_requires=">=3.8.0", + install_requires=list(install_requires), + extras_require=extras, + entry_points={"console_scripts": ["diffusers-cli=diffusers.commands.diffusers_cli:main"]}, + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Programming Language :: Python :: 3", + ] + + [f"Programming Language :: Python :: 3.{i}" for i in range(8, version_range_max)], + cmdclass={"deps_table_update": DepsTableUpdateCommand}, +) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..cd7a2cb581b7e916640afde3f127f0e5e9538c3f --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/__init__.py @@ -0,0 +1,1443 @@ +__version__ = "0.36.0.dev0" + +from typing import TYPE_CHECKING + +from .utils import ( + DIFFUSERS_SLOW_IMPORT, + OptionalDependencyNotAvailable, + _LazyModule, + is_accelerate_available, + is_bitsandbytes_available, + is_flax_available, + is_gguf_available, + is_k_diffusion_available, + is_librosa_available, + is_note_seq_available, + is_nvidia_modelopt_available, + is_onnx_available, + is_opencv_available, + is_optimum_quanto_available, + is_scipy_available, + is_sentencepiece_available, + is_torch_available, + is_torchao_available, + is_torchsde_available, + is_transformers_available, +) + + +# Lazy Import based on +# https://github.com/huggingface/transformers/blob/main/src/transformers/__init__.py + +# When adding a new object to this init, please add it to `_import_structure`. The `_import_structure` is a dictionary submodule to list of object names, +# and is used to defer the actual importing for when the objects are requested. +# This way `import diffusers` provides the names in the namespace without actually importing anything (and especially none of the backends). + +_import_structure = { + "configuration_utils": ["ConfigMixin"], + "guiders": [], + "hooks": [], + "loaders": ["FromOriginalModelMixin"], + "models": [], + "modular_pipelines": [], + "pipelines": [], + "quantizers.pipe_quant_config": ["PipelineQuantizationConfig"], + "quantizers.quantization_config": [], + "schedulers": [], + "utils": [ + "OptionalDependencyNotAvailable", + "is_flax_available", + "is_inflect_available", + "is_invisible_watermark_available", + "is_k_diffusion_available", + "is_k_diffusion_version", + "is_librosa_available", + "is_note_seq_available", + "is_onnx_available", + "is_scipy_available", + "is_torch_available", + "is_torchsde_available", + "is_transformers_available", + "is_transformers_version", + "is_unidecode_available", + "logging", + ], +} + +try: + if not is_torch_available() and not is_accelerate_available() and not is_bitsandbytes_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_bitsandbytes_objects + + _import_structure["utils.dummy_bitsandbytes_objects"] = [ + name for name in dir(dummy_bitsandbytes_objects) if not name.startswith("_") + ] +else: + _import_structure["quantizers.quantization_config"].append("BitsAndBytesConfig") + +try: + if not is_torch_available() and not is_accelerate_available() and not is_gguf_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_gguf_objects + + _import_structure["utils.dummy_gguf_objects"] = [ + name for name in dir(dummy_gguf_objects) if not name.startswith("_") + ] +else: + _import_structure["quantizers.quantization_config"].append("GGUFQuantizationConfig") + +try: + if not is_torch_available() and not is_accelerate_available() and not is_torchao_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torchao_objects + + _import_structure["utils.dummy_torchao_objects"] = [ + name for name in dir(dummy_torchao_objects) if not name.startswith("_") + ] +else: + _import_structure["quantizers.quantization_config"].append("TorchAoConfig") + +try: + if not is_torch_available() and not is_accelerate_available() and not is_optimum_quanto_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_optimum_quanto_objects + + _import_structure["utils.dummy_optimum_quanto_objects"] = [ + name for name in dir(dummy_optimum_quanto_objects) if not name.startswith("_") + ] +else: + _import_structure["quantizers.quantization_config"].append("QuantoConfig") + +try: + if not is_torch_available() and not is_accelerate_available() and not is_nvidia_modelopt_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_nvidia_modelopt_objects + + _import_structure["utils.dummy_nvidia_modelopt_objects"] = [ + name for name in dir(dummy_nvidia_modelopt_objects) if not name.startswith("_") + ] +else: + _import_structure["quantizers.quantization_config"].append("NVIDIAModelOptConfig") + +try: + if not is_onnx_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_onnx_objects # noqa F403 + + _import_structure["utils.dummy_onnx_objects"] = [ + name for name in dir(dummy_onnx_objects) if not name.startswith("_") + ] + +else: + _import_structure["pipelines"].extend(["OnnxRuntimeModel"]) + +try: + if not is_torch_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_pt_objects # noqa F403 + + _import_structure["utils.dummy_pt_objects"] = [name for name in dir(dummy_pt_objects) if not name.startswith("_")] + +else: + _import_structure["guiders"].extend( + [ + "AdaptiveProjectedGuidance", + "AdaptiveProjectedMixGuidance", + "AutoGuidance", + "BaseGuidance", + "ClassifierFreeGuidance", + "ClassifierFreeZeroStarGuidance", + "FrequencyDecoupledGuidance", + "PerturbedAttentionGuidance", + "SkipLayerGuidance", + "SmoothedEnergyGuidance", + "TangentialClassifierFreeGuidance", + ] + ) + _import_structure["hooks"].extend( + [ + "FasterCacheConfig", + "FirstBlockCacheConfig", + "HookRegistry", + "LayerSkipConfig", + "PyramidAttentionBroadcastConfig", + "SmoothedEnergyGuidanceConfig", + "apply_faster_cache", + "apply_first_block_cache", + "apply_layer_skip", + "apply_pyramid_attention_broadcast", + ] + ) + _import_structure["models"].extend( + [ + "AllegroTransformer3DModel", + "AsymmetricAutoencoderKL", + "AttentionBackendName", + "AuraFlowTransformer2DModel", + "AutoencoderDC", + "AutoencoderKL", + "AutoencoderKLAllegro", + "AutoencoderKLCogVideoX", + "AutoencoderKLCosmos", + "AutoencoderKLHunyuanImage", + "AutoencoderKLHunyuanImageRefiner", + "AutoencoderKLHunyuanVideo", + "AutoencoderKLLTXVideo", + "AutoencoderKLMagvit", + "AutoencoderKLMochi", + "AutoencoderKLQwenImage", + "AutoencoderKLTemporalDecoder", + "AutoencoderKLWan", + "AutoencoderOobleck", + "AutoencoderTiny", + "AutoModel", + "BriaFiboTransformer2DModel", + "BriaTransformer2DModel", + "CacheMixin", + "ChromaTransformer2DModel", + "ChronoEditTransformer3DModel", + "CogVideoXTransformer3DModel", + "CogView3PlusTransformer2DModel", + "CogView4Transformer2DModel", + "ConsisIDTransformer3DModel", + "ConsistencyDecoderVAE", + "ContextParallelConfig", + "ControlNetModel", + "ControlNetUnionModel", + "ControlNetXSAdapter", + "CosmosTransformer3DModel", + "DiTTransformer2DModel", + "EasyAnimateTransformer3DModel", + "FluxControlNetModel", + "FluxMultiControlNetModel", + "FluxTransformer2DModel", + "HiDreamImageTransformer2DModel", + "HunyuanDiT2DControlNetModel", + "HunyuanDiT2DModel", + "HunyuanDiT2DMultiControlNetModel", + "HunyuanImageTransformer2DModel", + "HunyuanVideoFramepackTransformer3DModel", + "HunyuanVideoTransformer3DModel", + "I2VGenXLUNet", + "Kandinsky3UNet", + "Kandinsky5Transformer3DModel", + "LatteTransformer3DModel", + "LTXVideoTransformer3DModel", + "Lumina2Transformer2DModel", + "LuminaNextDiT2DModel", + "MochiTransformer3DModel", + "ModelMixin", + "MotionAdapter", + "MultiAdapter", + "MultiControlNetModel", + "OmniGenTransformer2DModel", + "ParallelConfig", + "PixArtTransformer2DModel", + "PriorTransformer", + "PRXTransformer2DModel", + "QwenImageControlNetModel", + "QwenImageMultiControlNetModel", + "QwenImageTransformer2DModel", + "SanaControlNetModel", + "SanaTransformer2DModel", + "SanaVideoTransformer3DModel", + "SD3ControlNetModel", + "SD3MultiControlNetModel", + "SD3Transformer2DModel", + "SkyReelsV2Transformer3DModel", + "SparseControlNetModel", + "StableAudioDiTModel", + "StableCascadeUNet", + "T2IAdapter", + "T5FilmDecoder", + "Transformer2DModel", + "TransformerTemporalModel", + "UNet1DModel", + "UNet2DConditionModel", + "UNet2DModel", + "UNet3DConditionModel", + "UNetControlNetXSModel", + "UNetMotionModel", + "UNetSpatioTemporalConditionModel", + "UVit2DModel", + "VQModel", + "WanAnimateTransformer3DModel", + "WanTransformer3DModel", + "WanVACETransformer3DModel", + "attention_backend", + ] + ) + _import_structure["modular_pipelines"].extend( + [ + "ComponentsManager", + "ComponentSpec", + "ModularPipeline", + "ModularPipelineBlocks", + ] + ) + _import_structure["optimization"] = [ + "get_constant_schedule", + "get_constant_schedule_with_warmup", + "get_cosine_schedule_with_warmup", + "get_cosine_with_hard_restarts_schedule_with_warmup", + "get_linear_schedule_with_warmup", + "get_polynomial_decay_schedule_with_warmup", + "get_scheduler", + ] + _import_structure["pipelines"].extend( + [ + "AudioPipelineOutput", + "AutoPipelineForImage2Image", + "AutoPipelineForInpainting", + "AutoPipelineForText2Image", + "ConsistencyModelPipeline", + "DanceDiffusionPipeline", + "DDIMPipeline", + "DDPMPipeline", + "DiffusionPipeline", + "DiTPipeline", + "ImagePipelineOutput", + "KarrasVePipeline", + "LDMPipeline", + "LDMSuperResolutionPipeline", + "PNDMPipeline", + "RePaintPipeline", + "ScoreSdeVePipeline", + "StableDiffusionMixin", + ] + ) + _import_structure["quantizers"] = ["DiffusersQuantizer"] + _import_structure["schedulers"].extend( + [ + "AmusedScheduler", + "CMStochasticIterativeScheduler", + "CogVideoXDDIMScheduler", + "CogVideoXDPMScheduler", + "DDIMInverseScheduler", + "DDIMParallelScheduler", + "DDIMScheduler", + "DDPMParallelScheduler", + "DDPMScheduler", + "DDPMWuerstchenScheduler", + "DEISMultistepScheduler", + "DPMSolverMultistepInverseScheduler", + "DPMSolverMultistepScheduler", + "DPMSolverSinglestepScheduler", + "EDMDPMSolverMultistepScheduler", + "EDMEulerScheduler", + "EulerAncestralDiscreteScheduler", + "EulerDiscreteScheduler", + "FlowMatchEulerDiscreteScheduler", + "FlowMatchHeunDiscreteScheduler", + "FlowMatchLCMScheduler", + "HeunDiscreteScheduler", + "IPNDMScheduler", + "KarrasVeScheduler", + "KDPM2AncestralDiscreteScheduler", + "KDPM2DiscreteScheduler", + "LCMScheduler", + "PNDMScheduler", + "RePaintScheduler", + "SASolverScheduler", + "SchedulerMixin", + "SCMScheduler", + "ScoreSdeVeScheduler", + "TCDScheduler", + "UnCLIPScheduler", + "UniPCMultistepScheduler", + "VQDiffusionScheduler", + ] + ) + _import_structure["training_utils"] = ["EMAModel"] + +try: + if not (is_torch_available() and is_scipy_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_scipy_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_scipy_objects"] = [ + name for name in dir(dummy_torch_and_scipy_objects) if not name.startswith("_") + ] + +else: + _import_structure["schedulers"].extend(["LMSDiscreteScheduler"]) + +try: + if not (is_torch_available() and is_torchsde_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_torchsde_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_torchsde_objects"] = [ + name for name in dir(dummy_torch_and_torchsde_objects) if not name.startswith("_") + ] + +else: + _import_structure["schedulers"].extend(["CosineDPMSolverMultistepScheduler", "DPMSolverSDEScheduler"]) + +try: + if not (is_torch_available() and is_transformers_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_transformers_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_transformers_objects"] = [ + name for name in dir(dummy_torch_and_transformers_objects) if not name.startswith("_") + ] + +else: + _import_structure["modular_pipelines"].extend( + [ + "FluxAutoBlocks", + "FluxKontextAutoBlocks", + "FluxKontextModularPipeline", + "FluxModularPipeline", + "QwenImageAutoBlocks", + "QwenImageEditAutoBlocks", + "QwenImageEditModularPipeline", + "QwenImageEditPlusAutoBlocks", + "QwenImageEditPlusModularPipeline", + "QwenImageModularPipeline", + "StableDiffusionXLAutoBlocks", + "StableDiffusionXLModularPipeline", + "Wan22AutoBlocks", + "WanAutoBlocks", + "WanModularPipeline", + ] + ) + _import_structure["pipelines"].extend( + [ + "AllegroPipeline", + "AltDiffusionImg2ImgPipeline", + "AltDiffusionPipeline", + "AmusedImg2ImgPipeline", + "AmusedInpaintPipeline", + "AmusedPipeline", + "AnimateDiffControlNetPipeline", + "AnimateDiffPAGPipeline", + "AnimateDiffPipeline", + "AnimateDiffSDXLPipeline", + "AnimateDiffSparseControlNetPipeline", + "AnimateDiffVideoToVideoControlNetPipeline", + "AnimateDiffVideoToVideoPipeline", + "AudioLDM2Pipeline", + "AudioLDM2ProjectionModel", + "AudioLDM2UNet2DConditionModel", + "AudioLDMPipeline", + "AuraFlowPipeline", + "BlipDiffusionControlNetPipeline", + "BlipDiffusionPipeline", + "BriaFiboPipeline", + "BriaPipeline", + "ChromaImg2ImgPipeline", + "ChromaPipeline", + "ChronoEditPipeline", + "CLIPImageProjection", + "CogVideoXFunControlPipeline", + "CogVideoXImageToVideoPipeline", + "CogVideoXPipeline", + "CogVideoXVideoToVideoPipeline", + "CogView3PlusPipeline", + "CogView4ControlPipeline", + "CogView4Pipeline", + "ConsisIDPipeline", + "Cosmos2TextToImagePipeline", + "Cosmos2VideoToWorldPipeline", + "CosmosTextToWorldPipeline", + "CosmosVideoToWorldPipeline", + "CycleDiffusionPipeline", + "EasyAnimateControlPipeline", + "EasyAnimateInpaintPipeline", + "EasyAnimatePipeline", + "FluxControlImg2ImgPipeline", + "FluxControlInpaintPipeline", + "FluxControlNetImg2ImgPipeline", + "FluxControlNetInpaintPipeline", + "FluxControlNetPipeline", + "FluxControlPipeline", + "FluxFillPipeline", + "FluxImg2ImgPipeline", + "FluxInpaintPipeline", + "FluxKontextInpaintPipeline", + "FluxKontextPipeline", + "FluxPipeline", + "FluxPriorReduxPipeline", + "HiDreamImagePipeline", + "HunyuanDiTControlNetPipeline", + "HunyuanDiTPAGPipeline", + "HunyuanDiTPipeline", + "HunyuanImagePipeline", + "HunyuanImageRefinerPipeline", + "HunyuanSkyreelsImageToVideoPipeline", + "HunyuanVideoFramepackPipeline", + "HunyuanVideoImageToVideoPipeline", + "HunyuanVideoPipeline", + "I2VGenXLPipeline", + "IFImg2ImgPipeline", + "IFImg2ImgSuperResolutionPipeline", + "IFInpaintingPipeline", + "IFInpaintingSuperResolutionPipeline", + "IFPipeline", + "IFSuperResolutionPipeline", + "ImageTextPipelineOutput", + "Kandinsky3Img2ImgPipeline", + "Kandinsky3Pipeline", + "Kandinsky5T2VPipeline", + "KandinskyCombinedPipeline", + "KandinskyImg2ImgCombinedPipeline", + "KandinskyImg2ImgPipeline", + "KandinskyInpaintCombinedPipeline", + "KandinskyInpaintPipeline", + "KandinskyPipeline", + "KandinskyPriorPipeline", + "KandinskyV22CombinedPipeline", + "KandinskyV22ControlnetImg2ImgPipeline", + "KandinskyV22ControlnetPipeline", + "KandinskyV22Img2ImgCombinedPipeline", + "KandinskyV22Img2ImgPipeline", + "KandinskyV22InpaintCombinedPipeline", + "KandinskyV22InpaintPipeline", + "KandinskyV22Pipeline", + "KandinskyV22PriorEmb2EmbPipeline", + "KandinskyV22PriorPipeline", + "LatentConsistencyModelImg2ImgPipeline", + "LatentConsistencyModelPipeline", + "LattePipeline", + "LDMTextToImagePipeline", + "LEditsPPPipelineStableDiffusion", + "LEditsPPPipelineStableDiffusionXL", + "LTXConditionPipeline", + "LTXImageToVideoPipeline", + "LTXLatentUpsamplePipeline", + "LTXPipeline", + "LucyEditPipeline", + "Lumina2Pipeline", + "Lumina2Text2ImgPipeline", + "LuminaPipeline", + "LuminaText2ImgPipeline", + "MarigoldDepthPipeline", + "MarigoldIntrinsicsPipeline", + "MarigoldNormalsPipeline", + "MochiPipeline", + "MusicLDMPipeline", + "OmniGenPipeline", + "PaintByExamplePipeline", + "PIAPipeline", + "PixArtAlphaPipeline", + "PixArtSigmaPAGPipeline", + "PixArtSigmaPipeline", + "PRXPipeline", + "QwenImageControlNetInpaintPipeline", + "QwenImageControlNetPipeline", + "QwenImageEditInpaintPipeline", + "QwenImageEditPipeline", + "QwenImageEditPlusPipeline", + "QwenImageImg2ImgPipeline", + "QwenImageInpaintPipeline", + "QwenImagePipeline", + "ReduxImageEncoder", + "SanaControlNetPipeline", + "SanaImageToVideoPipeline", + "SanaPAGPipeline", + "SanaPipeline", + "SanaSprintImg2ImgPipeline", + "SanaSprintPipeline", + "SanaVideoPipeline", + "SanaVideoPipeline", + "SemanticStableDiffusionPipeline", + "ShapEImg2ImgPipeline", + "ShapEPipeline", + "SkyReelsV2DiffusionForcingImageToVideoPipeline", + "SkyReelsV2DiffusionForcingPipeline", + "SkyReelsV2DiffusionForcingVideoToVideoPipeline", + "SkyReelsV2ImageToVideoPipeline", + "SkyReelsV2Pipeline", + "StableAudioPipeline", + "StableAudioProjectionModel", + "StableCascadeCombinedPipeline", + "StableCascadeDecoderPipeline", + "StableCascadePriorPipeline", + "StableDiffusion3ControlNetInpaintingPipeline", + "StableDiffusion3ControlNetPipeline", + "StableDiffusion3Img2ImgPipeline", + "StableDiffusion3InpaintPipeline", + "StableDiffusion3PAGImg2ImgPipeline", + "StableDiffusion3PAGImg2ImgPipeline", + "StableDiffusion3PAGPipeline", + "StableDiffusion3Pipeline", + "StableDiffusionAdapterPipeline", + "StableDiffusionAttendAndExcitePipeline", + "StableDiffusionControlNetImg2ImgPipeline", + "StableDiffusionControlNetInpaintPipeline", + "StableDiffusionControlNetPAGInpaintPipeline", + "StableDiffusionControlNetPAGPipeline", + "StableDiffusionControlNetPipeline", + "StableDiffusionControlNetXSPipeline", + "StableDiffusionDepth2ImgPipeline", + "StableDiffusionDiffEditPipeline", + "StableDiffusionGLIGENPipeline", + "StableDiffusionGLIGENTextImagePipeline", + "StableDiffusionImageVariationPipeline", + "StableDiffusionImg2ImgPipeline", + "StableDiffusionInpaintPipeline", + "StableDiffusionInpaintPipelineLegacy", + "StableDiffusionInstructPix2PixPipeline", + "StableDiffusionLatentUpscalePipeline", + "StableDiffusionLDM3DPipeline", + "StableDiffusionModelEditingPipeline", + "StableDiffusionPAGImg2ImgPipeline", + "StableDiffusionPAGInpaintPipeline", + "StableDiffusionPAGPipeline", + "StableDiffusionPanoramaPipeline", + "StableDiffusionParadigmsPipeline", + "StableDiffusionPipeline", + "StableDiffusionPipelineSafe", + "StableDiffusionPix2PixZeroPipeline", + "StableDiffusionSAGPipeline", + "StableDiffusionUpscalePipeline", + "StableDiffusionXLAdapterPipeline", + "StableDiffusionXLControlNetImg2ImgPipeline", + "StableDiffusionXLControlNetInpaintPipeline", + "StableDiffusionXLControlNetPAGImg2ImgPipeline", + "StableDiffusionXLControlNetPAGPipeline", + "StableDiffusionXLControlNetPipeline", + "StableDiffusionXLControlNetUnionImg2ImgPipeline", + "StableDiffusionXLControlNetUnionInpaintPipeline", + "StableDiffusionXLControlNetUnionPipeline", + "StableDiffusionXLControlNetXSPipeline", + "StableDiffusionXLImg2ImgPipeline", + "StableDiffusionXLInpaintPipeline", + "StableDiffusionXLInstructPix2PixPipeline", + "StableDiffusionXLPAGImg2ImgPipeline", + "StableDiffusionXLPAGInpaintPipeline", + "StableDiffusionXLPAGPipeline", + "StableDiffusionXLPipeline", + "StableUnCLIPImg2ImgPipeline", + "StableUnCLIPPipeline", + "StableVideoDiffusionPipeline", + "TextToVideoSDPipeline", + "TextToVideoZeroPipeline", + "TextToVideoZeroSDXLPipeline", + "UnCLIPImageVariationPipeline", + "UnCLIPPipeline", + "UniDiffuserModel", + "UniDiffuserPipeline", + "UniDiffuserTextDecoder", + "VersatileDiffusionDualGuidedPipeline", + "VersatileDiffusionImageVariationPipeline", + "VersatileDiffusionPipeline", + "VersatileDiffusionTextToImagePipeline", + "VideoToVideoSDPipeline", + "VisualClozeGenerationPipeline", + "VisualClozePipeline", + "VQDiffusionPipeline", + "WanAnimatePipeline", + "WanImageToVideoPipeline", + "WanPipeline", + "WanVACEPipeline", + "WanVideoToVideoPipeline", + "WuerstchenCombinedPipeline", + "WuerstchenDecoderPipeline", + "WuerstchenPriorPipeline", + ] + ) + + +try: + if not (is_torch_available() and is_transformers_available() and is_opencv_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_transformers_and_opencv_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_transformers_and_opencv_objects"] = [ + name for name in dir(dummy_torch_and_transformers_and_opencv_objects) if not name.startswith("_") + ] + +else: + _import_structure["pipelines"].extend(["ConsisIDPipeline"]) + +try: + if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_transformers_and_k_diffusion_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_transformers_and_k_diffusion_objects"] = [ + name for name in dir(dummy_torch_and_transformers_and_k_diffusion_objects) if not name.startswith("_") + ] + +else: + _import_structure["pipelines"].extend(["StableDiffusionKDiffusionPipeline", "StableDiffusionXLKDiffusionPipeline"]) + +try: + if not (is_torch_available() and is_transformers_available() and is_sentencepiece_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_transformers_and_sentencepiece_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_transformers_and_sentencepiece_objects"] = [ + name for name in dir(dummy_torch_and_transformers_and_sentencepiece_objects) if not name.startswith("_") + ] + +else: + _import_structure["pipelines"].extend(["KolorsImg2ImgPipeline", "KolorsPAGPipeline", "KolorsPipeline"]) + +try: + if not (is_torch_available() and is_transformers_available() and is_onnx_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_transformers_and_onnx_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_transformers_and_onnx_objects"] = [ + name for name in dir(dummy_torch_and_transformers_and_onnx_objects) if not name.startswith("_") + ] + +else: + _import_structure["pipelines"].extend( + [ + "OnnxStableDiffusionImg2ImgPipeline", + "OnnxStableDiffusionInpaintPipeline", + "OnnxStableDiffusionInpaintPipelineLegacy", + "OnnxStableDiffusionPipeline", + "OnnxStableDiffusionUpscalePipeline", + "StableDiffusionOnnxPipeline", + ] + ) + +try: + if not (is_torch_available() and is_librosa_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_torch_and_librosa_objects # noqa F403 + + _import_structure["utils.dummy_torch_and_librosa_objects"] = [ + name for name in dir(dummy_torch_and_librosa_objects) if not name.startswith("_") + ] + +else: + _import_structure["pipelines"].extend(["AudioDiffusionPipeline", "Mel"]) + +try: + if not (is_transformers_available() and is_torch_available() and is_note_seq_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_transformers_and_torch_and_note_seq_objects # noqa F403 + + _import_structure["utils.dummy_transformers_and_torch_and_note_seq_objects"] = [ + name for name in dir(dummy_transformers_and_torch_and_note_seq_objects) if not name.startswith("_") + ] + + +else: + _import_structure["pipelines"].extend(["SpectrogramDiffusionPipeline"]) + +try: + if not is_flax_available(): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_flax_objects # noqa F403 + + _import_structure["utils.dummy_flax_objects"] = [ + name for name in dir(dummy_flax_objects) if not name.startswith("_") + ] + + +else: + _import_structure["models.controlnets.controlnet_flax"] = ["FlaxControlNetModel"] + _import_structure["models.modeling_flax_utils"] = ["FlaxModelMixin"] + _import_structure["models.unets.unet_2d_condition_flax"] = ["FlaxUNet2DConditionModel"] + _import_structure["models.vae_flax"] = ["FlaxAutoencoderKL"] + _import_structure["pipelines"].extend(["FlaxDiffusionPipeline"]) + _import_structure["schedulers"].extend( + [ + "FlaxDDIMScheduler", + "FlaxDDPMScheduler", + "FlaxDPMSolverMultistepScheduler", + "FlaxEulerDiscreteScheduler", + "FlaxKarrasVeScheduler", + "FlaxLMSDiscreteScheduler", + "FlaxPNDMScheduler", + "FlaxSchedulerMixin", + "FlaxScoreSdeVeScheduler", + ] + ) + + +try: + if not (is_flax_available() and is_transformers_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_flax_and_transformers_objects # noqa F403 + + _import_structure["utils.dummy_flax_and_transformers_objects"] = [ + name for name in dir(dummy_flax_and_transformers_objects) if not name.startswith("_") + ] + + +else: + _import_structure["pipelines"].extend( + [ + "FlaxStableDiffusionControlNetPipeline", + "FlaxStableDiffusionImg2ImgPipeline", + "FlaxStableDiffusionInpaintPipeline", + "FlaxStableDiffusionPipeline", + "FlaxStableDiffusionXLPipeline", + ] + ) + +try: + if not (is_note_seq_available()): + raise OptionalDependencyNotAvailable() +except OptionalDependencyNotAvailable: + from .utils import dummy_note_seq_objects # noqa F403 + + _import_structure["utils.dummy_note_seq_objects"] = [ + name for name in dir(dummy_note_seq_objects) if not name.startswith("_") + ] + + +else: + _import_structure["pipelines"].extend(["MidiProcessor"]) + +if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT: + from .configuration_utils import ConfigMixin + from .quantizers import PipelineQuantizationConfig + + try: + if not is_bitsandbytes_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_bitsandbytes_objects import * + else: + from .quantizers.quantization_config import BitsAndBytesConfig + + try: + if not is_gguf_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_gguf_objects import * + else: + from .quantizers.quantization_config import GGUFQuantizationConfig + + try: + if not is_torchao_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torchao_objects import * + else: + from .quantizers.quantization_config import TorchAoConfig + + try: + if not is_optimum_quanto_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_optimum_quanto_objects import * + else: + from .quantizers.quantization_config import QuantoConfig + + try: + if not is_nvidia_modelopt_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_nvidia_modelopt_objects import * + else: + from .quantizers.quantization_config import NVIDIAModelOptConfig + + try: + if not is_onnx_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_onnx_objects import * # noqa F403 + else: + from .pipelines import OnnxRuntimeModel + + try: + if not is_torch_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_pt_objects import * # noqa F403 + else: + from .guiders import ( + AdaptiveProjectedGuidance, + AdaptiveProjectedMixGuidance, + AutoGuidance, + BaseGuidance, + ClassifierFreeGuidance, + ClassifierFreeZeroStarGuidance, + FrequencyDecoupledGuidance, + PerturbedAttentionGuidance, + SkipLayerGuidance, + SmoothedEnergyGuidance, + TangentialClassifierFreeGuidance, + ) + from .hooks import ( + FasterCacheConfig, + FirstBlockCacheConfig, + HookRegistry, + LayerSkipConfig, + PyramidAttentionBroadcastConfig, + SmoothedEnergyGuidanceConfig, + apply_faster_cache, + apply_first_block_cache, + apply_layer_skip, + apply_pyramid_attention_broadcast, + ) + from .models import ( + AllegroTransformer3DModel, + AsymmetricAutoencoderKL, + AttentionBackendName, + AuraFlowTransformer2DModel, + AutoencoderDC, + AutoencoderKL, + AutoencoderKLAllegro, + AutoencoderKLCogVideoX, + AutoencoderKLCosmos, + AutoencoderKLHunyuanImage, + AutoencoderKLHunyuanImageRefiner, + AutoencoderKLHunyuanVideo, + AutoencoderKLLTXVideo, + AutoencoderKLMagvit, + AutoencoderKLMochi, + AutoencoderKLQwenImage, + AutoencoderKLTemporalDecoder, + AutoencoderKLWan, + AutoencoderOobleck, + AutoencoderTiny, + AutoModel, + BriaFiboTransformer2DModel, + BriaTransformer2DModel, + CacheMixin, + ChromaTransformer2DModel, + ChronoEditTransformer3DModel, + CogVideoXTransformer3DModel, + CogView3PlusTransformer2DModel, + CogView4Transformer2DModel, + ConsisIDTransformer3DModel, + ConsistencyDecoderVAE, + ContextParallelConfig, + ControlNetModel, + ControlNetUnionModel, + ControlNetXSAdapter, + CosmosTransformer3DModel, + DiTTransformer2DModel, + EasyAnimateTransformer3DModel, + FluxControlNetModel, + FluxMultiControlNetModel, + FluxTransformer2DModel, + HiDreamImageTransformer2DModel, + HunyuanDiT2DControlNetModel, + HunyuanDiT2DModel, + HunyuanDiT2DMultiControlNetModel, + HunyuanImageTransformer2DModel, + HunyuanVideoFramepackTransformer3DModel, + HunyuanVideoTransformer3DModel, + I2VGenXLUNet, + Kandinsky3UNet, + Kandinsky5Transformer3DModel, + LatteTransformer3DModel, + LTXVideoTransformer3DModel, + Lumina2Transformer2DModel, + LuminaNextDiT2DModel, + MochiTransformer3DModel, + ModelMixin, + MotionAdapter, + MultiAdapter, + MultiControlNetModel, + OmniGenTransformer2DModel, + ParallelConfig, + PixArtTransformer2DModel, + PriorTransformer, + PRXTransformer2DModel, + QwenImageControlNetModel, + QwenImageMultiControlNetModel, + QwenImageTransformer2DModel, + SanaControlNetModel, + SanaTransformer2DModel, + SanaVideoTransformer3DModel, + SD3ControlNetModel, + SD3MultiControlNetModel, + SD3Transformer2DModel, + SkyReelsV2Transformer3DModel, + SparseControlNetModel, + StableAudioDiTModel, + T2IAdapter, + T5FilmDecoder, + Transformer2DModel, + TransformerTemporalModel, + UNet1DModel, + UNet2DConditionModel, + UNet2DModel, + UNet3DConditionModel, + UNetControlNetXSModel, + UNetMotionModel, + UNetSpatioTemporalConditionModel, + UVit2DModel, + VQModel, + WanAnimateTransformer3DModel, + WanTransformer3DModel, + WanVACETransformer3DModel, + attention_backend, + ) + from .modular_pipelines import ComponentsManager, ComponentSpec, ModularPipeline, ModularPipelineBlocks + from .optimization import ( + get_constant_schedule, + get_constant_schedule_with_warmup, + get_cosine_schedule_with_warmup, + get_cosine_with_hard_restarts_schedule_with_warmup, + get_linear_schedule_with_warmup, + get_polynomial_decay_schedule_with_warmup, + get_scheduler, + ) + from .pipelines import ( + AudioPipelineOutput, + AutoPipelineForImage2Image, + AutoPipelineForInpainting, + AutoPipelineForText2Image, + BlipDiffusionControlNetPipeline, + BlipDiffusionPipeline, + CLIPImageProjection, + ConsistencyModelPipeline, + DanceDiffusionPipeline, + DDIMPipeline, + DDPMPipeline, + DiffusionPipeline, + DiTPipeline, + ImagePipelineOutput, + KarrasVePipeline, + LDMPipeline, + LDMSuperResolutionPipeline, + PNDMPipeline, + RePaintPipeline, + ScoreSdeVePipeline, + StableDiffusionMixin, + ) + from .quantizers import DiffusersQuantizer + from .schedulers import ( + AmusedScheduler, + CMStochasticIterativeScheduler, + CogVideoXDDIMScheduler, + CogVideoXDPMScheduler, + DDIMInverseScheduler, + DDIMParallelScheduler, + DDIMScheduler, + DDPMParallelScheduler, + DDPMScheduler, + DDPMWuerstchenScheduler, + DEISMultistepScheduler, + DPMSolverMultistepInverseScheduler, + DPMSolverMultistepScheduler, + DPMSolverSinglestepScheduler, + EDMDPMSolverMultistepScheduler, + EDMEulerScheduler, + EulerAncestralDiscreteScheduler, + EulerDiscreteScheduler, + FlowMatchEulerDiscreteScheduler, + FlowMatchHeunDiscreteScheduler, + FlowMatchLCMScheduler, + HeunDiscreteScheduler, + IPNDMScheduler, + KarrasVeScheduler, + KDPM2AncestralDiscreteScheduler, + KDPM2DiscreteScheduler, + LCMScheduler, + PNDMScheduler, + RePaintScheduler, + SASolverScheduler, + SchedulerMixin, + SCMScheduler, + ScoreSdeVeScheduler, + TCDScheduler, + UnCLIPScheduler, + UniPCMultistepScheduler, + VQDiffusionScheduler, + ) + from .training_utils import EMAModel + + try: + if not (is_torch_available() and is_scipy_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_scipy_objects import * # noqa F403 + else: + from .schedulers import LMSDiscreteScheduler + + try: + if not (is_torch_available() and is_torchsde_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_torchsde_objects import * # noqa F403 + else: + from .schedulers import CosineDPMSolverMultistepScheduler, DPMSolverSDEScheduler + + try: + if not (is_torch_available() and is_transformers_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_transformers_objects import * # noqa F403 + else: + from .modular_pipelines import ( + FluxAutoBlocks, + FluxKontextAutoBlocks, + FluxKontextModularPipeline, + FluxModularPipeline, + QwenImageAutoBlocks, + QwenImageEditAutoBlocks, + QwenImageEditModularPipeline, + QwenImageEditPlusAutoBlocks, + QwenImageEditPlusModularPipeline, + QwenImageModularPipeline, + StableDiffusionXLAutoBlocks, + StableDiffusionXLModularPipeline, + Wan22AutoBlocks, + WanAutoBlocks, + WanModularPipeline, + ) + from .pipelines import ( + AllegroPipeline, + AltDiffusionImg2ImgPipeline, + AltDiffusionPipeline, + AmusedImg2ImgPipeline, + AmusedInpaintPipeline, + AmusedPipeline, + AnimateDiffControlNetPipeline, + AnimateDiffPAGPipeline, + AnimateDiffPipeline, + AnimateDiffSDXLPipeline, + AnimateDiffSparseControlNetPipeline, + AnimateDiffVideoToVideoControlNetPipeline, + AnimateDiffVideoToVideoPipeline, + AudioLDM2Pipeline, + AudioLDM2ProjectionModel, + AudioLDM2UNet2DConditionModel, + AudioLDMPipeline, + AuraFlowPipeline, + BriaFiboPipeline, + BriaPipeline, + ChromaImg2ImgPipeline, + ChromaPipeline, + ChronoEditPipeline, + CLIPImageProjection, + CogVideoXFunControlPipeline, + CogVideoXImageToVideoPipeline, + CogVideoXPipeline, + CogVideoXVideoToVideoPipeline, + CogView3PlusPipeline, + CogView4ControlPipeline, + CogView4Pipeline, + ConsisIDPipeline, + Cosmos2TextToImagePipeline, + Cosmos2VideoToWorldPipeline, + CosmosTextToWorldPipeline, + CosmosVideoToWorldPipeline, + CycleDiffusionPipeline, + EasyAnimateControlPipeline, + EasyAnimateInpaintPipeline, + EasyAnimatePipeline, + FluxControlImg2ImgPipeline, + FluxControlInpaintPipeline, + FluxControlNetImg2ImgPipeline, + FluxControlNetInpaintPipeline, + FluxControlNetPipeline, + FluxControlPipeline, + FluxFillPipeline, + FluxImg2ImgPipeline, + FluxInpaintPipeline, + FluxKontextInpaintPipeline, + FluxKontextPipeline, + FluxPipeline, + FluxPriorReduxPipeline, + HiDreamImagePipeline, + HunyuanDiTControlNetPipeline, + HunyuanDiTPAGPipeline, + HunyuanDiTPipeline, + HunyuanImagePipeline, + HunyuanImageRefinerPipeline, + HunyuanSkyreelsImageToVideoPipeline, + HunyuanVideoFramepackPipeline, + HunyuanVideoImageToVideoPipeline, + HunyuanVideoPipeline, + I2VGenXLPipeline, + IFImg2ImgPipeline, + IFImg2ImgSuperResolutionPipeline, + IFInpaintingPipeline, + IFInpaintingSuperResolutionPipeline, + IFPipeline, + IFSuperResolutionPipeline, + ImageTextPipelineOutput, + Kandinsky3Img2ImgPipeline, + Kandinsky3Pipeline, + Kandinsky5T2VPipeline, + KandinskyCombinedPipeline, + KandinskyImg2ImgCombinedPipeline, + KandinskyImg2ImgPipeline, + KandinskyInpaintCombinedPipeline, + KandinskyInpaintPipeline, + KandinskyPipeline, + KandinskyPriorPipeline, + KandinskyV22CombinedPipeline, + KandinskyV22ControlnetImg2ImgPipeline, + KandinskyV22ControlnetPipeline, + KandinskyV22Img2ImgCombinedPipeline, + KandinskyV22Img2ImgPipeline, + KandinskyV22InpaintCombinedPipeline, + KandinskyV22InpaintPipeline, + KandinskyV22Pipeline, + KandinskyV22PriorEmb2EmbPipeline, + KandinskyV22PriorPipeline, + LatentConsistencyModelImg2ImgPipeline, + LatentConsistencyModelPipeline, + LattePipeline, + LDMTextToImagePipeline, + LEditsPPPipelineStableDiffusion, + LEditsPPPipelineStableDiffusionXL, + LTXConditionPipeline, + LTXImageToVideoPipeline, + LTXLatentUpsamplePipeline, + LTXPipeline, + LucyEditPipeline, + Lumina2Pipeline, + Lumina2Text2ImgPipeline, + LuminaPipeline, + LuminaText2ImgPipeline, + MarigoldDepthPipeline, + MarigoldIntrinsicsPipeline, + MarigoldNormalsPipeline, + MochiPipeline, + MusicLDMPipeline, + OmniGenPipeline, + PaintByExamplePipeline, + PIAPipeline, + PixArtAlphaPipeline, + PixArtSigmaPAGPipeline, + PixArtSigmaPipeline, + PRXPipeline, + QwenImageControlNetInpaintPipeline, + QwenImageControlNetPipeline, + QwenImageEditInpaintPipeline, + QwenImageEditPipeline, + QwenImageEditPlusPipeline, + QwenImageImg2ImgPipeline, + QwenImageInpaintPipeline, + QwenImagePipeline, + ReduxImageEncoder, + SanaControlNetPipeline, + SanaImageToVideoPipeline, + SanaPAGPipeline, + SanaPipeline, + SanaSprintImg2ImgPipeline, + SanaSprintPipeline, + SanaVideoPipeline, + SemanticStableDiffusionPipeline, + ShapEImg2ImgPipeline, + ShapEPipeline, + SkyReelsV2DiffusionForcingImageToVideoPipeline, + SkyReelsV2DiffusionForcingPipeline, + SkyReelsV2DiffusionForcingVideoToVideoPipeline, + SkyReelsV2ImageToVideoPipeline, + SkyReelsV2Pipeline, + StableAudioPipeline, + StableAudioProjectionModel, + StableCascadeCombinedPipeline, + StableCascadeDecoderPipeline, + StableCascadePriorPipeline, + StableDiffusion3ControlNetInpaintingPipeline, + StableDiffusion3ControlNetPipeline, + StableDiffusion3Img2ImgPipeline, + StableDiffusion3InpaintPipeline, + StableDiffusion3PAGImg2ImgPipeline, + StableDiffusion3PAGPipeline, + StableDiffusion3Pipeline, + StableDiffusionAdapterPipeline, + StableDiffusionAttendAndExcitePipeline, + StableDiffusionControlNetImg2ImgPipeline, + StableDiffusionControlNetInpaintPipeline, + StableDiffusionControlNetPAGInpaintPipeline, + StableDiffusionControlNetPAGPipeline, + StableDiffusionControlNetPipeline, + StableDiffusionControlNetXSPipeline, + StableDiffusionDepth2ImgPipeline, + StableDiffusionDiffEditPipeline, + StableDiffusionGLIGENPipeline, + StableDiffusionGLIGENTextImagePipeline, + StableDiffusionImageVariationPipeline, + StableDiffusionImg2ImgPipeline, + StableDiffusionInpaintPipeline, + StableDiffusionInpaintPipelineLegacy, + StableDiffusionInstructPix2PixPipeline, + StableDiffusionLatentUpscalePipeline, + StableDiffusionLDM3DPipeline, + StableDiffusionModelEditingPipeline, + StableDiffusionPAGImg2ImgPipeline, + StableDiffusionPAGInpaintPipeline, + StableDiffusionPAGPipeline, + StableDiffusionPanoramaPipeline, + StableDiffusionParadigmsPipeline, + StableDiffusionPipeline, + StableDiffusionPipelineSafe, + StableDiffusionPix2PixZeroPipeline, + StableDiffusionSAGPipeline, + StableDiffusionUpscalePipeline, + StableDiffusionXLAdapterPipeline, + StableDiffusionXLControlNetImg2ImgPipeline, + StableDiffusionXLControlNetInpaintPipeline, + StableDiffusionXLControlNetPAGImg2ImgPipeline, + StableDiffusionXLControlNetPAGPipeline, + StableDiffusionXLControlNetPipeline, + StableDiffusionXLControlNetUnionImg2ImgPipeline, + StableDiffusionXLControlNetUnionInpaintPipeline, + StableDiffusionXLControlNetUnionPipeline, + StableDiffusionXLControlNetXSPipeline, + StableDiffusionXLImg2ImgPipeline, + StableDiffusionXLInpaintPipeline, + StableDiffusionXLInstructPix2PixPipeline, + StableDiffusionXLPAGImg2ImgPipeline, + StableDiffusionXLPAGInpaintPipeline, + StableDiffusionXLPAGPipeline, + StableDiffusionXLPipeline, + StableUnCLIPImg2ImgPipeline, + StableUnCLIPPipeline, + StableVideoDiffusionPipeline, + TextToVideoSDPipeline, + TextToVideoZeroPipeline, + TextToVideoZeroSDXLPipeline, + UnCLIPImageVariationPipeline, + UnCLIPPipeline, + UniDiffuserModel, + UniDiffuserPipeline, + UniDiffuserTextDecoder, + VersatileDiffusionDualGuidedPipeline, + VersatileDiffusionImageVariationPipeline, + VersatileDiffusionPipeline, + VersatileDiffusionTextToImagePipeline, + VideoToVideoSDPipeline, + VisualClozeGenerationPipeline, + VisualClozePipeline, + VQDiffusionPipeline, + WanAnimatePipeline, + WanImageToVideoPipeline, + WanPipeline, + WanVACEPipeline, + WanVideoToVideoPipeline, + WuerstchenCombinedPipeline, + WuerstchenDecoderPipeline, + WuerstchenPriorPipeline, + ) + + try: + if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_transformers_and_k_diffusion_objects import * # noqa F403 + else: + from .pipelines import StableDiffusionKDiffusionPipeline, StableDiffusionXLKDiffusionPipeline + + try: + if not (is_torch_available() and is_transformers_available() and is_sentencepiece_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_transformers_and_sentencepiece_objects import * # noqa F403 + else: + from .pipelines import KolorsImg2ImgPipeline, KolorsPAGPipeline, KolorsPipeline + + try: + if not (is_torch_available() and is_transformers_available() and is_opencv_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_transformers_and_opencv_objects import * # noqa F403 + else: + from .pipelines import ConsisIDPipeline + + try: + if not (is_torch_available() and is_transformers_available() and is_onnx_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_transformers_and_onnx_objects import * # noqa F403 + else: + from .pipelines import ( + OnnxStableDiffusionImg2ImgPipeline, + OnnxStableDiffusionInpaintPipeline, + OnnxStableDiffusionInpaintPipelineLegacy, + OnnxStableDiffusionPipeline, + OnnxStableDiffusionUpscalePipeline, + StableDiffusionOnnxPipeline, + ) + + try: + if not (is_torch_available() and is_librosa_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_torch_and_librosa_objects import * # noqa F403 + else: + from .pipelines import AudioDiffusionPipeline, Mel + + try: + if not (is_transformers_available() and is_torch_available() and is_note_seq_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_transformers_and_torch_and_note_seq_objects import * # noqa F403 + else: + from .pipelines import SpectrogramDiffusionPipeline + + try: + if not is_flax_available(): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_flax_objects import * # noqa F403 + else: + from .models.controlnets.controlnet_flax import FlaxControlNetModel + from .models.modeling_flax_utils import FlaxModelMixin + from .models.unets.unet_2d_condition_flax import FlaxUNet2DConditionModel + from .models.vae_flax import FlaxAutoencoderKL + from .pipelines import FlaxDiffusionPipeline + from .schedulers import ( + FlaxDDIMScheduler, + FlaxDDPMScheduler, + FlaxDPMSolverMultistepScheduler, + FlaxEulerDiscreteScheduler, + FlaxKarrasVeScheduler, + FlaxLMSDiscreteScheduler, + FlaxPNDMScheduler, + FlaxSchedulerMixin, + FlaxScoreSdeVeScheduler, + ) + + try: + if not (is_flax_available() and is_transformers_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_flax_and_transformers_objects import * # noqa F403 + else: + from .pipelines import ( + FlaxStableDiffusionControlNetPipeline, + FlaxStableDiffusionImg2ImgPipeline, + FlaxStableDiffusionInpaintPipeline, + FlaxStableDiffusionPipeline, + FlaxStableDiffusionXLPipeline, + ) + + try: + if not (is_note_seq_available()): + raise OptionalDependencyNotAvailable() + except OptionalDependencyNotAvailable: + from .utils.dummy_note_seq_objects import * # noqa F403 + else: + from .pipelines import MidiProcessor + +else: + import sys + + sys.modules[__name__] = _LazyModule( + __name__, + globals()["__file__"], + _import_structure, + module_spec=__spec__, + extra_objects={"__version__": __version__}, + ) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/callbacks.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/callbacks.py new file mode 100644 index 0000000000000000000000000000000000000000..2a08f091d9f3f0b1e13ed7eaa10379ea8d5bf962 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/callbacks.py @@ -0,0 +1,244 @@ +from typing import Any, Dict, List + +from .configuration_utils import ConfigMixin, register_to_config +from .utils import CONFIG_NAME + + +class PipelineCallback(ConfigMixin): + """ + Base class for all the official callbacks used in a pipeline. This class provides a structure for implementing + custom callbacks and ensures that all callbacks have a consistent interface. + + Please implement the following: + `tensor_inputs`: This should return a list of tensor inputs specific to your callback. You will only be able to + include + variables listed in the `._callback_tensor_inputs` attribute of your pipeline class. + `callback_fn`: This method defines the core functionality of your callback. + """ + + config_name = CONFIG_NAME + + @register_to_config + def __init__(self, cutoff_step_ratio=1.0, cutoff_step_index=None): + super().__init__() + + if (cutoff_step_ratio is None and cutoff_step_index is None) or ( + cutoff_step_ratio is not None and cutoff_step_index is not None + ): + raise ValueError("Either cutoff_step_ratio or cutoff_step_index should be provided, not both or none.") + + if cutoff_step_ratio is not None and ( + not isinstance(cutoff_step_ratio, float) or not (0.0 <= cutoff_step_ratio <= 1.0) + ): + raise ValueError("cutoff_step_ratio must be a float between 0.0 and 1.0.") + + @property + def tensor_inputs(self) -> List[str]: + raise NotImplementedError(f"You need to set the attribute `tensor_inputs` for {self.__class__}") + + def callback_fn(self, pipeline, step_index, timesteps, callback_kwargs) -> Dict[str, Any]: + raise NotImplementedError(f"You need to implement the method `callback_fn` for {self.__class__}") + + def __call__(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + return self.callback_fn(pipeline, step_index, timestep, callback_kwargs) + + +class MultiPipelineCallbacks: + """ + This class is designed to handle multiple pipeline callbacks. It accepts a list of PipelineCallback objects and + provides a unified interface for calling all of them. + """ + + def __init__(self, callbacks: List[PipelineCallback]): + self.callbacks = callbacks + + @property + def tensor_inputs(self) -> List[str]: + return [input for callback in self.callbacks for input in callback.tensor_inputs] + + def __call__(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + """ + Calls all the callbacks in order with the given arguments and returns the final callback_kwargs. + """ + for callback in self.callbacks: + callback_kwargs = callback(pipeline, step_index, timestep, callback_kwargs) + + return callback_kwargs + + +class SDCFGCutoffCallback(PipelineCallback): + """ + Callback function for Stable Diffusion Pipelines. After certain number of steps (set by `cutoff_step_ratio` or + `cutoff_step_index`), this callback will disable the CFG. + + Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step. + """ + + tensor_inputs = ["prompt_embeds"] + + def callback_fn(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + cutoff_step_ratio = self.config.cutoff_step_ratio + cutoff_step_index = self.config.cutoff_step_index + + # Use cutoff_step_index if it's not None, otherwise use cutoff_step_ratio + cutoff_step = ( + cutoff_step_index if cutoff_step_index is not None else int(pipeline.num_timesteps * cutoff_step_ratio) + ) + + if step_index == cutoff_step: + prompt_embeds = callback_kwargs[self.tensor_inputs[0]] + prompt_embeds = prompt_embeds[-1:] # "-1" denotes the embeddings for conditional text tokens. + + pipeline._guidance_scale = 0.0 + + callback_kwargs[self.tensor_inputs[0]] = prompt_embeds + return callback_kwargs + + +class SDXLCFGCutoffCallback(PipelineCallback): + """ + Callback function for the base Stable Diffusion XL Pipelines. After certain number of steps (set by + `cutoff_step_ratio` or `cutoff_step_index`), this callback will disable the CFG. + + Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step. + """ + + tensor_inputs = [ + "prompt_embeds", + "add_text_embeds", + "add_time_ids", + ] + + def callback_fn(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + cutoff_step_ratio = self.config.cutoff_step_ratio + cutoff_step_index = self.config.cutoff_step_index + + # Use cutoff_step_index if it's not None, otherwise use cutoff_step_ratio + cutoff_step = ( + cutoff_step_index if cutoff_step_index is not None else int(pipeline.num_timesteps * cutoff_step_ratio) + ) + + if step_index == cutoff_step: + prompt_embeds = callback_kwargs[self.tensor_inputs[0]] + prompt_embeds = prompt_embeds[-1:] # "-1" denotes the embeddings for conditional text tokens. + + add_text_embeds = callback_kwargs[self.tensor_inputs[1]] + add_text_embeds = add_text_embeds[-1:] # "-1" denotes the embeddings for conditional pooled text tokens + + add_time_ids = callback_kwargs[self.tensor_inputs[2]] + add_time_ids = add_time_ids[-1:] # "-1" denotes the embeddings for conditional added time vector + + pipeline._guidance_scale = 0.0 + + callback_kwargs[self.tensor_inputs[0]] = prompt_embeds + callback_kwargs[self.tensor_inputs[1]] = add_text_embeds + callback_kwargs[self.tensor_inputs[2]] = add_time_ids + + return callback_kwargs + + +class SDXLControlnetCFGCutoffCallback(PipelineCallback): + """ + Callback function for the Controlnet Stable Diffusion XL Pipelines. After certain number of steps (set by + `cutoff_step_ratio` or `cutoff_step_index`), this callback will disable the CFG. + + Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step. + """ + + tensor_inputs = [ + "prompt_embeds", + "add_text_embeds", + "add_time_ids", + "image", + ] + + def callback_fn(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + cutoff_step_ratio = self.config.cutoff_step_ratio + cutoff_step_index = self.config.cutoff_step_index + + # Use cutoff_step_index if it's not None, otherwise use cutoff_step_ratio + cutoff_step = ( + cutoff_step_index if cutoff_step_index is not None else int(pipeline.num_timesteps * cutoff_step_ratio) + ) + + if step_index == cutoff_step: + prompt_embeds = callback_kwargs[self.tensor_inputs[0]] + prompt_embeds = prompt_embeds[-1:] # "-1" denotes the embeddings for conditional text tokens. + + add_text_embeds = callback_kwargs[self.tensor_inputs[1]] + add_text_embeds = add_text_embeds[-1:] # "-1" denotes the embeddings for conditional pooled text tokens + + add_time_ids = callback_kwargs[self.tensor_inputs[2]] + add_time_ids = add_time_ids[-1:] # "-1" denotes the embeddings for conditional added time vector + + # For Controlnet + image = callback_kwargs[self.tensor_inputs[3]] + image = image[-1:] + + pipeline._guidance_scale = 0.0 + + callback_kwargs[self.tensor_inputs[0]] = prompt_embeds + callback_kwargs[self.tensor_inputs[1]] = add_text_embeds + callback_kwargs[self.tensor_inputs[2]] = add_time_ids + callback_kwargs[self.tensor_inputs[3]] = image + + return callback_kwargs + + +class IPAdapterScaleCutoffCallback(PipelineCallback): + """ + Callback function for any pipeline that inherits `IPAdapterMixin`. After certain number of steps (set by + `cutoff_step_ratio` or `cutoff_step_index`), this callback will set the IP Adapter scale to `0.0`. + + Note: This callback mutates the IP Adapter attention processors by setting the scale to 0.0 after the cutoff step. + """ + + tensor_inputs = [] + + def callback_fn(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + cutoff_step_ratio = self.config.cutoff_step_ratio + cutoff_step_index = self.config.cutoff_step_index + + # Use cutoff_step_index if it's not None, otherwise use cutoff_step_ratio + cutoff_step = ( + cutoff_step_index if cutoff_step_index is not None else int(pipeline.num_timesteps * cutoff_step_ratio) + ) + + if step_index == cutoff_step: + pipeline.set_ip_adapter_scale(0.0) + return callback_kwargs + + +class SD3CFGCutoffCallback(PipelineCallback): + """ + Callback function for Stable Diffusion 3 Pipelines. After certain number of steps (set by `cutoff_step_ratio` or + `cutoff_step_index`), this callback will disable the CFG. + + Note: This callback mutates the pipeline by changing the `_guidance_scale` attribute to 0.0 after the cutoff step. + """ + + tensor_inputs = ["prompt_embeds", "pooled_prompt_embeds"] + + def callback_fn(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]: + cutoff_step_ratio = self.config.cutoff_step_ratio + cutoff_step_index = self.config.cutoff_step_index + + # Use cutoff_step_index if it's not None, otherwise use cutoff_step_ratio + cutoff_step = ( + cutoff_step_index if cutoff_step_index is not None else int(pipeline.num_timesteps * cutoff_step_ratio) + ) + + if step_index == cutoff_step: + prompt_embeds = callback_kwargs[self.tensor_inputs[0]] + prompt_embeds = prompt_embeds[-1:] # "-1" denotes the embeddings for conditional text tokens. + + pooled_prompt_embeds = callback_kwargs[self.tensor_inputs[1]] + pooled_prompt_embeds = pooled_prompt_embeds[ + -1: + ] # "-1" denotes the embeddings for conditional pooled text tokens. + + pipeline._guidance_scale = 0.0 + + callback_kwargs[self.tensor_inputs[0]] = prompt_embeds + callback_kwargs[self.tensor_inputs[1]] = pooled_prompt_embeds + return callback_kwargs diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3a8c10147e8bdc6be186193fa7775460b474a9ba --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from abc import ABC, abstractmethod +from argparse import ArgumentParser + + +class BaseDiffusersCLICommand(ABC): + @staticmethod + @abstractmethod + def register_subcommand(parser: ArgumentParser): + raise NotImplementedError() + + @abstractmethod + def run(self): + raise NotImplementedError() diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/custom_blocks.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/custom_blocks.py new file mode 100644 index 0000000000000000000000000000000000000000..43d9ea88577a398329a6c538a37810a718a1bccc --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/custom_blocks.py @@ -0,0 +1,134 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Usage example: + TODO +""" + +import ast +import importlib.util +import os +from argparse import ArgumentParser, Namespace +from pathlib import Path + +from ..utils import logging +from . import BaseDiffusersCLICommand + + +EXPECTED_PARENT_CLASSES = ["ModularPipelineBlocks"] +CONFIG = "config.json" + + +def conversion_command_factory(args: Namespace): + return CustomBlocksCommand(args.block_module_name, args.block_class_name) + + +class CustomBlocksCommand(BaseDiffusersCLICommand): + @staticmethod + def register_subcommand(parser: ArgumentParser): + conversion_parser = parser.add_parser("custom_blocks") + conversion_parser.add_argument( + "--block_module_name", + type=str, + default="block.py", + help="Module filename in which the custom block will be implemented.", + ) + conversion_parser.add_argument( + "--block_class_name", + type=str, + default=None, + help="Name of the custom block. If provided None, we will try to infer it.", + ) + conversion_parser.set_defaults(func=conversion_command_factory) + + def __init__(self, block_module_name: str = "block.py", block_class_name: str = None): + self.logger = logging.get_logger("diffusers-cli/custom_blocks") + self.block_module_name = Path(block_module_name) + self.block_class_name = block_class_name + + def run(self): + # determine the block to be saved. + out = self._get_class_names(self.block_module_name) + classes_found = list({cls for cls, _ in out}) + + if self.block_class_name is not None: + child_class, parent_class = self._choose_block(out, self.block_class_name) + if child_class is None and parent_class is None: + raise ValueError( + "`block_class_name` could not be retrieved. Available classes from " + f"{self.block_module_name}:\n{classes_found}" + ) + else: + self.logger.info( + f"Found classes: {classes_found} will be using {classes_found[0]}. " + "If this needs to be changed, re-run the command specifying `block_class_name`." + ) + child_class, parent_class = out[0][0], out[0][1] + + # dynamically get the custom block and initialize it to call `save_pretrained` in the current directory. + # the user is responsible for running it, so I guess that is safe? + module_name = f"__dynamic__{self.block_module_name.stem}" + spec = importlib.util.spec_from_file_location(module_name, str(self.block_module_name)) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + getattr(module, child_class)().save_pretrained(os.getcwd()) + + # or, we could create it manually. + # automap = self._create_automap(parent_class=parent_class, child_class=child_class) + # with open(CONFIG, "w") as f: + # json.dump(automap, f) + with open("requirements.txt", "w") as f: + f.write("") + + def _choose_block(self, candidates, chosen=None): + for cls, base in candidates: + if cls == chosen: + return cls, base + return None, None + + def _get_class_names(self, file_path): + source = file_path.read_text(encoding="utf-8") + try: + tree = ast.parse(source, filename=file_path) + except SyntaxError as e: + raise ValueError(f"Could not parse {file_path!r}: {e}") from e + + results: list[tuple[str, str]] = [] + for node in tree.body: + if not isinstance(node, ast.ClassDef): + continue + + # extract all base names for this class + base_names = [bname for b in node.bases if (bname := self._get_base_name(b)) is not None] + + # for each allowed base that appears in the class's bases, emit a tuple + for allowed in EXPECTED_PARENT_CLASSES: + if allowed in base_names: + results.append((node.name, allowed)) + + return results + + def _get_base_name(self, node: ast.expr): + if isinstance(node, ast.Name): + return node.id + elif isinstance(node, ast.Attribute): + val = self._get_base_name(node.value) + return f"{val}.{node.attr}" if val else node.attr + return None + + def _create_automap(self, parent_class, child_class): + module = str(self.block_module_name).replace(".py", "").rsplit(".", 1)[-1] + auto_map = {f"{parent_class}": f"{module}.{child_class}"} + return {"auto_map": auto_map} diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/diffusers_cli.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/diffusers_cli.py new file mode 100644 index 0000000000000000000000000000000000000000..a27ac24f2a3eab862e2e78c2e3eea872b8036eb0 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/diffusers_cli.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from argparse import ArgumentParser + +from .custom_blocks import CustomBlocksCommand +from .env import EnvironmentCommand +from .fp16_safetensors import FP16SafetensorsCommand + + +def main(): + parser = ArgumentParser("Diffusers CLI tool", usage="diffusers-cli []") + commands_parser = parser.add_subparsers(help="diffusers-cli command helpers") + + # Register commands + EnvironmentCommand.register_subcommand(commands_parser) + FP16SafetensorsCommand.register_subcommand(commands_parser) + CustomBlocksCommand.register_subcommand(commands_parser) + + # Let's go + args = parser.parse_args() + + if not hasattr(args, "func"): + parser.print_help() + exit(1) + + # Run + service = args.func(args) + service.run() + + +if __name__ == "__main__": + main() diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/env.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/env.py new file mode 100644 index 0000000000000000000000000000000000000000..58f31d478bf35420b3bd324b0aaf57bef934b380 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/env.py @@ -0,0 +1,180 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import platform +import subprocess +from argparse import ArgumentParser + +import huggingface_hub + +from .. import __version__ as version +from ..utils import ( + is_accelerate_available, + is_bitsandbytes_available, + is_flax_available, + is_google_colab, + is_peft_available, + is_safetensors_available, + is_torch_available, + is_transformers_available, + is_xformers_available, +) +from . import BaseDiffusersCLICommand + + +def info_command_factory(_): + return EnvironmentCommand() + + +class EnvironmentCommand(BaseDiffusersCLICommand): + @staticmethod + def register_subcommand(parser: ArgumentParser) -> None: + download_parser = parser.add_parser("env") + download_parser.set_defaults(func=info_command_factory) + + def run(self) -> dict: + hub_version = huggingface_hub.__version__ + + safetensors_version = "not installed" + if is_safetensors_available(): + import safetensors + + safetensors_version = safetensors.__version__ + + pt_version = "not installed" + pt_cuda_available = "NA" + if is_torch_available(): + import torch + + pt_version = torch.__version__ + pt_cuda_available = torch.cuda.is_available() + + flax_version = "not installed" + jax_version = "not installed" + jaxlib_version = "not installed" + jax_backend = "NA" + if is_flax_available(): + import flax + import jax + import jaxlib + + flax_version = flax.__version__ + jax_version = jax.__version__ + jaxlib_version = jaxlib.__version__ + jax_backend = jax.lib.xla_bridge.get_backend().platform + + transformers_version = "not installed" + if is_transformers_available(): + import transformers + + transformers_version = transformers.__version__ + + accelerate_version = "not installed" + if is_accelerate_available(): + import accelerate + + accelerate_version = accelerate.__version__ + + peft_version = "not installed" + if is_peft_available(): + import peft + + peft_version = peft.__version__ + + bitsandbytes_version = "not installed" + if is_bitsandbytes_available(): + import bitsandbytes + + bitsandbytes_version = bitsandbytes.__version__ + + xformers_version = "not installed" + if is_xformers_available(): + import xformers + + xformers_version = xformers.__version__ + + platform_info = platform.platform() + + is_google_colab_str = "Yes" if is_google_colab() else "No" + + accelerator = "NA" + if platform.system() in {"Linux", "Windows"}: + try: + sp = subprocess.Popen( + ["nvidia-smi", "--query-gpu=gpu_name,memory.total", "--format=csv,noheader"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + out_str, _ = sp.communicate() + out_str = out_str.decode("utf-8") + + if len(out_str) > 0: + accelerator = out_str.strip() + except FileNotFoundError: + pass + elif platform.system() == "Darwin": # Mac OS + try: + sp = subprocess.Popen( + ["system_profiler", "SPDisplaysDataType"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + out_str, _ = sp.communicate() + out_str = out_str.decode("utf-8") + + start = out_str.find("Chipset Model:") + if start != -1: + start += len("Chipset Model:") + end = out_str.find("\n", start) + accelerator = out_str[start:end].strip() + + start = out_str.find("VRAM (Total):") + if start != -1: + start += len("VRAM (Total):") + end = out_str.find("\n", start) + accelerator += " VRAM: " + out_str[start:end].strip() + except FileNotFoundError: + pass + else: + print("It seems you are running an unusual OS. Could you fill in the accelerator manually?") + + info = { + "🤗 Diffusers version": version, + "Platform": platform_info, + "Running on Google Colab?": is_google_colab_str, + "Python version": platform.python_version(), + "PyTorch version (GPU?)": f"{pt_version} ({pt_cuda_available})", + "Flax version (CPU?/GPU?/TPU?)": f"{flax_version} ({jax_backend})", + "Jax version": jax_version, + "JaxLib version": jaxlib_version, + "Huggingface_hub version": hub_version, + "Transformers version": transformers_version, + "Accelerate version": accelerate_version, + "PEFT version": peft_version, + "Bitsandbytes version": bitsandbytes_version, + "Safetensors version": safetensors_version, + "xFormers version": xformers_version, + "Accelerator": accelerator, + "Using GPU in script?": "", + "Using distributed or parallel set-up in script?": "", + } + + print("\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n") + print(self.format_dict(info)) + + return info + + @staticmethod + def format_dict(d: dict) -> str: + return "\n".join([f"- {prop}: {val}" for prop, val in d.items()]) + "\n" diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/fp16_safetensors.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/fp16_safetensors.py new file mode 100644 index 0000000000000000000000000000000000000000..41739261e55341d0f555ac7fb61739846e214ed4 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/commands/fp16_safetensors.py @@ -0,0 +1,132 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Usage example: + diffusers-cli fp16_safetensors --ckpt_id=openai/shap-e --fp16 --use_safetensors +""" + +import glob +import json +import warnings +from argparse import ArgumentParser, Namespace +from importlib import import_module + +import huggingface_hub +import torch +from huggingface_hub import hf_hub_download +from packaging import version + +from ..utils import logging +from . import BaseDiffusersCLICommand + + +def conversion_command_factory(args: Namespace): + if args.use_auth_token: + warnings.warn( + "The `--use_auth_token` flag is deprecated and will be removed in a future version. Authentication is now" + " handled automatically if user is logged in." + ) + return FP16SafetensorsCommand(args.ckpt_id, args.fp16, args.use_safetensors) + + +class FP16SafetensorsCommand(BaseDiffusersCLICommand): + @staticmethod + def register_subcommand(parser: ArgumentParser): + conversion_parser = parser.add_parser("fp16_safetensors") + conversion_parser.add_argument( + "--ckpt_id", + type=str, + help="Repo id of the checkpoints on which to run the conversion. Example: 'openai/shap-e'.", + ) + conversion_parser.add_argument( + "--fp16", action="store_true", help="If serializing the variables in FP16 precision." + ) + conversion_parser.add_argument( + "--use_safetensors", action="store_true", help="If serializing in the safetensors format." + ) + conversion_parser.add_argument( + "--use_auth_token", + action="store_true", + help="When working with checkpoints having private visibility. When used `hf auth login` needs to be run beforehand.", + ) + conversion_parser.set_defaults(func=conversion_command_factory) + + def __init__(self, ckpt_id: str, fp16: bool, use_safetensors: bool): + self.logger = logging.get_logger("diffusers-cli/fp16_safetensors") + self.ckpt_id = ckpt_id + self.local_ckpt_dir = f"/tmp/{ckpt_id}" + self.fp16 = fp16 + + self.use_safetensors = use_safetensors + + if not self.use_safetensors and not self.fp16: + raise NotImplementedError( + "When `use_safetensors` and `fp16` both are False, then this command is of no use." + ) + + def run(self): + if version.parse(huggingface_hub.__version__) < version.parse("0.9.0"): + raise ImportError( + "The huggingface_hub version must be >= 0.9.0 to use this command. Please update your huggingface_hub" + " installation." + ) + else: + from huggingface_hub import create_commit + from huggingface_hub._commit_api import CommitOperationAdd + + model_index = hf_hub_download(repo_id=self.ckpt_id, filename="model_index.json") + with open(model_index, "r") as f: + pipeline_class_name = json.load(f)["_class_name"] + pipeline_class = getattr(import_module("diffusers"), pipeline_class_name) + self.logger.info(f"Pipeline class imported: {pipeline_class_name}.") + + # Load the appropriate pipeline. We could have use `DiffusionPipeline` + # here, but just to avoid any rough edge cases. + pipeline = pipeline_class.from_pretrained( + self.ckpt_id, torch_dtype=torch.float16 if self.fp16 else torch.float32 + ) + pipeline.save_pretrained( + self.local_ckpt_dir, + safe_serialization=True if self.use_safetensors else False, + variant="fp16" if self.fp16 else None, + ) + self.logger.info(f"Pipeline locally saved to {self.local_ckpt_dir}.") + + # Fetch all the paths. + if self.fp16: + modified_paths = glob.glob(f"{self.local_ckpt_dir}/*/*.fp16.*") + elif self.use_safetensors: + modified_paths = glob.glob(f"{self.local_ckpt_dir}/*/*.safetensors") + + # Prepare for the PR. + commit_message = f"Serialize variables with FP16: {self.fp16} and safetensors: {self.use_safetensors}." + operations = [] + for path in modified_paths: + operations.append(CommitOperationAdd(path_in_repo="/".join(path.split("/")[4:]), path_or_fileobj=path)) + + # Open the PR. + commit_description = ( + "Variables converted by the [`diffusers`' `fp16_safetensors`" + " CLI](https://github.com/huggingface/diffusers/blob/main/src/diffusers/commands/fp16_safetensors.py)." + ) + hub_pr_url = create_commit( + repo_id=self.ckpt_id, + operations=operations, + commit_message=commit_message, + commit_description=commit_description, + repo_type="model", + create_pr=True, + ).pr_url + self.logger.info(f"PR created here: {hub_pr_url}.") diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/configuration_utils.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/configuration_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..1c4ee33acbfdadb70b0f022761011242ef073d4a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/configuration_utils.py @@ -0,0 +1,769 @@ +# coding=utf-8 +# Copyright 2025 The HuggingFace Inc. team. +# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""ConfigMixin base class and utilities.""" + +import dataclasses +import functools +import importlib +import inspect +import json +import os +import re +from collections import OrderedDict +from pathlib import Path +from typing import Any, Dict, Optional, Tuple, Union + +import numpy as np +from huggingface_hub import DDUFEntry, create_repo, hf_hub_download +from huggingface_hub.utils import ( + EntryNotFoundError, + HfHubHTTPError, + RepositoryNotFoundError, + RevisionNotFoundError, + validate_hf_hub_args, +) +from typing_extensions import Self + +from . import __version__ +from .utils import ( + HUGGINGFACE_CO_RESOLVE_ENDPOINT, + DummyObject, + deprecate, + extract_commit_hash, + http_user_agent, + logging, +) + + +logger = logging.get_logger(__name__) + +_re_configuration_file = re.compile(r"config\.(.*)\.json") + + +class FrozenDict(OrderedDict): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + for key, value in self.items(): + setattr(self, key, value) + + self.__frozen = True + + def __delitem__(self, *args, **kwargs): + raise Exception(f"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.") + + def setdefault(self, *args, **kwargs): + raise Exception(f"You cannot use ``setdefault`` on a {self.__class__.__name__} instance.") + + def pop(self, *args, **kwargs): + raise Exception(f"You cannot use ``pop`` on a {self.__class__.__name__} instance.") + + def update(self, *args, **kwargs): + raise Exception(f"You cannot use ``update`` on a {self.__class__.__name__} instance.") + + def __setattr__(self, name, value): + if hasattr(self, "__frozen") and self.__frozen: + raise Exception(f"You cannot use ``__setattr__`` on a {self.__class__.__name__} instance.") + super().__setattr__(name, value) + + def __setitem__(self, name, value): + if hasattr(self, "__frozen") and self.__frozen: + raise Exception(f"You cannot use ``__setattr__`` on a {self.__class__.__name__} instance.") + super().__setitem__(name, value) + + +class ConfigMixin: + r""" + Base class for all configuration classes. All configuration parameters are stored under `self.config`. Also + provides the [`~ConfigMixin.from_config`] and [`~ConfigMixin.save_config`] methods for loading, downloading, and + saving classes that inherit from [`ConfigMixin`]. + + Class attributes: + - **config_name** (`str`) -- A filename under which the config should stored when calling + [`~ConfigMixin.save_config`] (should be overridden by parent class). + - **ignore_for_config** (`List[str]`) -- A list of attributes that should not be saved in the config (should be + overridden by subclass). + - **has_compatibles** (`bool`) -- Whether the class has compatible classes (should be overridden by subclass). + - **_deprecated_kwargs** (`List[str]`) -- Keyword arguments that are deprecated. Note that the `init` function + should only have a `kwargs` argument if at least one argument is deprecated (should be overridden by + subclass). + """ + + config_name = None + ignore_for_config = [] + has_compatibles = False + + _deprecated_kwargs = [] + + def register_to_config(self, **kwargs): + if self.config_name is None: + raise NotImplementedError(f"Make sure that {self.__class__} has defined a class name `config_name`") + # Special case for `kwargs` used in deprecation warning added to schedulers + # TODO: remove this when we remove the deprecation warning, and the `kwargs` argument, + # or solve in a more general way. + kwargs.pop("kwargs", None) + + if not hasattr(self, "_internal_dict"): + internal_dict = kwargs + else: + previous_dict = dict(self._internal_dict) + internal_dict = {**self._internal_dict, **kwargs} + logger.debug(f"Updating config from {previous_dict} to {internal_dict}") + + self._internal_dict = FrozenDict(internal_dict) + + def __getattr__(self, name: str) -> Any: + """The only reason we overwrite `getattr` here is to gracefully deprecate accessing + config attributes directly. See https://github.com/huggingface/diffusers/pull/3129 + + This function is mostly copied from PyTorch's __getattr__ overwrite: + https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module + """ + + is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name) + is_attribute = name in self.__dict__ + + if is_in_config and not is_attribute: + deprecation_message = f"Accessing config attribute `{name}` directly via '{type(self).__name__}' object attribute is deprecated. Please access '{name}' over '{type(self).__name__}'s config object instead, e.g. 'scheduler.config.{name}'." + deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False) + return self._internal_dict[name] + + raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") + + def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool = False, **kwargs): + """ + Save a configuration object to the directory specified in `save_directory` so that it can be reloaded using the + [`~ConfigMixin.from_config`] class method. + + Args: + save_directory (`str` or `os.PathLike`): + Directory where the configuration JSON file is saved (will be created if it does not exist). + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether or not to push your model to the Hugging Face Hub after saving it. You can specify the + repository you want to push to with `repo_id` (will default to the name of `save_directory` in your + namespace). + kwargs (`Dict[str, Any]`, *optional*): + Additional keyword arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method. + """ + if os.path.isfile(save_directory): + raise AssertionError(f"Provided path ({save_directory}) should be a directory, not a file") + + os.makedirs(save_directory, exist_ok=True) + + # If we save using the predefined names, we can load using `from_config` + output_config_file = os.path.join(save_directory, self.config_name) + + self.to_json_file(output_config_file) + logger.info(f"Configuration saved in {output_config_file}") + + if push_to_hub: + commit_message = kwargs.pop("commit_message", None) + private = kwargs.pop("private", None) + create_pr = kwargs.pop("create_pr", False) + token = kwargs.pop("token", None) + repo_id = kwargs.pop("repo_id", save_directory.split(os.path.sep)[-1]) + repo_id = create_repo(repo_id, exist_ok=True, private=private, token=token).repo_id + subfolder = kwargs.pop("subfolder", None) + + self._upload_folder( + save_directory, + repo_id, + token=token, + commit_message=commit_message, + create_pr=create_pr, + subfolder=subfolder, + ) + + @classmethod + def from_config( + cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_unused_kwargs=False, **kwargs + ) -> Union[Self, Tuple[Self, Dict[str, Any]]]: + r""" + Instantiate a Python class from a config dictionary. + + Parameters: + config (`Dict[str, Any]`): + A config dictionary from which the Python class is instantiated. Make sure to only load configuration + files of compatible classes. + return_unused_kwargs (`bool`, *optional*, defaults to `False`): + Whether kwargs that are not consumed by the Python class should be returned or not. + kwargs (remaining dictionary of keyword arguments, *optional*): + Can be used to update the configuration object (after it is loaded) and initiate the Python class. + `**kwargs` are passed directly to the underlying scheduler/model's `__init__` method and eventually + overwrite the same named arguments in `config`. + + Returns: + [`ModelMixin`] or [`SchedulerMixin`]: + A model or scheduler object instantiated from a config dictionary. + + Examples: + + ```python + >>> from diffusers import DDPMScheduler, DDIMScheduler, PNDMScheduler + + >>> # Download scheduler from huggingface.co and cache. + >>> scheduler = DDPMScheduler.from_pretrained("google/ddpm-cifar10-32") + + >>> # Instantiate DDIM scheduler class with same config as DDPM + >>> scheduler = DDIMScheduler.from_config(scheduler.config) + + >>> # Instantiate PNDM scheduler class with same config as DDPM + >>> scheduler = PNDMScheduler.from_config(scheduler.config) + ``` + """ + # <===== TO BE REMOVED WITH DEPRECATION + # TODO(Patrick) - make sure to remove the following lines when config=="model_path" is deprecated + if "pretrained_model_name_or_path" in kwargs: + config = kwargs.pop("pretrained_model_name_or_path") + + if config is None: + raise ValueError("Please make sure to provide a config as the first positional argument.") + # ======> + + if not isinstance(config, dict): + deprecation_message = "It is deprecated to pass a pretrained model name or path to `from_config`." + if "Scheduler" in cls.__name__: + deprecation_message += ( + f"If you were trying to load a scheduler, please use {cls}.from_pretrained(...) instead." + " Otherwise, please make sure to pass a configuration dictionary instead. This functionality will" + " be removed in v1.0.0." + ) + elif "Model" in cls.__name__: + deprecation_message += ( + f"If you were trying to load a model, please use {cls}.load_config(...) followed by" + f" {cls}.from_config(...) instead. Otherwise, please make sure to pass a configuration dictionary" + " instead. This functionality will be removed in v1.0.0." + ) + deprecate("config-passed-as-path", "1.0.0", deprecation_message, standard_warn=False) + config, kwargs = cls.load_config(pretrained_model_name_or_path=config, return_unused_kwargs=True, **kwargs) + + init_dict, unused_kwargs, hidden_dict = cls.extract_init_dict(config, **kwargs) + + # Allow dtype to be specified on initialization + if "dtype" in unused_kwargs: + init_dict["dtype"] = unused_kwargs.pop("dtype") + + # add possible deprecated kwargs + for deprecated_kwarg in cls._deprecated_kwargs: + if deprecated_kwarg in unused_kwargs: + init_dict[deprecated_kwarg] = unused_kwargs.pop(deprecated_kwarg) + + # Return model and optionally state and/or unused_kwargs + model = cls(**init_dict) + + # make sure to also save config parameters that might be used for compatible classes + # update _class_name + if "_class_name" in hidden_dict: + hidden_dict["_class_name"] = cls.__name__ + + model.register_to_config(**hidden_dict) + + # add hidden kwargs of compatible classes to unused_kwargs + unused_kwargs = {**unused_kwargs, **hidden_dict} + + if return_unused_kwargs: + return (model, unused_kwargs) + else: + return model + + @classmethod + def get_config_dict(cls, *args, **kwargs): + deprecation_message = ( + f" The function get_config_dict is deprecated. Please use {cls}.load_config instead. This function will be" + " removed in version v1.0.0" + ) + deprecate("get_config_dict", "1.0.0", deprecation_message, standard_warn=False) + return cls.load_config(*args, **kwargs) + + @classmethod + @validate_hf_hub_args + def load_config( + cls, + pretrained_model_name_or_path: Union[str, os.PathLike], + return_unused_kwargs=False, + return_commit_hash=False, + **kwargs, + ) -> Tuple[Dict[str, Any], Dict[str, Any]]: + r""" + Load a model or scheduler configuration. + + Parameters: + pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*): + Can be either: + + - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on + the Hub. + - A path to a *directory* (for example `./my_model_directory`) containing model weights saved with + [`~ConfigMixin.save_config`]. + + cache_dir (`Union[str, os.PathLike]`, *optional*): + Path to a directory where a downloaded pretrained model configuration is cached if the standard cache + is not used. + force_download (`bool`, *optional*, defaults to `False`): + Whether or not to force the (re-)download of the model weights and configuration files, overriding the + cached versions if they exist. + proxies (`Dict[str, str]`, *optional*): + A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', + 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. + output_loading_info(`bool`, *optional*, defaults to `False`): + Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. + local_files_only (`bool`, *optional*, defaults to `False`): + Whether to only load local model weights and configuration files or not. If set to `True`, the model + won't be downloaded from the Hub. + token (`str` or *bool*, *optional*): + The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from + `diffusers-cli login` (stored in `~/.huggingface`) is used. + revision (`str`, *optional*, defaults to `"main"`): + The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier + allowed by Git. + subfolder (`str`, *optional*, defaults to `""`): + The subfolder location of a model file within a larger model repository on the Hub or locally. + return_unused_kwargs (`bool`, *optional*, defaults to `False): + Whether unused keyword arguments of the config are returned. + return_commit_hash (`bool`, *optional*, defaults to `False): + Whether the `commit_hash` of the loaded configuration are returned. + + Returns: + `dict`: + A dictionary of all the parameters stored in a JSON configuration file. + + """ + cache_dir = kwargs.pop("cache_dir", None) + local_dir = kwargs.pop("local_dir", None) + local_dir_use_symlinks = kwargs.pop("local_dir_use_symlinks", "auto") + force_download = kwargs.pop("force_download", False) + proxies = kwargs.pop("proxies", None) + token = kwargs.pop("token", None) + local_files_only = kwargs.pop("local_files_only", False) + revision = kwargs.pop("revision", None) + _ = kwargs.pop("mirror", None) + subfolder = kwargs.pop("subfolder", None) + user_agent = kwargs.pop("user_agent", {}) + dduf_entries: Optional[Dict[str, DDUFEntry]] = kwargs.pop("dduf_entries", None) + + user_agent = {**user_agent, "file_type": "config"} + user_agent = http_user_agent(user_agent) + + pretrained_model_name_or_path = str(pretrained_model_name_or_path) + + if cls.config_name is None: + raise ValueError( + "`self.config_name` is not defined. Note that one should not load a config from " + "`ConfigMixin`. Please make sure to define `config_name` in a class inheriting from `ConfigMixin`" + ) + # Custom path for now + if dduf_entries: + if subfolder is not None: + raise ValueError( + "DDUF file only allow for 1 level of directory (e.g transformer/model1/model.safetentors is not allowed). " + "Please check the DDUF structure" + ) + config_file = cls._get_config_file_from_dduf(pretrained_model_name_or_path, dduf_entries) + elif os.path.isfile(pretrained_model_name_or_path): + config_file = pretrained_model_name_or_path + elif os.path.isdir(pretrained_model_name_or_path): + if subfolder is not None and os.path.isfile( + os.path.join(pretrained_model_name_or_path, subfolder, cls.config_name) + ): + config_file = os.path.join(pretrained_model_name_or_path, subfolder, cls.config_name) + elif os.path.isfile(os.path.join(pretrained_model_name_or_path, cls.config_name)): + # Load from a PyTorch checkpoint + config_file = os.path.join(pretrained_model_name_or_path, cls.config_name) + else: + raise EnvironmentError( + f"Error no file named {cls.config_name} found in directory {pretrained_model_name_or_path}." + ) + else: + try: + # Load from URL or cache if already cached + config_file = hf_hub_download( + pretrained_model_name_or_path, + filename=cls.config_name, + cache_dir=cache_dir, + force_download=force_download, + proxies=proxies, + local_files_only=local_files_only, + token=token, + user_agent=user_agent, + subfolder=subfolder, + revision=revision, + local_dir=local_dir, + local_dir_use_symlinks=local_dir_use_symlinks, + ) + except RepositoryNotFoundError: + raise EnvironmentError( + f"{pretrained_model_name_or_path} is not a local folder and is not a valid model identifier" + " listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to pass a" + " token having permission to this repo with `token` or log in with `hf auth login`." + ) + except RevisionNotFoundError: + raise EnvironmentError( + f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for" + " this model name. Check the model page at" + f" 'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions." + ) + except EntryNotFoundError: + raise EnvironmentError( + f"{pretrained_model_name_or_path} does not appear to have a file named {cls.config_name}." + ) + except HfHubHTTPError as err: + raise EnvironmentError( + "There was a specific connection error when trying to load" + f" {pretrained_model_name_or_path}:\n{err}" + ) + except ValueError: + raise EnvironmentError( + f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it" + f" in the cached files and it looks like {pretrained_model_name_or_path} is not the path to a" + f" directory containing a {cls.config_name} file.\nCheckout your internet connection or see how to" + " run the library in offline mode at" + " 'https://huggingface.co/docs/diffusers/installation#offline-mode'." + ) + except EnvironmentError: + raise EnvironmentError( + f"Can't load config for '{pretrained_model_name_or_path}'. If you were trying to load it from " + "'https://huggingface.co/models', make sure you don't have a local directory with the same name. " + f"Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory " + f"containing a {cls.config_name} file" + ) + try: + config_dict = cls._dict_from_json_file(config_file, dduf_entries=dduf_entries) + + commit_hash = extract_commit_hash(config_file) + except (json.JSONDecodeError, UnicodeDecodeError): + raise EnvironmentError(f"It looks like the config file at '{config_file}' is not a valid JSON file.") + + if not (return_unused_kwargs or return_commit_hash): + return config_dict + + outputs = (config_dict,) + + if return_unused_kwargs: + outputs += (kwargs,) + + if return_commit_hash: + outputs += (commit_hash,) + + return outputs + + @staticmethod + def _get_init_keys(input_class): + return set(dict(inspect.signature(input_class.__init__).parameters).keys()) + + @classmethod + def extract_init_dict(cls, config_dict, **kwargs): + # Skip keys that were not present in the original config, so default __init__ values were used + used_defaults = config_dict.get("_use_default_values", []) + config_dict = {k: v for k, v in config_dict.items() if k not in used_defaults and k != "_use_default_values"} + + # 0. Copy origin config dict + original_dict = dict(config_dict.items()) + + # 1. Retrieve expected config attributes from __init__ signature + expected_keys = cls._get_init_keys(cls) + expected_keys.remove("self") + # remove general kwargs if present in dict + if "kwargs" in expected_keys: + expected_keys.remove("kwargs") + # remove flax internal keys + if hasattr(cls, "_flax_internal_args"): + for arg in cls._flax_internal_args: + expected_keys.remove(arg) + + # 2. Remove attributes that cannot be expected from expected config attributes + # remove keys to be ignored + if len(cls.ignore_for_config) > 0: + expected_keys = expected_keys - set(cls.ignore_for_config) + + # load diffusers library to import compatible and original scheduler + diffusers_library = importlib.import_module(__name__.split(".")[0]) + + if cls.has_compatibles: + compatible_classes = [c for c in cls._get_compatibles() if not isinstance(c, DummyObject)] + else: + compatible_classes = [] + + expected_keys_comp_cls = set() + for c in compatible_classes: + expected_keys_c = cls._get_init_keys(c) + expected_keys_comp_cls = expected_keys_comp_cls.union(expected_keys_c) + expected_keys_comp_cls = expected_keys_comp_cls - cls._get_init_keys(cls) + config_dict = {k: v for k, v in config_dict.items() if k not in expected_keys_comp_cls} + + # remove attributes from orig class that cannot be expected + orig_cls_name = config_dict.pop("_class_name", cls.__name__) + if ( + isinstance(orig_cls_name, str) + and orig_cls_name != cls.__name__ + and hasattr(diffusers_library, orig_cls_name) + ): + orig_cls = getattr(diffusers_library, orig_cls_name) + unexpected_keys_from_orig = cls._get_init_keys(orig_cls) - expected_keys + config_dict = {k: v for k, v in config_dict.items() if k not in unexpected_keys_from_orig} + elif not isinstance(orig_cls_name, str) and not isinstance(orig_cls_name, (list, tuple)): + raise ValueError( + "Make sure that the `_class_name` is of type string or list of string (for custom pipelines)." + ) + + # remove private attributes + config_dict = {k: v for k, v in config_dict.items() if not k.startswith("_")} + + # remove quantization_config + config_dict = {k: v for k, v in config_dict.items() if k != "quantization_config"} + + # 3. Create keyword arguments that will be passed to __init__ from expected keyword arguments + init_dict = {} + for key in expected_keys: + # if config param is passed to kwarg and is present in config dict + # it should overwrite existing config dict key + if key in kwargs and key in config_dict: + config_dict[key] = kwargs.pop(key) + + if key in kwargs: + # overwrite key + init_dict[key] = kwargs.pop(key) + elif key in config_dict: + # use value from config dict + init_dict[key] = config_dict.pop(key) + + # 4. Give nice warning if unexpected values have been passed + if len(config_dict) > 0: + logger.warning( + f"The config attributes {config_dict} were passed to {cls.__name__}, " + "but are not expected and will be ignored. Please verify your " + f"{cls.config_name} configuration file." + ) + + # 5. Give nice info if config attributes are initialized to default because they have not been passed + passed_keys = set(init_dict.keys()) + if len(expected_keys - passed_keys) > 0: + logger.info( + f"{expected_keys - passed_keys} was not found in config. Values will be initialized to default values." + ) + + # 6. Define unused keyword arguments + unused_kwargs = {**config_dict, **kwargs} + + # 7. Define "hidden" config parameters that were saved for compatible classes + hidden_config_dict = {k: v for k, v in original_dict.items() if k not in init_dict} + + return init_dict, unused_kwargs, hidden_config_dict + + @classmethod + def _dict_from_json_file( + cls, json_file: Union[str, os.PathLike], dduf_entries: Optional[Dict[str, DDUFEntry]] = None + ): + if dduf_entries: + text = dduf_entries[json_file].read_text() + else: + with open(json_file, "r", encoding="utf-8") as reader: + text = reader.read() + return json.loads(text) + + def __repr__(self): + return f"{self.__class__.__name__} {self.to_json_string()}" + + @property + def config(self) -> Dict[str, Any]: + """ + Returns the config of the class as a frozen dictionary + + Returns: + `Dict[str, Any]`: Config of the class. + """ + return self._internal_dict + + def to_json_string(self) -> str: + """ + Serializes the configuration instance to a JSON string. + + Returns: + `str`: + String containing all the attributes that make up the configuration instance in JSON format. + """ + config_dict = self._internal_dict if hasattr(self, "_internal_dict") else {} + config_dict["_class_name"] = self.__class__.__name__ + config_dict["_diffusers_version"] = __version__ + + def to_json_saveable(value): + if isinstance(value, np.ndarray): + value = value.tolist() + elif isinstance(value, Path): + value = value.as_posix() + elif hasattr(value, "to_dict") and callable(value.to_dict): + value = value.to_dict() + elif isinstance(value, list): + value = [to_json_saveable(v) for v in value] + return value + + if "quantization_config" in config_dict: + config_dict["quantization_config"] = ( + config_dict.quantization_config.to_dict() + if not isinstance(config_dict.quantization_config, dict) + else config_dict.quantization_config + ) + + config_dict = {k: to_json_saveable(v) for k, v in config_dict.items()} + # Don't save "_ignore_files" or "_use_default_values" + config_dict.pop("_ignore_files", None) + config_dict.pop("_use_default_values", None) + # pop the `_pre_quantization_dtype` as torch.dtypes are not serializable. + _ = config_dict.pop("_pre_quantization_dtype", None) + + return json.dumps(config_dict, indent=2, sort_keys=True) + "\n" + + def to_json_file(self, json_file_path: Union[str, os.PathLike]): + """ + Save the configuration instance's parameters to a JSON file. + + Args: + json_file_path (`str` or `os.PathLike`): + Path to the JSON file to save a configuration instance's parameters. + """ + with open(json_file_path, "w", encoding="utf-8") as writer: + writer.write(self.to_json_string()) + + @classmethod + def _get_config_file_from_dduf(cls, pretrained_model_name_or_path: str, dduf_entries: Dict[str, DDUFEntry]): + # paths inside a DDUF file must always be "/" + config_file = ( + cls.config_name + if pretrained_model_name_or_path == "" + else "/".join([pretrained_model_name_or_path, cls.config_name]) + ) + if config_file not in dduf_entries: + raise ValueError( + f"We did not manage to find the file {config_file} in the dduf file. We only have the following files {dduf_entries.keys()}" + ) + return config_file + + +def register_to_config(init): + r""" + Decorator to apply on the init of classes inheriting from [`ConfigMixin`] so that all the arguments are + automatically sent to `self.register_for_config`. To ignore a specific argument accepted by the init but that + shouldn't be registered in the config, use the `ignore_for_config` class variable + + Warning: Once decorated, all private arguments (beginning with an underscore) are trashed and not sent to the init! + """ + + @functools.wraps(init) + def inner_init(self, *args, **kwargs): + # Ignore private kwargs in the init. + init_kwargs = {k: v for k, v in kwargs.items() if not k.startswith("_")} + config_init_kwargs = {k: v for k, v in kwargs.items() if k.startswith("_")} + if not isinstance(self, ConfigMixin): + raise RuntimeError( + f"`@register_for_config` was applied to {self.__class__.__name__} init method, but this class does " + "not inherit from `ConfigMixin`." + ) + + ignore = getattr(self, "ignore_for_config", []) + # Get positional arguments aligned with kwargs + new_kwargs = {} + signature = inspect.signature(init) + parameters = { + name: p.default for i, (name, p) in enumerate(signature.parameters.items()) if i > 0 and name not in ignore + } + for arg, name in zip(args, parameters.keys()): + new_kwargs[name] = arg + + # Then add all kwargs + new_kwargs.update( + { + k: init_kwargs.get(k, default) + for k, default in parameters.items() + if k not in ignore and k not in new_kwargs + } + ) + + # Take note of the parameters that were not present in the loaded config + if len(set(new_kwargs.keys()) - set(init_kwargs)) > 0: + new_kwargs["_use_default_values"] = list(set(new_kwargs.keys()) - set(init_kwargs)) + + new_kwargs = {**config_init_kwargs, **new_kwargs} + getattr(self, "register_to_config")(**new_kwargs) + init(self, *args, **init_kwargs) + + return inner_init + + +def flax_register_to_config(cls): + original_init = cls.__init__ + + @functools.wraps(original_init) + def init(self, *args, **kwargs): + if not isinstance(self, ConfigMixin): + raise RuntimeError( + f"`@register_for_config` was applied to {self.__class__.__name__} init method, but this class does " + "not inherit from `ConfigMixin`." + ) + + # Ignore private kwargs in the init. Retrieve all passed attributes + init_kwargs = dict(kwargs.items()) + + # Retrieve default values + fields = dataclasses.fields(self) + default_kwargs = {} + for field in fields: + # ignore flax specific attributes + if field.name in self._flax_internal_args: + continue + if type(field.default) == dataclasses._MISSING_TYPE: + default_kwargs[field.name] = None + else: + default_kwargs[field.name] = getattr(self, field.name) + + # Make sure init_kwargs override default kwargs + new_kwargs = {**default_kwargs, **init_kwargs} + # dtype should be part of `init_kwargs`, but not `new_kwargs` + if "dtype" in new_kwargs: + new_kwargs.pop("dtype") + + # Get positional arguments aligned with kwargs + for i, arg in enumerate(args): + name = fields[i].name + new_kwargs[name] = arg + + # Take note of the parameters that were not present in the loaded config + if len(set(new_kwargs.keys()) - set(init_kwargs)) > 0: + new_kwargs["_use_default_values"] = list(set(new_kwargs.keys()) - set(init_kwargs)) + + getattr(self, "register_to_config")(**new_kwargs) + original_init(self, *args, **kwargs) + + cls.__init__ = init + return cls + + +class LegacyConfigMixin(ConfigMixin): + r""" + A subclass of `ConfigMixin` to resolve class mapping from legacy classes (like `Transformer2DModel`) to more + pipeline-specific classes (like `DiTTransformer2DModel`). + """ + + @classmethod + def from_config(cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_unused_kwargs=False, **kwargs): + # To prevent dependency import problem. + from .models.model_loading_utils import _fetch_remapped_cls_from_config + + # resolve remapping + remapped_class = _fetch_remapped_cls_from_config(config, cls) + + if remapped_class is cls: + return super(LegacyConfigMixin, remapped_class).from_config(config, return_unused_kwargs, **kwargs) + else: + return remapped_class.from_config(config, return_unused_kwargs, **kwargs) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/dependency_versions_check.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/dependency_versions_check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3670b136af45742a64a96b0d68849a2ca0700ed --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/dependency_versions_check.py @@ -0,0 +1,34 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .dependency_versions_table import deps +from .utils.versions import require_version, require_version_core + + +# define which module versions we always want to check at run time +# (usually the ones defined in `install_requires` in setup.py) +# +# order specific notes: +# - tqdm must be checked before tokenizers + +pkgs_to_check_at_runtime = "python requests filelock numpy".split() +for pkg in pkgs_to_check_at_runtime: + if pkg in deps: + require_version_core(deps[pkg]) + else: + raise ValueError(f"can't find {pkg} in {deps.keys()}, check dependency_versions_table.py") + + +def dep_version_check(pkg, hint=None): + require_version(deps[pkg], hint) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/dependency_versions_table.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/dependency_versions_table.py new file mode 100644 index 0000000000000000000000000000000000000000..6e5ac630ab08b34b8567034f7b6d13a63691a120 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/dependency_versions_table.py @@ -0,0 +1,56 @@ +# THIS FILE HAS BEEN AUTOGENERATED. To update: +# 1. modify the `_deps` dict in setup.py +# 2. run `make deps_table_update` +deps = { + "Pillow": "Pillow", + "accelerate": "accelerate>=0.31.0", + "compel": "compel==0.1.8", + "datasets": "datasets", + "filelock": "filelock", + "flax": "flax>=0.4.1", + "hf-doc-builder": "hf-doc-builder>=0.3.0", + "httpx": "httpx<1.0.0", + "huggingface-hub": "huggingface-hub>=0.34.0,<2.0", + "requests-mock": "requests-mock==1.10.0", + "importlib_metadata": "importlib_metadata", + "invisible-watermark": "invisible-watermark>=0.2.0", + "isort": "isort>=5.5.4", + "jax": "jax>=0.4.1", + "jaxlib": "jaxlib>=0.4.1", + "Jinja2": "Jinja2", + "k-diffusion": "k-diffusion==0.0.12", + "torchsde": "torchsde", + "note_seq": "note_seq", + "librosa": "librosa", + "numpy": "numpy", + "parameterized": "parameterized", + "peft": "peft>=0.17.0", + "protobuf": "protobuf>=3.20.3,<4", + "pytest": "pytest", + "pytest-timeout": "pytest-timeout", + "pytest-xdist": "pytest-xdist", + "python": "python>=3.8.0", + "ruff": "ruff==0.9.10", + "safetensors": "safetensors>=0.3.1", + "sentencepiece": "sentencepiece>=0.1.91,!=0.1.92", + "GitPython": "GitPython<3.1.19", + "scipy": "scipy", + "onnx": "onnx", + "optimum_quanto": "optimum_quanto>=0.2.6", + "gguf": "gguf>=0.10.0", + "torchao": "torchao>=0.7.0", + "bitsandbytes": "bitsandbytes>=0.43.3", + "nvidia_modelopt[hf]": "nvidia_modelopt[hf]>=0.33.1", + "regex": "regex!=2019.12.17", + "requests": "requests", + "tensorboard": "tensorboard", + "tiktoken": "tiktoken>=0.7.0", + "torch": "torch>=1.4", + "torchvision": "torchvision", + "transformers": "transformers>=4.41.2", + "urllib3": "urllib3<=2.0.0", + "black": "black", + "phonemizer": "phonemizer", + "opencv-python": "opencv-python", + "timm": "timm", +} diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/README.md b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/README.md new file mode 100644 index 0000000000000000000000000000000000000000..77594b14dbfc3131aa79f09fb1d64231c124ae7b --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/README.md @@ -0,0 +1,5 @@ +# 🧨 Diffusers Experimental + +We are adding experimental code to support novel applications and usages of the Diffusers library. +Currently, the following experiments are supported: +* Reinforcement learning via an implementation of the [Diffuser](https://huggingface.co/papers/2205.09991) model. \ No newline at end of file diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ebc8155403016dfd8ad7fb78d246f9da9098ac50 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/__init__.py @@ -0,0 +1 @@ +from .rl import ValueGuidedRLPipeline diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/rl/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/rl/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..7b338d3173e12d478b6b6d6fd0e50650a0ab5a4c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/rl/__init__.py @@ -0,0 +1 @@ +from .value_guided_sampling import ValueGuidedRLPipeline diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/rl/value_guided_sampling.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/rl/value_guided_sampling.py new file mode 100644 index 0000000000000000000000000000000000000000..c69d308ecc6894edd39557d7f16fc01914e4bd85 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/experimental/rl/value_guided_sampling.py @@ -0,0 +1,153 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import numpy as np +import torch +import tqdm + +from ...models.unets.unet_1d import UNet1DModel +from ...pipelines import DiffusionPipeline +from ...utils.dummy_pt_objects import DDPMScheduler +from ...utils.torch_utils import randn_tensor + + +class ValueGuidedRLPipeline(DiffusionPipeline): + r""" + Pipeline for value-guided sampling from a diffusion model trained to predict sequences of states. + + This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods + implemented for all pipelines (downloading, saving, running on a particular device, etc.). + + Parameters: + value_function ([`UNet1DModel`]): + A specialized UNet for fine-tuning trajectories base on reward. + unet ([`UNet1DModel`]): + UNet architecture to denoise the encoded trajectories. + scheduler ([`SchedulerMixin`]): + A scheduler to be used in combination with `unet` to denoise the encoded trajectories. Default for this + application is [`DDPMScheduler`]. + env (): + An environment following the OpenAI gym API to act in. For now only Hopper has pretrained models. + """ + + def __init__( + self, + value_function: UNet1DModel, + unet: UNet1DModel, + scheduler: DDPMScheduler, + env, + ): + super().__init__() + + self.register_modules(value_function=value_function, unet=unet, scheduler=scheduler, env=env) + + self.data = env.get_dataset() + self.means = {} + for key in self.data.keys(): + try: + self.means[key] = self.data[key].mean() + except: # noqa: E722 + pass + self.stds = {} + for key in self.data.keys(): + try: + self.stds[key] = self.data[key].std() + except: # noqa: E722 + pass + self.state_dim = env.observation_space.shape[0] + self.action_dim = env.action_space.shape[0] + + def normalize(self, x_in, key): + return (x_in - self.means[key]) / self.stds[key] + + def de_normalize(self, x_in, key): + return x_in * self.stds[key] + self.means[key] + + def to_torch(self, x_in): + if isinstance(x_in, dict): + return {k: self.to_torch(v) for k, v in x_in.items()} + elif torch.is_tensor(x_in): + return x_in.to(self.unet.device) + return torch.tensor(x_in, device=self.unet.device) + + def reset_x0(self, x_in, cond, act_dim): + for key, val in cond.items(): + x_in[:, key, act_dim:] = val.clone() + return x_in + + def run_diffusion(self, x, conditions, n_guide_steps, scale): + batch_size = x.shape[0] + y = None + for i in tqdm.tqdm(self.scheduler.timesteps): + # create batch of timesteps to pass into model + timesteps = torch.full((batch_size,), i, device=self.unet.device, dtype=torch.long) + for _ in range(n_guide_steps): + with torch.enable_grad(): + x.requires_grad_() + + # permute to match dimension for pre-trained models + y = self.value_function(x.permute(0, 2, 1), timesteps).sample + grad = torch.autograd.grad([y.sum()], [x])[0] + + posterior_variance = self.scheduler._get_variance(i) + model_std = torch.exp(0.5 * posterior_variance) + grad = model_std * grad + + grad[timesteps < 2] = 0 + x = x.detach() + x = x + scale * grad + x = self.reset_x0(x, conditions, self.action_dim) + + prev_x = self.unet(x.permute(0, 2, 1), timesteps).sample.permute(0, 2, 1) + + # TODO: verify deprecation of this kwarg + x = self.scheduler.step(prev_x, i, x)["prev_sample"] + + # apply conditions to the trajectory (set the initial state) + x = self.reset_x0(x, conditions, self.action_dim) + x = self.to_torch(x) + return x, y + + def __call__(self, obs, batch_size=64, planning_horizon=32, n_guide_steps=2, scale=0.1): + # normalize the observations and create batch dimension + obs = self.normalize(obs, "observations") + obs = obs[None].repeat(batch_size, axis=0) + + conditions = {0: self.to_torch(obs)} + shape = (batch_size, planning_horizon, self.state_dim + self.action_dim) + + # generate initial noise and apply our conditions (to make the trajectories start at current state) + x1 = randn_tensor(shape, device=self.unet.device) + x = self.reset_x0(x1, conditions, self.action_dim) + x = self.to_torch(x) + + # run the diffusion process + x, y = self.run_diffusion(x, conditions, n_guide_steps, scale) + + # sort output trajectories by value + sorted_idx = y.argsort(0, descending=True).squeeze() + sorted_values = x[sorted_idx] + actions = sorted_values[:, :, : self.action_dim] + actions = actions.detach().cpu().numpy() + denorm_actions = self.de_normalize(actions, key="actions") + + # select the action with the highest value + if y is not None: + selected_index = 0 + else: + # if we didn't run value guiding, select a random action + selected_index = np.random.randint(0, batch_size) + + denorm_actions = denorm_actions[selected_index, 0] + return denorm_actions diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4e53c373c4f40b981498d676b186f4c201a0069a --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/__init__.py @@ -0,0 +1,31 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Union + +from ..utils import is_torch_available, logging + + +if is_torch_available(): + from .adaptive_projected_guidance import AdaptiveProjectedGuidance + from .adaptive_projected_guidance_mix import AdaptiveProjectedMixGuidance + from .auto_guidance import AutoGuidance + from .classifier_free_guidance import ClassifierFreeGuidance + from .classifier_free_zero_star_guidance import ClassifierFreeZeroStarGuidance + from .frequency_decoupled_guidance import FrequencyDecoupledGuidance + from .guider_utils import BaseGuidance + from .perturbed_attention_guidance import PerturbedAttentionGuidance + from .skip_layer_guidance import SkipLayerGuidance + from .smoothed_energy_guidance import SmoothedEnergyGuidance + from .tangential_classifier_free_guidance import TangentialClassifierFreeGuidance diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/adaptive_projected_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/adaptive_projected_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..8ec30d02d758cf50c629e9fa947981a09a50ecdd --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/adaptive_projected_guidance.py @@ -0,0 +1,235 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class AdaptiveProjectedGuidance(BaseGuidance): + """ + Adaptive Projected Guidance (APG): https://huggingface.co/papers/2410.02416 + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + adaptive_projected_guidance_momentum (`float`, defaults to `None`): + The momentum parameter for the adaptive projected guidance. Disabled if set to `None`. + adaptive_projected_guidance_rescale (`float`, defaults to `15.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.0`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `1.0`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + adaptive_projected_guidance_momentum: Optional[float] = None, + adaptive_projected_guidance_rescale: float = 15.0, + eta: float = 1.0, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.adaptive_projected_guidance_momentum = adaptive_projected_guidance_momentum + self.adaptive_projected_guidance_rescale = adaptive_projected_guidance_rescale + self.eta = eta + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + self.momentum_buffer = None + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + if self._step == 0: + if self.adaptive_projected_guidance_momentum is not None: + self.momentum_buffer = MomentumBuffer(self.adaptive_projected_guidance_momentum) + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + if self._step == 0: + if self.adaptive_projected_guidance_momentum is not None: + self.momentum_buffer = MomentumBuffer(self.adaptive_projected_guidance_momentum) + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + if not self._is_apg_enabled(): + pred = pred_cond + else: + pred = normalized_guidance( + pred_cond, + pred_uncond, + self.guidance_scale, + self.momentum_buffer, + self.eta, + self.adaptive_projected_guidance_rescale, + self.use_original_formulation, + ) + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_apg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_apg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + +class MomentumBuffer: + def __init__(self, momentum: float): + self.momentum = momentum + self.running_average = 0 + + def update(self, update_value: torch.Tensor): + new_average = self.momentum * self.running_average + self.running_average = update_value + new_average + + def __repr__(self) -> str: + """ + Returns a string representation showing momentum, shape, statistics, and a slice of the running_average. + """ + if isinstance(self.running_average, torch.Tensor): + shape = tuple(self.running_average.shape) + + # Calculate statistics + with torch.no_grad(): + stats = { + "mean": self.running_average.mean().item(), + "std": self.running_average.std().item(), + "min": self.running_average.min().item(), + "max": self.running_average.max().item(), + } + + # Get a slice (max 3 elements per dimension) + slice_indices = tuple(slice(None, min(3, dim)) for dim in shape) + sliced_data = self.running_average[slice_indices] + + # Format the slice for display (convert to float32 for numpy compatibility with bfloat16) + slice_str = str(sliced_data.detach().float().cpu().numpy()) + if len(slice_str) > 200: # Truncate if too long + slice_str = slice_str[:200] + "..." + + stats_str = ", ".join([f"{k}={v:.4f}" for k, v in stats.items()]) + + return ( + f"MomentumBuffer(\n" + f" momentum={self.momentum},\n" + f" shape={shape},\n" + f" stats=[{stats_str}],\n" + f" slice={slice_str}\n" + f")" + ) + else: + return f"MomentumBuffer(momentum={self.momentum}, running_average={self.running_average})" + + +def normalized_guidance( + pred_cond: torch.Tensor, + pred_uncond: torch.Tensor, + guidance_scale: float, + momentum_buffer: Optional[MomentumBuffer] = None, + eta: float = 1.0, + norm_threshold: float = 0.0, + use_original_formulation: bool = False, +): + diff = pred_cond - pred_uncond + dim = [-i for i in range(1, len(diff.shape))] + + if momentum_buffer is not None: + momentum_buffer.update(diff) + diff = momentum_buffer.running_average + + if norm_threshold > 0: + ones = torch.ones_like(diff) + diff_norm = diff.norm(p=2, dim=dim, keepdim=True) + scale_factor = torch.minimum(ones, norm_threshold / diff_norm) + diff = diff * scale_factor + + v0, v1 = diff.double(), pred_cond.double() + v1 = torch.nn.functional.normalize(v1, dim=dim) + v0_parallel = (v0 * v1).sum(dim=dim, keepdim=True) * v1 + v0_orthogonal = v0 - v0_parallel + diff_parallel, diff_orthogonal = v0_parallel.type_as(diff), v0_orthogonal.type_as(diff) + normalized_update = diff_orthogonal + eta * diff_parallel + + pred = pred_cond if use_original_formulation else pred_uncond + pred = pred + guidance_scale * normalized_update + + return pred diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/adaptive_projected_guidance_mix.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/adaptive_projected_guidance_mix.py new file mode 100644 index 0000000000000000000000000000000000000000..bdc97bcf62697381a9af6e9ad54409e4a9fd5a95 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/adaptive_projected_guidance_mix.py @@ -0,0 +1,297 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class AdaptiveProjectedMixGuidance(BaseGuidance): + """ + Adaptive Projected Guidance (APG) https://huggingface.co/papers/2410.02416 combined with Classifier-Free Guidance + (CFG). This guider is used in HunyuanImage2.1 https://github.com/Tencent-Hunyuan/HunyuanImage-2.1 + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + adaptive_projected_guidance_momentum (`float`, defaults to `None`): + The momentum parameter for the adaptive projected guidance. Disabled if set to `None`. + adaptive_projected_guidance_rescale (`float`, defaults to `15.0`): + The rescale factor applied to the noise predictions for adaptive projected guidance. This is used to + improve image quality and fix + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions for classifier-free guidance. This is used to improve + image quality and fix overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample + Steps are Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.0`): + The fraction of the total number of denoising steps after which the classifier-free guidance starts. + stop (`float`, defaults to `1.0`): + The fraction of the total number of denoising steps after which the classifier-free guidance stops. + adaptive_projected_guidance_start_step (`int`, defaults to `5`): + The step at which the adaptive projected guidance starts (before this step, classifier-free guidance is + used, and momentum buffer is updated). + enabled (`bool`, defaults to `True`): + Whether this guidance is enabled. + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 3.5, + guidance_rescale: float = 0.0, + adaptive_projected_guidance_scale: float = 10.0, + adaptive_projected_guidance_momentum: float = -0.5, + adaptive_projected_guidance_rescale: float = 10.0, + eta: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + adaptive_projected_guidance_start_step: int = 5, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.guidance_rescale = guidance_rescale + self.adaptive_projected_guidance_scale = adaptive_projected_guidance_scale + self.adaptive_projected_guidance_momentum = adaptive_projected_guidance_momentum + self.adaptive_projected_guidance_rescale = adaptive_projected_guidance_rescale + self.eta = eta + self.adaptive_projected_guidance_start_step = adaptive_projected_guidance_start_step + self.use_original_formulation = use_original_formulation + self.momentum_buffer = None + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + if self._step == 0: + if self.adaptive_projected_guidance_momentum is not None: + self.momentum_buffer = MomentumBuffer(self.adaptive_projected_guidance_momentum) + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + if self._step == 0: + if self.adaptive_projected_guidance_momentum is not None: + self.momentum_buffer = MomentumBuffer(self.adaptive_projected_guidance_momentum) + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + # no guidance + if not self._is_cfg_enabled(): + pred = pred_cond + + # CFG + update momentum buffer + elif not self._is_apg_enabled(): + if self.momentum_buffer is not None: + update_momentum_buffer(pred_cond, pred_uncond, self.momentum_buffer) + # CFG + update momentum buffer + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + + # APG + elif self._is_apg_enabled(): + pred = normalized_guidance( + pred_cond, + pred_uncond, + self.adaptive_projected_guidance_scale, + self.momentum_buffer, + self.eta, + self.adaptive_projected_guidance_rescale, + self.use_original_formulation, + ) + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_apg_enabled() or self._is_cfg_enabled(): + num_conditions += 1 + return num_conditions + + # Copied from diffusers.guiders.classifier_free_guidance.ClassifierFreeGuidance._is_cfg_enabled + def _is_cfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + def _is_apg_enabled(self) -> bool: + if not self._enabled: + return False + + if not self._is_cfg_enabled(): + return False + + is_within_range = False + if self._step is not None: + is_within_range = self._step > self.adaptive_projected_guidance_start_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.adaptive_projected_guidance_scale, 0.0) + else: + is_close = math.isclose(self.adaptive_projected_guidance_scale, 1.0) + + return is_within_range and not is_close + + def get_state(self): + state = super().get_state() + state["momentum_buffer"] = self.momentum_buffer + state["is_apg_enabled"] = self._is_apg_enabled() + state["is_cfg_enabled"] = self._is_cfg_enabled() + return state + + +# Copied from diffusers.guiders.adaptive_projected_guidance.MomentumBuffer +class MomentumBuffer: + def __init__(self, momentum: float): + self.momentum = momentum + self.running_average = 0 + + def update(self, update_value: torch.Tensor): + new_average = self.momentum * self.running_average + self.running_average = update_value + new_average + + def __repr__(self) -> str: + """ + Returns a string representation showing momentum, shape, statistics, and a slice of the running_average. + """ + if isinstance(self.running_average, torch.Tensor): + shape = tuple(self.running_average.shape) + + # Calculate statistics + with torch.no_grad(): + stats = { + "mean": self.running_average.mean().item(), + "std": self.running_average.std().item(), + "min": self.running_average.min().item(), + "max": self.running_average.max().item(), + } + + # Get a slice (max 3 elements per dimension) + slice_indices = tuple(slice(None, min(3, dim)) for dim in shape) + sliced_data = self.running_average[slice_indices] + + # Format the slice for display (convert to float32 for numpy compatibility with bfloat16) + slice_str = str(sliced_data.detach().float().cpu().numpy()) + if len(slice_str) > 200: # Truncate if too long + slice_str = slice_str[:200] + "..." + + stats_str = ", ".join([f"{k}={v:.4f}" for k, v in stats.items()]) + + return ( + f"MomentumBuffer(\n" + f" momentum={self.momentum},\n" + f" shape={shape},\n" + f" stats=[{stats_str}],\n" + f" slice={slice_str}\n" + f")" + ) + else: + return f"MomentumBuffer(momentum={self.momentum}, running_average={self.running_average})" + + +def update_momentum_buffer( + pred_cond: torch.Tensor, + pred_uncond: torch.Tensor, + momentum_buffer: Optional[MomentumBuffer] = None, +): + diff = pred_cond - pred_uncond + if momentum_buffer is not None: + momentum_buffer.update(diff) + + +def normalized_guidance( + pred_cond: torch.Tensor, + pred_uncond: torch.Tensor, + guidance_scale: float, + momentum_buffer: Optional[MomentumBuffer] = None, + eta: float = 1.0, + norm_threshold: float = 0.0, + use_original_formulation: bool = False, +): + if momentum_buffer is not None: + update_momentum_buffer(pred_cond, pred_uncond, momentum_buffer) + diff = momentum_buffer.running_average + else: + diff = pred_cond - pred_uncond + + dim = [-i for i in range(1, len(diff.shape))] + + if norm_threshold > 0: + ones = torch.ones_like(diff) + diff_norm = diff.norm(p=2, dim=dim, keepdim=True) + scale_factor = torch.minimum(ones, norm_threshold / diff_norm) + diff = diff * scale_factor + + v0, v1 = diff.double(), pred_cond.double() + v1 = torch.nn.functional.normalize(v1, dim=dim) + v0_parallel = (v0 * v1).sum(dim=dim, keepdim=True) * v1 + v0_orthogonal = v0 - v0_parallel + diff_parallel, diff_orthogonal = v0_parallel.type_as(diff), v0_orthogonal.type_as(diff) + normalized_update = diff_orthogonal + eta * diff_parallel + + pred = pred_cond if use_original_formulation else pred_uncond + pred = pred + guidance_scale * normalized_update + + return pred diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/auto_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/auto_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..b7f62e2f4a6ee56e87a3d3b9ac4da22e4f2250df --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/auto_guidance.py @@ -0,0 +1,196 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from ..hooks import HookRegistry, LayerSkipConfig +from ..hooks.layer_skip import _apply_layer_skip_hook +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class AutoGuidance(BaseGuidance): + """ + AutoGuidance: https://huggingface.co/papers/2406.02507 + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + auto_guidance_layers (`int` or `List[int]`, *optional*): + The layer indices to apply skip layer guidance to. Can be a single integer or a list of integers. If not + provided, `skip_layer_config` must be provided. + auto_guidance_config (`LayerSkipConfig` or `List[LayerSkipConfig]`, *optional*): + The configuration for the skip layer guidance. Can be a single `LayerSkipConfig` or a list of + `LayerSkipConfig`. If not provided, `skip_layer_guidance_layers` must be provided. + dropout (`float`, *optional*): + The dropout probability for autoguidance on the enabled skip layers (either with `auto_guidance_layers` or + `auto_guidance_config`). If not provided, the dropout probability will be set to 1.0. + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.0`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `1.0`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + auto_guidance_layers: Optional[Union[int, List[int]]] = None, + auto_guidance_config: Union[LayerSkipConfig, List[LayerSkipConfig], Dict[str, Any]] = None, + dropout: Optional[float] = None, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.auto_guidance_layers = auto_guidance_layers + self.auto_guidance_config = auto_guidance_config + self.dropout = dropout + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + is_layer_or_config_provided = auto_guidance_layers is not None or auto_guidance_config is not None + is_layer_and_config_provided = auto_guidance_layers is not None and auto_guidance_config is not None + if not is_layer_or_config_provided: + raise ValueError( + "Either `auto_guidance_layers` or `auto_guidance_config` must be provided to enable AutoGuidance." + ) + if is_layer_and_config_provided: + raise ValueError("Only one of `auto_guidance_layers` or `auto_guidance_config` can be provided.") + if auto_guidance_config is None and dropout is None: + raise ValueError("`dropout` must be provided if `auto_guidance_layers` is provided.") + + if auto_guidance_layers is not None: + if isinstance(auto_guidance_layers, int): + auto_guidance_layers = [auto_guidance_layers] + if not isinstance(auto_guidance_layers, list): + raise ValueError( + f"Expected `auto_guidance_layers` to be an int or a list of ints, but got {type(auto_guidance_layers)}." + ) + auto_guidance_config = [ + LayerSkipConfig(layer, fqn="auto", dropout=dropout) for layer in auto_guidance_layers + ] + + if isinstance(auto_guidance_config, dict): + auto_guidance_config = LayerSkipConfig.from_dict(auto_guidance_config) + + if isinstance(auto_guidance_config, LayerSkipConfig): + auto_guidance_config = [auto_guidance_config] + + if not isinstance(auto_guidance_config, list): + raise ValueError( + f"Expected `auto_guidance_config` to be a LayerSkipConfig or a list of LayerSkipConfig, but got {type(auto_guidance_config)}." + ) + elif isinstance(next(iter(auto_guidance_config), None), dict): + auto_guidance_config = [LayerSkipConfig.from_dict(config) for config in auto_guidance_config] + + self.auto_guidance_config = auto_guidance_config + self._auto_guidance_hook_names = [f"AutoGuidance_{i}" for i in range(len(self.auto_guidance_config))] + + def prepare_models(self, denoiser: torch.nn.Module) -> None: + self._count_prepared += 1 + if self._is_ag_enabled() and self.is_unconditional: + for name, config in zip(self._auto_guidance_hook_names, self.auto_guidance_config): + _apply_layer_skip_hook(denoiser, config, name=name) + + def cleanup_models(self, denoiser: torch.nn.Module) -> None: + if self._is_ag_enabled() and self.is_unconditional: + for name in self._auto_guidance_hook_names: + registry = HookRegistry.check_if_exists_or_initialize(denoiser) + registry.remove_hook(name, recurse=True) + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + if not self._is_ag_enabled(): + pred = pred_cond + else: + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_ag_enabled(): + num_conditions += 1 + return num_conditions + + def _is_ag_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/classifier_free_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/classifier_free_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..5e55d4d869c190f83270eb95a5f9223cca0bb094 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/classifier_free_guidance.py @@ -0,0 +1,154 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class ClassifierFreeGuidance(BaseGuidance): + """ + Implements Classifier-Free Guidance (CFG) for diffusion models. + + Reference: https://huggingface.co/papers/2207.12598 + + CFG improves generation quality and prompt adherence by jointly training models on both conditional and + unconditional data, then combining predictions during inference. This allows trading off between quality (high + guidance) and diversity (low guidance). + + **Two CFG Formulations:** + + 1. **Original formulation** (from paper): + ``` + x_pred = x_cond + guidance_scale * (x_cond - x_uncond) + ``` + Moves conditional predictions further from unconditional ones. + + 2. **Diffusers-native formulation** (default, from Imagen paper): + ``` + x_pred = x_uncond + guidance_scale * (x_cond - x_uncond) + ``` + Moves unconditional predictions toward conditional ones, effectively suppressing negative features (e.g., "bad + quality", "watermarks"). Equivalent in theory but more intuitive. + + Use `use_original_formulation=True` to switch to the original formulation. + + Args: + guidance_scale (`float`, defaults to `7.5`): + CFG scale applied by this guider during post-processing. Higher values = stronger prompt conditioning but + may reduce quality. Typical range: 1.0-20.0. + guidance_rescale (`float`, defaults to `0.0`): + Rescaling factor to prevent overexposure from high guidance scales. Based on [Common Diffusion Noise + Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891). Range: 0.0 (no rescaling) + to 1.0 (full rescaling). + use_original_formulation (`bool`, defaults to `False`): + If `True`, uses the original CFG formulation from the paper. If `False` (default), uses the + diffusers-native formulation from the Imagen paper. + start (`float`, defaults to `0.0`): + Fraction of denoising steps (0.0-1.0) after which CFG starts. Use > 0.0 to disable CFG in early denoising + steps. + stop (`float`, defaults to `1.0`): + Fraction of denoising steps (0.0-1.0) after which CFG stops. Use < 1.0 to disable CFG in late denoising + steps. + enabled (`bool`, defaults to `True`): + Whether CFG is enabled. Set to `False` to disable CFG entirely (uses only conditional predictions). + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + if not self._is_cfg_enabled(): + pred = pred_cond + else: + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_cfg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_cfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/classifier_free_zero_star_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/classifier_free_zero_star_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..23b492e51b023f21e1d2d01db3151ca354ff661c --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/classifier_free_zero_star_guidance.py @@ -0,0 +1,162 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class ClassifierFreeZeroStarGuidance(BaseGuidance): + """ + Classifier-free Zero* (CFG-Zero*): https://huggingface.co/papers/2503.18886 + + This is an implementation of the Classifier-Free Zero* guidance technique, which is a variant of classifier-free + guidance. It proposes zero initialization of the noise predictions for the first few steps of the diffusion + process, and also introduces an optimal rescaling factor for the noise predictions, which can help in improving the + quality of generated images. + + The authors of the paper suggest setting zero initialization in the first 4% of the inference steps. + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + zero_init_steps (`int`, defaults to `1`): + The number of inference steps for which the noise predictions are zeroed out (see Section 4.2). + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.01`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `0.2`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + zero_init_steps: int = 1, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.zero_init_steps = zero_init_steps + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + # YiYi Notes: add default behavior for self._enabled == False + if not self._enabled: + pred = pred_cond + + elif self._step < self.zero_init_steps: + pred = torch.zeros_like(pred_cond) + elif not self._is_cfg_enabled(): + pred = pred_cond + else: + pred_cond_flat = pred_cond.flatten(1) + pred_uncond_flat = pred_uncond.flatten(1) + alpha = cfg_zero_star_scale(pred_cond_flat, pred_uncond_flat) + alpha = alpha.view(-1, *(1,) * (len(pred_cond.shape) - 1)) + pred_uncond = pred_uncond * alpha + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_cfg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_cfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + +def cfg_zero_star_scale(cond: torch.Tensor, uncond: torch.Tensor, eps: float = 1e-8) -> torch.Tensor: + cond_dtype = cond.dtype + cond = cond.float() + uncond = uncond.float() + dot_product = torch.sum(cond * uncond, dim=1, keepdim=True) + squared_norm = torch.sum(uncond**2, dim=1, keepdim=True) + eps + # st_star = v_cond^T * v_uncond / ||v_uncond||^2 + scale = dot_product / squared_norm + return scale.to(dtype=cond_dtype) diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/frequency_decoupled_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/frequency_decoupled_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..4ec6e2d36da93a0b52304d16c9417be5e61e081d --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/frequency_decoupled_guidance.py @@ -0,0 +1,333 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from ..utils import is_kornia_available +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +_CAN_USE_KORNIA = is_kornia_available() + + +if _CAN_USE_KORNIA: + from kornia.geometry import pyrup as upsample_and_blur_func + from kornia.geometry.transform import build_laplacian_pyramid as build_laplacian_pyramid_func +else: + upsample_and_blur_func = None + build_laplacian_pyramid_func = None + + +def project(v0: torch.Tensor, v1: torch.Tensor, upcast_to_double: bool = True) -> Tuple[torch.Tensor, torch.Tensor]: + """ + Project vector v0 onto vector v1, returning the parallel and orthogonal components of v0. Implementation from paper + (Algorithm 2). + """ + # v0 shape: [B, ...] + # v1 shape: [B, ...] + # Assume first dim is a batch dim and all other dims are channel or "spatial" dims + all_dims_but_first = list(range(1, len(v0.shape))) + if upcast_to_double: + dtype = v0.dtype + v0, v1 = v0.double(), v1.double() + v1 = torch.nn.functional.normalize(v1, dim=all_dims_but_first) + v0_parallel = (v0 * v1).sum(dim=all_dims_but_first, keepdim=True) * v1 + v0_orthogonal = v0 - v0_parallel + if upcast_to_double: + v0_parallel = v0_parallel.to(dtype) + v0_orthogonal = v0_orthogonal.to(dtype) + return v0_parallel, v0_orthogonal + + +def build_image_from_pyramid(pyramid: List[torch.Tensor]) -> torch.Tensor: + """ + Recovers the data space latents from the Laplacian pyramid frequency space. Implementation from the paper + (Algorithm 2). + """ + # pyramid shapes: [[B, C, H, W], [B, C, H/2, W/2], ...] + img = pyramid[-1] + for i in range(len(pyramid) - 2, -1, -1): + img = upsample_and_blur_func(img) + pyramid[i] + return img + + +class FrequencyDecoupledGuidance(BaseGuidance): + """ + Frequency-Decoupled Guidance (FDG): https://huggingface.co/papers/2506.19713 + + FDG is a technique similar to (and based on) classifier-free guidance (CFG) which is used to improve generation + quality and condition-following in diffusion models. Like CFG, during training we jointly train the model on both + conditional and unconditional data, and use a combination of the two during inference. (If you want more details on + how CFG works, you can check out the CFG guider.) + + FDG differs from CFG in that the normal CFG prediction is instead decoupled into low- and high-frequency components + using a frequency transform (such as a Laplacian pyramid). The CFG update is then performed in frequency space + separately for the low- and high-frequency components with different guidance scales. Finally, the inverse + frequency transform is used to map the CFG frequency predictions back to data space (e.g. pixel space for images) + to form the final FDG prediction. + + For images, the FDG authors found that using low guidance scales for the low-frequency components retains sample + diversity and realistic color composition, while using high guidance scales for high-frequency components enhances + sample quality (such as better visual details). Therefore, they recommend using low guidance scales (low w_low) for + the low-frequency components and high guidance scales (high w_high) for the high-frequency components. As an + example, they suggest w_low = 5.0 and w_high = 10.0 for Stable Diffusion XL (see Table 8 in the paper). + + As with CFG, Diffusers implements the scaling and shifting on the unconditional prediction based on the [Imagen + paper](https://huggingface.co/papers/2205.11487), which is equivalent to what the original CFG paper proposed in + theory. [x_pred = x_uncond + scale * (x_cond - x_uncond)] + + The `use_original_formulation` argument can be set to `True` to use the original CFG formulation mentioned in the + paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. + + Args: + guidance_scales (`List[float]`, defaults to `[10.0, 5.0]`): + The scale parameter for frequency-decoupled guidance for each frequency component, listed from highest + frequency level to lowest. Higher values result in stronger conditioning on the text prompt, while lower + values allow for more freedom in generation. Higher values may lead to saturation and deterioration of + image quality. The FDG authors recommend using higher guidance scales for higher frequency components and + lower guidance scales for lower frequency components (so `guidance_scales` should typically be sorted in + descending order). + guidance_rescale (`float` or `List[float]`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). If a list is supplied, it should be the same length as + `guidance_scales`. + parallel_weights (`float` or `List[float]`, *optional*): + Optional weights for the parallel component of each frequency component of the projected CFG shift. If not + set, the weights will default to `1.0` for all components, which corresponds to using the normal CFG shift + (that is, equal weights for the parallel and orthogonal components). If set, a value in `[0, 1]` is + recommended. If a list is supplied, it should be the same length as `guidance_scales`. + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float` or `List[float]`, defaults to `0.0`): + The fraction of the total number of denoising steps after which guidance starts. If a list is supplied, it + should be the same length as `guidance_scales`. + stop (`float` or `List[float]`, defaults to `1.0`): + The fraction of the total number of denoising steps after which guidance stops. If a list is supplied, it + should be the same length as `guidance_scales`. + guidance_rescale_space (`str`, defaults to `"data"`): + Whether to performance guidance rescaling in `"data"` space (after the full FDG update in data space) or in + `"freq"` space (right after the CFG update, for each freq level). Note that frequency space rescaling is + speculative and may not produce expected results. If `"data"` is set, the first `guidance_rescale` value + will be used; otherwise, per-frequency-level guidance rescale values will be used if available. + upcast_to_double (`bool`, defaults to `True`): + Whether to upcast certain operations, such as the projection operation when using `parallel_weights`, to + float64 when performing guidance. This may result in better performance at the cost of increased runtime. + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scales: Union[List[float], Tuple[float]] = [10.0, 5.0], + guidance_rescale: Union[float, List[float], Tuple[float]] = 0.0, + parallel_weights: Optional[Union[float, List[float], Tuple[float]]] = None, + use_original_formulation: bool = False, + start: Union[float, List[float], Tuple[float]] = 0.0, + stop: Union[float, List[float], Tuple[float]] = 1.0, + guidance_rescale_space: str = "data", + upcast_to_double: bool = True, + enabled: bool = True, + ): + if not _CAN_USE_KORNIA: + raise ImportError( + "The `FrequencyDecoupledGuidance` guider cannot be instantiated because the `kornia` library on which " + "it depends is not available in the current environment. You can install `kornia` with `pip install " + "kornia`." + ) + + # Set start to earliest start for any freq component and stop to latest stop for any freq component + min_start = start if isinstance(start, float) else min(start) + max_stop = stop if isinstance(stop, float) else max(stop) + super().__init__(min_start, max_stop, enabled) + + self.guidance_scales = guidance_scales + self.levels = len(guidance_scales) + + if isinstance(guidance_rescale, float): + self.guidance_rescale = [guidance_rescale] * self.levels + elif len(guidance_rescale) == self.levels: + self.guidance_rescale = guidance_rescale + else: + raise ValueError( + f"`guidance_rescale` has length {len(guidance_rescale)} but should have the same length as " + f"`guidance_scales` ({len(self.guidance_scales)})" + ) + # Whether to perform guidance rescaling in frequency space (right after the CFG update) or data space (after + # transforming from frequency space back to data space) + if guidance_rescale_space not in ["data", "freq"]: + raise ValueError( + f"Guidance rescale space is {guidance_rescale_space} but must be one of `data` or `freq`." + ) + self.guidance_rescale_space = guidance_rescale_space + + if parallel_weights is None: + # Use normal CFG shift (equal weights for parallel and orthogonal components) + self.parallel_weights = [1.0] * self.levels + elif isinstance(parallel_weights, float): + self.parallel_weights = [parallel_weights] * self.levels + elif len(parallel_weights) == self.levels: + self.parallel_weights = parallel_weights + else: + raise ValueError( + f"`parallel_weights` has length {len(parallel_weights)} but should have the same length as " + f"`guidance_scales` ({len(self.guidance_scales)})" + ) + + self.use_original_formulation = use_original_formulation + self.upcast_to_double = upcast_to_double + + if isinstance(start, float): + self.guidance_start = [start] * self.levels + elif len(start) == self.levels: + self.guidance_start = start + else: + raise ValueError( + f"`start` has length {len(start)} but should have the same length as `guidance_scales` " + f"({len(self.guidance_scales)})" + ) + if isinstance(stop, float): + self.guidance_stop = [stop] * self.levels + elif len(stop) == self.levels: + self.guidance_stop = stop + else: + raise ValueError( + f"`stop` has length {len(stop)} but should have the same length as `guidance_scales` " + f"({len(self.guidance_scales)})" + ) + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + if not self._is_fdg_enabled(): + pred = pred_cond + else: + # Apply the frequency transform (e.g. Laplacian pyramid) to the conditional and unconditional predictions. + pred_cond_pyramid = build_laplacian_pyramid_func(pred_cond, self.levels) + pred_uncond_pyramid = build_laplacian_pyramid_func(pred_uncond, self.levels) + + # From high frequencies to low frequencies, following the paper implementation + pred_guided_pyramid = [] + parameters = zip(self.guidance_scales, self.parallel_weights, self.guidance_rescale) + for level, (guidance_scale, parallel_weight, guidance_rescale) in enumerate(parameters): + if self._is_fdg_enabled_for_level(level): + # Get the cond/uncond preds (in freq space) at the current frequency level + pred_cond_freq = pred_cond_pyramid[level] + pred_uncond_freq = pred_uncond_pyramid[level] + + shift = pred_cond_freq - pred_uncond_freq + + # Apply parallel weights, if used (1.0 corresponds to using the normal CFG shift) + if not math.isclose(parallel_weight, 1.0): + shift_parallel, shift_orthogonal = project(shift, pred_cond_freq, self.upcast_to_double) + shift = parallel_weight * shift_parallel + shift_orthogonal + + # Apply CFG update for the current frequency level + pred = pred_cond_freq if self.use_original_formulation else pred_uncond_freq + pred = pred + guidance_scale * shift + + if self.guidance_rescale_space == "freq" and guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond_freq, guidance_rescale) + + # Add the current FDG guided level to the FDG prediction pyramid + pred_guided_pyramid.append(pred) + else: + # Add the current pred_cond_pyramid level as the "non-FDG" prediction + pred_guided_pyramid.append(pred_cond_freq) + + # Convert from frequency space back to data (e.g. pixel) space by applying inverse freq transform + pred = build_image_from_pyramid(pred_guided_pyramid) + + # If rescaling in data space, use the first elem of self.guidance_rescale as the "global" rescale value + # across all freq levels + if self.guidance_rescale_space == "data" and self.guidance_rescale[0] > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale[0]) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_fdg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_fdg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = all(math.isclose(guidance_scale, 0.0) for guidance_scale in self.guidance_scales) + else: + is_close = all(math.isclose(guidance_scale, 1.0) for guidance_scale in self.guidance_scales) + + return is_within_range and not is_close + + def _is_fdg_enabled_for_level(self, level: int) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self.guidance_start[level] * self._num_inference_steps) + skip_stop_step = int(self.guidance_stop[level] * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scales[level], 0.0) + else: + is_close = math.isclose(self.guidance_scales[level], 1.0) + + return is_within_range and not is_close diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/guider_utils.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/guider_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6c328328fc3bab961f32f1418116049eb09f3c61 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/guider_utils.py @@ -0,0 +1,394 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union + +import torch +from huggingface_hub.utils import validate_hf_hub_args +from typing_extensions import Self + +from ..configuration_utils import ConfigMixin +from ..utils import BaseOutput, PushToHubMixin, get_logger + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +GUIDER_CONFIG_NAME = "guider_config.json" + + +logger = get_logger(__name__) # pylint: disable=invalid-name + + +class BaseGuidance(ConfigMixin, PushToHubMixin): + r"""Base class providing the skeleton for implementing guidance techniques.""" + + config_name = GUIDER_CONFIG_NAME + _input_predictions = None + _identifier_key = "__guidance_identifier__" + + def __init__(self, start: float = 0.0, stop: float = 1.0, enabled: bool = True): + logger.warning( + "Guiders are currently an experimental feature under active development. The API is subject to breaking changes in future releases." + ) + + self._start = start + self._stop = stop + self._step: int = None + self._num_inference_steps: int = None + self._timestep: torch.LongTensor = None + self._count_prepared = 0 + self._input_fields: Dict[str, Union[str, Tuple[str, str]]] = None + self._enabled = enabled + + if not (0.0 <= start < 1.0): + raise ValueError(f"Expected `start` to be between 0.0 and 1.0, but got {start}.") + if not (start <= stop <= 1.0): + raise ValueError(f"Expected `stop` to be between {start} and 1.0, but got {stop}.") + + if self._input_predictions is None or not isinstance(self._input_predictions, list): + raise ValueError( + "`_input_predictions` must be a list of required prediction names for the guidance technique." + ) + + def new(self, **kwargs): + """ + Creates a copy of this guider instance, optionally with modified configuration parameters. + + Args: + **kwargs: Configuration parameters to override in the new instance. If no kwargs are provided, + returns an exact copy with the same configuration. + + Returns: + A new guider instance with the same (or updated) configuration. + + Example: + ```python + # Create a CFG guider + guider = ClassifierFreeGuidance(guidance_scale=3.5) + + # Create an exact copy + same_guider = guider.new() + + # Create a copy with different start step, keeping other config the same + new_guider = guider.new(guidance_scale=5) + ``` + """ + return self.__class__.from_config(self.config, **kwargs) + + def disable(self): + self._enabled = False + + def enable(self): + self._enabled = True + + def set_state(self, step: int, num_inference_steps: int, timestep: torch.LongTensor) -> None: + self._step = step + self._num_inference_steps = num_inference_steps + self._timestep = timestep + self._count_prepared = 0 + + def get_state(self) -> Dict[str, Any]: + """ + Returns the current state of the guidance technique as a dictionary. The state variables will be included in + the __repr__ method. Returns: + `Dict[str, Any]`: A dictionary containing the current state variables including: + - step: Current inference step + - num_inference_steps: Total number of inference steps + - timestep: Current timestep tensor + - count_prepared: Number of times prepare_models has been called + - enabled: Whether the guidance is enabled + - num_conditions: Number of conditions + """ + state = { + "step": self._step, + "num_inference_steps": self._num_inference_steps, + "timestep": self._timestep, + "count_prepared": self._count_prepared, + "enabled": self._enabled, + "num_conditions": self.num_conditions, + } + return state + + def __repr__(self) -> str: + """ + Returns a string representation of the guidance object including both config and current state. + """ + # Get ConfigMixin's __repr__ + str_repr = super().__repr__() + + # Get current state + state = self.get_state() + + # Format each state variable on its own line with indentation + state_lines = [] + for k, v in state.items(): + # Convert value to string and handle multi-line values + v_str = str(v) + if "\n" in v_str: + # For multi-line values (like MomentumBuffer), indent subsequent lines + v_lines = v_str.split("\n") + v_str = v_lines[0] + "\n" + "\n".join([" " + line for line in v_lines[1:]]) + state_lines.append(f" {k}: {v_str}") + + state_str = "\n".join(state_lines) + + return f"{str_repr}\nState:\n{state_str}" + + def prepare_models(self, denoiser: torch.nn.Module) -> None: + """ + Prepares the models for the guidance technique on a given batch of data. This method should be overridden in + subclasses to implement specific model preparation logic. + """ + self._count_prepared += 1 + + def cleanup_models(self, denoiser: torch.nn.Module) -> None: + """ + Cleans up the models for the guidance technique after a given batch of data. This method should be overridden + in subclasses to implement specific model cleanup logic. It is useful for removing any hooks or other stateful + modifications made during `prepare_models`. + """ + pass + + def prepare_inputs(self, data: "BlockState") -> List["BlockState"]: + raise NotImplementedError("BaseGuidance::prepare_inputs must be implemented in subclasses.") + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + raise NotImplementedError("BaseGuidance::prepare_inputs_from_block_state must be implemented in subclasses.") + + def __call__(self, data: List["BlockState"]) -> Any: + if not all(hasattr(d, "noise_pred") for d in data): + raise ValueError("Expected all data to have `noise_pred` attribute.") + if len(data) != self.num_conditions: + raise ValueError( + f"Expected {self.num_conditions} data items, but got {len(data)}. Please check the input data." + ) + forward_inputs = {getattr(d, self._identifier_key): d.noise_pred for d in data} + return self.forward(**forward_inputs) + + def forward(self, *args, **kwargs) -> Any: + raise NotImplementedError("BaseGuidance::forward must be implemented in subclasses.") + + @property + def is_conditional(self) -> bool: + raise NotImplementedError("BaseGuidance::is_conditional must be implemented in subclasses.") + + @property + def is_unconditional(self) -> bool: + return not self.is_conditional + + @property + def num_conditions(self) -> int: + raise NotImplementedError("BaseGuidance::num_conditions must be implemented in subclasses.") + + @classmethod + def _prepare_batch( + cls, + data: Dict[str, Tuple[torch.Tensor, torch.Tensor]], + tuple_index: int, + identifier: str, + ) -> "BlockState": + """ + Prepares a batch of data for the guidance technique. This method is used in the `prepare_inputs` method of the + `BaseGuidance` class. It prepares the batch based on the provided tuple index. + + Args: + input_fields (`Dict[str, Union[str, Tuple[str, str]]]`): + A dictionary where the keys are the names of the fields that will be used to store the data once it is + prepared with `prepare_inputs`. The values can be either a string or a tuple of length 2, which is used + to look up the required data provided for preparation. If a string is provided, it will be used as the + conditional data (or unconditional if used with a guidance method that requires it). If a tuple of + length 2 is provided, the first element must be the conditional data identifier and the second element + must be the unconditional data identifier or None. + data (`BlockState`): + The input data to be prepared. + tuple_index (`int`): + The index to use when accessing input fields that are tuples. + + Returns: + `BlockState`: The prepared batch of data. + """ + from ..modular_pipelines.modular_pipeline import BlockState + + data_batch = {} + for key, value in data.items(): + try: + if isinstance(value, torch.Tensor): + data_batch[key] = value + elif isinstance(value, tuple): + data_batch[key] = value[tuple_index] + else: + raise ValueError(f"Invalid value type: {type(value)}") + except ValueError: + logger.debug(f"`data` does not have attribute(s) {value}, skipping.") + data_batch[cls._identifier_key] = identifier + return BlockState(**data_batch) + + @classmethod + def _prepare_batch_from_block_state( + cls, + input_fields: Dict[str, Union[str, Tuple[str, str]]], + data: "BlockState", + tuple_index: int, + identifier: str, + ) -> "BlockState": + """ + Prepares a batch of data for the guidance technique. This method is used in the `prepare_inputs` method of the + `BaseGuidance` class. It prepares the batch based on the provided tuple index. + + Args: + input_fields (`Dict[str, Union[str, Tuple[str, str]]]`): + A dictionary where the keys are the names of the fields that will be used to store the data once it is + prepared with `prepare_inputs`. The values can be either a string or a tuple of length 2, which is used + to look up the required data provided for preparation. If a string is provided, it will be used as the + conditional data (or unconditional if used with a guidance method that requires it). If a tuple of + length 2 is provided, the first element must be the conditional data identifier and the second element + must be the unconditional data identifier or None. + data (`BlockState`): + The input data to be prepared. + tuple_index (`int`): + The index to use when accessing input fields that are tuples. + + Returns: + `BlockState`: The prepared batch of data. + """ + from ..modular_pipelines.modular_pipeline import BlockState + + data_batch = {} + for key, value in input_fields.items(): + try: + if isinstance(value, str): + data_batch[key] = getattr(data, value) + elif isinstance(value, tuple): + data_batch[key] = getattr(data, value[tuple_index]) + else: + # We've already checked that value is a string or a tuple of strings with length 2 + pass + except AttributeError: + logger.debug(f"`data` does not have attribute(s) {value}, skipping.") + data_batch[cls._identifier_key] = identifier + return BlockState(**data_batch) + + @classmethod + @validate_hf_hub_args + def from_pretrained( + cls, + pretrained_model_name_or_path: Optional[Union[str, os.PathLike]] = None, + subfolder: Optional[str] = None, + return_unused_kwargs=False, + **kwargs, + ) -> Self: + r""" + Instantiate a guider from a pre-defined JSON configuration file in a local directory or Hub repository. + + Parameters: + pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*): + Can be either: + + - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on + the Hub. + - A path to a *directory* (for example `./my_model_directory`) containing the guider configuration + saved with [`~BaseGuidance.save_pretrained`]. + subfolder (`str`, *optional*): + The subfolder location of a model file within a larger model repository on the Hub or locally. + return_unused_kwargs (`bool`, *optional*, defaults to `False`): + Whether kwargs that are not consumed by the Python class should be returned or not. + cache_dir (`Union[str, os.PathLike]`, *optional*): + Path to a directory where a downloaded pretrained model configuration is cached if the standard cache + is not used. + force_download (`bool`, *optional*, defaults to `False`): + Whether or not to force the (re-)download of the model weights and configuration files, overriding the + cached versions if they exist. + + proxies (`Dict[str, str]`, *optional*): + A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', + 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. + output_loading_info(`bool`, *optional*, defaults to `False`): + Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. + local_files_only(`bool`, *optional*, defaults to `False`): + Whether to only load local model weights and configuration files or not. If set to `True`, the model + won't be downloaded from the Hub. + token (`str` or *bool*, *optional*): + The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from + `diffusers-cli login` (stored in `~/.huggingface`) is used. + revision (`str`, *optional*, defaults to `"main"`): + The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier + allowed by Git. + + > [!TIP] > To use private or [gated models](https://huggingface.co/docs/hub/models-gated#gated-models), log-in + with `hf > auth login`. You can also activate the special > + ["offline-mode"](https://huggingface.co/diffusers/installation.html#offline-mode) to use this method in a > + firewalled environment. + + """ + config, kwargs, commit_hash = cls.load_config( + pretrained_model_name_or_path=pretrained_model_name_or_path, + subfolder=subfolder, + return_unused_kwargs=True, + return_commit_hash=True, + **kwargs, + ) + return cls.from_config(config, return_unused_kwargs=return_unused_kwargs, **kwargs) + + def save_pretrained(self, save_directory: Union[str, os.PathLike], push_to_hub: bool = False, **kwargs): + """ + Save a guider configuration object to a directory so that it can be reloaded using the + [`~BaseGuidance.from_pretrained`] class method. + + Args: + save_directory (`str` or `os.PathLike`): + Directory where the configuration JSON file will be saved (will be created if it does not exist). + push_to_hub (`bool`, *optional*, defaults to `False`): + Whether or not to push your model to the Hugging Face Hub after saving it. You can specify the + repository you want to push to with `repo_id` (will default to the name of `save_directory` in your + namespace). + kwargs (`Dict[str, Any]`, *optional*): + Additional keyword arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method. + """ + self.save_config(save_directory=save_directory, push_to_hub=push_to_hub, **kwargs) + + +class GuiderOutput(BaseOutput): + pred: torch.Tensor + pred_cond: Optional[torch.Tensor] + pred_uncond: Optional[torch.Tensor] + + +def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0): + r""" + Rescales `noise_cfg` tensor based on `guidance_rescale` to improve image quality and fix overexposure. Based on + Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + + Args: + noise_cfg (`torch.Tensor`): + The predicted noise tensor for the guided diffusion process. + noise_pred_text (`torch.Tensor`): + The predicted noise tensor for the text-guided diffusion process. + guidance_rescale (`float`, *optional*, defaults to 0.0): + A rescale factor applied to the noise predictions. + Returns: + noise_cfg (`torch.Tensor`): The rescaled noise prediction tensor. + """ + std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True) + std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True) + # rescale the results from guidance (fixes overexposure) + noise_pred_rescaled = noise_cfg * (std_text / std_cfg) + # mix with the original results from guidance by factor guidance_rescale to avoid "plain looking" images + noise_cfg = guidance_rescale * noise_pred_rescaled + (1 - guidance_rescale) * noise_cfg + return noise_cfg diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/perturbed_attention_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/perturbed_attention_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..f233e90ca41071076fb8dcb9c6b80b2df3e7ad16 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/perturbed_attention_guidance.py @@ -0,0 +1,287 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from ..hooks import HookRegistry, LayerSkipConfig +from ..hooks.layer_skip import _apply_layer_skip_hook +from ..utils import get_logger +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +logger = get_logger(__name__) # pylint: disable=invalid-name + + +class PerturbedAttentionGuidance(BaseGuidance): + """ + Perturbed Attention Guidance (PAG): https://huggingface.co/papers/2403.17377 + + The intution behind PAG can be thought of as moving the CFG predicted distribution estimates further away from + worse versions of the conditional distribution estimates. PAG was one of the first techniques to introduce the idea + of using a worse version of the trained model for better guiding itself in the denoising process. It perturbs the + attention scores of the latent stream by replacing the score matrix with an identity matrix for selectively chosen + layers. + + Additional reading: + - [Guiding a Diffusion Model with a Bad Version of Itself](https://huggingface.co/papers/2406.02507) + + PAG is implemented with similar implementation to SkipLayerGuidance due to overlap in the configuration parameters + and implementation details. + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + perturbed_guidance_scale (`float`, defaults to `2.8`): + The scale parameter for perturbed attention guidance. + perturbed_guidance_start (`float`, defaults to `0.01`): + The fraction of the total number of denoising steps after which perturbed attention guidance starts. + perturbed_guidance_stop (`float`, defaults to `0.2`): + The fraction of the total number of denoising steps after which perturbed attention guidance stops. + perturbed_guidance_layers (`int` or `List[int]`, *optional*): + The layer indices to apply perturbed attention guidance to. Can be a single integer or a list of integers. + If not provided, `perturbed_guidance_config` must be provided. + perturbed_guidance_config (`LayerSkipConfig` or `List[LayerSkipConfig]`, *optional*): + The configuration for the perturbed attention guidance. Can be a single `LayerSkipConfig` or a list of + `LayerSkipConfig`. If not provided, `perturbed_guidance_layers` must be provided. + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.01`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `0.2`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + # NOTE: The current implementation does not account for joint latent conditioning (text + image/video tokens in + # the same latent stream). It assumes the entire latent is a single stream of visual tokens. It would be very + # complex to support joint latent conditioning in a model-agnostic manner without specializing the implementation + # for each model architecture. + + _input_predictions = ["pred_cond", "pred_uncond", "pred_cond_skip"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + perturbed_guidance_scale: float = 2.8, + perturbed_guidance_start: float = 0.01, + perturbed_guidance_stop: float = 0.2, + perturbed_guidance_layers: Optional[Union[int, List[int]]] = None, + perturbed_guidance_config: Union[LayerSkipConfig, List[LayerSkipConfig], Dict[str, Any]] = None, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.skip_layer_guidance_scale = perturbed_guidance_scale + self.skip_layer_guidance_start = perturbed_guidance_start + self.skip_layer_guidance_stop = perturbed_guidance_stop + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + if perturbed_guidance_config is None: + if perturbed_guidance_layers is None: + raise ValueError( + "`perturbed_guidance_layers` must be provided if `perturbed_guidance_config` is not specified." + ) + perturbed_guidance_config = LayerSkipConfig( + indices=perturbed_guidance_layers, + fqn="auto", + skip_attention=False, + skip_attention_scores=True, + skip_ff=False, + ) + else: + if perturbed_guidance_layers is not None: + raise ValueError( + "`perturbed_guidance_layers` should not be provided if `perturbed_guidance_config` is specified." + ) + + if isinstance(perturbed_guidance_config, dict): + perturbed_guidance_config = LayerSkipConfig.from_dict(perturbed_guidance_config) + + if isinstance(perturbed_guidance_config, LayerSkipConfig): + perturbed_guidance_config = [perturbed_guidance_config] + + if not isinstance(perturbed_guidance_config, list): + raise ValueError( + "`perturbed_guidance_config` must be a `LayerSkipConfig`, a list of `LayerSkipConfig`, or a dict that can be converted to a `LayerSkipConfig`." + ) + elif isinstance(next(iter(perturbed_guidance_config), None), dict): + perturbed_guidance_config = [LayerSkipConfig.from_dict(config) for config in perturbed_guidance_config] + + for config in perturbed_guidance_config: + if config.skip_attention or not config.skip_attention_scores or config.skip_ff: + logger.warning( + "Perturbed Attention Guidance is designed to perturb attention scores, so `skip_attention` should be False, `skip_attention_scores` should be True, and `skip_ff` should be False. " + "Please check your configuration. Modifying the config to match the expected values." + ) + config.skip_attention = False + config.skip_attention_scores = True + config.skip_ff = False + + self.skip_layer_config = perturbed_guidance_config + self._skip_layer_hook_names = [f"SkipLayerGuidance_{i}" for i in range(len(self.skip_layer_config))] + + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance.prepare_models + def prepare_models(self, denoiser: torch.nn.Module) -> None: + self._count_prepared += 1 + if self._is_slg_enabled() and self.is_conditional and self._count_prepared > 1: + for name, config in zip(self._skip_layer_hook_names, self.skip_layer_config): + _apply_layer_skip_hook(denoiser, config, name=name) + + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance.cleanup_models + def cleanup_models(self, denoiser: torch.nn.Module) -> None: + if self._is_slg_enabled() and self.is_conditional and self._count_prepared > 1: + registry = HookRegistry.check_if_exists_or_initialize(denoiser) + # Remove the hooks after inference + for hook_name in self._skip_layer_hook_names: + registry.remove_hook(hook_name, recurse=True) + + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance.prepare_inputs + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + if self.num_conditions == 1: + tuple_indices = [0] + input_predictions = ["pred_cond"] + elif self.num_conditions == 2: + tuple_indices = [0, 1] + input_predictions = ( + ["pred_cond", "pred_uncond"] if self._is_cfg_enabled() else ["pred_cond", "pred_cond_skip"] + ) + else: + tuple_indices = [0, 1, 0] + input_predictions = ["pred_cond", "pred_uncond", "pred_cond_skip"] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + if self.num_conditions == 1: + tuple_indices = [0] + input_predictions = ["pred_cond"] + elif self.num_conditions == 2: + tuple_indices = [0, 1] + input_predictions = ( + ["pred_cond", "pred_uncond"] if self._is_cfg_enabled() else ["pred_cond", "pred_cond_skip"] + ) + else: + tuple_indices = [0, 1, 0] + input_predictions = ["pred_cond", "pred_uncond", "pred_cond_skip"] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance.forward + def forward( + self, + pred_cond: torch.Tensor, + pred_uncond: Optional[torch.Tensor] = None, + pred_cond_skip: Optional[torch.Tensor] = None, + ) -> GuiderOutput: + pred = None + + if not self._is_cfg_enabled() and not self._is_slg_enabled(): + pred = pred_cond + elif not self._is_cfg_enabled(): + shift = pred_cond - pred_cond_skip + pred = pred_cond if self.use_original_formulation else pred_cond_skip + pred = pred + self.skip_layer_guidance_scale * shift + elif not self._is_slg_enabled(): + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + else: + shift = pred_cond - pred_uncond + shift_skip = pred_cond - pred_cond_skip + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + self.skip_layer_guidance_scale * shift_skip + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance.is_conditional + def is_conditional(self) -> bool: + return self._count_prepared == 1 or self._count_prepared == 3 + + @property + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance.num_conditions + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_cfg_enabled(): + num_conditions += 1 + if self._is_slg_enabled(): + num_conditions += 1 + return num_conditions + + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance._is_cfg_enabled + def _is_cfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + # Copied from diffusers.guiders.skip_layer_guidance.SkipLayerGuidance._is_slg_enabled + def _is_slg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self.skip_layer_guidance_start * self._num_inference_steps) + skip_stop_step = int(self.skip_layer_guidance_stop * self._num_inference_steps) + is_within_range = skip_start_step < self._step < skip_stop_step + + is_zero = math.isclose(self.skip_layer_guidance_scale, 0.0) + + return is_within_range and not is_zero diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/skip_layer_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/skip_layer_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..e6109300d99c2591157accb8d3aa563a8d39e284 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/skip_layer_guidance.py @@ -0,0 +1,278 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from ..hooks import HookRegistry, LayerSkipConfig +from ..hooks.layer_skip import _apply_layer_skip_hook +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class SkipLayerGuidance(BaseGuidance): + """ + Skip Layer Guidance (SLG): https://github.com/Stability-AI/sd3.5 + + Spatio-Temporal Guidance (STG): https://huggingface.co/papers/2411.18664 + + SLG was introduced by StabilityAI for improving structure and anotomy coherence in generated images. It works by + skipping the forward pass of specified transformer blocks during the denoising process on an additional conditional + batch of data, apart from the conditional and unconditional batches already used in CFG + ([~guiders.classifier_free_guidance.ClassifierFreeGuidance]), and then scaling and shifting the CFG predictions + based on the difference between conditional without skipping and conditional with skipping predictions. + + The intution behind SLG can be thought of as moving the CFG predicted distribution estimates further away from + worse versions of the conditional distribution estimates (because skipping layers is equivalent to using a worse + version of the model for the conditional prediction). + + STG is an improvement and follow-up work combining ideas from SLG, PAG and similar techniques for improving + generation quality in video diffusion models. + + Additional reading: + - [Guiding a Diffusion Model with a Bad Version of Itself](https://huggingface.co/papers/2406.02507) + + The values for `skip_layer_guidance_scale`, `skip_layer_guidance_start`, and `skip_layer_guidance_stop` are + defaulted to the recommendations by StabilityAI for Stable Diffusion 3.5 Medium. + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + skip_layer_guidance_scale (`float`, defaults to `2.8`): + The scale parameter for skip layer guidance. Anatomy and structure coherence may improve with higher + values, but it may also lead to overexposure and saturation. + skip_layer_guidance_start (`float`, defaults to `0.01`): + The fraction of the total number of denoising steps after which skip layer guidance starts. + skip_layer_guidance_stop (`float`, defaults to `0.2`): + The fraction of the total number of denoising steps after which skip layer guidance stops. + skip_layer_guidance_layers (`int` or `List[int]`, *optional*): + The layer indices to apply skip layer guidance to. Can be a single integer or a list of integers. If not + provided, `skip_layer_config` must be provided. The recommended values are `[7, 8, 9]` for Stable Diffusion + 3.5 Medium. + skip_layer_config (`LayerSkipConfig` or `List[LayerSkipConfig]`, *optional*): + The configuration for the skip layer guidance. Can be a single `LayerSkipConfig` or a list of + `LayerSkipConfig`. If not provided, `skip_layer_guidance_layers` must be provided. + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.01`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `0.2`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + _input_predictions = ["pred_cond", "pred_uncond", "pred_cond_skip"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + skip_layer_guidance_scale: float = 2.8, + skip_layer_guidance_start: float = 0.01, + skip_layer_guidance_stop: float = 0.2, + skip_layer_guidance_layers: Optional[Union[int, List[int]]] = None, + skip_layer_config: Union[LayerSkipConfig, List[LayerSkipConfig], Dict[str, Any]] = None, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.skip_layer_guidance_scale = skip_layer_guidance_scale + self.skip_layer_guidance_start = skip_layer_guidance_start + self.skip_layer_guidance_stop = skip_layer_guidance_stop + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + if not (0.0 <= skip_layer_guidance_start < 1.0): + raise ValueError( + f"Expected `skip_layer_guidance_start` to be between 0.0 and 1.0, but got {skip_layer_guidance_start}." + ) + if not (skip_layer_guidance_start <= skip_layer_guidance_stop <= 1.0): + raise ValueError( + f"Expected `skip_layer_guidance_stop` to be between 0.0 and 1.0, but got {skip_layer_guidance_stop}." + ) + + if skip_layer_guidance_layers is None and skip_layer_config is None: + raise ValueError( + "Either `skip_layer_guidance_layers` or `skip_layer_config` must be provided to enable Skip Layer Guidance." + ) + if skip_layer_guidance_layers is not None and skip_layer_config is not None: + raise ValueError("Only one of `skip_layer_guidance_layers` or `skip_layer_config` can be provided.") + + if skip_layer_guidance_layers is not None: + if isinstance(skip_layer_guidance_layers, int): + skip_layer_guidance_layers = [skip_layer_guidance_layers] + if not isinstance(skip_layer_guidance_layers, list): + raise ValueError( + f"Expected `skip_layer_guidance_layers` to be an int or a list of ints, but got {type(skip_layer_guidance_layers)}." + ) + skip_layer_config = [LayerSkipConfig(layer, fqn="auto") for layer in skip_layer_guidance_layers] + + if isinstance(skip_layer_config, dict): + skip_layer_config = LayerSkipConfig.from_dict(skip_layer_config) + + if isinstance(skip_layer_config, LayerSkipConfig): + skip_layer_config = [skip_layer_config] + + if not isinstance(skip_layer_config, list): + raise ValueError( + f"Expected `skip_layer_config` to be a LayerSkipConfig or a list of LayerSkipConfig, but got {type(skip_layer_config)}." + ) + elif isinstance(next(iter(skip_layer_config), None), dict): + skip_layer_config = [LayerSkipConfig.from_dict(config) for config in skip_layer_config] + + self.skip_layer_config = skip_layer_config + self._skip_layer_hook_names = [f"SkipLayerGuidance_{i}" for i in range(len(self.skip_layer_config))] + + def prepare_models(self, denoiser: torch.nn.Module) -> None: + self._count_prepared += 1 + if self._is_slg_enabled() and self.is_conditional and self._count_prepared > 1: + for name, config in zip(self._skip_layer_hook_names, self.skip_layer_config): + _apply_layer_skip_hook(denoiser, config, name=name) + + def cleanup_models(self, denoiser: torch.nn.Module) -> None: + if self._is_slg_enabled() and self.is_conditional and self._count_prepared > 1: + registry = HookRegistry.check_if_exists_or_initialize(denoiser) + # Remove the hooks after inference + for hook_name in self._skip_layer_hook_names: + registry.remove_hook(hook_name, recurse=True) + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + if self.num_conditions == 1: + tuple_indices = [0] + input_predictions = ["pred_cond"] + elif self.num_conditions == 2: + tuple_indices = [0, 1] + input_predictions = ( + ["pred_cond", "pred_uncond"] if self._is_cfg_enabled() else ["pred_cond", "pred_cond_skip"] + ) + else: + tuple_indices = [0, 1, 0] + input_predictions = ["pred_cond", "pred_uncond", "pred_cond_skip"] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + if self.num_conditions == 1: + tuple_indices = [0] + input_predictions = ["pred_cond"] + elif self.num_conditions == 2: + tuple_indices = [0, 1] + input_predictions = ( + ["pred_cond", "pred_uncond"] if self._is_cfg_enabled() else ["pred_cond", "pred_cond_skip"] + ) + else: + tuple_indices = [0, 1, 0] + input_predictions = ["pred_cond", "pred_uncond", "pred_cond_skip"] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward( + self, + pred_cond: torch.Tensor, + pred_uncond: Optional[torch.Tensor] = None, + pred_cond_skip: Optional[torch.Tensor] = None, + ) -> GuiderOutput: + pred = None + + if not self._is_cfg_enabled() and not self._is_slg_enabled(): + pred = pred_cond + elif not self._is_cfg_enabled(): + shift = pred_cond - pred_cond_skip + pred = pred_cond if self.use_original_formulation else pred_cond_skip + pred = pred + self.skip_layer_guidance_scale * shift + elif not self._is_slg_enabled(): + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + else: + shift = pred_cond - pred_uncond + shift_skip = pred_cond - pred_cond_skip + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + self.skip_layer_guidance_scale * shift_skip + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 or self._count_prepared == 3 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_cfg_enabled(): + num_conditions += 1 + if self._is_slg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_cfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + def _is_slg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self.skip_layer_guidance_start * self._num_inference_steps) + skip_stop_step = int(self.skip_layer_guidance_stop * self._num_inference_steps) + is_within_range = skip_start_step < self._step < skip_stop_step + + is_zero = math.isclose(self.skip_layer_guidance_scale, 0.0) + + return is_within_range and not is_zero diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/smoothed_energy_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/smoothed_energy_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..6c3906e820e037c464b84658a5c3e33773e7d631 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/smoothed_energy_guidance.py @@ -0,0 +1,267 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from ..hooks import HookRegistry +from ..hooks.smoothed_energy_guidance_utils import SmoothedEnergyGuidanceConfig, _apply_smoothed_energy_guidance_hook +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class SmoothedEnergyGuidance(BaseGuidance): + """ + Smoothed Energy Guidance (SEG): https://huggingface.co/papers/2408.00760 + + SEG is only supported as an experimental prototype feature for now, so the implementation may be modified in the + future without warning or guarantee of reproducibility. This implementation assumes: + - Generated images are square (height == width) + - The model does not combine different modalities together (e.g., text and image latent streams are not combined + together such as Flux) + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + seg_guidance_scale (`float`, defaults to `3.0`): + The scale parameter for smoothed energy guidance. Anatomy and structure coherence may improve with higher + values, but it may also lead to overexposure and saturation. + seg_blur_sigma (`float`, defaults to `9999999.0`): + The amount by which we blur the attention weights. Setting this value greater than 9999.0 results in + infinite blur, which means uniform queries. Controlling it exponentially is empirically effective. + seg_blur_threshold_inf (`float`, defaults to `9999.0`): + The threshold above which the blur is considered infinite. + seg_guidance_start (`float`, defaults to `0.0`): + The fraction of the total number of denoising steps after which smoothed energy guidance starts. + seg_guidance_stop (`float`, defaults to `1.0`): + The fraction of the total number of denoising steps after which smoothed energy guidance stops. + seg_guidance_layers (`int` or `List[int]`, *optional*): + The layer indices to apply smoothed energy guidance to. Can be a single integer or a list of integers. If + not provided, `seg_guidance_config` must be provided. The recommended values are `[7, 8, 9]` for Stable + Diffusion 3.5 Medium. + seg_guidance_config (`SmoothedEnergyGuidanceConfig` or `List[SmoothedEnergyGuidanceConfig]`, *optional*): + The configuration for the smoothed energy layer guidance. Can be a single `SmoothedEnergyGuidanceConfig` or + a list of `SmoothedEnergyGuidanceConfig`. If not provided, `seg_guidance_layers` must be provided. + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.01`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `0.2`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + _input_predictions = ["pred_cond", "pred_uncond", "pred_cond_seg"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + seg_guidance_scale: float = 2.8, + seg_blur_sigma: float = 9999999.0, + seg_blur_threshold_inf: float = 9999.0, + seg_guidance_start: float = 0.0, + seg_guidance_stop: float = 1.0, + seg_guidance_layers: Optional[Union[int, List[int]]] = None, + seg_guidance_config: Union[SmoothedEnergyGuidanceConfig, List[SmoothedEnergyGuidanceConfig]] = None, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.seg_guidance_scale = seg_guidance_scale + self.seg_blur_sigma = seg_blur_sigma + self.seg_blur_threshold_inf = seg_blur_threshold_inf + self.seg_guidance_start = seg_guidance_start + self.seg_guidance_stop = seg_guidance_stop + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + if not (0.0 <= seg_guidance_start < 1.0): + raise ValueError(f"Expected `seg_guidance_start` to be between 0.0 and 1.0, but got {seg_guidance_start}.") + if not (seg_guidance_start <= seg_guidance_stop <= 1.0): + raise ValueError(f"Expected `seg_guidance_stop` to be between 0.0 and 1.0, but got {seg_guidance_stop}.") + + if seg_guidance_layers is None and seg_guidance_config is None: + raise ValueError( + "Either `seg_guidance_layers` or `seg_guidance_config` must be provided to enable Smoothed Energy Guidance." + ) + if seg_guidance_layers is not None and seg_guidance_config is not None: + raise ValueError("Only one of `seg_guidance_layers` or `seg_guidance_config` can be provided.") + + if seg_guidance_layers is not None: + if isinstance(seg_guidance_layers, int): + seg_guidance_layers = [seg_guidance_layers] + if not isinstance(seg_guidance_layers, list): + raise ValueError( + f"Expected `seg_guidance_layers` to be an int or a list of ints, but got {type(seg_guidance_layers)}." + ) + seg_guidance_config = [SmoothedEnergyGuidanceConfig(layer, fqn="auto") for layer in seg_guidance_layers] + + if isinstance(seg_guidance_config, dict): + seg_guidance_config = SmoothedEnergyGuidanceConfig.from_dict(seg_guidance_config) + + if isinstance(seg_guidance_config, SmoothedEnergyGuidanceConfig): + seg_guidance_config = [seg_guidance_config] + + if not isinstance(seg_guidance_config, list): + raise ValueError( + f"Expected `seg_guidance_config` to be a SmoothedEnergyGuidanceConfig or a list of SmoothedEnergyGuidanceConfig, but got {type(seg_guidance_config)}." + ) + elif isinstance(next(iter(seg_guidance_config), None), dict): + seg_guidance_config = [SmoothedEnergyGuidanceConfig.from_dict(config) for config in seg_guidance_config] + + self.seg_guidance_config = seg_guidance_config + self._seg_layer_hook_names = [f"SmoothedEnergyGuidance_{i}" for i in range(len(self.seg_guidance_config))] + + def prepare_models(self, denoiser: torch.nn.Module) -> None: + if self._is_seg_enabled() and self.is_conditional and self._count_prepared > 1: + for name, config in zip(self._seg_layer_hook_names, self.seg_guidance_config): + _apply_smoothed_energy_guidance_hook(denoiser, config, self.seg_blur_sigma, name=name) + + def cleanup_models(self, denoiser: torch.nn.Module): + if self._is_seg_enabled() and self.is_conditional and self._count_prepared > 1: + registry = HookRegistry.check_if_exists_or_initialize(denoiser) + # Remove the hooks after inference + for hook_name in self._seg_layer_hook_names: + registry.remove_hook(hook_name, recurse=True) + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + if self.num_conditions == 1: + tuple_indices = [0] + input_predictions = ["pred_cond"] + elif self.num_conditions == 2: + tuple_indices = [0, 1] + input_predictions = ( + ["pred_cond", "pred_uncond"] if self._is_cfg_enabled() else ["pred_cond", "pred_cond_seg"] + ) + else: + tuple_indices = [0, 1, 0] + input_predictions = ["pred_cond", "pred_uncond", "pred_cond_seg"] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + if self.num_conditions == 1: + tuple_indices = [0] + input_predictions = ["pred_cond"] + elif self.num_conditions == 2: + tuple_indices = [0, 1] + input_predictions = ( + ["pred_cond", "pred_uncond"] if self._is_cfg_enabled() else ["pred_cond", "pred_cond_seg"] + ) + else: + tuple_indices = [0, 1, 0] + input_predictions = ["pred_cond", "pred_uncond", "pred_cond_seg"] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward( + self, + pred_cond: torch.Tensor, + pred_uncond: Optional[torch.Tensor] = None, + pred_cond_seg: Optional[torch.Tensor] = None, + ) -> GuiderOutput: + pred = None + + if not self._is_cfg_enabled() and not self._is_seg_enabled(): + pred = pred_cond + elif not self._is_cfg_enabled(): + shift = pred_cond - pred_cond_seg + pred = pred_cond if self.use_original_formulation else pred_cond_seg + pred = pred + self.seg_guidance_scale * shift + elif not self._is_seg_enabled(): + shift = pred_cond - pred_uncond + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + else: + shift = pred_cond - pred_uncond + shift_seg = pred_cond - pred_cond_seg + pred = pred_cond if self.use_original_formulation else pred_uncond + pred = pred + self.guidance_scale * shift + self.seg_guidance_scale * shift_seg + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._count_prepared == 1 or self._count_prepared == 3 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_cfg_enabled(): + num_conditions += 1 + if self._is_seg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_cfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + def _is_seg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self.seg_guidance_start * self._num_inference_steps) + skip_stop_step = int(self.seg_guidance_stop * self._num_inference_steps) + is_within_range = skip_start_step < self._step < skip_stop_step + + is_zero = math.isclose(self.seg_guidance_scale, 0.0) + + return is_within_range and not is_zero diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/tangential_classifier_free_guidance.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/tangential_classifier_free_guidance.py new file mode 100644 index 0000000000000000000000000000000000000000..76899c6e8494508744169d60352f46944b6bca31 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/guiders/tangential_classifier_free_guidance.py @@ -0,0 +1,149 @@ +# Copyright 2025 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union + +import torch + +from ..configuration_utils import register_to_config +from .guider_utils import BaseGuidance, GuiderOutput, rescale_noise_cfg + + +if TYPE_CHECKING: + from ..modular_pipelines.modular_pipeline import BlockState + + +class TangentialClassifierFreeGuidance(BaseGuidance): + """ + Tangential Classifier Free Guidance (TCFG): https://huggingface.co/papers/2503.18137 + + Args: + guidance_scale (`float`, defaults to `7.5`): + The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text + prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and + deterioration of image quality. + guidance_rescale (`float`, defaults to `0.0`): + The rescale factor applied to the noise predictions. This is used to improve image quality and fix + overexposure. Based on Section 3.4 from [Common Diffusion Noise Schedules and Sample Steps are + Flawed](https://huggingface.co/papers/2305.08891). + use_original_formulation (`bool`, defaults to `False`): + Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, + we use the diffusers-native implementation that has been in the codebase for a long time. See + [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details. + start (`float`, defaults to `0.0`): + The fraction of the total number of denoising steps after which guidance starts. + stop (`float`, defaults to `1.0`): + The fraction of the total number of denoising steps after which guidance stops. + """ + + _input_predictions = ["pred_cond", "pred_uncond"] + + @register_to_config + def __init__( + self, + guidance_scale: float = 7.5, + guidance_rescale: float = 0.0, + use_original_formulation: bool = False, + start: float = 0.0, + stop: float = 1.0, + enabled: bool = True, + ): + super().__init__(start, stop, enabled) + + self.guidance_scale = guidance_scale + self.guidance_rescale = guidance_rescale + self.use_original_formulation = use_original_formulation + + def prepare_inputs(self, data: Dict[str, Tuple[torch.Tensor, torch.Tensor]]) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch(data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def prepare_inputs_from_block_state( + self, data: "BlockState", input_fields: Dict[str, Union[str, Tuple[str, str]]] + ) -> List["BlockState"]: + tuple_indices = [0] if self.num_conditions == 1 else [0, 1] + data_batches = [] + for tuple_idx, input_prediction in zip(tuple_indices, self._input_predictions): + data_batch = self._prepare_batch_from_block_state(input_fields, data, tuple_idx, input_prediction) + data_batches.append(data_batch) + return data_batches + + def forward(self, pred_cond: torch.Tensor, pred_uncond: Optional[torch.Tensor] = None) -> GuiderOutput: + pred = None + + if not self._is_tcfg_enabled(): + pred = pred_cond + else: + pred = normalized_guidance(pred_cond, pred_uncond, self.guidance_scale, self.use_original_formulation) + + if self.guidance_rescale > 0.0: + pred = rescale_noise_cfg(pred, pred_cond, self.guidance_rescale) + + return GuiderOutput(pred=pred, pred_cond=pred_cond, pred_uncond=pred_uncond) + + @property + def is_conditional(self) -> bool: + return self._num_outputs_prepared == 1 + + @property + def num_conditions(self) -> int: + num_conditions = 1 + if self._is_tcfg_enabled(): + num_conditions += 1 + return num_conditions + + def _is_tcfg_enabled(self) -> bool: + if not self._enabled: + return False + + is_within_range = True + if self._num_inference_steps is not None: + skip_start_step = int(self._start * self._num_inference_steps) + skip_stop_step = int(self._stop * self._num_inference_steps) + is_within_range = skip_start_step <= self._step < skip_stop_step + + is_close = False + if self.use_original_formulation: + is_close = math.isclose(self.guidance_scale, 0.0) + else: + is_close = math.isclose(self.guidance_scale, 1.0) + + return is_within_range and not is_close + + +def normalized_guidance( + pred_cond: torch.Tensor, pred_uncond: torch.Tensor, guidance_scale: float, use_original_formulation: bool = False +) -> torch.Tensor: + cond_dtype = pred_cond.dtype + preds = torch.stack([pred_cond, pred_uncond], dim=1).float() + preds = preds.flatten(2) + U, S, Vh = torch.linalg.svd(preds, full_matrices=False) + Vh_modified = Vh.clone() + Vh_modified[:, 1] = 0 + + uncond_flat = pred_uncond.reshape(pred_uncond.size(0), 1, -1).float() + x_Vh = torch.matmul(uncond_flat, Vh.transpose(-2, -1)) + x_Vh_V = torch.matmul(x_Vh, Vh_modified) + pred_uncond = x_Vh_V.reshape(pred_uncond.shape).to(cond_dtype) + + pred = pred_cond if use_original_formulation else pred_uncond + shift = pred_cond - pred_uncond + pred = pred + guidance_scale * shift + + return pred diff --git a/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/hooks/__init__.py b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/hooks/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..524a92ea9966b1101b2be5623f9a72700e59ac98 --- /dev/null +++ b/tasks/tasksmith-1c5704b1f07f/environment/source/src/diffusers/hooks/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2024 The HuggingFace Team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ..utils import is_torch_available + + +if is_torch_available(): + from .context_parallel import apply_context_parallel + from .faster_cache import FasterCacheConfig, apply_faster_cache + from .first_block_cache import FirstBlockCacheConfig, apply_first_block_cache + from .group_offloading import apply_group_offloading + from .hooks import HookRegistry, ModelHook + from .layer_skip import LayerSkipConfig, apply_layer_skip + from .layerwise_casting import apply_layerwise_casting, apply_layerwise_casting_hook + from .pyramid_attention_broadcast import PyramidAttentionBroadcastConfig, apply_pyramid_attention_broadcast + from .smoothed_energy_guidance_utils import SmoothedEnergyGuidanceConfig