Skip to content

Fix EPContext node referencing MXR files that are never written - #69

Open
ivarusic-amd wants to merge 4 commits into
mainfrom
fix_epcontext_mxr_cache_dir
Open

Fix EPContext node referencing MXR files that are never written#69
ivarusic-amd wants to merge 4 commits into
mainfrom
fix_epcontext_mxr_cache_dir

Conversation

@ivarusic-amd

@ivarusic-amd ivarusic-amd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

When ep.context_enable was set without cache_dir (or with disable_caching), the generated EPContext node referenced/embedded a .mxr file that the EP never actually saved to disk, breaking the model on load. Default the cache directory to context_file_path's or the model's directory in that case, always persist the .mxr when context_enable is on, and fail fast instead of emitting a broken node when the graph has dynamic input shapes.

Is defaulting to the original model's directory (rather than erroring out) the right last resort, or should we require the user to set at least one of cache_dir/context_file_path explicitly when context_enable=1?
Should context_enable=1 on a dynamic-input-shape graph hard-fail?

NOTE : need to retest if everything else stays unchanged before merge

…tten

When ep.context_enable was set without cache_dir (or with disable_caching),
the generated EPContext node referenced/embedded a .mxr file that the EP
never actually saved to disk, breaking the model on load. Default the
cache directory to context_file_path's or the model's directory in that
case, always persist the .mxr when context_enable is on, and fail fast
instead of emitting a broken node when the graph has dynamic input shapes.
urpetkov-amd
urpetkov-amd previously approved these changes Jul 29, 2026
@urpetkov-amd

Copy link
Copy Markdown
Collaborator

LGTM

@TedThemistokleous TedThemistokleous left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall looks good just need to update comment to represent new state regarding the added dynamic batch functionality using the ORT flags

Comment thread src/migraphx/mgx_ep.cc Outdated
"ep.context_enable is set but the graph has dynamic input shapes at compile time; "
"MIGraphX EP cannot produce a single MXR cache file up front for this subgraph. "
"Provide static input shapes (or fix the shapes before session creation) to use "
"EPContext model generation with the MIGraphX EP.");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With the hip graph and recent changes, we do support dynamic batching currently by leveraging MXR files. We should update this to represent that path forward should the user request dynamic batch and the ORT_MIGRPAHX_USE_SPECIFIC_BATCH or ORT_MIGRAPHX_MAX_DYNAMIC_BATCH are set

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I updated it; feel free to change it if i missunderstood somehting

@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ivarusic-amd
ivarusic-amd force-pushed the fix_epcontext_mxr_cache_dir branch from 712eb97 to 299aa4b Compare July 30, 2026 12:56
@ivarusic-amd
ivarusic-amd marked this pull request as ready for review July 31, 2026 09:22
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.

4 participants