-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feedback and next steps on relaxed mode #107
Comments
I like the idea of making NaN semantics deterministic, but feel it is out of scope of the Relaxed SIMD proposal. |
My (personal!) opinions:
|
What does it mean for "relaxed" to be the clear default? My understanding from the presentation was that even if relaxed is a mode in the appendix, all toolchains and users are expected to conservatively assume that they may be run on a platform that uses relaxed mode. I would guess the argument for making it a 'default' in spec language is to signal this is the desired long-term behavior, and to ensure that 'relaxed mode' has an ability to be removed easily in the future if hardware support becomes widespread enough. But this just all framing I suppose. I also meant to say in the original presentation that we could see certain browsers (like Tor) adopt strict determinism (including NaNs). So I don't think this is just a 'cloud vendor' thing, if that changes the calculus. |
@eqrion part of my reasoning is that we will likely see toolchains with at least the option of producing "strict" mode specific code. It's always safe to produce code targetting the "relaxed" mode, which will then still work correctly in the "strict" mode, so we should be strongly encouraging at least the user-facing side of Wasm to clearly signal this as the default. |
In WebAssembly/relaxed-simd#107, there is a suggestion that "relaxed-math mode" be implemented as a profile using Andreas' profiles proposal. This adds an agenda item to discuss the current options with the CG.
* Add an agenda item to discuss relaxed-math mode. In WebAssembly/relaxed-simd#107, there is a suggestion that "relaxed-math mode" be implemented as a profile using Andreas' profiles proposal. This adds an agenda item to discuss the current options with the CG.
Circling back to this thread after the CG meeting to discuss next steps. The CG consensus was to not block on profiles, but there are a couple of things that might be worthwhile to discuss:
|
Currently we specify only the relaxed mode operations: https://www.ngzhian.com/relaxed-simd/core/exec/numerics.html#relaxed-operators We would need to specify the deterministic variation of this. The actual semantics of the operators will be "subscripted" by the mode. I'm thinking that in the Numerics section, right now we have a "Relaxed operator" header. It can be divided into 2 subsections, "Relaxed operator in deterministic mode", and "Relaxed operator in relaxed-mode". The summary of the section can be along the lines: "Relaxed operators are operations whose definition depend on the host environment. The host environment can provide either a deterministic mode, or a relaxed mode. Relaxed operators are specified based on this mode." Then proceed with definitions of deterministic relaxed operations, and relaxed-mode relaxed operations. |
I think it was proposed deterministic FMA to be mul+add. From acceptance criteria angle, would relaxed mode be required for browsers, i.e. is it OK if one Web implementation choses defaults to relaxed mode, while another - to strict? |
Don't think so, see slide 4 of https://sunfishcode.github.io/RelaxedMathMode.pdf. FMA is deterministic, relaxed mode allows FMA or mul+add. |
Oh, that is surprising! I guess the motivation is that strict mode would run on newer hardware which has FMA... |
I think it is important that deterministic mode is not an alternative semantics, but a restriction of the general semantics, i.e., a subset of rules. So rather than 2 sections, there ought to be a single definition with some rules marked as unavailable in deterministic mode. Notably, all rules are applicable in non-deterministic mode. Rationale: This makes sure that both semantics are consistent, and moreover, trivially ensures that all programs behaving correctly in non-deterministic mode also behave correctly in deterministic mode. |
Good point, here's my attempt:
where Somewhere in a paragraph above, we will have to describe the host as being in relaxed mode or not. |
Just to bikeshed a little, I'd prefer if the "relaxed" semantics is called something like "full"/"general"/"default" in the spec, and the deterministic semantics is called something like "strict"/"deterministic", especially if we aim to (for example) narrow the allowed NaN bit patterns of existing scalar float instructions in "deterministic" mode. |
@ngzhian, something like that, but without an "otherwise" and inverting the terminology like @conrad-watt suggested. I would also keep these annotations separate from side conditions, since they are a different dimension, and some rules could have both side conditions and annotations. I envision something like:
Let me try to flesh out something for NaNs next week, so that you can perhaps follow that pattern. |
I chose the phrasing "relaxed-math mode" in my presentation because I proposed we use it to provide some level of containment around the list nondeterminism, rather than embracing it and having the deterministic mode be a subordinate subset of it. However, if we end up structuring the spec in terms of profiles, then yes, it likely needs to be structured in terms of the common superset and subsets. I would still prefer to avoid the implied value judgement of calling it "default" though. |
I rebased relaxed-simd changes on top of WebAssembly/profiles#5, changes are at https://www.ngzhian.com/relaxed-simd/core/syntax/instructions.html#vector-instructions see #115 for the code changes Summary of changes:
|
Hm, I thought the idea was that deterministic mode assigns deterministic semantics to these, rather than forbidding the instructions? |
We discussed that during the sync, the concern is that not all instructions will have a satisfactory deterministic semantics, so it can be confusing if we have some that are map to deterministic semantics, and some that don't. Now that I look at the list of instructions again, the only instruction that does not have a mapping to SIMD 128 instruction is FMA, since we don't have a FMA instruction. (The other tricky one is #77 but we voted to not include that.) I think we can switch it to assigning deterministic semantics. |
Given the support for relaxed mode in #105, let's address some feedback we got during Dan's presentation, and discuss next steps.
Some feedback from meeting notes
(Discussions for BF16 dot product should go to #106)
The text was updated successfully, but these errors were encountered: