-
Notifications
You must be signed in to change notification settings - Fork 592
Speed up slow unit/gpu/example tests #1616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
27e2e17
Disable HF Hub access for unit tests and enable gpt_oss example tests
kevalmorabia97 99742ff
Speed up slow unit tests and gate rarely-used autonas/fastnas tests
kevalmorabia97 178fc65
Optimize gpu test dist setup
kevalmorabia97 756eb8f
Speed up slow example tests and reuse shared dataset utils
kevalmorabia97 7a936b5
Fix unit-test hang: use spawn (not fork) for multiprocess jobs
kevalmorabia97 2c269e8
Fix CI failures and simplify/stabilize the test suite
kevalmorabia97 3a8b6f2
Address review feedback and fix speculative_decoding CI regressions
kevalmorabia97 14938df
Move all test imports to the top of the file
kevalmorabia97 3496246
Disable torch compile in most eagle tests to speedup ~1mins each
kevalmorabia97 3026652
Move test_sparse_attn_worker from unit to gpu_vllm
kevalmorabia97 1452e14
make llm_eval tests faster by limiting eval samples and output len
kevalmorabia97 a356a77
Revert trt_builder_optimization_level back to 4 for tests
kevalmorabia97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,38 +20,15 @@ | |
|
|
||
| import numpy as np | ||
| import torch | ||
| from datasets import load_dataset | ||
| from torch.utils.data import DataLoader | ||
| from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedModel, PreTrainedTokenizer | ||
|
|
||
| import modelopt.torch.opt as mto | ||
| import modelopt.torch.sparsity as mts | ||
| from modelopt.torch.utils import get_dataset_dataloader | ||
|
|
||
| DEFAULT_PAD_TOKEN = "[PAD]" | ||
|
|
||
|
|
||
| def get_calib_dataloader( | ||
| data="cnn_dailymail", tokenizer=None, batch_size=1, calib_size=512, block_size=512, device=None | ||
| ): | ||
| print("Loading calibration dataset") | ||
| if data == "cnn_dailymail": | ||
| dataset = load_dataset("abisee/cnn_dailymail", name="3.0.0", split="train") | ||
| dataset = dataset["article"][:calib_size] | ||
| else: | ||
| raise NotImplementedError | ||
|
|
||
| batch_encoded = tokenizer( | ||
| dataset, return_tensors="pt", padding=True, truncation=True, max_length=block_size | ||
| ) | ||
| if device: | ||
| batch_encoded = batch_encoded.to(device) | ||
| batch_encoded = batch_encoded["input_ids"] | ||
|
|
||
| calib_dataloader = DataLoader(batch_encoded, batch_size=batch_size, shuffle=False) | ||
|
|
||
| return calib_dataloader | ||
|
|
||
|
|
||
| def smart_tokenizer_and_embedding_resize( | ||
| special_tokens_dict: dict, | ||
| tokenizer: PreTrainedTokenizer, | ||
|
|
@@ -80,7 +57,8 @@ def get_tokenizer(ckpt_path: str, model_max_length: int, trust_remote_code: bool | |
| tokenizer = AutoTokenizer.from_pretrained( | ||
| ckpt_path, | ||
| model_max_length=model_max_length, | ||
| padding_side="right", | ||
| # Left padding is recommended for calibration (get_dataset_dataloader warns otherwise). | ||
| padding_side="left", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kaix-nv could you review this change? |
||
| use_fast=False, | ||
| trust_remote_code=trust_remote_code, | ||
| ) | ||
|
|
@@ -126,13 +104,13 @@ def main(args): | |
| model=model, | ||
| ) | ||
|
|
||
| calib_size = args.calib_size | ||
|
|
||
| # Get calibration dataloader | ||
| calib_dataloader = get_calib_dataloader( | ||
| calib_dataloader = get_dataset_dataloader( | ||
| dataset_name=args.dataset, | ||
| tokenizer=tokenizer, | ||
| batch_size=args.batch_size, | ||
| calib_size=calib_size, | ||
| num_samples=args.calib_size, | ||
| max_sample_length=args.model_max_length, | ||
| device=args.device, | ||
| ) | ||
|
kevalmorabia97 marked this conversation as resolved.
|
||
|
|
||
|
|
@@ -160,11 +138,18 @@ def main(args): | |
| "--model_name_or_path", help="Specify where the PyTorch checkpoint path is", required=True | ||
| ) | ||
| parser.add_argument("--device", default="cuda") | ||
| parser.add_argument( | ||
| "--dataset", | ||
| default="cnn_dailymail", | ||
| help="Calibration dataset: a ModelOpt-registered name (see get_supported_datasets()), " | ||
| "a HuggingFace dataset id, or a local .jsonl path.", | ||
| ) | ||
| parser.add_argument("--dtype", help="Model data type.", default="fp16") | ||
| parser.add_argument( | ||
| "--model_max_length", | ||
| type=int, | ||
| default=2048, | ||
| help="Maximum sequence length. Sequences will be right padded (and possibly truncated).", | ||
| help="Maximum sequence length used for both the tokenizer and calibration sequences.", | ||
| ) | ||
| parser.add_argument("--batch_size", help="Batch size for calibration.", type=int, default=1) | ||
| parser.add_argument( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.