Skip to content

[bug] --use_paged_context_fmha enable broken #2255

Closed as not planned
Closed as not planned

Description

@akhoroshev

My model is

{
    "mlp_bias": false,
    "attn_bias": false,
    "rotary_base": 300000,
    "rotary_scaling": null,
    "residual_mlp": false,
    "disable_weight_only_quant_plugin": false,
    "moe": {
        "num_experts": 0,
        "top_k": 0,
        "normalization_mode": null,
        "sparse_mixer_epsilon": 0.01,
        "tp_mode": 0
    },
    "remove_duplicated_kv_heads": false,
    "architecture": "LlamaForCausalLM",
    "dtype": "float16",
    "vocab_size": 42016,
    "hidden_size": 6656,
    "num_hidden_layers": 60,
    "num_attention_heads": 64,
    "hidden_act": "silu",
    "logits_dtype": "float32",
    "norm_epsilon": 1e-06,
    "position_embedding_type": "rope_gpt_neox",
    "max_position_embeddings": 32768,
    "num_key_value_heads": 16,
    "intermediate_size": 17920,
    "mapping": {
        "world_size": 1,
        "gpus_per_node": 8,
        "cp_size": 1,
        "tp_size": 1,
        "pp_size": 1,
        "moe_tp_size": 1,
        "moe_ep_size": 1
    },
    "quantization": {
        "quant_algo": null,
        "kv_cache_quant_algo": null,
        "group_size": 128,
        "smoothquant_val": 0.5,
        "clamp_val": null,
        "has_zero_point": false,
        "pre_quant_scale": false,
        "exclude_modules": null
    },
    "use_parallel_embedding": false,
    "embedding_sharding_dim": 0,
    "share_embedding_table": false,
    "head_size": 128,
    "qk_layernorm": false
}

When I build engine with command:

trtllm-build  \
--checkpoint_dir 1-gpu-tmp \
--output_dir 1-gpu \
--max_input_len 31744 \
--max_seq_len 32768 \
--max_num_tokens 4096 \
--max_batch_size 256 \
--gemm_plugin float16 \
--use_paged_context_fmha enable

All works fine.

But when I build engine with command

trtllm-build  \
--checkpoint_dir 1-gpu-tmp \
--output_dir 1-gpu \
--max_input_len 31744 \
--max_seq_len 32768 \
--max_num_tokens 32768 \
--max_batch_size 256 \
--gemm_plugin float16 \
--use_paged_context_fmha enable

NaN occurs in logits.

Key difference is --max_num_tokens value.

Behavior reproduces with all combination of runtime options enableBlockReuse(true/false) and enableChunkedContext(true/false) on Executor API 31ac30e928a

If I set --use_paged_context_fmha disable all works fine with --max_num_tokens 32768

Activity

  1. akhoroshev commented on Sep 26, 2024

    @akhoroshev
    ContributorAuthor

    looks like ctx attention when use_paged_context_fmha is enabled can produce NaN

  2. added
    bug
    on Oct 15, 2024
  3. added
    triaged
    on Oct 15, 2024
  4. added
    Customized kernels
    Testing
    on Sep 9, 2025
  5. karljang commented on Oct 6, 2025

    @karljang
    Collaborator

    Hi @akhoroshev ,
    Apologies for the very delayed response. I'm wondering if this issue is still relevant to you, and if it is, would you be able to try PyTorch backend instead?

  6. github-actions commented on Oct 21, 2025

    @github-actions

    Issue has not received an update in over 14 days. Adding stale label.

  7. github-actions commented on Nov 4, 2025

    @github-actions

    This issue was closed because it has been 14 days without activity since it has been marked as stale.

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

Metadata

Metadata

Assignees

Labels

Customized kernelsTestingbugstaletriagedwaiting for feedback

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions