Skip to content

Use block sampling to accelerate measurement for Fock backend#143

Merged
sansiro77 merged 3 commits intoTuringQ:mainfrom
Jooyuza:measure_dict
Feb 13, 2026
Merged

Use block sampling to accelerate measurement for Fock backend#143
sansiro77 merged 3 commits intoTuringQ:mainfrom
Jooyuza:measure_dict

Conversation

@Jooyuza
Copy link
Copy Markdown
Collaborator

@Jooyuza Jooyuza commented Feb 13, 2026

torch.multinomial is much faster than random.choices in sampling tasks. #78
Here we reuse qmath.block_sample to replace random.choices in QumodeCircuit._prob_dict_to_measure_result, so that measurement of fock backend like _measure_fock_unitary & _measure_dict will benefit from this.

Before:
image

After:
image

@Jooyuza Jooyuza requested a review from sansiro77 February 13, 2026 03:09
@Jooyuza Jooyuza added the enhancement New feature or request label Feb 13, 2026
@Jooyuza
Copy link
Copy Markdown
Collaborator Author

Jooyuza commented Feb 13, 2026

Now measure_dict without batch will output probabiliity with same data shape as measure_unitary.
image

Comment thread src/deepquantum/photonic/circuit.py
Copy link
Copy Markdown
Contributor

@sansiro77 sansiro77 left a comment

Choose a reason for hiding this comment

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

LGTM

@sansiro77 sansiro77 changed the title Use torch.multinomial to accelerate measurement of fock backend Use block sampling to accelerate measurement for Fock backend Feb 13, 2026
@sansiro77 sansiro77 merged commit f9d5de2 into TuringQ:main Feb 13, 2026
@Jooyuza Jooyuza deleted the measure_dict branch February 13, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants