Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIR]Fix optional output error when input is none #60269

Merged
merged 1 commit into from
Dec 25, 2023

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented Dec 22, 2023

PR types

Bug fixes

PR changes

Others

Description

修复optional 输出的bug,以masked_multihead_attention_为例

- op : masked_multihead_attention_
  args : (Tensor x, Tensor cache_kv, Tensor bias, Tensor src_mask, Tensor cum_offsets, Tensor sequence_lengths, Tensor rotary_tensor, Tensor beam_cache_offset, Tensor qkv_out_scale, Tensor out_shift, Tensor out_smooth, int seq_len, int rotary_emb_dims, bool use_neox_rotary_style=false, str compute_dtype = "default", float out_scale=-1, int quant_round_type=1, float quant_max_bound=127.0, float quant_min_bound=-127.0)
  output : Tensor(out), Tensor(cache_kv_out), Tensor(beam_cache_offset_out)
  infer_meta :
    func : MaskedMultiheadAttentionInferMeta
  kernel :
    func : masked_multihead_attention
    data_type : x
  optional : bias, src_mask, cum_offsets, sequence_lengths, rotary_tensor, beam_cache_offset, qkv_out_scale, out_shift, out_smooth
  inplace : (cache_kv -> cache_kv_out), (beam_cache_offset -> beam_cache_offset_out)

第三个输出beam_cache_offset_out是optional的,它会和输入beam_cache_offset做inplace,输入beam_cache_offset是optional 的,当输入beam_cache_offset为None时,执行器会报错。在此PR中对这种情况做了处理,当beam_cache_offset为None时,将beam_cache_offset_out的type设置为null type。会在API内生成类似下面的代码

  if (!beam_cache_offset) {
    masked_multihead_attention__op.result(2).set_type(pir::Type());
  }

Pcard-67164

@0x45f 0x45f merged commit 1468a0a into PaddlePaddle:develop Dec 25, 2023
29 checks passed
@0x45f 0x45f deleted the pir-fix-optional-output branch December 25, 2023 06:12
Wanglongzhi2001 pushed a commit to Wanglongzhi2001/Paddle that referenced this pull request Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants