Skip to content

Wrong device for residual-based weights in RBAPINN #613

Description

@GiovanniCanali

Describe the bug
When training with RBAPINN, if the selected accelerator is not cpu (e.g., "cuda"), the residual-based weight buffers are not properly moved to the correct device. As a result, a device mismatch error occurs during training, preventing execution from continuing.

To Reproduce

from pina.problem.zoo import Poisson2DSquareProblem as Poisson
from pina.model import FeedForward
from pina.solver import RBAPINN
from pina import Trainer

# Define the problem
problem = Poisson()
problem.discretise_domain(n=50, mode="grid")

# Define the model and the solver
model = FeedForward(2, 1, 64, 2)
solver = RBAPINN(problem=problem, model=model)

# Initialize the trainer and begin training
trainer = Trainer(solver=solver, max_epochs=100, accelerator="cuda", devices=1)
trainer.train()

Expected behavior
Training should proceed without device mismatch errors, and all internal buffers should be moved automatically to the specified accelerator prior to training.

Metadata

Metadata

Labels

bugSomething isn't workinghigh priorityHigher priority

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions