Skip to content

fix(ir): Preserve auto deps across dynamic loop fallback#1739

Open
sunkaixuan2018 wants to merge 1 commit into
hw-native-sys:mainfrom
sunkaixuan2018:codex/auto-deps-dynamic-loop-fallback
Open

fix(ir): Preserve auto deps across dynamic loop fallback#1739
sunkaixuan2018 wants to merge 1 commit into
hw-native-sys:mainfrom
sunkaixuan2018:codex/auto-deps-dynamic-loop-fallback

Conversation

@sunkaixuan2018

Copy link
Copy Markdown
Contributor

Summary

  • Preserve compiler-derived AUTO-scope dependency edges when a later dynamic loop hazard falls back to runtime TensorMap tracking.
  • Add regression coverage so encodable sibling edges survive even when an unresolved dynamic loop producer exists elsewhere in the same AUTO scope.

Testing

  • Remote qwen single decode layer on myserver via task-submit: PASS
    • commit: 3c8afd0
    • evidence: /data/sunkaixuan/skx_log_output/qwen_current_auto_deps_single_20260611_002216/evidence_summary.json
    • deps: creator=33, tensormap=111, explicit=38
    • explicit/non-creator=25.50%, explicit TensorMap-pair coverage=60.32%
  • Remote targeted unit test: tests/ut/ir/transforms/test_auto_derive_task_dependencies.py -v (34 passed)

Notes

  • Remote validation used a repo-local .venv under /data/sunkaixuan/all_pyptos/auto-deps-dynamic-loop-fallback-current/.venv to avoid modifying shared Python environments.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f34b6bb7-6ab0-4eed-a481-4bbba4466f00

📥 Commits

Reviewing files that changed from the base of the PR and between 614122a and 3c8afd0.

📒 Files selected for processing (2)
  • src/ir/transforms/auto_derive_task_dependencies_pass.cpp
  • tests/ut/ir/transforms/test_auto_derive_task_dependencies.py

📝 Walkthrough

Walkthrough

The PR refines dynamic producer hazard handling in the auto-derivation task dependencies pass. When a call encounters a dynamic producer hazard inside an auto scope (not manual), fallback is now suppressed with a debug log rather than triggered. A new test validates that encodable compiler edges are preserved correctly across consume calls in dynamic loop scenarios.

Changes

Dynamic Producer Hazard Scoping

Layer / File(s) Summary
Manual scope check for dynamic producer hazards
src/ir/transforms/auto_derive_task_dependencies_pass.cpp
AnalyzeCallLike now evaluates in_manual_scope when handling prior.dynamic_producer hazards; calls in auto scopes skip fallback with a debug log, while calls in manual scopes retain existing fallback behavior.
Test verification of auto scope dynamic loop hazard handling
tests/ut/ir/transforms/test_auto_derive_task_dependencies.py
New test confirms first consume call in auto scope preserves the produced compiler edge while second consume call after loop update has empty compiler edges.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A hazard found within the scope,
Dynamic producers need some hope,
We check if manual, skip if not—
The fallback's now a clearer plot!
Loop edges dance, the edges stay,
Auto-scope shines the rabbit's way. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: preserving auto dependencies across a dynamic loop fallback scenario, which aligns with the code modifications in AutoDepMutator.
Description check ✅ Passed The description clearly relates to the changeset, explaining the purpose of modifications to dependency edge handling and providing test coverage details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/ir/transforms/auto_derive_task_dependencies_pass.cpp

src/ir/transforms/auto_derive_task_dependencies_pass.cpp:29:10: fatal error: 'pypto/codegen/orchestration/orchestration_analysis.h' file not found
29 | #include "pypto/codegen/orchestration/orchestration_analysis.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
src/ir/transforms/auto_derive_task_dependencies_pass.cpp:126:3-10: ERROR translating statement 'ReturnStmt'
Aborting translation of method 'pypto::ir::anonymous_namespace_src_ir_transforms_auto_derive_task_dependencies_pass.cpp::ConstIntTupleValues' in file 'src/ir/transforms/auto_derive_task_dependencies_pass.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, ch

... [truncated 2200 characters] ...

truction_log.(fun) in file "src/clang/cTrans.ml", line 4782, characters 12-47
Re-raised at IStdlib__IExn.reraise_after in file "src/istd/IExn.ml" (inlined), line 13, characters 2-50
Called from ClangFrontend__CTrans.CTrans_funct.instruction_log.(fun) in file "src/clang/cTrans.ml", line 4784, characters 10-1023
Called from ClangFrontend__CTrans.CTrans_funct.instruction in file "src/clang/cTrans.ml" (inlined), line 4765, characters 38-71
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml" (inlined), line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/cla


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request modifies the AutoDepMutator to skip dynamic prior producers when not within a manual scope, preventing unnecessary fallback behavior. A corresponding unit test has been added to verify that encodable edges are not stripped under these conditions. There are no review comments, so no additional feedback is provided.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant