feat(cambricon): enable TaskTopo graph capture - #1434
Open
gongchensu wants to merge 1 commit into
Open
Conversation
Avoid queue synchronization while CNRT is capturing, while preserving the synchronous eager-execution contract outside capture. Record descriptor-owned metadata with cnrtMemcpyAsync_V2 and pass temporary elementwise input pointers as kernel arguments so captured graphs can safely reuse frozen workspaces across batch shapes. Initialize the Cambricon runtime and freeze cached allocations when they become visible to captured graphs so memory trimming cannot invalidate recorded pointers.
wooway777
reviewed
Aug 4, 2026
wooway777
left a comment
Collaborator
There was a problem hiding this comment.
如果syncQueueIfNotCapturing意味着录图的时候不需要同步,那么不录图的时候是否也不需要同步呢?
wooway777
approved these changes
Aug 5, 2026
voltjia
approved these changes
Aug 5, 2026
Collaborator
Author
eager模式下异步调用依赖的handle、descriptor、workspace 或 host metadata 生命周期还是需要依赖同步来保证不出问题,最关键就是图的CNRT是会将capture期间提交的任务记录成tasktopo节点,graph会持续保存整套operator和planned_meta,graph可见的内存地址也会被冻结,因此是不需要用queue来同步,但是eager模式下,每个算子将任务提交到queue后就返回,workspace会被allocator标记为可复用,这些资源需要同步来保证生命周期。总之目前还是需要这样,后续如果想eager模式不用同步需要单独引入event延迟回收或per-stream resorce pool,并且重新管理CNNL handle、descriptor、metadata和workspace生命周期 |
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.
Avoid queue synchronization while CNRT is capturing, while preserving the synchronous eager-execution contract outside capture.
Record descriptor-owned metadata with cnrtMemcpyAsync_V2 and pass temporary elementwise input pointers as kernel arguments so captured graphs can safely reuse frozen workspaces across batch shapes.
Initialize the Cambricon runtime and freeze cached allocations when they become visible to captured graphs so memory trimming cannot invalidate recorded pointers.