Skip to content

Automatically select calibration datasets for code models - #2107

Open
changwangss wants to merge 6 commits into
mainfrom
feat/auto-code-calibration-dataset-v3
Open

Automatically select calibration datasets for code models#2107
changwangss wants to merge 6 commits into
mainfrom
feat/auto-code-calibration-dataset-v3

Conversation

@changwangss

@changwangss changwangss commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Automatically select code-oriented calibration datasets when quantizing a pure-text code model without an explicitly configured calibration dataset.

  • Add is_code_model() following the existing model-detection style.

    • Detect code-specialized models from the model name and existing config metadata without additional Hub requests.
    • Avoid false positives such as encoder, decoder, codec, and unrelated parent directories named code.
  • Select an exact-size code calibration dataset:

    • datasets <= 3.6.0: OpenCodeInstruct 50% and GitHub Code Clean 50%.
    • datasets > 3.6.0: OpenCodeInstruct only, because script-based GitHub Code Clean is no longer supported.
    • Enable cross-sample concatenation for OpenCodeInstruct so short examples can form fixed-length calibration sequences.
  • Apply automatic selection only to pure-text LLMs that require calibration.

  • Preserve explicit user dataset choices, including both NeelNanda/pile-10k and its pile-10k alias.

    • If dataset / --dataset is omitted, normal models continue to use Pile-10k, while detected code models use the code-oriented calibration dataset.
    • If the user explicitly specifies any dataset, that choice is left unchanged.
  • Keep the existing diffusion default behavior (coco2014) unchanged.

Type of Change

New feature

Related Issues

Fixes or relates to ##1986

Checklist Before Submitting

  • My code has been tested locally.
  • Documentation has been updated as needed.
  • New or updated tests are included where applicable.
  • The CUDA CI has passed. You can trigger it by commenting /azp run Unit-Test-CUDA-AutoRound.

@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@changwangss
changwangss requested a review from wenhuach21 July 31, 2026 06:28
Comment thread auto_round/utils/model.py
"codestral",
"deepseekcoder",
"granitecode",
"magicoder",

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.

Is it still doable if the user wants to use Pile-10k for a code model?

@changwangss changwangss Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed the issue.
added a dataset_was_explicitly_set flag, changed the dataset default to None across all entry points, and then selected the appropriate default dataset only after determining whether the user had explicitly specified one.

@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

quant_lm_head: bool = False,
to_quant_block_names: Optional[Union[str, list[str]]] = None,
dataset: Union[str, list, tuple, torch.utils.data.DataLoader] = "NeelNanda/pile-10k",
dataset: Optional[Union[str, list, tuple, torch.utils.data.DataLoader]] = None,

@wenhuach21 wenhuach21 Aug 3, 2026

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.

I think the API entry of AutoRound is not this one, so you need to change auto_round/autoround.py /AutoRound as well
@n1ck-guo is it possible to merge your pr ASAP, the different entries confuse developers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Already addressed in commit 9961d8e. The public AutoRound API in auto_round/autoround.py now defaults dataset to None and forwards it unchanged, allowing the downstream orchestrator to distinguish an omitted dataset from an explicit user choice.

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.

There is no conflict, this is the correct modification.

Comment thread auto_round/compressors/base.py Outdated
self.dataset = dataset
if self.dataset is None:
self.dataset = "NeelNanda/pile-10k"
self.dataset_was_explicitly_set = dataset is not None

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.

based on the code, there is no need to save dataset_was_explicitly_set to self

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. dataset_was_explicitly_set is now a local variable because it is only needed during initialization and does not need to be stored on self.

@changwangss
changwangss requested a review from n1ck-guo August 3, 2026 02:36
Comment thread auto_round/calib_dataset.py Outdated

datasets_version = datasets.__version__
parsed_version = Version(str(datasets_version))
sources = [("opencode-instruct:concat=true", 50), ("github-code-clean", 40), ("mbpp:split=train:concat=true", 10)]

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.

is there any data to support this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated based on our discussion. MBPP has been removed from the automatically selected mixture. For datasets <= 3.6.0, OpenCodeInstruct and GitHub Code Clean are now selected with a 50/50 ratio. For newer datasets versions, the code falls back to OpenCodeInstruct only because script-based GitHub Code Clean is no longer supported.

Comment thread auto_round/calib_dataset.py Outdated
sources = [("opencode-instruct:concat=true", 50), ("github-code-clean", 40), ("mbpp:split=train:concat=true", 10)]
if parsed_version > _GITHUB_CODE_CLEAN_MAX_DATASETS_VERSION:
sources = [source for source in sources if source[0] != "github-code-clean"]
logger.warning(

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.

warning_once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Changed logger.warning() to logger.warning_once() to avoid repeatedly reporting the same datasets-version compatibility warning when multiple AutoRound instances are created.

@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: changwangss <chang1.wang@intel.com>

@n1ck-guo n1ck-guo 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.

LGTM

quant_lm_head: bool = False,
to_quant_block_names: Optional[Union[str, list[str]]] = None,
dataset: Union[str, list, tuple, torch.utils.data.DataLoader] = "NeelNanda/pile-10k",
dataset: Optional[Union[str, list, tuple, torch.utils.data.DataLoader]] = None,

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.

There is no conflict, this is the correct modification.

@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants