Skip to content

Conversation

@ShangkunLi
Copy link
Collaborator

@ShangkunLi ShangkunLi commented Jul 11, 2025

In this pr, we add the following features to enable backtrack mapping. And we can achieve CompiledII = 4 for branch_for.mlir now.

  • Enable choosing different mapping strategies using the command line. e.g., --map-to-accelerator="mapping-strategy=backtrack_mapping"

  • Support backtrack mapping. Users can specify some parameters in include/Mapping/BacktrackMapping/BacktrackMapping.h for this mapping strategy:

    1. max_location_to_try: The MAX number of candidate locations for each op to try.
    2. max_backtrack_depth: The MAX depth of backtrack.

TODO:

  • Fix the bug when handling functions with arguments. My initial plan is to create a neura.constant for each function argument.

Copy link
Contributor

@tancheng tancheng left a comment

Choose a reason for hiding this comment

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

Thanks for the awesome work~! I just have one concern:

The CGRA-mapper repo's heuristic is exactly your backtrackMap with max_location_to_try = All & max_backtrack_depth = 1, while its exhaustive is exactly your backtrackMap with max_location_to_try = All & max_backtrack_depth = All.

So for this repo, can we deprecate the current heuristic, but wrap your max_location_to_try = All & max_backtrack_depth = 1 as the new heuristic and treat your max_location_to_try = All & max_backtrack_depth = All as the new exhaustive?

@tancheng
Copy link
Contributor

Hi @ShangkunLi, re: #59

We didn't touch the placement tile selection, or prioritize anything related to utilization. This PR just enables backtrack and everything works as expected, right?

How many minutes we can get a valid mapping solution with your new algorithm? And how many times the location_to_try and backtrack_depth are updated (i.e., #times for backtracking)?

If it is fast enough, we can close that issue, instead, we can create new ones if compilation time is bottleneck in the future.

@ShangkunLi
Copy link
Collaborator Author

Hi @ShangkunLi, re: #59

We didn't touch the placement tile selection, or prioritize anything related to utilization. This PR just enables backtrack and everything works as expected, right?

How many minutes we can get a valid mapping solution with your new algorithm? And how many times the location_to_try and backtrack_depth are updated (i.e., #times for backtracking)?

If it is fast enough, we can close that issue, instead, we can create new ones if compilation time is bottleneck in the future.

I only added the backtracking functionality in this pr. The mapper can only map the former ~10 operations (most are neura.constant and grant_once/always) without triggering backtrack. And nearly all operations following need backtracking. So I think it's crucial to properly design the cost function.

For now, I set max_location_to_try = 5, and max_backtrack_depth = 3 in the mapper. The running time of mapping branch_for.mlir is about 14 seconds. It could be faster if we remove those debugging outputs, as they consume a lot of time.

@ShangkunLi
Copy link
Collaborator Author

Thanks for the awesome work~! I just have one concern:

The CGRA-mapper repo's heuristic is exactly your backtrackMap with max_location_to_try = All & max_backtrack_depth = 1, while its exhaustive is exactly your backtrackMap with max_location_to_try = All & max_backtrack_depth = All.

So for this repo, can we deprecate the current heuristic, but wrap your max_location_to_try = All & max_backtrack_depth = 1 as the new heuristic and treat your max_location_to_try = All & max_backtrack_depth = All as the new exhaustive?

Sure, will add it soon!

@ShangkunLi
Copy link
Collaborator Author

Thanks for the awesome work~! I just have one concern:
The CGRA-mapper repo's heuristic is exactly your backtrackMap with max_location_to_try = All & max_backtrack_depth = 1, while its exhaustive is exactly your backtrackMap with max_location_to_try = All & max_backtrack_depth = All.
So for this repo, can we deprecate the current heuristic, but wrap your max_location_to_try = All & max_backtrack_depth = 1 as the new heuristic and treat your max_location_to_try = All & max_backtrack_depth = All as the new exhaustive?

Sure, will add it soon!

In fact, in current heuristic, the max_location_to_try is also 1. If we set max_location_to_try = All & max_backtrack_depth = 1 as heuristic, we can also get an II=4, but the mapping time is ~30s.

Anyway, I will set max_location_to_try = All & max_backtrack_depth = 1 for new heuristic.

@ShangkunLi ShangkunLi marked this pull request as ready for review July 11, 2025 16:45
@tancheng tancheng added bug Something isn't working new feature New feature or request labels Jul 11, 2025
@ShangkunLi ShangkunLi merged commit bb79163 into coredac:main Jul 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants