Skip to content

Add context_lengths option to QairtGenAIBuilder#2505

Merged
shaahji merged 3 commits into
microsoft:mainfrom
CodeLinaro:dev/qti-kromero/qairt-genai-custom-cl-list
Jun 11, 2026
Merged

Add context_lengths option to QairtGenAIBuilder#2505
shaahji merged 3 commits into
microsoft:mainfrom
CodeLinaro:dev/qti-kromero/qairt-genai-custom-cl-list

Conversation

@qti-kromero

@qti-kromero qti-kromero commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

Introduces a context_lengths parameter to QairtGenAIBuilder that allows users to specify an explicit list of context lengths (CLs) to compile for HTP backends.

This provides fine-grained control over which context-length binaries are produced, as an alternative to the fixed CL set generated by multi_graph. The two options are mutually exclusive.

Usage:

"qgab": {
    "type": "QairtGenAIBuilder",
    "backend": "HTP",
    "context_lengths": [512, 1024, 2048, 3072, 4096, 6144, 8192, 10240, 13312, 16384]
}

Sets arn_cl_options.context_length directly on the underlying GenAI builder when provided, bypassing the multi_graph path.

Checklist before requesting a review

  • I have added unit tests for the new parameter
  • All tests pass locally
  • I have updated relevant documentation/descriptions
  • I have run linting

@qti-kromero qti-kromero changed the title Dev/qti kromero/qairt genai custom cl list Add context_lengths option to QairtGenAIBuilder Jun 8, 2026
Introduces a context_lengths parameter that allows users to specify an
explicit list of context lengths (CLs) to compile, bypassing the fixed
CL set produced by multi_graph. The two options are mutually exclusive.
Like multi_graph, context_lengths is HTP-only.

Sets arn_cl_options.context_length directly on the builder when provided,
falling through to the existing multi_graph path otherwise.
@qti-kromero qti-kromero force-pushed the dev/qti-kromero/qairt-genai-custom-cl-list branch from c74cd36 to 4deb92a Compare June 10, 2026 20:42
@qti-kromero qti-kromero marked this pull request as ready for review June 10, 2026 20:44
Copilot AI review requested due to automatic review settings June 10, 2026 20:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for explicitly specifying context length combinations for Qairt GenAI compilation, with validation and tests to ensure it’s HTP-only and mutually exclusive with multi_graph.

Changes:

  • Added context_lengths pass config parameter (default None) and updated multi_graph description to reflect mutual exclusivity.
  • Enforced validation rules: context_lengths is HTP-only and cannot be used with multi_graph.
  • Updated builder run logic to set arn_cl_options.context_length when context_lengths is provided, and added unit tests for the new behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
test/passes/qairt/test_gen_ai_builder.py Adds tests for context_lengths config behavior and validation rules.
olive/passes/qairt/gen_ai_builder.py Introduces context_lengths config, validates it, and wires it into the builder config.

Comment thread olive/passes/qairt/gen_ai_builder.py
Comment thread olive/passes/qairt/gen_ai_builder.py
Comment thread olive/passes/qairt/gen_ai_builder.py
Comment thread test/passes/qairt/test_gen_ai_builder.py Outdated
@shaahji

shaahji commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Please resolve all Copilot conversations.

Attribute assignment on MagicMock does not appear in mock_calls, so the
previous string-matching assertion was vacuously passing. Replace with
PropertyMock + patch.object so the setter is actually tracked.
@qti-kromero

Copy link
Copy Markdown
Contributor Author

@shaahji copilot comments are resolved

patch.object requires the attribute to already exist on the class;
plain MagicMock has no multi_graph attribute. Create a unique subclass
per test so type(mock_builder) is isolated, then attach PropertyMock
directly to track setter calls correctly.
@qti-kromero

Copy link
Copy Markdown
Contributor Author

@shaahji sorry, fixed CI unit test failure - should succeed now

@shaahji shaahji merged commit 491cd7f into microsoft:main Jun 11, 2026
19 checks passed
@shaahji shaahji mentioned this pull request Jun 11, 2026
5 tasks
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