Skip to content

[Unity][BYOC] Use arith.Analyzer to check batch equality of matmul in cublas#16982

Merged
tqchen merged 3 commits intoapache:mainfrom
rickzx:pr-cublas-equality
May 9, 2024
Merged

[Unity][BYOC] Use arith.Analyzer to check batch equality of matmul in cublas#16982
tqchen merged 3 commits intoapache:mainfrom
rickzx:pr-cublas-equality

Conversation

@rickzx
Copy link
Copy Markdown
Contributor

@rickzx rickzx commented May 8, 2024

For workloads with a mixture of symbolic shape and concrete shape as batch sizes, we cannot directly use int() to obtain the batch size. Instead, we can use arith.Analyzer to check equality.

For example:

permute_dims1: R.Tensor((batch_size, 12, seq_len, 64), dtype="float16") = R.permute_dims(split_0, axes=[0, 2, 1, 3])
permute_dims2: R.Tensor((batch_size, 12, seq_len, 64), dtype="float16") = R.permute_dims(split_1, axes=[0, 2, 1, 3])
permute_dims3: R.Tensor((batch_size, 12, seq_len, 64), dtype="float16") = R.permute_dims(split_2, axes=[0, 2, 1, 3])
permute_dims4: R.Tensor((batch_size, 12, 64, seq_len), dtype="float16") = R.permute_dims(permute_dims2, axes=[0, 1, 3, 2])
matmul1: R.Tensor((batch_size, 12, seq_len, seq_len), dtype="float16") = R.matmul(permute_dims1, permute_dims4, out_dtype="float16")

@rickzx
Copy link
Copy Markdown
Contributor Author

rickzx commented May 8, 2024

cc: @MasterJH5574

Copy link
Copy Markdown
Contributor

@MasterJH5574 MasterJH5574 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

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.

3 participants