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

[ScatterElements] Clarify the requirement on indices uniqueness #3234

Open
masahi opened this issue Jan 23, 2021 · 8 comments
Open

[ScatterElements] Clarify the requirement on indices uniqueness #3234

masahi opened this issue Jan 23, 2021 · 8 comments
Labels
contributions welcome operator Issues related to ONNX operators spec clarification Clarification of the ONNX spec needed
Milestone

Comments

@masahi
Copy link

masahi commented Jan 23, 2021

The spec of ScatterElements op doesn't tell if elements of indices tensor need to be unique or not along the scattered axis. I think there should be an explicit clarification on this, because it would determine if non-deterministic outputs from "embarassingly parallel" scatter implementation (e.g. on GPU) are allowed or not.

Here some data points for reference:

@masahi masahi added the question Questions about ONNX label Jan 23, 2021
@masahi
Copy link
Author

masahi commented Jan 27, 2021

cc @askhade @jcwchen What do you think?

@jcwchen
Copy link
Member

jcwchen commented Jan 27, 2021

Hi @masahi,
Thank you for providing the details. I think it makes sense to me. Could someone in @onnx/sig-operators verify this? Thanks.

@jcwchen jcwchen added the operator Issues related to ONNX operators label Jan 27, 2021
@gramalingam
Copy link
Contributor

I agree (personally speaking). I think an equivalent way of saying it is that the spec does not guarantee a specific execution ordering for the updates (and so a unique output is guaranteed only if there indices are unique). The question is: is there any user (model) that is assuming otherwise and has a dependence on it? It seems unlikely, but would be good to verify. Does TF have the same assumption?

@masahi
Copy link
Author

masahi commented Jan 27, 2021

TF also says the output is non deterministic if there are duplicated indices https://www.tensorflow.org/api_docs/python/tf/compat/v1/scatter_update

JAX too, https://jax.readthedocs.io/en/latest/_autosummary/jax.lax.scatter.html

So the industry clearly favors more performance than guaranteeing determinism. I highly doubt there is anyone relying on the deterministic result.

To be on the safe side and support both modes, we can add a new attribute to specify if indices are supposed to be unique or not. That's what I'm thinking I'll do for TVM, which currently guarantees determinism and hence slow.

@postrational
Copy link
Contributor

I think we should avoid creating a new version of the operator, which acts a a superset of both behaviours. This would place the burden on implementors, to support both modes.

If the industry favours the parallel, non-deterministic approach, than we should document that this is what ONNX expects as well. If we do run into models, where this causes problems, we can come back to this issue and reconsider.

We should update our docs to be more explicit about the behaviour, but without introducing a new operator version.

@gramalingam
Copy link
Contributor

I also agree. Let us clarify the specification, not add an attribute to support both mode now. We can add it if and when there is a need for the second mode.

@stale
Copy link

stale bot commented Mar 28, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Mar 28, 2022
@stale stale bot closed this as completed Apr 19, 2022
@jcwchen
Copy link
Member

jcwchen commented Apr 20, 2022

Reopen it since this issue hasn't been resolved yet.

@jcwchen jcwchen reopened this Apr 20, 2022
@stale stale bot removed the stale label Apr 20, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
@jcwchen jcwchen reopened this May 22, 2023
@justinchuby justinchuby added spec clarification Clarification of the ONNX spec needed and removed question Questions about ONNX labels Aug 26, 2023
@justinchuby justinchuby added this to the 1.16 milestone Aug 26, 2023
@justinchuby justinchuby modified the milestones: 1.16, 1.17 Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome operator Issues related to ONNX operators spec clarification Clarification of the ONNX spec needed
Projects
None yet
Development

No branches or pull requests

5 participants