Skip to content

Add support for test generation when manual test is provided#117

Open
Jack-Khuu wants to merge 6 commits intomainfrom
serial-tests
Open

Add support for test generation when manual test is provided#117
Jack-Khuu wants to merge 6 commits intomainfrom
serial-tests

Conversation

@Jack-Khuu
Copy link
Contributor

@Jack-Khuu Jack-Khuu commented Mar 7, 2026

tldr: Add support to still generate tests when a custom one is provided to TKA.generate_kernel.

Currently, when a custom test is provided, the pipeline does not attempt to generate an LLM test for the problem.
This is fine, but the generated testing is very useful to have even if there is a custom test (e.g. if the custom test is expensive to run or incomplete).

This PR adds support for generating this test via a generate_default_test flag.

  • To support this, the test_code signature throughout the repo needed to be updated from str to list[str]. Most of the files are changed, just change the type for test_code from str => list[str].

The only interesting changes are:

  • triton_kernel_agent/agent.py and triton_kernel_agent/worker.py
    When multiple tests are provided, code extraction will prefer the code block with kernel_function in it.
    Extraction is unchanged for single tests

  • triton_kernel_agent/worker_util.py
    Helper for formatting the additional tests as context

f"\n\n# === ADDITIONAL VALIDATION TEST {i + 1} "
            f"(for reference only — do NOT copy into your kernel) ===\n"

Note: this does not enable secondary tests for the Fuser path. This would require a separate effort as testing occurs only during composition which is after the sub-kernels have already been built

This use case will be used for integrating auxiliary testing (internally)


Tested internally via

result = agent.generate_kernel(
        problem_description=problem_description,
        test_code=submission_test_code,
        generate_default_test=True,
    )

result = agent.generate_kernel(
        problem_description=problem_description,
        test_code=submission_test_code,
        generate_default_test=False,
    )

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 7, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 9, 2026

@Jack-Khuu has imported this pull request. If you are a Meta employee, you can view this in D95858679.

Copy link
Contributor

@kaiming-cheng kaiming-cheng left a comment

Choose a reason for hiding this comment

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

Overall looks good! My comments is mainly on the design of using a list to store different test cases. Let me know what you think!

@kaiming-cheng kaiming-cheng self-requested a review March 10, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants