Skip to content

[Feature][QDP] Add MPI-ready distributed amplitude execution scaffolding#1296

Open
viiccwen wants to merge 26 commits into
apache:mainfrom
viiccwen:feature/qdp-multigpu-plan
Open

[Feature][QDP] Add MPI-ready distributed amplitude execution scaffolding#1296
viiccwen wants to merge 26 commits into
apache:mainfrom
viiccwen:feature/qdp-multigpu-plan

Conversation

@viiccwen

@viiccwen viiccwen commented May 4, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Closes #1295
Part of #1297

Summary

This PR adds the first QDP-native distributed GPU state execution foundation, with amplitude state construction as the first workload.

The implementation is intentionally MPI-ready but does not require MPI or NCCL as mandatory dependencies. The executable path in this PR is a real single-process fallback that runs through the same rank-local planning, runtime, transport, and state boundaries that a future MPI-backed execution path should use.

In other words, this PR is not claiming full mpirun -n N support yet. It establishes the architecture and a testable fallback boundary that future MPI, CUDA-aware MPI, and NCCL backends can replace or extend.

The main architecture boundary is intentionally split into four layers:

  • Planning decides where shards should live.
  • Runtime decides what work the current rank performs.
  • Transport owns scalar and future GPU-resident collectives.
  • State owns local GPU shard buffers and exposes local zero-copy views.

Current Capability

This PR currently supports:

  • rank/world execution metadata through DistributedExecutionContext
  • rank-local device meshes and placement planning
  • shared distributed state planning through DistributedStatePlan
  • amplitude-specific execution through DistributedAmplitudePlan
  • local GPU shard materialization for shards owned by the current rank
  • scalar rank-level reduction through CollectiveCommunicator
  • single-process fallback through LocalCollectiveCommunicator
  • zero-copy local shard metadata through DistributedStateVector::local_shard_views()
  • planned device_id to CUDA handle resolution, so shard metadata, active CUDA device context, and allocated buffers stay aligned
  • placeholder CUDA-aware MPI / NCCL device collective types that identify their backend but return NotImplemented for GPU-resident collectives

Architecture Shape

sequenceDiagram
    participant Caller as QdpEngine caller
    participant Engine as QdpEngine
    participant Ctx as DistributedExecutionContext
    participant Planner as PlacementPlanner
    participant StatePlan as DistributedStatePlan
    participant AmpPlan as DistributedAmplitudePlan
    participant Runtime as distributed runtime
    participant Comm as CollectiveCommunicator
    participant State as DistributedStateVector

    Caller->>Engine: submit distributed amplitude request
    Engine->>Engine: validate input and resolve request
    Engine->>Ctx: construct rank-local execution context
    Engine->>Planner: build rank-local placement plan
    Planner-->>Engine: placement + shard ranges
    Engine->>StatePlan: build shared shard/rank contract
    StatePlan-->>AmpPlan: wrap for amplitude workload
    AmpPlan->>Runtime: execute local-rank shard work
    Runtime->>Runtime: compute local norm contribution
    Runtime->>Comm: all_reduce_sum_f64(local_norm_sq)
    Comm-->>Runtime: global norm
    Runtime->>Runtime: allocate and encode local GPU shards
    Runtime-->>State: local distributed state
    State-->>Caller: zero-copy local shard views available
Loading

This PR does not yet support:

  • true MPI multi-rank launch
  • CUDA-aware MPI collective execution
  • NCCL collective execution
  • multi-node execution
  • cross-rank zero-copy transport

Follow-up Work

  • Implement a true MPI scalar communicator for CollectiveCommunicator.
  • Add a documented mpirun -n N launch path.
  • Add multi-rank smoke tests gated behind an MPI feature or CI environment.
  • Implement CUDA-aware MPI and/or NCCL DeviceCollectiveCommunicator backends.
  • Define gather/export and downstream consumer contracts for distributed state.

@400Ping

400Ping commented May 4, 2026

Copy link
Copy Markdown
Member

