Skip to content

Conversation

Eric-Wei-10
Copy link
Contributor

Implement a gpu health check script, including:

  • Testing communication within tp/pp/dp subgroups.
  • Testing GPU hareward information
  • Testing GPU calculation functionality

@Eric-Wei-10 Eric-Wei-10 requested a review from a team as a code owner September 3, 2025 09:41
@aoyulong
Copy link
Contributor

aoyulong commented Sep 5, 2025

@gemini-code-assist, please review this pr in details

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a GPU health check script. The script is well-structured and covers communication, hardware, and calculation tests. I've identified a few areas for improvement, including removing duplicated code, correcting a misleading help message and an error message, and refactoring a function to reduce code duplication. These changes will improve the script's clarity and maintainability.

Comment on lines +275 to +276
rank = dist.get_rank()
device = torch.device(f'cuda:{rank % torch.cuda.device_count()}')
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These lines are duplicates of lines 272-273 and can be removed to avoid redundancy.

'--tensor-model-parallel-size',
type=int,
default=1,
help='Degree of pipeline model parallelism.',
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The help message for --tensor-model-parallel-size is incorrect and seems to be a copy-paste from --pipeline-model-parallel-size. It should describe tensor model parallelism to avoid confusion.

Suggested change
help='Degree of pipeline model parallelism.',
help='Degree of tensor model parallelism.',

result2 = torch.inverse(c)

if torch.any(torch.isnan(result1)) or torch.any(torch.isnan(result2)):
print(f"test_calculation_float failed: nan detected in iteration {iteration}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The error message here incorrectly states that test_calculation_float failed. It should be test_calculation_endurance to provide accurate information for debugging.

Suggested change
print(f"test_calculation_float failed: nan detected in iteration {iteration}")
print(f"test_calculation_endurance failed: nan detected in iteration {iteration}")

Comment on lines +498 to +526
args = get_args()

result = test_calculation_float()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_float", result_tensor)

result = test_calculation_double()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_double", result_tensor)

result = test_calculation_half()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_half", result_tensor)

result = test_calculation_endurance()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_endurance", result_tensor)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for running each calculation test and checking the result is repeated four times. This can be refactored into a loop to reduce code duplication and improve maintainability.

Suggested change
args = get_args()
result = test_calculation_float()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_float", result_tensor)
result = test_calculation_double()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_double", result_tensor)
result = test_calculation_half()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_half", result_tensor)
result = test_calculation_endurance()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result("test_calculation_endurance", result_tensor)
args = get_args()
calculation_tests = {
"test_calculation_float": test_calculation_float,
"test_calculation_double": test_calculation_double,
"test_calculation_half": test_calculation_half,
"test_calculation_endurance": test_calculation_endurance,
}
for test_name, test_func in calculation_tests.items():
result = test_func()
result_tensor = torch.zeros(args.world_size).cuda()
result_tensor[args.rank] = 1.0 if result else 0.0
dist.all_reduce(result_tensor, dist.ReduceOp.SUM)
if args.rank == 0:
check_test_result(test_name, result_tensor)

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