Skip to content

Stream targeted block re-quantization's calibration pass - #2064

Open
aquilarubra wants to merge 3 commits into
intel:mainfrom
aquilarubra:pr/targeted-block-calib
Open

Stream targeted block re-quantization's calibration pass#2064
aquilarubra wants to merge 3 commits into
intel:mainfrom
aquilarubra:pr/targeted-block-calib

Conversation

@aquilarubra

Copy link
Copy Markdown
Collaborator

Summary

Depends on #2061 (disk-streaming core) — stacked on top of it, so the diff includes those commits until it merges; only the last commit is new here.

to_quant_block_names lets a caller restrict tuning to a subset of decoder blocks — useful for cheaply re-quantizing just a couple of blocks in an already-produced checkpoint at higher precision instead of redoing a full multi-hour run. Combined with AR_DISK_STREAM_MODEL, this crashes: the "cache block inputs" calibration forward pass needs real weights in every block leading up to (and sometimes through) the target block(s), but nothing materializes blocks outside quant_block_list for this specific pass — they stay meta forever, and the forward silently propagates meta-ness until it collides with a genuinely-materialized module. Full (unrestricted) runs never hit this, since quant_block_list already covers every block in that case.

What's in this PR

auto_round/calibration/llm.py: when disk streaming is active and any decoder block still has meta parameters at the point this calibration forward runs, wraps it with the existing stream_block_forward primitive (from #2061), scoped to just the still-meta blocks. Only activates when there's something left meta to fix, so it's a no-op for the normal full-quantization path.

Also adds an AR_CALIB_STREAM_DEVICE env-gated fast path: the default keeps this forward entirely on CPU (mixing a GPU-streamed block with CPU-resident hidden states crashes with a device mismatch), but a full CPU forward through every pre-target block of a 100B+ model is unusably slow for this specific targeted-requant use case. When set, every already-real tensor is moved to that device for the pass's duration and moved back afterward.

Validation

Reproduced and fixed against a tiny hybrid-MoE fixture with an MTP head, with both a single restricted block and two adjacent ones, plus a control run of the full (unrestricted) path confirming no regression.

@aquilarubra
aquilarubra force-pushed the pr/targeted-block-calib branch 2 times, most recently from 11ba30e to 3be3fae Compare July 19, 2026 14:31
@chensuyue
chensuyue requested review from xin3he and yiliu30 and removed request for yiliu30 July 20, 2026 02:12
@aquilarubra
aquilarubra force-pushed the pr/targeted-block-calib branch 6 times, most recently from c6e097e to 3841bb3 Compare July 29, 2026 07:34
Rebase of PR intel#2064 onto current main. Most of the original stack
(disk-streaming-core intel#2061, resumability intel#2062, AutoScheme streaming
intel#2063) is already merged verbatim or superseded by intel#2220, so this
commit carries only the calibration-pass streaming logic and its
tests that weren't already upstream.
@aquilarubra
aquilarubra force-pushed the pr/targeted-block-calib branch from e193420 to 3f26e3c Compare August 29, 2026 06:43
@aquilarubra

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main — the previous stack this was built on (#2061/#2063) is fully merged now, so I rebuilt this PR's unique diff on top of the merged result instead of a mechanical rebase. Most of the old diff (streaming helpers, resumability plumbing, parallel-scoring gating) turned out to already be upstream via #2063/#2220; what's left is the actual calibration-streaming feature in auto_round/calibration/llm.py plus docs/tests. Force-pushed to this branch.

@wenhuach21
wenhuach21 requested a review from n1ck-guo September 2, 2026 01:50
Comment thread docs/environments.md Outdated
export AR_RESUME_DIR=/path/to/resume/state
```

### AR_DISK_STREAM_MODEL

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.

We already have this variable; please clean up the relevant documentation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — the merge with main had duplicated the AR_DISK_STREAM_MODEL and AR_RESUME_DIR sections verbatim. Removed the duplicate copy, kept the richer one (mentions the parallel-scoring interaction). Pushed.

@xin3he xin3he 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.

Nice catch, please clean up the document

Comment thread docs/environments.md
export AR_DISK_STREAM_MODEL=1
```

### AR_RESUME_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.

We already have this variable; please clean up the relevant documentation.

The merge with main duplicated these two sections verbatim; keep the
richer copy (mentions parallel-scoring interaction) and drop the dupe.
@aquilarubra
aquilarubra force-pushed the pr/targeted-block-calib branch from 38b10ff to 8f89538 Compare September 2, 2026 20:05
@wenhuach21

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound.

@wenhuach21

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@azure-pipelines

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

@wenhuach21 wenhuach21 added this to the 0.16.0 milestone Sep 3, 2026
@wenhuach21

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

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

@wenhuach21

Copy link
Copy Markdown
Contributor

/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.

3 participants