8000 (CUDA) Templating Rewrite, main branch (2025.06.20.) by krasznaa · Pull Request #1029 · acts-project/traccc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

(CUDA) Templating Rewrite, main branch (2025.06.20.) #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

krasznaa
Copy link
Member

Similar to #1026, in preparation for introducing inhomogeneous magnetic fields as discussed in #1017, this PR attempts to harmonize the setup of the CUDA CFK and KF algorithms with how all the other algorithms are implemented by now.

This is of course a big change, but we do need it relatively urgently.

A couple of things to point out:

  • The template specializations for the KF were in a relatively easily extensible state already, there I just needed to separate out the building of the fill_sort_keys kernel. This was not an issue previously, where only a single template specialization existed for the KF algorithm.
    • Note though that the magnetic field type is a bit more deeply woven into the helper typedefs in traccc::core, but I decided to leave that alone in this PR.
  • The template specializations for the CKF were however pretty rigidly written. Not allowing for the introduction of the telescope geometry in an easy way.
    • It was the specializations for propagate_to_next_surface that I modified a bit more deeply. In such a way that (hopefully) introducing non-constant magnetic fields should now be a bit easier in a follow-up PR.

The clients (in this repository) were all easy to update, but it's worth pointing out to people like @paradajzblond (I couldn't easily find Fabrice's GitHub handle...) that client code will need some changes after this PR.

@krasznaa krasznaa added cuda Changes related to CUDA high priority labels Jun 20, 2025
krasznaa added 3 commits June 20, 2025 12:37
So that it would follow the same UI that all the other CKF algorithms
provide.

Had to modify the kernel specialization code a little, as it was itself
relying on definitions from the old algorithm class. In sort of a
circular way.
So that it would follow the same UI that all the other KF algorithms
provide.
@krasznaa krasznaa force-pushed the CUDATemplatingRewrite-main-20250620 branch from 780e44c to 314edcc Compare June 20, 2025 10:37
Copy link
Member
@stephenswat stephenswat left a comment

Choose a reason for hiding this comment

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

Looks mostly harmless assuming you didn't change any of the actual algorithm code, but let's get all the B-field specialisation done in one go. Plus could do with some refactoring to reduce code volume and improve maintainability.

Comment on lines +58 to +59
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_default_detector.cu"
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_telescope_detector.cu"
Copy link
Member

Choose a reason for hiding this comment

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

This should go into some kind of specialization directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it could. Though we're not doing that with any of the other libraries either. And it's not really "specialization" that we do here. But rather we split the implementation of the traccc::cuda::combinatorial_kalman_filter_algorithm into multiple source files. As combinatorial_kalman_filter_algorithm.cpp just implements the constructor, while the other two implement the two current "execute functions" of the class.

Comment on lines +114 to +115
"src/fitting/kalman_fitting_algorithm_constant_field_default_detector.cu"
"src/fitting/kalman_fitting_algorithm_constant_field_telescope_detector.cu"
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Comment on lines 26 to 29
detray::actor_chain<detray::pathlimit_aborter<scalar>,
detray::parameter_transporter<default_algebra>,
interaction_register<interactor_t>, interactor_t,
detray::momentum_aborter<scalar>, ckf_aborter>>;
Copy link
Member

Choose a reason for hiding this comment

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

This actor chain can be deduplicated between the different CKF TUs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me see how to best do this. 🤔

Comment on lines 32 to 34
detray::rk_stepper<bfield_type::view_t,
default_detector::device::algebra_type,
detray::constrained_step<scalar_type>>;
Copy link
Member

Choose a reason for hiding this comment

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

This RK stepper can also be deduplicated.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Comment on lines 32 to 34
detray::rk_stepper<bfield_type::view_t,
telescope_detector::device::algebra_type,
detray::constrained_step<scalar_type>>;
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, some refactoring will make this a lot more maintainable.

#include "traccc/utils/detector_type_utils.hpp"

namespace traccc::cuda {
using fitter = fitter_for_t<traccc::telescope_detector::device>;
Copy link
Member

Choose a reason for hiding this comment

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

While you're at it, could you specialise these on the B-field?

#include "traccc/utils/detector_type_utils.hpp"

namespace traccc::cuda {
using fitter = fitter_for_t<traccc::telescope_detector::device>;
Copy link
Member

Choose a reason for hiding this comment

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

This will also need to specialized on the B-field.

Copy link
Member Author
@krasznaa krasznaa left a comment

Choose a reason for hiding this comment

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

I'd prefer to attack traccc/utils/detector_type_utils.hpp in a separate PR. One that mainly deals with the magnetic field. I was on purpose trying to limit the number of changes in this PR. 🤔

Comment on lines +58 to +59
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_default_detector.cu"
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_telescope_detector.cu"
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it could. Though we're not doing that with any of the other libraries either. And it's not really "specialization" that we do here. But rather we split the implementation of the traccc::cuda::combinatorial_kalman_filter_algorithm into multiple source files. As combinatorial_kalman_filter_algorithm.cpp just implements the constructor, while the other two implement the two current "execute functions" of the class.

Comment on lines 26 to 29
detray::actor_chain<detray::pathlimit_aborter<scalar>,
detray::parameter_transporter<default_algebra>,
interaction_register<interactor_t>, interactor_t,
detray::momentum_aborter<scalar>, ckf_aborter>>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Let me see how to best do this. 🤔

Comment on lines 32 to 34
detray::rk_stepper<bfield_type::view_t,
default_detector::device::algebra_type,
detray::constrained_step<scalar_type>>;
Copy link
Member Author

Choose a reason for hiding this comment

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

6D47

👍

krasznaa added 2 commits June 20, 2025 16:00
While also re-designing the templating in the functions that implement
the CKF algorithms for the different backends.
@krasznaa krasznaa force-pushed the CUDATemplatingRewrite-main-20250620 branch from 314edcc to a336d1f Compare June 20, 2025 14:07
@krasznaa
Copy link
Member Author

I think I managed to find a way to make the templating int he CKF functions a bit more user friendly. Making the "main functions" specifically templated on the detector and magnetic field types. And then using some newly introduced typedefs to figure out the correct Detray types based on just the detector and magnetic field types.

Now on to do the same for the KF algorithms...

While also slightly re-designing the templating in the functions that
implement the KF algorithms for the different backends.
@krasznaa
Copy link
Member Author

This PR ballooned into a much bigger thing by now than I originally intended. But the good news is that after this, adding non-const magnetic field versions of the finding and fitting functions will take a very finite amount of new lines of code. 🤔

Copy link

@krasznaa krasznaa changed the title CUDA Templating Rewrite, main branch (2025.06.20.) (CUDA) Templating Rewrite, main branch (2025.06.20.) Jun 20, 2025
Comment on lines +23 to 27
traccc::details::kalman_fitter_t<
default_detector::host,
covfie::field<traccc::const_bfield_backend_t<
default_detector::host::scalar_type>>::view_t>
fitter{det, field, m_config};
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically... this could also be expressed like:

auto fitter = details::make_kalman_fitter(det, field, m_config);

(After writing an appropriate helper function of course.)

But let's leave that to a future improvement.

const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const {

using scalar_type = default_detector::device::scalar_type;
Copy link
Member Author

Choose a reason for hiding this comment

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

Shoot. Forgot to remove this typedef...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda Changes related to CUDA high priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0