Skip to content

Check the name and the factory given to register_quantum_system - #409

Merged
anthony-santana merged 2 commits into
NVIDIA:mainfrom
shuseng8:fix-392-register-quantum-system-checks
Nov 30, 2026
Merged

anthony-santana merged 2 commits into
NVIDIA:mainfrom
shuseng8:fix-392-register-quantum-system-checks

Conversation

@shuseng8

Copy link
Copy Markdown
Contributor

What this changes and why

Closes #392.

register_quantum_system now checks what it is given before it registers anything:

  • a name that is not a str raises InvalidTypeError ("a quantum system name is a str, got int") instead of a built-in TypeError from deeper in the registry;
  • a factory that is not callable raises InvalidTypeError naming the system, at registration time, instead of being stored and failing only when the system is first looked up.

The factory check runs after the existing name check, and in both cases nothing is added to the registry, so a failed call leaves it unchanged. The tests cover an int and a bytes name, an int and a str factory, and confirm the registry is untouched afterwards. There is a changelog entry under ### Fixed.

Checklist

  • cmake --build build/dev --target check-pulse passes (lit and pytest). (CPU build, CUDAQ_PULSE_ENABLE_GPU=OFF: lit 130/130, pytest 12946 passed / 86 skipped, cuDensityMat host and classical handler tests pass.)
  • pre-commit run --all-files and MYPYPATH=build/dev/python mypy -p cudaq_pulse pass.
  • New behavior has tests; GPU-only changes say how they were tested on a GPU. (No GPU-only changes; the new tests fail without the fix.)
  • User-visible changes have an entry in the top section of CHANGELOG.md (## [X.Y.Z] - Unreleased).
  • Breaking changes follow the versioning policy in CONTRIBUTING.md. (Not breaking: only inputs that could never work are rejected earlier.)
  • Every commit is signed off with a Signed-off-by: line (Developer Certificate of Origin, CONTRIBUTING.md).

A name that is not a str failed with a built-in TypeError, and a factory
that is not callable was registered and failed only when the system was
first asked for. Both now raise InvalidTypeError at registration, and
nothing is registered.

Closes NVIDIA#392

Signed-off-by: Shubham <[email protected]>
Several open pull requests add their entry at the top of the list, so
each conflicts with the others as they merge. The entry is unchanged.

Signed-off-by: A.M. Santana <[email protected]>
@anthony-santana
anthony-santana merged commit 9c06d2a into NVIDIA:main Nov 30, 2026
24 checks passed
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.

Check the name and the factory given to register_quantum_system

2 participants