Nice one, will probably take a look on Thursday.

@ryankert01 ryankert01 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, nice initiative. Curious of can it be plugging in our current lighting.gpu (penny lane) workflow?

mahout.qdp -> lighting.gpu (by zero copy)

@viiccwen viiccwen force-pushed the feature/qdp-multigpu-plan branch from 4145efa to baa6a90 Compare May 5, 2026 12:25
@viiccwen viiccwen changed the title Feat(GPU): add single-node distributed amplitude scaffolding [Feature][QDP] Add MPI-ready distributed amplitude execution scaffolding May 5, 2026
@viiccwen

viiccwen commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@ryankert01, after researching, I think the main gap is on the lightning.gpu integration boundary.

From what I can tell, the missing piece is not “can Mahout produce a GPU-resident state?” but “can lightning.gpu ingest an external GPU state buffer through a stable public interface without copying?”.

So my current estimate would be:

  1. expose or formalize an external-state ingest path on the PennyLane / lightning.gpu side
  2. add a Mahout-side bridge/adapter for mahout.qdp -> lightning.gpu
  3. add end-to-end tests and examples for the workflow

So yes: for a proper zero-copy integration, I would expect roughly 3 PRs for a narrow MVP.

@ryankert01

ryankert01 commented May 7, 2026

Copy link
Copy Markdown
Member

@viiccwen I think since it's 3 PRs away and so big. Can we postpone it to the next release? It will be more mature at next release and we can think about its detail.

@viiccwen

viiccwen commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@viiccwen I think since it's 3 PRs away and so big. Can we postpone it to the next release? It will be more mature at next release and we can think about its detail.

Sure, it'll be fine.

@400Ping

400Ping commented May 11, 2026

Copy link
Copy Markdown
Member

@viiccwen do you have a design doc for this?

@400Ping

400Ping commented May 11, 2026

Copy link
Copy Markdown
Member

Also please solve conflicts

@viiccwen viiccwen force-pushed the feature/qdp-multigpu-plan branch from 2a2c952 to 14faf38 Compare May 11, 2026 18:02
@rich7420

rich7420 commented May 12, 2026

Copy link
Copy Markdown
Contributor

hey @viiccwen — i think we'll overlap here. i'm planning a follow-up pr for ddp rank-aware sharding in QuantumDataLoader (feistel-based O(1) partitioning).

two quick questions:

  1. rough merge eta for [Feature][QDP] Add MPI-ready distributed amplitude execution scaffolding #1296?
  2. what does the MPIContext / topology api surface look like? would prefer to consume yours than invent a parallel one.

happy to wait if you're close, otherwise i'll build single-node-first and layer mpi on top later.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 30 days.

It will be closed in another 7 days if no further activity occurs. Thank you for your contribution. If you'd like to keep this open, leave any comment and the stale label will be removed.

You can always ask for help on the Mahout dev mailing list or in GitHub Discussions.

@github-actions github-actions Bot added the stale label Jun 23, 2026
@400Ping 400Ping removed the stale label Jun 23, 2026
@400Ping 400Ping self-assigned this Jun 23, 2026
@viiccwen viiccwen force-pushed the feature/qdp-multigpu-plan branch 2 times, most recently from 6eefecf to 16f588f Compare June 26, 2026 14:35
@viiccwen viiccwen force-pushed the feature/qdp-multigpu-plan branch 2 times, most recently from 5906476 to d535d97 Compare June 26, 2026 15:08
@viiccwen

Copy link
Copy Markdown
Contributor Author

This branch supports single-process, single-node multi-GPU shard materialization with zero-copy local shard views. It does not yet implement true MPI multi-rank execution or cross-rank GPU-resident zero-copy transport.

@viiccwen viiccwen force-pushed the feature/qdp-multigpu-plan branch from 02a6936 to 939027e Compare June 29, 2026 04:54
@guan404ming guan404ming removed their request for review July 12, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][QDP] Add MPI-ready rank-local distributed amplitude execution foundation

4 participants