Skip to content

Commit 2c36283

Browse files
authored
fix: replace deprecated fractions.gcd with math.gcd (#7845)
## Bug `fractions.gcd` was deprecated in Python 3.5 and removed in Python 3.9. This causes an `AttributeError` on Python 3.9+. ## Fix Replaced `fractions.gcd` with `math.gcd` which is the standard replacement.
1 parent 72b9465 commit 2c36283

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

deepspeed/runtime/zero/stage3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def isclose(a, b, rtol=1e-09, atol=0.0):
6767

6868

6969
def lcm(x, y):
70-
from fractions import gcd # or can import gcd from `math` in Python 3
70+
from math import gcd
7171
return x * y // gcd(x, y)
7272

7373

deepspeed/runtime/zero/stage_1_and_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def isclose(a, b, rtol=1e-09, atol=0.0):
7676

7777

7878
def lcm(x, y):
79-
from fractions import gcd # or can import gcd from `math` in Python 3
79+
from math import gcd
8080
return x * y // gcd(x, y)
8181

8282

0 commit comments

Comments
 (0)