Skip to content
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

Bug: Incompatible uniqueness assumption causes crashes #842

Open
emchristiansen opened this issue Aug 3, 2023 · 1 comment
Open

Bug: Incompatible uniqueness assumption causes crashes #842

emchristiansen opened this issue Aug 3, 2023 · 1 comment

Comments

@emchristiansen
Copy link

emchristiansen commented Aug 3, 2023

Code to reproduce for OwnedTape<_, _>:

let x = dev.tensor(1.0);
let y = x
  .clone()
  .put_tape(OwnedTape::<f32, Cpu>::default())
  + x.with_empty_tape();
// Crash is here.
y.backward();

Code to reproduce for Arc<Mutex<OwnedTape<_, _>>>:

let dev = Cpu::default();
let x = dev
  .tensor(1.0)
  .put_tape(Arc::<
    Mutex<OwnedTape<f32, Cpu>>,
  >::default(
  ));
let y = x.clone() + x;
// Crash is here.
y.backward();

The code crashes with this error:

Message:  assertion failed: `(left != right)`
  left: `UniqueId(0)`,
 right: `UniqueId(0)`
Location: dfdx/src/tensor/gradients.rs:143

The crash is caused by the assert here, which appear to be related to a requirement that operands represent unique tensors.

@emchristiansen emchristiansen changed the title Bug: Arc<Mutex<OwnedTape<_, _>>> breaks uniqueness assumption, causing crash Bug: Incompatible uniqueness assumption causes crashes Aug 3, 2023
@coreylowman
Copy link
Owner

Hmm yeah thanks for raising this. As a workaround, you can probably just use 2 * x instead of x + x in the meantime.

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

No branches or pull requests

2 participants