Skip to content

feat: add --dry-run VRAM/size estimation mode#1958

Open
mvanhorn wants to merge 3 commits into
intel:mainfrom
mvanhorn:osc/feat-dry-run
Open

feat: add --dry-run VRAM/size estimation mode#1958
mvanhorn wants to merge 3 commits into
intel:mainfrom
mvanhorn:osc/feat-dry-run

Conversation

@mvanhorn

Copy link
Copy Markdown

Re-submit of #1592, reworked per your feedback. The VRAM estimate is now built on auto-round's own block-wise memory model instead of a raw parameter count:

  • Reuses auto_round.utils.device.estimate_tuning_block_mem and get_moe_memory_ratio (@xin3he's card_0 = block_input_output + layer_activation + additional formula).
  • Models peak memory at decoder-block granularity (@wenhuach21).
  • Excludes the block input/output cache when low_gpu_mem_usage is set, and includes it otherwise (@wenhuach21's caching point).
  • MoE handled via get_moe_memory_ratio; layer/hidden-size discovery is robust across config field names and nested configs (text_config etc.) since num_hidden_layers doesn't cover every model (@xin3he).
  • Loads AutoConfig only, no weights.

Unit tests cover helper reuse, the low_gpu_mem_usage path, MoE, and layer-count fallbacks (8 passing). Supersedes #1592 (couldn't reopen after the rebase).

mvanhorn and others added 3 commits June 27, 2026 10:27
Adds a --dry-run flag that estimates peak block-tuning VRAM, output size,
and approximate time from the model config alone (AutoConfig only, no
weights). The VRAM estimate is built on auto-round's own block-wise memory
model, reusing auto_round.utils.device.estimate_tuning_block_mem and
get_moe_memory_ratio per maintainer feedback on intel#1592:

- peak memory at decoder-block granularity (card_0 = block I/O cache +
  layer activations + additional overhead)
- block input/output cache excluded when low_gpu_mem_usage is set
- MoE handled via get_moe_memory_ratio
- robust layer/hidden-size discovery across config field names and nested
  (text_config etc.) configs

Adds unit tests for helper reuse, the low_gpu_mem_usage path, MoE, and
layer-count fallbacks.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
for more information, see https://pre-commit.ci

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Matches the codebase convention (calib_dataset.py, utils/model.py) where
every optional modelscope import carries a pylint E0401 disable, since
modelscope is not in requirements. Fixes the Code-Scan-AutoRound failure.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn

Copy link
Copy Markdown
Author

Pushed a fix for the two red checks:

  • Code-Scan (pylint E0401): the optional modelscope import in _load_auto_config now carries # pylint: disable=E0401, matching how calib_dataset.py and utils/model.py handle modelscope (it's not in requirements). Scan is now 10.00/10 locally.
  • DCO: signed off all commits on the branch.

@wenhuach21

Copy link
Copy Markdown
Contributor

Hi, thanks for the PR! It would be very useful if the estimation is both general and accurate.

Could you kindly share some evaluation results demonstrating its accuracy? It would be helpful to include results covering an LLM, a VLM, and an MoE model.

@mvanhorn

mvanhorn commented Jul 8, 2026

Copy link
Copy Markdown
Author

Happy to. Since --dry-run estimates VRAM/size analytically from the model config rather than measuring on hardware, I can put together a table comparing the estimate against the theoretical footprint (param count x bit-width, plus the group/zp/scale overhead the estimator accounts for) for a representative LLM, VLM, and MoE. That validates the estimation math end to end without needing a specific GPU.

Where I'd lean on you: confirming the estimate against actual measured peak VRAM on real hardware for those three model classes - you're better set up for that than I am. If a config-vs-theoretical table plus your measured spot-check works, I'll post the table. Which three models would you want represented (so the numbers match something you can cross-check)?

Copilot AI 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.

Pull request overview

Adds a user-facing --dry-run mode to the auto_round quantize CLI that estimates peak VRAM, output artifact size, and rough runtime using AutoRound’s existing block-wise memory model while loading only the model config (no weights).

Changes:

  • Added auto_round/estimation.py with config-only, synthetic-block-based estimators and a printable dry-run report.
  • Added --dry_run/--dry-run CLI flag and early-exit flow in tune() to run estimation without loading weights.
  • Added CPU unit tests covering estimator behavior, MoE handling, low_gpu_mem_usage, and CLI flag parsing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
auto_round/estimation.py New estimation utilities: config discovery, synthetic decoder block, VRAM/size/time estimation, and report printing.
auto_round/cli/parser.py Adds --dry_run/--dry-run flag to the quantize CLI parser.
auto_round/cli/main.py Implements dry-run short-circuit path in tune() that prints estimation report and returns.
test/test_cpu/core/test_estimation.py Adds unit tests for estimation helpers and CLI dry-run flag aliases.

Comment thread auto_round/estimation.py
Comment on lines +360 to +363
num_heads = _discover_num_heads(config)
head_dim = hidden_size // num_heads if num_heads else hidden_size
num_kv_heads = _discover_num_kv_heads(config, num_heads)
kv_size = hidden_size if num_kv_heads is None else num_kv_heads * head_dim
Comment thread auto_round/estimation.py
Comment on lines +493 to +496
def estimate_time(num_layers, iters, nsamples, batch_size):
"""Estimate approximate quantization time in seconds."""
batches_per_iter = math.ceil(nsamples / batch_size)
return num_layers * iters * batches_per_iter * _SECS_PER_LAYER_PER_ITER
Comment thread auto_round/estimation.py
Comment on lines +474 to +483
def estimate_output_size(param_count, target_bits, group_size):
"""Estimate output file size in bytes for the quantized model."""
weight_bits = param_count * target_bits
normalized_group_size = _normalize_group_size(group_size)
if normalized_group_size and normalized_group_size > 0:
num_groups = math.ceil(param_count / normalized_group_size)
overhead_bits = num_groups * (16 + target_bits)
else:
overhead_bits = 0
return int(math.ceil((weight_bits + overhead_bits) / 8))
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.

[Bug]: dry-run estimation should fall back to text_config for Qwen3.5-MoE [Feature]: add --dry-run estimation mode

3 participants