Skip to content

[AIMIGRAPHX-1100] Add no-rebuild callback for verify - #5067

Draft
eddieliao wants to merge 10 commits into
developfrom
verify_callback
Draft

[AIMIGRAPHX-1100] Add no-rebuild callback for verify#5067
eddieliao wants to merge 10 commits into
developfrom
verify_callback

Conversation

@eddieliao

Copy link
Copy Markdown
Contributor

Motivation

Technical Details

Changelog Category

Add a CHANGELOG.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

Follow the LLVM AI Tool Use Policy for contributions using AI.

@eddieliao eddieliao self-assigned this Jul 15, 2026
@eddieliao eddieliao added enhancement New feature or request Tooling Touches tools used for or that aid in MIGraphX development and debugging labels Jul 15, 2026
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5067      +/-   ##
===========================================
+ Coverage    92.89%   93.26%   +0.37%     
===========================================
  Files          603      623      +20     
  Lines        32448    32969     +521     
===========================================
+ Hits         30140    30747     +607     
+ Misses        2308     2222      -86     

see 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jul 15, 2026

Copy link
Copy Markdown
Test Batch New Rate (e4bdb3) Old Rate (3a503c)* Diff Status
torchvision-resnet50 64 3,264.86 3,264.92 -0.00%
torchvision-resnet50_fp16 64 7,547.90 7,548.67 -0.01%
torchvision-densenet121 32 2,483.37 2,483.99 -0.02%
torchvision-densenet121_fp16 32 5,004.10 5,004.24 -0.00%
torchvision-inceptionv3 32 2,057.49 2,058.51 -0.05%
torchvision-inceptionv3_fp16 32 4,404.72 4,416.99 -0.28%
cadene-inceptionv4 16 821.91 820.61 0.16%
cadene-resnext64x4 16 782.80 782.78 0.00%
slim-mobilenet 64 8,391.43 8,386.36 0.06%
slim-nasnetalarge 64 228.87 228.86 0.00%
slim-resnet50v2 64 3,181.06 3,180.91 0.00%
bert-mrpc-onnx 8 1,169.26 1,168.84 0.04%
bert-mrpc-tf 1 495.33 498.63 -0.66%
pytorch-examples-wlang-gru 1 486.29 473.35 2.73%
pytorch-examples-wlang-lstm 1 389.35 384.83 1.18%
torchvision-resnet50_1 1 1,037.90 1,046.63 -0.83%
cadene-dpn92_1 1 445.13 437.32 1.79%
cadene-resnext101_1 1 366.30 365.89 0.11%
onnx-taau-downsample 1 843.01 844.09 -0.13%
dlrm-criteoterabyte 1 32.38 32.42 -0.14%
dlrm-criteoterabyte_fp16 1 51.81 51.80 0.02%
agentmodel 1 9,244.02 9,209.12 0.38%
unet_fp16 2 58.69 58.80 -0.19%
resnet50v1_fp16 1 1,354.40 1,366.11 -0.86%
resnet50v1_int8 1 385.81 1,883.96 -79.52% 🔴
bert_base_cased_fp16 64 987.22 1,098.16 -10.10% 🔴
bert_large_uncased_fp16 32 345.72 345.59 0.04%
bert_large_fp16 1 204.25 206.59 -1.13%
distilgpt2_fp16 16 2,090.41 2,092.89 -0.12%
yolov5s 1 560.64 558.33 0.41%
tinyllama 1 45.84 45.83 0.03%
vicuna-fastchat 1 22.72 44.20 -48.60% 🔴
whisper-tiny-encoder 1 382.99 411.87 -7.01% 🔴
whisper-tiny-decoder 1 408.26 408.48 -0.06%
llama2_7b 1 20.70 20.84 -0.67%
qwen1.5-7b 1 9.32 23.58 -60.48% 🔴
phi3-3.8b 1 6.34 26.72 -76.27% 🔴
llama3-8b 1 21.69 21.80 -0.53%
whisper-large-encoder 1 9.80 10.18 -3.70%
whisper-large-decoder 1 105.48 105.30 0.17%
mistral-7b 1 6.72 23.78 -71.73% 🔴
FLUX.1-schnell 1 120.98 755.22 -83.98% 🔴

Regressions detected 🔴

* No develop baseline was found for this PR's branch point; compared against the latest available develop run instead.

@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jul 15, 2026

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx PASSED: MIGraphX meets tolerance
bert-mrpc-tf PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-gru PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-lstm PASSED: MIGraphX meets tolerance
dlrm-criteoterabyte PASSED: MIGraphX meets tolerance
agentmodel PASSED: MIGraphX meets tolerance
unet PASSED: MIGraphX meets tolerance
resnet50v1 PASSED: MIGraphX meets tolerance
bert_base_cased_fp16 PASSED: MIGraphX meets tolerance
bert_large_uncased_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
bert_large PASSED: MIGraphX meets tolerance
yolov5s PASSED: MIGraphX meets tolerance
tinyllama PASSED: MIGraphX meets tolerance
vicuna-fastchat PASSED: MIGraphX meets tolerance
whisper-tiny-encoder PASSED: MIGraphX meets tolerance
whisper-tiny-decoder PASSED: MIGraphX meets tolerance
distilgpt2_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
llama2_7b PASSED: MIGraphX meets tolerance
qwen1.5-7b PASSED: MIGraphX meets tolerance
phi3-3.8b PASSED: MIGraphX meets tolerance
llama3-8b PASSED: MIGraphX meets tolerance
whisper-large-encoder PASSED: MIGraphX meets tolerance
whisper-large-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

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

This PR adds a --no-rebuild verification mode to the MIGraphX driver that performs a single reference run and a single target run while tracing instruction outputs by debug symbol, enabling layer-wise divergence reporting without recompiling for --reduce/--bisect workflows.

Changes:

  • Adds verify_options::no_rebuild and wires --no-rebuild into the driver CLI.
  • Introduces a trace-based verify_callback that captures reference outputs by debug symbol and compares them against target outputs.
  • Updates verify flows (verify_program, reduced, bisected) to use the new layer-wise compare path when --no-rebuild is enabled.

Reviewed changes

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

File Description
src/driver/verify.hpp Declares verify_callback and exposes layer-wise compare support from the driver verify interface.
src/driver/verify.cpp Implements trace-based capture/compare, baseline error attribution, and integrates --no-rebuild into verify/reduce/bisect modes.
src/driver/verify_options.hpp Adds no_rebuild option to the verify options struct.
src/driver/main.cpp Adds --no-rebuild CLI flag and help text for verify.

Comment thread src/driver/verify.cpp Outdated
Comment thread src/driver/verify.cpp Outdated
Comment on lines +296 to +298
// Last-writer-wins on the symbol keeps the fused op's final value, not an interior one.
target_outputs[symbol] = {output.copy(), ins->name(), order, std::move(inputs)};
};
Comment thread src/driver/verify.cpp Outdated
Comment on lines +451 to +462
bool any_failed = false;
for(const auto& [symbol, lr] : vcb->results)
{
if(not lr.passed)
{
any_failed = true;
log::error() << "FAILED at " << lr.symbol << " (" << lr.op << ")";
}
}
if(not any_failed)
log::info() << "MIGraphX verification passed successfully.";
return;
Comment thread src/driver/verify.hpp Outdated
Comment on lines +49 to +53
// Captures ref outputs by debug symbol and compares each target op at its terminal symbol.
struct verify_callback
{
using trace_function = std::function<void(instruction_ref, const argument&)>;

@eddieliao
eddieliao requested a balanced review from Copilot August 6, 2026 18:16

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@eddieliao
eddieliao requested a lite review from Copilot August 6, 2026 18:57

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

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

Suppressed comments (4)

src/driver/verify.cpp:177

  • Returning nullopt for every lens mismatch hides actual target shape regressions. If a symbol's target output has the wrong dimensions, that layer is omitted from results; other layers can still pass and the command reports overall success. Distinguish inherited-symbol intermediates from the terminal output, and record a failed shape comparison when the terminal symbol has no shape-compatible target result.
            // Reshapes and slices inherit the symbol; only the op whose lens match produced it.
            if(not shape::same_lens(ref.output.get_shape(), output.get_shape()))
                return nullopt;

src/driver/verify.cpp:304

  • This helper can return successfully with zero comparisons. For example, a constant-only model has debug symbols on literals/return but neither is inspectable, and a --compiled-model without corresponding symbols also leaves results empty. Both callers then treat failures().empty() as verification success. Reject an empty result set instead of reporting a pass.
    log::info() << "Layers compared: " << vcb.results.size();
    return vcb;

src/program.cpp:733

  • substitute is a public callback, so its return value is an external API boundary. This debug-only assertion disappears in release builds, allowing an incompatible argument to reach downstream operators. Validate the replacement shape at runtime and throw a clear error.
                        assert(sub->get_shape() == result.get_shape());

src/include/migraphx/execution_environment.hpp:42

  • The new substitution execution path and layer-wise verifier have no regression tests in this PR, although adjacent evaluation callback behavior is covered in test/trace_eval_test.cpp and test/api/test_trace_callback.cpp. Add tests proving a replacement is consumed by downstream instructions and covering no-match, shape-mismatch, and multi-output debug-symbol cases; these cases currently permit false passes or incorrect substitutions.
    // Replaces an instruction's result, so later instructions read the returned value instead.
    std::function<optional<argument>(instruction_ref, const argument&)> substitute = nullptr;

Comment thread src/driver/verify.cpp
Comment on lines +143 to +144
for(const auto& symbol : ins->get_debug_symbols())
ref_outputs[symbol] = {buf, order};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Tooling Touches tools used for or that aid in MIGraphX development and debugging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants