deepspeedai / deepspeedai/DeepSpeed

[Question] Is CPU-only inference supported ?

Open
#4,743 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I set ds_accelerator to cpu,
and pip install intel_extension_for_pytorch, setup torch_ccl from https://github.com/intel/torch-ccl .
I run a llama2-7B model.

And from the source code, I find that pre_norm_rms has only CUDA support.
So, I wonder that if the deepspeed can run in CPU-only inference environment ?

[2023-11-28 18:48:08,800] [INFO] [engine_v2.py:82:__init__] Building model...
Traceback (most recent call last):
  File "examples/test.py", line 18, in <module>
    pipe = pipeline("Llama-2-7b-chat-ms")
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/mii/api.py", line 159, in pipeline
    inference_engine = load_model(model_config)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/mii/modeling/models.py", line 20, in load_model
    inference_engine = build_hf_engine(
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/engine_factory.py", line 106, in build_hf_engine
    return InferenceEngineV2(policy, engine_config)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/engine_v2.py", line 83, in __init__    self._model = self._policy.build_model(self._config, self._base_mp_group)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/model_implementations/inference_policy_base.py", line 156, in build_model
    self.model = self.instantiate_model(engine_config, mp_group)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/model_implementations/llama_v2/llama_v2_policy.py", line 17, in instantiate_model
    return Llama2InferenceModel(config=self._model_config, engine_config=engine_config, base_mp_group=mp_group)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/model_implementations/inference_transformer_base.py", line 206, in __init__
    self.make_norm_layer()
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/model_implementations/inference_transformer_base.py", line 504, in make_norm_layer
    self.norm = heuristics.instantiate_pre_norm(norm_config, self._engine_config)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/modules/heuristics.py", line 160, in instantiate_pre_norm
    return DSPreNormRegistry.instantiate_config(config)
  File ".conda/envs/deepspeed-cpu/lib/python3.8/site-packages/deepspeed/inference/v2/modules/module_registry.py", line 38, in instantiate_config
    raise ValueError(f"Config {config_bundle.config} is not supported by {target_implementation}")
ValueError: Config max_tokens=768 type='rms_norm' channels=4096 residual_dtype=torch.float16 input_dtype=torch.float16 output_dtype=torch.float16 eps=1e-05 is not supported by <class 'deepspeed.inference.v2.modules.implementations.pre_norm.cuda_pre_rms.DSPreRMSCUDAModule'>
[2023-11-28 18:48:10,264] [INFO] [launch.py:320:sigkill_handler] Killing subprocess 28105

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 with deepspeed/inference/v2/modules/heuristics.py and the pre-norm implementations referenced by the traceback, then inspect the Llama v2 path in deepspeed/inference/v2/model_implementations/llama_v2/llama_v2_policy.py. Reproduce the CPU-only Llama-2 inference setup and determine the scope of CPU support; done would require a documented support decision and a passing CPU inference path if support is added.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.