Skip to content

Conversation

@venkywonka
Copy link
Collaborator

@venkywonka venkywonka commented Jul 1, 2025

  • Add basic PR auto-assign action
  • Add more entries into the module-owners.json, create another module-paths.json to map repo paths to modules
  • Make it respect CODEOWNERS and explicit manual overrides
  • Add knobs in script to force-assign and dry-run
  • Add comprehensive testing
  • Verify manually with PRs to a seperate experimental branch ([test] [mock] touch various files and check if correctly auto-assigns reviewers #5626, [mock] Testing the auto-assign PR functionality #5725)
  • Add a short section in CONTRIBUTING.md
  • Add helpful logging when file changes correspond to no pre-mapped modules/module-owners (and corresponding tests)
  • Add functionality to sample upto PER_MODULE_REVIEWER_LIMIT for each module touched by the PR.
  • Makes sure if there are overlapping modules for a given changed file, only the most specific module-owner is taken.

@venkywonka venkywonka changed the base branch from main to user/venky/auto-assign-pr-test July 1, 2025 01:19
@venkywonka venkywonka changed the base branch from user/venky/auto-assign-pr-test to main July 1, 2025 01:19
@venkywonka venkywonka force-pushed the user/venky/auto-assign-pr-test branch from aa6184e to 0cc40e7 Compare July 2, 2025 02:42
@venkywonka venkywonka marked this pull request as ready for review July 2, 2025 02:43

This comment was marked as outdated.

Copy link
Collaborator Author

@venkywonka venkywonka Jul 2, 2025

Choose a reason for hiding this comment

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

picked up these module-owners mappings from this internal google sheet

@venkywonka venkywonka self-assigned this Jul 2, 2025
@venkywonka venkywonka added Infra <NV>automated tests, build checks, github actions, system stability & efficiency. Ease of Use Items about improving or complaints about TRTLLM ease of use labels Jul 2, 2025
Comment on lines +43 to +44
# Get team reviewers
team_result = subprocess.run(
Copy link
Collaborator

Choose a reason for hiding this comment

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

For team reviewers, it would probably be helpful to randomly assign one reviewer in the team. That may also help automate the round-robin-style review balancing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i believe the CODEOWNERS already does this tyler, my action does not deal with the github teams (although the same information is present in module-owners.json)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think so: GitHub assigns the whole team as a reviewer when the team is in the CODEOWNERS list, and then GitHub optionally sends a email notification to the whole team when the team is assigned as a reviewer. I'm not aware of any built-in mechanism to send a notification to a single person in that team.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it might even be appropriate to replace each team reviewer with a single person in the team. The CODEOWNERS requirement would still allow any member of the team to approve.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can leave that as a future improvement if you'd prefer, I'll approve this MR for now

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I didn't realize this setting existed; I suppose each team can decide how they want to balance their own reviews this way. The built-in teams probably would be sufficient instead of this action if we were able to mix required and not-required CODEOWNERS.

Copy link
Collaborator Author

@venkywonka venkywonka Jul 11, 2025

Choose a reason for hiding this comment

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

but imagine a scenario where the CODEOWNERS has very specific module mappings, each with a team/individual. If a PR touches multiple of these, then all these teams will get tagged as required codeowner approvals. It is possible that some module-mappings are so specific that its probably just 1-2 people. And they will effectivley block the approval and merge of the PR.
If the person that's randomly selected by the CODEOWNER routing algorithm happens to be OOTO, then i believe it will block the merge too as the PR author won't have the ability to remove such a person.

but the github action can alleviate that.
It does seem like a trade-off between getting specific module-owner mappings vs not imposing too many codeowner-approvals. Ideally a "coarse" CODEOWNERS and a "fine" github action would be the balance right?

the above assumes that the CODEOWNERS-enabled assignments are rigid (and hence blocking).

What do you think @tburt-nv ? also tagging @juney-nvidia @zeroepoch @kevinch-nv @atrifex @hlu1 @MartinMarciniszyn

Copy link
Collaborator

@kevinch-nv kevinch-nv Jul 11, 2025

Choose a reason for hiding this comment

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

If the person that's randomly selected by the CODEOWNER routing algorithm happens to be OOTO, then i believe it will block the merge too as the PR author won't have the ability to remove such a person.

Other members of the team in that case can still be manually assigned to the PR after the fact and their approval would unblock the PR.

It comes down to what the goals are for enforcing reviews and approvals.

  1. If the goal is that module owners must explicitly approve every PR that touches their module, then using CODEOWNERs is the better solution since Github has built-in options requiring their approval, and we can guarantee the right individual or team is auto-assigned per PR.
  2. If module owner approval is optional, then it makes sense to have this system in place to auto-assign a few reviewers for visibility on changes, as IIRC no default reviewers are assigned if the code changes are outside the limited modules covered in CODEOWNERs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I thought I had already resolved this thread. I'm personally ok with the flexibility of maintaining both the required CODEOWNERs with native GitHub features and the optional module-owners.json with this script. I only wish GitHub supported both natively.

Copy link
Collaborator Author

@venkywonka venkywonka Jul 12, 2025

Choose a reason for hiding this comment

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

Thanks @kevinch-nv / @tburt-nv .
@kevinch-nv , with regards to the 2 goals you detailed above, i believe we should lean towards (1) over (2).

So that means the module-owners must explicitly approve every PR (atleast 1 of them) that touches their module. This can potentially blow up the required approvals (like in this PR you mentioned), but that's okay/necessary.

BUT if, for any reason, none of the module owners of specific CODEOWNERS rule/mapping are available for approval, we'll need an unblocking mechanism.
And I believe that is an override-approval by an administrator. I think that's okay, because the likelihood that none of the owners inside a team is available is very low, and in such a case we anyway should not ignore it.


I should also correct my original comment - the auto-routing done per-team, when the team is pulled by the CODEOWNERS for a particular change, does respect OOTO/Busy statuses (here).

so, if the following things are done properly, CODEOWNERS + team settings are alone enough:

  1. CODEOWNERS is fleshed out carefully, with the module-mappings in the right heirarchical order: This means more-specific paths come below less-specific ones. (/tensorrt_llm/_torch/, followed by /tensorrt_llm/_torch/models/ followed by /tensorrt_llm/_torch/models/modeling_qwen3.py )
  2. Appropriate granularity of github teams need to be created, by expanding existing teams. For example, @NVIDIA/trt-llm-torch-devs maps to /tensorrt_llm/_torch, but we need another @NVIDIA/trt-llm-torch-custom-ops-devs created as child team to @NVIDIA/trt-llm-torch-devs. This means for the /tensorrt_llm/_torch/custom_ops files, @NVIDIA/trt-llm-torch-devs need not be spammed.
  3. To avoid notifying all of the members of the coarser github teams (like @NVIDIA/trt-llm-torch-devs, ~23 members), we need to enable auto-routing and notifying only 1-2 people from that team (in a load-balanced way).
  4. In mappings where one needs to notify an individual, but not necessarily be blocked by that person, one should include both the teams + individuals to take advantage of notifying reviewers in a specific + randomized way:
/tensorrt_llm/_torch/modules/fused_moe.py @hlu1 @dongxuy04 @zongfeijing @HuiGao-NV @NVIDIA/trt-llm-torch-devs

I have another draft PR #5977 that expands CODEOWNERS, but basically takes care of the ordering and heirarchy, but maintains the same coverage as @kevinch-nv 's reverted #4105 . I think that should be a good starting point.

@venkywonka venkywonka force-pushed the user/venky/auto-assign-pr-test branch from 0cc40e7 to 63339cd Compare July 3, 2025 17:14
@venkywonka
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #10878 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #10878 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #8041 completed with status: 'FAILURE'

@venkywonka venkywonka force-pushed the user/venky/auto-assign-pr-test branch from 87c4ea9 to c0e3ec0 Compare July 7, 2025 15:00
@venkywonka
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #11161 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #11161 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #8254 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.


# Get modules and reviewers for module-mapped files
modules = get_modules_from_files(module_files, module_paths)
reviewers, modules_without_owners = get_reviewers_for_modules(
Copy link
Collaborator

Choose a reason for hiding this comment

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

From my understanding of this code, all the reviewers for all the modules are placed in a set and randomly chosen.
If that's the case, it's possible that the final chosen reviewers do not span all the modules, thus leading to potential missed coverage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yea that is correct, it is a risk because choosing a reviwer randomly per-module can be done but might exceed reviewer_limit if the modules touched are arbitrarily high - and that will anyways cause missed coverage.

i guess instead of having a coarse reviewer_limit, we can have a per-module reviewer_limit (maybe 2?) so we ensure module coverage and yet stick to an upper bound.

i can include that in this PR too, does the above make sense @kevinch-nv ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

These are just review assignments that doesn't block merge right? In that case can we make sure that at least one person from each module is assigned?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

have resolved this in the latest push. now we have a per_module_reviewer_limit and ensures module coverage (that accounts for overlapping module-owners and overlapping modules)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

have verified it works with this comment

@venkywonka venkywonka force-pushed the user/venky/auto-assign-pr-test branch from c0e3ec0 to 2597ad5 Compare July 8, 2025 21:45
@venkywonka venkywonka requested a review from kevinch-nv July 8, 2025 21:47
@venkywonka venkywonka requested review from Copilot and tburt-nv July 8, 2025 21:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a GitHub Action and supporting scripts to automatically assign PR reviewers based on module ownership, while respecting CODEOWNERS and manual overrides.

  • Adds assign_reviewers.py script with module-paths and module-owners JSON mappings
  • Defines a auto-assign-reviewers.yml workflow with dry-run and force-assign options
  • Updates documentation and adds end-to-end tests covering various assignment scenarios

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CONTRIBUTING.md New section describing the auto-assignment feature
.github/module-paths.json New mapping of repository paths to logical modules
.github/module-owners.json New mapping of modules to owner lists
.github/workflows/module-owners.json Extended list of module owners for CI workflows
.github/workflows/auto-assign-reviewers.yml Workflow definition for automatic reviewer assignment
.github/scripts/assign_reviewers.py Script to detect changed files, map modules, and assign reviewers
.github/scripts/tests/test_assign_reviewers.py Comprehensive tests for assign_reviewers.py
Comments suppressed due to low confidence (2)

.github/workflows/auto-assign-reviewers.yml:6

  • The workflow_dispatch inputs block does not include an input for pr_author, but the script relies on PR_AUTHOR. Consider adding a pr_author input or using github.actor to populate the PR author in manual dispatch.
    inputs:

CONTRIBUTING.md:108

  • The docs mention REVIEWER_LIMIT but the code and workflow use PER_MODULE_REVIEWER_LIMIT. Update the documentation to reference the correct environment variable name.
* **Limits reviewer count**: Randomly samples up to 3 reviewers if more are eligible (configurable via `REVIEWER_LIMIT`)


# Log if there were multiple matches (for debugging)
if len(matches) > 1:
matches[0][1]
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

This standalone expression is a no-op and appears to be leftover debugging code. It can be removed to improve readability.

Suggested change
matches[0][1]

Copilot uses AI. Check for mistakes.
@venkywonka
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #11359 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #11359 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #8407 completed with status: 'SUCCESS'

Copy link
Collaborator

@poweiw poweiw left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +43 to +44
# Get team reviewers
team_result = subprocess.run(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can leave that as a future improvement if you'd prefer, I'll approve this MR for now

- Add logic to check existing reviewers before assignment
- Skip auto-assignment if reviewers already exist (unless --force-assign)
- Improve logging and error handling with status messages
- Add force-assign option for manual override
- Switch back to pull_request trigger for proper access
- Fix workflow parameter handling for force_assign option

Signed-off-by: Venky Ganesh <[email protected]>
Add comprehensive documentation about the GitHub action for automatic
PR reviewer assignment, including its behavior with CODEOWNERS,
module-based assignment, and existing reviewer respect.

Signed-off-by: Venky Ganesh <[email protected]>
- Replace broad 'CI/CD' with 5 granular modules
- Separate test concerns from pipeline logic
- Move module-owners.json to .github/ for consistency

Signed-off-by: Venky Ganesh <[email protected]>
…s and modules

- Modified map_modules() to return both modules and unmapped files
- Enhanced gather_reviewers() to track modules without owners
- Added comprehensive feedback when no reviewers are assigned:
  - Warns about files with no module mapping
  - Warns about modules with no owners
  - Explains specific reasons for no assignment
  - Provides actionable guidance for fixing coverage gaps
- Updated test cases to cover new functionality
- Added test cases for unmapped files and modules without owners

Signed-off-by: Venky Ganesh <[email protected]>
@venkywonka venkywonka force-pushed the user/venky/auto-assign-pr-test branch from 2597ad5 to bb53b5b Compare July 11, 2025 00:35
@venkywonka
Copy link
Collaborator Author

closing this as auto-assignment has been taken care of by CODEOWNERS itself.

@venkywonka venkywonka closed this Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ease of Use Items about improving or complaints about TRTLLM ease of use Infra <NV>automated tests, build checks, github actions, system stability & efficiency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants