Skip to content

Replace example datasets with prebaked "perfectblend" and "flickr30k" - #3062

Open
kylesayrs wants to merge 1 commit into
ddp-prebaked-dataset-supportfrom
simplify-example-datasets
Open

Replace example datasets with prebaked "perfectblend" and "flickr30k"#3062
kylesayrs wants to merge 1 commit into
ddp-prebaked-dataset-supportfrom
simplify-example-datasets

Conversation

@kylesayrs

Copy link
Copy Markdown
Collaborator

Summary

  • Replace manual dataset loading boilerplate across ~55 example files with dataset="perfectblend", removing ~1700 lines of repetitive load_dataset + preprocess + tokenize code.
  • DDP examples are also simplified — automatic rank partitioning from Support DDP partitioning for prebaked datasets #3061 means get_rank_partition() is no longer needed when using prebaked datasets.
  • Add examples/custom_dataset_example.py showing how to use a custom dataset (e.g. ultrachat_200k) for users who need custom preprocessing.
  • Examples with model-specific processing (custom processors/collators, audio/vision pipelines, AutoRound, DeepSeek encoding) are left unchanged.
  • Stacked on Support DDP partitioning for prebaked datasets #3061.

Examples kept as-is (custom processing required)

  • AutoRound examples (use auto_round.calib_dataset.get_dataset)
  • Multimodal vision examples with custom image/processor handling (idefics3, internvl3, phi3_vision, qwen VL, etc.)
  • Multimodal audio examples (whisper, qwen2_audio)
  • Examples with custom data collators (qwen3_5, qwen3_6, qwen3_8 GPTQ+AWQ)
  • Examples using specialized datasets (neuralmagic/calibration, codeparrot, Magpie)
  • AWQ masking example (custom loss_mask tokenization)
  • DeepSeek V4 examples (custom encoding)
  • Benchmark scripts (complex argparse + timing)
  • Data-free examples (FP8_DYNAMIC, model_free_ptq, etc.)

Test plan

  • Spot-checked simplified files preserve model loading, recipe, generation, and save logic
  • Verified no unintended ultrachat/perfectblend HF references remain in simplified files
  • Run a simplified example end-to-end with a small model
  • Run a simplified DDP example with torchrun --nproc_per_node=2

🤖 Generated with Claude Code

Simplify ~55 example files by replacing manual dataset loading, preprocessing,
and tokenization with `dataset="perfectblend"`. DDP examples also benefit from
automatic rank partitioning added in the parent PR.

Add `examples/custom_dataset_example.py` showing how to use a custom dataset
(e.g. ultrachat_200k) for users who need custom preprocessing.

Examples with model-specific processing (custom processors, data collators,
audio/vision pipelines, AutoRound) are left unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 700dae97-ae0c-4768-a4ad-628e46bdecc8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added the documentation Improvements or additions to documentation label Aug 19, 2026
@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 1 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require one maintainer review 👀 reviews

🔴 Require one maintainer review

Waiting for any of

  • approved-reviews-by=HDCharles
  • approved-reviews-by=brian-dellabetta
  • approved-reviews-by=dsikka
  • approved-reviews-by=kylesayrs
  • approved-reviews-by=yiliu30
This rule is failing.

All PRs must have at least one approving review from a maintainer before merging.

  • any of:
    • approved-reviews-by=HDCharles
    • approved-reviews-by=brian-dellabetta
    • approved-reviews-by=dsikka
    • approved-reviews-by=kylesayrs
    • approved-reviews-by=yiliu30
  • #changes-requested-reviews-by = 0

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the repository's example scripts by removing manual dataset loading, preprocessing, and tokenization, replacing them with the prebaked "perfectblend" dataset inside the oneshot() function. To ensure users still have a reference for custom data, a new custom_dataset_example.py script has been added. The review feedback suggests removing unused tokenizer imports and variables in the prefetch benchmark example, and ensuring that the model is saved with save_compressed=True in the new custom dataset example to align with the comments and other scripts.

Comment on lines 17 to 24
from transformers import AutoModelForCausalLM, AutoTokenizer

from llmcompressor import oneshot

MODEL_ID = "meta-llama/Meta-Llama-3.1-8B-Instruct"
DATASET_ID = "HuggingFaceH4/ultrachat_200k"
DATASET_SPLIT = "train_sft"
NUM_CALIBRATION_SAMPLES = 20
MAX_SEQUENCE_LENGTH = 2048

model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The AutoTokenizer import and tokenizer instantiation are completely unused in this prefetch benchmark script. Since the dataset loading and tokenization are now handled automatically by oneshot using the prebaked "perfectblend" dataset, we can safely remove them to clean up the code and avoid redundant overhead.

Suggested change
from transformers import AutoModelForCausalLM, AutoTokenizer
from llmcompressor import oneshot
MODEL_ID = "meta-llama/Meta-Llama-3.1-8B-Instruct"
DATASET_ID = "HuggingFaceH4/ultrachat_200k"
DATASET_SPLIT = "train_sft"
NUM_CALIBRATION_SAMPLES = 20
MAX_SEQUENCE_LENGTH = 2048
model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
from transformers import AutoModelForCausalLM
from llmcompressor import oneshot
MODEL_ID = "meta-llama/Meta-Llama-3.1-8B-Instruct"
model = AutoModelForCausalLM.from_pretrained(MODEL_ID)


# Save to disk in compressed-tensors format.
SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-Dynamic"
model.save_pretrained(SAVE_DIR)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure the model is saved in the serialized compressed-tensors format (as indicated by the comment on line 85), save_compressed=True should be passed to save_pretrained(). This is consistent with other examples in the repository.

Suggested change
model.save_pretrained(SAVE_DIR)
model.save_pretrained(SAVE_DIR, save_compressed=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant