deepspeedai / deepspeedai/DeepSpeed

init_inference rejects dtype=torch.int8 on every accelerator

Open Beginner friendly
#8,577 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Describe the bug
deepspeed.init_inference(model, dtype=torch.int8) raises ValueError: Data type torch.int8 is not supported by <device> accelerator unconditionally, on every accelerator DeepSpeed ships
(checked cpu, cuda, hpu, mlu, xpu — none list torch.int8 in supported_dtypes()).
This is a regression: two unrelated cleanup PRs (#6528, "add bfloat16 to inference support
dtypes", 2024-09-27; and #5505, "remove unused _validate_args function", 2025-01-07) combined to
silently tighten InferenceEngine.__init__'s dtype gate (deepspeed/inference/engine.py:74) from
its original fp16-only check to a blanket supported_dtypes() check that was never meant to
describe DeepSpeed's own int8 weight-quantization dtype. docs/_tutorials/inference-tutorial.md
("Datatypes and Quantized Models", rewritten as recently as #8535) still documents int8 as
supported.

Found while investigating #1454 — the compute_attention()/input_mask crash reported there is
already fixed upstream, but the underlying "run int8 quantized inference" workflow that issue was
trying to use is broken by this separate, still-live gap.

To Reproduce

import torch, deepspeed
deepspeed.init_inference(torch.nn.Linear(4, 4), dtype=torch.int8)

No GPU needed — the gate itself is device-agnostic and raises identically on CPU.

Expected behavior
init_inference should accept dtype=torch.int8 as it did before #6528, since DeepSpeed's own
int8 weight-quantization path (DeepSpeedSelfAttention/DeepSpeedMLP in
deepspeed/ops/transformer/inference/ds_attention.py) still special-cases torch.int8
construction today — that code is presently unreachable dead code because the engine can no
longer be constructed with this dtype at all.

System info:

  • Reproduces identically on every accelerator backend (cpu, cuda, hpu, mlu, xpu) since
    the dtype check is evaluated before any accelerator-specific code runs.
  • Python 3.12, torch 2.14 (CPU repro); not version-specific — same gate on current master.

Additional context
A one-line fix (exempt torch.int8 from the supported_dtypes() gate, matching the code's
pre-#6528 scope) plus a regression test is ready; opening a PR alongside this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at deepspeed/inference/engine.py:74 and compare the dtype gate with the int8 handling in deepspeed/ops/transformer/inference/ds_attention.py. Reproduce the failure with the provided CPU example, then add a regression test for init_inference with torch.int8. Done means int8 initialization is accepted and the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.