[PTSBE] fully qualify names and drop using namespace directives#4391
Open
taalexander wants to merge 5 commits intoNVIDIA:mainfrom
Open
[PTSBE] fully qualify names and drop using namespace directives#4391taalexander wants to merge 5 commits intoNVIDIA:mainfrom
using namespace directives#4391taalexander wants to merge 5 commits intoNVIDIA:mainfrom
Conversation
18c5b77 to
a13243b
Compare
Several PTSBE test files and the Python binding piled up multiple `using namespace` directives (cudaq + cudaq::ptsbe + cudaq::ptsbe::detail). The house style is zero using-namespace directives with names fully qualified at the use site. This removes every using-namespace directive from unittests/ptsbe/*.cpp and python/runtime/cudaq/algorithms/py_sample_ptsbe.cpp and qualifies each identifier against its owning namespace. Behavior is unchanged; only name lookup is tightened. Signed-off-by: Thomas Alexander <talexander@nvidia.com>
The previous commit's name-qualification pass accidentally prefixed `cudaq::` inside two `#include` paths, yielding `cudaq/ptsbe/cudaq::KrausSelection.h` and `cudaq/ptsbe/cudaq::KrausTrajectory.h`, which broke the python binding build. Signed-off-by: Thomas Alexander <talexander@nvidia.com>
…ions Previous qualification pass placed these in the wrong sub-namespace: - `countInstructions` and `numQubits` live in `cudaq::ptsbe`, not `cudaq::ptsbe::detail` (declared in PTSBEExecutionData.h). - `sample_options` used in PTSBE tests is `cudaq::ptsbe::sample_options` (has a `.ptsbe` configuration sub-struct), not `cudaq::sample_options`. Fixes compile errors in PTSBESampleTester.cpp and PTSBEMultiBackendTester.cpp. Signed-off-by: Thomas Alexander <talexander@nvidia.com>
…_EPSILON
These identifiers are declared in `cudaq::` (KrausSelection.h and
KrausTrajectory.h open `namespace cudaq {...}`), not `cudaq::ptsbe::`.
A previous qualification pass wrongly placed them in `cudaq::ptsbe::`,
which broke KrausSelectionTester.cpp and KrausTrajectoryTester.cpp
because those TUs only include KrausSelection.h / KrausTrajectory.h
and never expose the `cudaq::ptsbe` namespace.
This also aligns with the convention noted in
.claude/rules/vendor-cuda-quantum.md and AGENTS.md: KrausSelection and
KrausTrajectory live in the `cudaq` namespace.
Signed-off-by: Thomas Alexander <talexander@nvidia.com>
The return type of buildAndExtract() was left as bare `detail::` after the using-namespace drop. It needs `cudaq::ptsbe::detail::` since NoiseExtractionResult is declared in `namespace cudaq::ptsbe::detail` (see NoiseExtractor.h). Verified with a local build + ctest of the qpp-backend PTSBE suite (49/49 passing). Signed-off-by: Thomas Alexander <talexander@nvidia.com>
a13243b to
251b855
Compare
schweitzpgi
approved these changes
Apr 28, 2026
Collaborator
schweitzpgi
left a comment
There was a problem hiding this comment.
I think this can be a much smaller PR and just have focused on the files with more than 1
using namespace foo;
using namespace bar;
....open namespace in the .cpp files.
For .h files, the number of open namespaces should be zero.
| #include <nanobind/stl/unordered_map.h> | ||
| #include <nanobind/stl/vector.h> | ||
|
|
||
| using namespace cudaq; |
Collaborator
There was a problem hiding this comment.
FWIW, having one wide open namespace is fine. We just do not want more than one.
|
|
||
| using namespace cudaq; | ||
| using namespace cudaq::ptsbe; | ||
| using namespace cudaq::ptsbe::detail; |
Collaborator
There was a problem hiding this comment.
Like here. You could leave
using namespace cudaq;
But we don't want the other 2.
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.
Address comments from @schweitzpgi that pointed out the style did not match the existing codebase.