Skip to content

Implement barrier collective primitive#10

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/implement-barrier-primitive
Draft

Implement barrier collective primitive#10
Copilot wants to merge 4 commits intomainfrom
copilot/implement-barrier-primitive

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Adds barrier() synchronization primitive to complete the core QMPI collective operations API.

Implementation

  • Abstract interface: Added barrier() to CollectiveComm base class
  • Centralized algorithm: Rank 0 coordinates by collecting arrival messages from all ranks, then broadcasting release
  • Message validation: Headers validated to ensure protocol correctness ("BarrierArrival" / "BarrierRelease")
  • API integration: Exposed via QMPICommunicator.barrier()

Usage

from netqmpi.sdk.communicator import QMPICommunicator

def main(app_config=None, rank=0, size=1):
    COMM_WORLD = QMPICommunicator(rank, size, app_config)
    
    with COMM_WORLD:
        # Phase 1: Each rank does independent work
        q = COMM_WORLD.create_qubit()
        q.H()
        
        # Synchronization point
        COMM_WORLD.barrier()
        
        # Phase 2: All ranks have completed phase 1
        q.measure()
        COMM_WORLD.flush()

Classical message passing only - no quantum operations required.

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement additional collective primitives (barrier, etc.)</issue_title>
<issue_description>## Description

Files: netqmpi/sdk/primitives/collective/, netqmpi/sdk/communicator/communicator.py

Current primitive status

Primitive Status
qsend / qrecv
qscatter / qgather
expose / unexpose ✅ (telegate)
qreduce
barrier

Implementation priority

  1. barrier - Basic synchronization between nodes
  2. qreduce - For quantum reduction operations

Impact

  • Severity: Low (additional functionality)
  • Improvement: QMPI API completeness</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 17, 2026 17:32
Co-authored-by: CardamaS99 <36961760+CardamaS99@users.noreply.github.com>
Co-authored-by: CardamaS99 <36961760+CardamaS99@users.noreply.github.com>
Co-authored-by: CardamaS99 <36961760+CardamaS99@users.noreply.github.com>
Copilot AI changed the title [WIP] Add barrier primitive for collective synchronization Implement barrier collective primitive Feb 17, 2026
Copilot AI requested a review from CardamaS99 February 17, 2026 17:39
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.

Implement additional collective primitives (barrier, etc.)

2 participants