Repository navigation
Conversation
ternaus
force-pushed
the
agent/rng-generator
branch
from
August 19, 2026 11:03
1c3ec01 to
8d61947
Compare
ternaus
marked this pull request as ready for review
August 19, 2026 11:08
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
TheseNK_PUBLICfunctions are defined in a public header, which will typically produce… · New The GIL is released whilefill(...)mutatesgenerator->generator.state. If the sameGenerator… · New This example assertion is likely incorrect/ambiguous:==for array/tensor-like objects is often… · New The stubs indicatesizeis optional foruniform/normal/integers(defaulting to...), but… · NewGenerator.integersparseslow/highstrictly as signed int64 regardless ofdtype. This… · New The error message format here is non-standard for Python call errors. For consistency with typical… · New
What changed in this PR
Adds a stateful nk.Generator(seed=...) API to provide independent, reproducible random generation from Python (with optional out= support and dtype/shape controls), backed by new native RNG utilities.
Changes:
- Introduces native RNG core (
include/numkong/random.h) and Python bindings (python/random.c/.h) forGeneratormethods (random,uniform,normal,standard_normal,integers) andstate. - Exposes the new
Generatortype from the extension module and adds typing stubs + Python documentation. - Adds a dedicated pytest suite covering determinism, state restore, dtype/shape/bounds, and
out=behavior.
| File | Description |
|---|---|
| test/test_random.py | Adds tests for determinism, state independence/restore, out= validation, and argument errors. |
| setup.py | Adds python/random.c to the extension build sources. |
| python/random.h | Declares the new RandomGeneratorType for module registration. |
| python/random.c | Implements numkong.Generator Python C-extension type and distribution methods (GIL-releasing fills). |
| python/numkong/__init__.pyi | Adds typing stubs for the new Generator API. |
| python/numkong.c | Registers the Generator type with the extension module. |
| python/README.md | Documents nk.Generator usage and out= semantics. |
| include/numkong/random.h | Adds the native RNG generator struct and RNG/distribution functions. |
| include/numkong/numkong.h | Re-exports the new RNG header from the umbrella include. |
Review effort: Lite
Copilot stopped reviewing on behalf of
ternaus due to an error
October 17, 2026 10:44
Expose seeded generation through native state and a Python Generator wrapper. Refs ashvardanian#299.
ashvardanian
force-pushed
the
agent/rng-generator
branch
from
October 18, 2026 22:58
1f64d28 to
883f108
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Introduce a seeded
Generatorwith independent state, floating distributions, bounded integers, and caller-owned output buffers. State and fills are serialized per instance. Generation is scalar, and normal sampling uses host libm.This introduces a new public API and remains a separate, lower-priority review.
Refs #299.