Skip to content

Conversation

@horizon-blue
Copy link
Contributor

Part of MET-36

Summary of Changes

While working on the forward kernel, I noticed that currently we don't have a way to create a FMBScene with data from Python side. This PR fills in this missing piece by defining a new constructor for FMBScene that takes in references to std::vectors and copy the values.

Sadly, this copy is needed because FMBScene is designed to manage the memory for itself and we want to avoid double-free issue. In addition, since Python list is always on host (CPU) side, if we want the scene to live in GPU memory, then we have to move the data anyways.

Aside: Using RAII Containers in FMBScene

While writing the constructor & the unit test, I started to get a bit frustrated by having to write similar code twice to specialize for host/device memory management, so I replaced the underlying containers in FMBScene with thrust::device/host_vector :). Another nice side effect of this is that Thrust's device pointer & device reference types handle the moving of data for us automatically when we attempt to read it from host (see the definition of FMBScene.__getitem__ in bindints.cu for example).

Test Plans

I added a unit test to verify that we can create FMBScene on both device & host and read the values stored in it.

pixi run test

@linear
Copy link

linear bot commented Dec 5, 2025

MET-36 Integrate and test the forward pass

Definition of done:

  • the results of render_fmbs function calls should agree with the JAX code up to numerics
    • generate a teddy bear image
  • [ ]

@horizon-blue horizon-blue merged commit 8a69ad8 into master Dec 5, 2025
1 check passed
@horizon-blue horizon-blue deleted the xiaoyan/fmbscene-plus-plus branch December 5, 2025 21:52
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.

2 participants