NVIDIA / TensorRT-LLM

TensorRT-LLM provides users with an easy-to-use Python API to define Large Language Models (LLMs) and build TensorRT engines that contain state-of-the-art optimizations to perform inference efficiently on NVIDIA GPUs. TensorRT-LLM also contains components to create Python and C++ runtimes that execute those TensorRT engines.
https://nvidia.github.io/TensorRT-LLM
Apache License 2.0
8.3k stars 927 forks source link

`--max_input_len` vs `--max_output_len` vs `maxInputLen` and `maxSequenceLen` in the logs #1780

Closed DreamGenX closed 3 months ago

DreamGenX commented 3 months ago

System Info

Hello, I am building a llama 3 70b engine. If I do not specify --max_input_len and --max_output_len then requests are capped at 1024 tokens for some reason. Ideally I want the input len and output len be flexible, and allow any combination that adds up to 8192 (the native length of the model).

Is there a way to do this?

Right now I set the following when using trtllm-build in order to do both long input and output, but I am worried it might have some side effects (e.g. does it somehow affect RoPE?):

--max_input_len 8192 \
--max_output_len 4096

This generated the following engine config:

{
    "version": "0.11.0.dev2024061100",
    "pretrained_config": {
        "mlp_bias": false,
        "attn_bias": false,
        "rotary_base": 500000.0,
        "rotary_scaling": null,
        "residual_mlp": false,
        "disable_weight_only_quant_plugin": false,
        "moe": {
            "num_experts": 0,
            "top_k": 0,
            "tp_mode": 2,
            "normalization_mode": null
        },
        "architecture": "LlamaForCausalLM",
        "dtype": "float16",
        "vocab_size": 128256,
        "hidden_size": 8192,
        "num_hidden_layers": 80,
        "num_attention_heads": 64,
        "hidden_act": "silu",
        "logits_dtype": "float32",
        "norm_epsilon": 1e-05,
        "position_embedding_type": "rope_gpt_neox",
        "max_position_embeddings": 8192,
        "num_key_value_heads": 8,
        "intermediate_size": 28672,
        "mapping": {
            "world_size": 4,
            "gpus_per_node": 8,
            "tp_size": 4,
            "pp_size": 1
        },
        "quantization": {
            "quant_algo": null,
            "kv_cache_quant_algo": null,
            "group_size": 128,
            "smoothquant_val": null,
            "has_zero_point": false,
            "pre_quant_scale": false,
            "exclude_modules": [
                "lm_head",
                "router",
                "vocab_embedding",
                "position_embedding",
                "block_embedding"
            ]
        },
        "use_parallel_embedding": false,
        "embedding_sharding_dim": 0,
        "share_embedding_table": false,
        "head_size": 128,
        "qk_layernorm": false,
        "mup_width_multiplier": 1.0
    },
    "build_config": {
        "max_input_len": 8192,
        "max_output_len": 4096,
        "opt_batch_size": null,
        "max_batch_size": 48,
        "max_beam_width": 1,
        "max_num_tokens": 32768,
        "opt_num_tokens": null,
        "max_prompt_embedding_table_size": 0,
        "gather_context_logits": false,
        "gather_generation_logits": false,
        "strongly_typed": true,
        "builder_opt": null,
        "profiling_verbosity": "layer_names_only",
        "enable_debug_output": false,
        "max_draft_len": 0,
        "speculative_decoding_mode": 1,
        "use_refit": false,
        "input_timing_cache": null,
        "output_timing_cache": "model.cache",
        "lora_config": {
            "lora_dir": [],
            "lora_ckpt_source": "hf",
            "max_lora_rank": 64,
            "lora_target_modules": [],
            "trtllm_modules_to_hf_modules": {}
        },
        "auto_parallel_config": {
            "world_size": 1,
            "gpus_per_node": 8,
            "cluster_key": "H100-PCIe",
            "cluster_info": null,
            "sharding_cost_model": "alpha_beta",
            "comm_cost_model": "alpha_beta",
            "enable_pipeline_parallelism": false,
            "enable_shard_unbalanced_shape": false,
            "enable_shard_dynamic_shape": false,
            "enable_reduce_scatter": true,
            "builder_flags": null,
            "debug_mode": false,
            "infer_shape": true,
            "validation_mode": false,
            "same_buffer_io": {
                "past_key_value_(\\d+)": "present_key_value_\\1"
            },
            "same_spec_io": {},
            "sharded_io_allowlist": [
                "past_key_value_\\d+",
                "present_key_value_\\d*"
            ],
            "fast_reduce": true,
            "fill_weights": false,
            "parallel_config_cache": null,
            "profile_cache": null,
            "dump_path": null,
            "debug_outputs": []
        },
        "weight_sparsity": false,
        "weight_streaming": false,
        "plugin_config": {
            "dtype": "float16",
            "bert_attention_plugin": "auto",
            "gpt_attention_plugin": "auto",
            "gemm_plugin": "float16",
            "gemm_swiglu_plugin": null,
            "smooth_quant_gemm_plugin": null,
            "identity_plugin": null,
            "layernorm_quantization_plugin": null,
            "rmsnorm_quantization_plugin": null,
            "nccl_plugin": "float16",
            "lookup_plugin": null,
            "lora_plugin": null,
            "weight_only_groupwise_quant_matmul_plugin": null,
            "weight_only_quant_matmul_plugin": null,
            "quantize_per_token_plugin": false,
            "quantize_tensor_plugin": false,
            "moe_plugin": "auto",
            "mamba_conv1d_plugin": "auto",
            "context_fmha": true,
            "context_fmha_fp32_acc": false,
            "paged_kv_cache": true,
            "remove_input_padding": true,
            "use_custom_all_reduce": true,
            "reduce_fusion": false,
            "multi_block_mode": false,
            "enable_xqa": true,
            "attention_qk_half_accumulation": false,
            "tokens_per_block": 64,
            "use_paged_context_fmha": false,
            "use_fp8_context_fmha": false,
            "multiple_profiles": true,
            "paged_state": true,
            "streamingllm": false
        },
        "use_strip_plan": false,
        "max_encoder_input_len": 1024,
        "use_fused_mlp": false
    }
}

But when I load the model, I see this in the logs:

[TensorRT-LLM][INFO] TRTGptModel maxInputLen: 12287                                                                             
[TensorRT-LLM][INFO] TRTGptModel maxSequenceLen: 12288    

I am not sure what this is based on. It's possible that it's harmless...

Who can help?

@juney-nvidia

Information

Tasks

Reproduction

It's a documentation question.

Expected behavior

N/A

actual behavior

N/A

additional notes

N/A

hijkzzz commented 3 months ago

@kaiyux @QiJune could you help to comment on this issue?

hijkzzz commented 3 months ago

@DreamGenX Supported in https://github.com/NVIDIA/TensorRT-LLM/blob/2a115dae84f13daaa54727534daa837c534eceb4/tensorrt_llm/commands/build.py#L81 please use the latest main branch.