Repository navigation
Accept torch.int8 in init_inference's dtype validation gate #8578
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
Open
udsy19
wants to merge
3
commits into
deepspeedai:master
Choose a base branch
from
udsy19:fix/init-inference-int8-dtype-gate-1454
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this against
e57bdeda67e6430658c2f8cd542331544cd0f6cdin a cleanpython:3.11-slimcontainer, CPU accelerator, torch 2.14.0+cpu.The gate change does let int8 through, but the path it opens does not quantize.
_convert_to_dtype(engine.py:517) still keeps the int8 branch behindif False:, and no remaining branch matches int8, so the module keeps the dtype it arrived with:bfloat16 is a control, so the weight read is not just always printing float32. On base
fe8c4b10the same script raisesValueError: Data type torch.int8 is not supported by cpu accelerator. So with no checkpoint andreplace_with_kernel_injectat its defaultFalse, this swaps a loud error for an engine reporting_config.dtype == torch.int8over fp32 weights.Both places that do act on int8 are unreached there:
engine.py:480inside_load_checkpoint, andreplace_module.py:201insidereplace_transformer_layer, which__init__calls only for one of its three injection modes (lines 135-169).One correction to the body:
279bf743ddoes delete theif False:block, but it is not an ancestor of master, so it never landed.git blamestill puts that line atb5d18a6ab.test_int8_dtype_acceptedasserts_config.dtypeonly, which passes whether or not anything quantized. Asserting the weight dtype the engine produces would pin the real behaviour, and if that is fp32 then narrowing the exemption to the cases that consume int8 seems better than opening it for all.CPU only, no checkpoint, no kernel injection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up. I ran ce500b2 in a clean container (python:3.11-slim, torch 2.14.0+cpu,
pip install .from the PR head, reported version 0.19.8+ce500b21e). The narrowed gate refuses one configuration that does reach the quantizer.tensor_parallel.mpuis a fourth way into AutoTP. The gate at engine.py:84 readsconfig.tensor_parallel.tp_size, but an mpu caller does not set that field: it is written at engine.py:125 fromdist.get_world_size(group=self.mpu.get_model_parallel_group()), after the gate has already raised. Soinit_inference(model, dtype=torch.int8, tensor_parallel={"mpu": mpu})is rejected even when that group would have given tp_size > 1 and mode 3 would have run.Measured on 2 ranks (gloo, world_size 2, an mpu stub returning the default group). Only dtype differs between the two runs:
The bf16 run gets past the gate and into the AutoTP branch. The int8 run never gets there. That assertion is my toy model having no AutoTP policy, which is what makes it a usable marker that the branch ran at all.
Your new test docstring already names the case: "AutoTP (tensor_parallel.tp_size > 1 or tensor_parallel.mpu)". The guard checks only the first half. One more term covers it:
I did not run a real model-parallel mpu, so what tp_size becomes for a genuine TP group is read from engine.py:125 rather than executed.