Skip to content

Add random.sample_modq op - #3596

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_1013255391
Nov 3, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_1013255391

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Add random.sample_modq op

Adds a random.sample_modq op that samples uniformly at random from a type
implementing ModQTypeInterface (e.g., a mod_arith or RNS type), or from a
tensor of such types. For an RNS type, each limb is sampled independently and
uniformly modulo its own modulus. By the Chinese Remainder Theorem, this is
equivalent to sampling uniformly modulo the product of the moduli, without
having to materialize that product as a range bound for
random.discrete_uniform_distribution.

This will be used to sample the uniform mask in secret-key RLWE encryption
(#880).

Adds a `random.sample_modq` op that samples uniformly at random from a type
implementing `ModQTypeInterface` (e.g., a `mod_arith` or RNS type), or from a
tensor of such types. For an RNS type, each limb is sampled independently and
uniformly modulo its own modulus. By the Chinese Remainder Theorem, this is
equivalent to sampling uniformly modulo the product of the moduli, without
having to materialize that product as a range bound for
`random.discrete_uniform_distribution`.

This will be used to sample the uniform mask in secret-key RLWE encryption
(#880).

PiperOrigin-RevId: 1013297248
@copybara-service
copybara-service Bot merged commit e450c39 into main Nov 3, 2026
1 of 2 checks passed
@copybara-service
copybara-service Bot deleted the test_1013255391 branch November 3, 2026 22:32
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