Add genie_overrides to QairtEncapsulation for GenAIConfig customization#2469
Draft
qti-kromero wants to merge 1 commit into
Draft
Conversation
Introduce a genie_overrides PassConfigParam that deep-merges user-supplied fields into the GenAIConfig before LLMContainer.export() bakes them into the Genie DLC. This allows callers to override any GenAIConfig field (engine config, positional encoding, etc.) without modifying QairtGenAIBuilder or QairtPipelinePass. Nested dicts are merged recursively so only the specified keys are changed; all other values set by the upstream builder pass are preserved.
| container: qairt_genai.LLMContainer = qairt_genai.LLMContainer.load(model.model_path) | ||
|
|
||
| if config.genie_overrides: | ||
| gen_ai_cfg = container._gen_ai_config |
| gen_ai_cfg = container._gen_ai_config | ||
| current = gen_ai_cfg.model_dump(mode="json", by_alias=False, exclude_none=True) | ||
| merged = _deep_merge(current, config.genie_overrides) | ||
| container._gen_ai_config = gen_ai_cfg.model_validate(merged) |
| "kv_dim": None, | ||
| "positional_encoding": {"type": "rope", "rope_dim": 64}, | ||
| } | ||
| mock_container._gen_ai_config.model_dump.return_value = initial_gen_ai_state |
| encap_pass.run(mock_qairt_model, str(output_path)) | ||
|
|
||
| # model_dump was called to capture current state | ||
| mock_container._gen_ai_config.model_dump.assert_called_once_with(mode="json", by_alias=False, exclude_none=True) |
| "kv_dim": 128, | ||
| "positional_encoding": {"type": "rope", "rope_dim": 64, "rope_theta": 500000.0}, | ||
| } | ||
| mock_container._gen_ai_config.model_validate.assert_called_once_with(expected_merged) |
| mock_container._gen_ai_config.model_validate.assert_called_once_with(expected_merged) | ||
| # _gen_ai_config was reassigned to the validated result | ||
| assert ( | ||
| mock_container._gen_ai_config |
| # _gen_ai_config was reassigned to the validated result | ||
| assert ( | ||
| mock_container._gen_ai_config | ||
| is not mock_qairt_modules["gen_ai_api"].LLMContainer.load.return_value._gen_ai_config |
|
|
||
| encap_pass.run(mock_qairt_model, str(output_path)) | ||
|
|
||
| mock_container._gen_ai_config.model_dump.assert_not_called() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a genie_overrides PassConfigParam that deep-merges user-supplied fields into the GenAIConfig before LLMContainer.export() bakes them into the Genie DLC. This allows callers to override any GenAIConfig field (engine config, positional encoding, etc.) without modifying QairtGenAIBuilder or QairtPipelinePass.
Nested dicts are merged recursively so only the specified keys are changed; all other values set by the upstream builder pass are preserved.
Describe your changes
Checklist before requesting a review
lintrunner -a(Optional) Issue link