Commit 03c0219
authored
This PR provides a comprehensive solution to Issue #993, addressing the
**hipErrorInvalidConfiguration** encountered when dispatching circuits
beyond 31 qubits on AMD hardware.
By refactoring the dispatch logic and indexing, qsim can now
successfully run simulations of **32+ qubits on high-memory devices like
the AMD MI300X.**
The Solution
Resolved Dispatch Limits:
Implemented 3D grid folding in CreateGrid to bypass the
hardware-specific 1D $x$-dimension limit (65,535 blocks). Large
workloads are now distributed across $(x, y, z)$ dimensions, supporting
the massive thread counts required for high-qubit states.
64-bit Indexing:
Replaced 32-bit signed integers with uint64_t for state-vector
addressing. This prevents index overflow when the state space exceeds
$2^{31}$ amplitudes, which occurs at the 32-qubit boundary.
Unlocked >32 Qubit Support:
**Full State-Vector:** Successfully verified 34 qubits (~128GB VRAM) on
a single MI300X.
**Hybrid Simulation:** Introduced a **GPU-accelerated hybrid simulator
(qsimh_base_cuda.cu)** to enable 32+ runs by partitioning the state
space into manageable segments.
Verification & Benchmarks
**Environment:** AMD MI300X (192GB), ROCm 7.1.0.
**Regression**: Small-scale circuits (< 30 qubits) run with 100%
accuracy.
**Stress Test**: Verified a 50-qubit hybrid simulation with 100% GPU
utilization and sustained 750W power draw.
**Correctness:** Confirmed that 64-bit block IDs are correctly
calculated across multi-dimensional grids.
**Modified Files**
**apps/qsimh_base_cuda.cu** (New Hybrid Simulator)
**lib/cuda2hip.h** (ROCm compatibility)
**lib/simulator_cuda.h** (3D Dispatch)
**lib/simulator_cuda_kernels.h** (64-bit Kernels)
**lib/statespace_cuda.h** (Grid Folding)
**lib/statespace_cuda_kernels.h** (Block ID Helpers)
**lib/vectorspace_cuda.h** (Namespace Isolation)
1 parent 7c89d16 commit 03c0219
6 files changed
Lines changed: 124 additions & 90 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | | - | |
| 353 | + | |
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
| 435 | + | |
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
456 | 456 | | |
457 | | - | |
| 457 | + | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
| 461 | + | |
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
482 | | - | |
| 482 | + | |
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
486 | | - | |
| 486 | + | |
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
| 520 | + | |
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
| 545 | + | |
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
554 | | - | |
| 553 | + | |
| 554 | + | |
555 | 555 | | |
556 | | - | |
| 556 | + | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
571 | | - | |
| 571 | + | |
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | | - | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| |||
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
140 | | - | |
| 144 | + | |
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
| |||
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
| 211 | + | |
| 212 | + | |
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
| |||
232 | 238 | | |
233 | 239 | | |
234 | 240 | | |
235 | | - | |
| 241 | + | |
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
| |||
288 | 294 | | |
289 | 295 | | |
290 | 296 | | |
| 297 | + | |
| 298 | + | |
291 | 299 | | |
292 | 300 | | |
293 | 301 | | |
| |||
300 | 308 | | |
301 | 309 | | |
302 | 310 | | |
303 | | - | |
| 311 | + | |
304 | 312 | | |
305 | 313 | | |
306 | 314 | | |
| |||
381 | 389 | | |
382 | 390 | | |
383 | 391 | | |
| 392 | + | |
| 393 | + | |
384 | 394 | | |
385 | 395 | | |
386 | 396 | | |
| |||
393 | 403 | | |
394 | 404 | | |
395 | 405 | | |
396 | | - | |
| 406 | + | |
397 | 407 | | |
398 | 408 | | |
399 | 409 | | |
| |||
477 | 487 | | |
478 | 488 | | |
479 | 489 | | |
| 490 | + | |
| 491 | + | |
480 | 492 | | |
481 | 493 | | |
482 | 494 | | |
| |||
508 | 520 | | |
509 | 521 | | |
510 | 522 | | |
511 | | - | |
| 523 | + | |
512 | 524 | | |
513 | 525 | | |
514 | 526 | | |
| |||
573 | 585 | | |
574 | 586 | | |
575 | 587 | | |
576 | | - | |
577 | | - | |
| 588 | + | |
| 589 | + | |
578 | 590 | | |
579 | 591 | | |
580 | 592 | | |
| |||
587 | 599 | | |
588 | 600 | | |
589 | 601 | | |
| 602 | + | |
| 603 | + | |
590 | 604 | | |
591 | 605 | | |
592 | 606 | | |
| |||
612 | 626 | | |
613 | 627 | | |
614 | 628 | | |
615 | | - | |
| 629 | + | |
616 | 630 | | |
617 | 631 | | |
618 | 632 | | |
| |||
673 | 687 | | |
674 | 688 | | |
675 | 689 | | |
676 | | - | |
677 | | - | |
| 690 | + | |
| 691 | + | |
678 | 692 | | |
679 | 693 | | |
680 | 694 | | |
| |||
0 commit comments