Skip to content

init_inference rejects dtype=torch.int8 on every accelerator #8577

Description

@udsy19

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions