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

Fix row parallel lora layers parameters initialization bug #9427

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

will-jl944
Copy link

PR types

Bug fixes

PR changes

Models

Description

Fix the bug that in row-parallel LoRA layers, without get_rng_state_tracker().rng_state() specified, shards of LoRA A are initialized identically among all devices in MP group. Please refer to how the parameter is initialized in paddle.distributed.fleet.meta_parallel.RowParallelLinear.

Copy link

paddle-bot bot commented Nov 14, 2024

Thanks for your contribution!

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.

Project coverage is 52.91%. Comparing base (018b530) to head (4892fff).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
paddlenlp/peft/lora/lora_layers.py 18.18% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9427      +/-   ##
===========================================
+ Coverage    52.82%   52.91%   +0.09%     
===========================================
  Files          676      676              
  Lines       107910   107926      +16     
===========================================
+ Hits         57001    57107     +106     
+ Misses       50909    50819      -90     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

lugimzzz
lugimzzz previously approved these changes Nov 14, 2024
Copy link
Contributor

@lugimzzz lugimzzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 202 to 204
if self.is_mp and paddle.in_dynamic_mode():
with get_rng_state_tracker().rng_state():
self.lora_A = self.create_parameter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要写两个if else 代码太冗余了, 直接 import contextlib ctx = contextlib.nullcontext() if xxx else get_rng_state_tracker().rng_state()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

JunnYu
JunnYu previously approved these changes Nov 15, 2024
Copy link
Member

@JunnYu JunnYu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

4 participants