Skip to content

[Issue]: Dead code in FmoeTuner.get_1stage_fmoe_func: unreachable elif branch and incorrect logical operator. #1391

@antsaukk

Description

@antsaukk

Problem Description

In the file aiter/hsa/gfx942/fmoe_2stages/tune.py, FmoeTuner.get_1stage_fmoe_func, the following branch appears to be dead code:

elif (q_dtype_a == dtypes.fp8) & doweight_stage1:
    fmoe_func = FmoeTuner.run_1stage_fmoe_g1u1_tkw1

due to the condition in preceding if statement:

if (
    quant_type == QuantType.No and activation == ActivationType.Silu and not isG1U1
    or doweight_stage1
    or quant_type == QuantType.per_1x32
):

The doweight_stage1 evaluating to True will always trigger the if block, so the else and subsequent elif can never be reached.

In addition to that, elif (q_dtype_a == dtypes.fp8) & doweight_stage1: uses bitwise and operator, which might happen to work fine, but perhaps not is intended to be used in this case since there is no bitwise AND comparison. Instead, and could be used.

Suggestion fix:
Either the unreachable elif branch should be removed, or the preceding if condition should be adjusted so that elif branch could be reached.
Also, & should be considered for replacement with and for clarity in boolean expressions.

Operating System

Any

CPU

Any

GPU

Any

ROCm Version

Any

ROCm Component

No response

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions