Repository navigation
Description
Hi!
I attempted to run the DeepSeek-V3 model using a single NVIDIA H100 (80GB) GPU in the DeepSeek branch.
I trimmed the model by retaining only the first five layers, which consist of three dense layers and two Mixture of Experts (MoE) layers, resulting in a total size of approximately 55 GB.
With the trimmed model, I created a checkpoint using this command (tensorrt_llm/examples/deepseek_v3).
$ python convert_checkpoint.py --model_dir {PATH_TO_TRIMMED_MODEL} --output_dir deepseek-v3-ckpt --dtype bfloat16
- I didn't set --tp_size, --pp_size, --moe_tp_size, --moe_ep_size because I'm using only one GPU
- I converted all weights to bf16, so I'm using --dtype bfloat16
I encountered an error when I attempted to build the engine using this command.
$ trtllm-build --checkpoint_dir deepseek-v3-ckpt --output_dir ./deepseek-v3-engine --gpt_attention_plugin bfloat16 --gemm_plugin bfloat16 --max_batch_size 16 --max_seq_len 8192 --max_input_len 4096 --use_paged_context_fmha enable
Which is:
[TRT] [E] IBuilder::buildSerializedNetwork: Error Code 8: Integer Overflow (weight transformer.layers.3.mlp.fc.weight count is out of range for int32_t: cast failure due to overflow with value 7516192768 and upper bound 2147483647)
In the MoE layer, the weights of the routed expert are as follows.
- model.layers.3.mlp.experts.0.down_proj.weight [7168, 2048]
- model.layers.3.mlp.experts.0.gate_proj.weight [2048, 7168]
- model.layers.3.mlp.experts.0.up_proj.weight [2048, 7168]
TensorRT-LLM concatenates gate_proj.weight and up_proj.weight which shape is [4096, 7168] for each routed expert.
In the class MOEWeightWrapper, all routed experts' weights are consolidated into a single weight with a shape of [256, 4096, 7168]. The product of this shape, 256 * 4096 * 7168, equals 7,516,192,768, which results in an integer overflow error.
This is the following error message.
Traceback (most recent call last):
File "/usr/local/bin/trtllm-build", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/commands/build.py", line 627, in main
parallel_build(model_config, ckpt_dir, build_config, args.output_dir,
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/commands/build.py", line 425, in parallel_build
passed = build_and_save(rank, rank % workers, ckpt_dir,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/commands/build.py", line 390, in build_and_save
engine = build_model(build_config,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/commands/build.py", line 383, in build_model
return build(model, build_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/builder.py", line 1273, in build
engine = None if build_config.dry_run else builder.build_engine(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/_common.py", line 220, in decorated
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorrt_llm/builder.py", line 429, in build_engine
assert engine is not None, 'Engine building failed, please check the error log.'
^^^^^^^^^^^^^^^^^^
AssertionError: Engine building failed, please check the error log.
So are there any solutions to avoid integer overflow error?
Thank you.
Activity
chuangz0 commentedon Mar 6, 2025
you can try torch flow
https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/deepseek_v3
dominicshanshan commentedon Mar 6, 2025
sorry, wrongly reference to another issue, please ignore
dominicshanshan commentedon Mar 7, 2025
@chung9868, let us know how is go, welcome to start a new issue if you encounter any error/bug, will close this one.
chung9868 commentedon Mar 7, 2025
Does torch flow mean this one?
chuangz0 commentedon Mar 7, 2025
cd examples/pytorch
python quickstart_advanced.py --model_dir <YOUR_MODEL_DIR> --tp_size 8