Store an Idle command's duration as time units instead of a rotation angle - #729
Open
ciaranra wants to merge 2 commits into
Open
Store an Idle command's duration as time units instead of a rotation angle#729ciaranra wants to merge 2 commits into
ciaranra wants to merge 2 commits into
Conversation
# Conflicts: # exp/pecos-neo/src/lib.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #727.
Problem
GateCommandinpecos-neohad only ananglesfield, soGateCommand::idlestored an idle gate's duration there by reinterpretingAngle64's u64 storage as a count of time units. The construction site said so outright. Every consumer that readanglestherefore treated an idle duration as a rotation angle.pecos-corealready models this correctly and is unchanged here:GateType::Idle.angle_arity()is 0, andGate::idlebuilds with empty angles and the duration inparams. Onlypecos-neodisagreed.The visible consequence was in
snap_command_queue, which snapped the duration to the nearest representable rotation angle: an idle of 23 time units became 0.Change
angles()returns&[]for a duration payload, so an Idle command genuinely has no angles and angle consumers need no special case for it. The duration is aTimeUnitsthroughout, exact across the fullu64range.new,with_angles,idleandget_idle_durationkeep their signatures, so callers do not churn.The consumers in
queue_validation.rschange only fromcmd.anglestocmd.angles(). Nothing there special-cases Idle, which is the point: the distinction now lives in the type rather than in each reader's memory.pecos-coreand the wire format are untouched.ByteMessagealready derives angle count from gate type and writes non-angle parameters separately, andGateCommandhas no serde implementation, so no encoding changes.Incidental fix
sim_neo_bindings.rscontained a hand-rolled copy of the command-to-gate conversion that built a coreGatewithparams: GateParams::new()while copying the command's angles across. For an Idle command that wrote the duration into the angle slot of a gate whose duration belongs inparams, so the experimental Python bridge was producing malformed Idle gates and dropping durations. It now calls the sharedcommand_queue_to_gates.Verification
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings: clean.cargo fmt --all -- --check: clean.f64, exposing a duration as an angle, dropping the duration during snapping, and dropping it on import, export and dispatch.Converting a
GateCommandinto a coreGatestill passes throughTimeUnits::as_f64(), so durations above 2^53 lose precision at that boundary. That limit is pre-existing, follows fromGate.paramsbeingf64, and is entangled with thef64-based wire format, so it is deliberately left alone here.Relationship to #701
#701 enforces gate angle arity. On its branch,
pecos-neospecial-casedIdleto report an angle arity of 1 so that the duration-in-angles storage would pass its own new validation, which is what made an idle duration visible to angle consumers as a rotation angle. With the storage corrected here, that special case is unnecessary.