lightseq icon indicating copy to clipboard operation
lightseq copied to clipboard

Possible memory leak in DecSelfAttentionLayer

Open Kangmo opened this issue 2 years ago • 2 comments

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.

Kangmo avatar Dec 27 '22 13:12 Kangmo

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

hexisyztem avatar Dec 28 '22 09:12 hexisyztem

got it, thanks! will see the MemoryManager module.

Kangmo avatar Jan 05 '23 15:01 Kangmo