bytedance / lightseq

LightSeq: A High Performance Library for Sequence Processing and Generation
Other
3.19k stars 329 forks source link

Possible memory leak in DecSelfAttentionLayer #443

Open Kangmo opened 1 year ago

Kangmo commented 1 year ago

The constructor creates new objects without shared_ptrs, but the destructor is empty.

In cpp:

DecSelfAttentionLayer<T1, T2>::DecSelfAttentionLayer(
    int layer_id, int max_batch_tokens, int max_seq_len, int hidden_size,
    int num_heads, float attn_prob_dropout_ratio,
    float hidden_output_dropout_ratio, bool pre_or_postLayerNorm,
    bool is_post_ln, bool is_continuous_cache)
    : Layer("DecSelfAttentionLayer"),  // necessary
      _layer_id(layer_id),
      _max_batch_tokens(max_batch_tokens),

     ..............................
      // operators
      _attn_ln(
          new LayerNormalizeOp<T1, T2>(max_batch_tokens, hidden_size, false)),

In header: virtual ~DecSelfAttentionLayer() {}

Not sure if this is by design or missing delete calls in the destructor.

hexisyztem commented 1 year ago

Yes, the new version of the architecture has not yet completed the entire development. There may be some logic loopholes in the process of ending the program and destructing. We expect to complete the repair before February. By the way, the management of GPU memory is uniformly held by the MemoryManager module. https://github.com/bytedance/lightseq/blob/master/lightseq/csrc/lsflow/manager.cpp

Kangmo commented 1 year ago

got it, thanks! will see the MemoryManager module.