Skip to content

Comments

Dynamic parallel cpu DAG scheduler 🚀#22

Merged
EricLBuehler merged 1 commit intomasterfrom
cpu_dynamic_dag_scheduler
Apr 26, 2025
Merged

Dynamic parallel cpu DAG scheduler 🚀#22
EricLBuehler merged 1 commit intomasterfrom
cpu_dynamic_dag_scheduler

Conversation

@EricLBuehler
Copy link
Owner

Based on the idea of CUDA streams.

@EricLBuehler EricLBuehler requested a review from Copilot April 26, 2025 02:58
Copy link

Copilot AI left a comment

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 implements a dynamic CPU DAG scheduler inspired by CUDA streams for improved parallel execution and concurrency. Key changes include:

  • Replacing Rc/RefCell with thread-safe Arc, Mutex, and AtomicUsize in tensor ID management.
  • Updating the buffer pool to use Arc<Mutex<…>> for thread safety.
  • Revamping the DAG evaluation logic in the CPU storage module with concurrent scheduling using rayon and mpsc for synchronization.

Reviewed Changes

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

File Description
constensor-core/src/graph.rs Replaces Rc/Cell with Arc/AtomicUsize for advanced thread-safe tensor ID handling.
constensor-core/src/cpu_storage/pool.rs Updates shared pool type to Arc<Mutex<BufferPool>> for safe concurrent buffer management.
constensor-core/src/cpu_storage/mod.rs Implements dynamic DAG scheduling with concurrency primitives and parallel task spawning.
Comments suppressed due to low confidence (2)

constensor-core/src/cpu_storage/mod.rs:408

  • [nitpick] For consistency with the rest of the evaluation branches, consider using unreachable!("NoOp should not be evaluated") instead of panic!().
Op::NoOp => panic!("NoOp should not be evaluated"),

constensor-core/src/cpu_storage/mod.rs:420

  • [nitpick] Variable names like 'pool2', 'ng2', 'res2', etc. are ambiguous; consider using more descriptive names to improve code clarity.
let pool2 = pool.clone();

@EricLBuehler EricLBuehler changed the title Dynamic cpu DAG scheduler Dynamic parallel cpu DAG scheduler 🚀 Apr 26, 2025
@EricLBuehler
Copy link
Owner Author

Before:

cpu_graph_matmul_128x128
                        time:   [533.90 µs 535.85 µs 537.77 µs]

After

cpu_graph_matmul_128x128
                        time:   [388.75 µs 390.19 µs 391.65 µs]
                        change: [-27.543% -27.084% -26.626%] (p = 0.00 < 0.05)
                        Performance has improved.

This is ~30% faster!

@EricLBuehler EricLBuehler merged commit b1b353a into master Apr 26, 2025
11 checks passed
@EricLBuehler EricLBuehler deleted the cpu_dynamic_dag_scheduler branch April 26, 2025 03:12
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.

1 participant