Skip to content

[Bug] Dataflow programming pass simulator test but fails at hw_emu test #572

@RuizeYu05

Description

@RuizeYu05

Describe the bug

When I try to implement systolic array based flashattention by dataflow programming in Allo. And I've already finished the following computation all in a single systolic array.

  1. Score computation (Matrix Multiplication):
    $$S = A B^T$$

  2. Row-wise maximum for numerical stability:
    $$m_i = \max_j (S_{ij})$$

  3. Scaled exponential (with max-shifting):
    $$P_{ij} = \exp\left((S_{ij} - m_i) \cdot D\right)$$

  4. Row-wise sum (Denominator):

$$\mathrm{Sum}_i = \sum_{j} P_{ij}$$

And these computation can both pass simulator and hw_emu tests.

However, after I added the following logic, the systolic array passes simulator tests and fails at hw_emu test. The output matrix O is all zeros.
5. Final Output computation:
$$O = P V$$

Reproduction

My test code is https://github.com/RuizeYu05/FlashAttention-allo/blob/main/systolic/test_systolic_flash_debug.py
(In order to do software simulator test, I mark the allo.exp in above code. The fully implemented code is https://github.com/RuizeYu05/FlashAttention-allo/blob/main/systolic/test_weight_sta_exp.py)

Buggy output

The following page shows software simulator can pass:
Image

The following page shows the output of hw_emu test:
Image

Expected behavior

Since this systolic array can pass software simulator test, it should also pass hw_emu test.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions