Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions exp/pecos-neo/src/ecs/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,12 @@ mod tests {
fn test_worker_state_with_entities() {
let mut worker: WorkerState<SparseStab> = WorkerState::new(0, 42);

worker.world.spawn_with_simulator(SparseStab::new(2));
worker.world.spawn_with_simulator(SparseStab::new(2));
worker
.world
.spawn_with_simulator(SparseStab::with_seed(2, 42));
worker
.world
.spawn_with_simulator(SparseStab::with_seed(2, 42));

assert_eq!(worker.active_count(), 2);

Expand Down Expand Up @@ -513,7 +517,7 @@ mod tests {

// Simple test: return entity count from each world
let results = coordinator.run(
|| SparseStab::new(1),
|| SparseStab::with_seed(1, 42),
|world| {
// Just return the entity IDs as results
world.entities().map(|e| e.0).collect()
Expand All @@ -538,12 +542,12 @@ mod tests {
let coordinator2: ParallelCoordinator<SparseStab> = ParallelCoordinator::new(config);

let results1 = coordinator1.run(
|| SparseStab::new(1),
|| SparseStab::with_seed(1, 42),
|world| world.entities().map(|e| world.base_seed() + e.0).collect(),
);

let results2 = coordinator2.run(
|| SparseStab::new(1),
|| SparseStab::with_seed(1, 42),
|world| world.entities().map(|e| world.base_seed() + e.0).collect(),
);

Expand All @@ -564,7 +568,7 @@ mod tests {
let coordinator: ParallelCoordinator<SparseStab> = ParallelCoordinator::new(config);

let results = coordinator.run(
|| SparseStab::new(1),
|| SparseStab::with_seed(1, 42),
|world| {
world
.entities()
Expand Down Expand Up @@ -596,7 +600,7 @@ mod tests {
let commands = CommandBuilder::new().pz(&[0]).h(&[0]).mz(&[0]).build();

let results = coordinator.run(
|| SparseStab::new(1),
|| SparseStab::with_seed(1, 42),
|world| {
// Run one shot per entity
world
Expand Down Expand Up @@ -665,7 +669,7 @@ mod tests {
let mut sync_count = 0;

let result: ParallelResult<()> = coordinator.run_with_sync(
|| SparseStab::new(1),
|| SparseStab::with_seed(1, 42),
5, // 5 steps
|_world, _step| {
// Do nothing per step
Expand Down
28 changes: 21 additions & 7 deletions exp/pecos-neo/src/ecs/redistribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,15 @@ mod tests {
let mut worker0: WorkerState<SparseStab> = WorkerState::new(0, 42);
let mut worker1: WorkerState<SparseStab> = WorkerState::new(1, 42);

worker0.world.spawn_with_simulator(SparseStab::new(1));
worker0.world.spawn_with_simulator(SparseStab::new(1));
worker1.world.spawn_with_simulator(SparseStab::new(1));
worker0
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));
worker0
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));
worker1
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));

let workers = vec![worker0, worker1];
let weights = collect_weights(&workers);
Expand All @@ -317,7 +323,9 @@ mod tests {
let mut worker = WorkerState::new(id, 42);
// Each worker gets 5 entities
for _ in 0..5 {
worker.world.spawn_with_simulator(SparseStab::new(1));
worker
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));
}
worker
})
Expand Down Expand Up @@ -357,10 +365,16 @@ mod tests {

// Worker 0 gets 10 entities, others get 1 each
for _ in 0..10 {
workers[0].world.spawn_with_simulator(SparseStab::new(1));
workers[0]
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));
}
workers[1].world.spawn_with_simulator(SparseStab::new(1));
workers[2].world.spawn_with_simulator(SparseStab::new(1));
workers[1]
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));
workers[2]
.world
.spawn_with_simulator(SparseStab::with_seed(1, 42));

let transfers = balance_entity_counts(&mut workers);

Expand Down
22 changes: 11 additions & 11 deletions exp/pecos-neo/src/ecs/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod tests {
fn test_world_spawn_with_simulator() {
let mut world: World<SparseStab> = World::new(42);

let e = world.spawn_with_simulator(SparseStab::new(2));
let e = world.spawn_with_simulator(SparseStab::with_seed(2, 42));

assert!(world.simulators.contains(e));
assert!(world.rngs.contains(e));
Expand All @@ -611,7 +611,7 @@ mod tests {
fn test_world_despawn() {
let mut world: World<SparseStab> = World::new(42);

let e = world.spawn_with_simulator(SparseStab::new(2));
let e = world.spawn_with_simulator(SparseStab::with_seed(2, 42));
assert!(world.is_alive(e));

world.despawn(e);
Expand All @@ -624,7 +624,7 @@ mod tests {
fn test_world_clone_entity() {
let mut world: World<SparseStab> = World::new(42);

let original = world.spawn_with_simulator(SparseStab::new(2));
let original = world.spawn_with_simulator(SparseStab::with_seed(2, 42));
let clone = world.clone_entity(original).unwrap();

assert_ne!(original, clone);
Expand All @@ -641,7 +641,7 @@ mod tests {
fn test_world_split_entity() {
let mut world: World<SparseStab> = World::new(42);

let original = world.spawn_with_simulator(SparseStab::new(2));
let original = world.spawn_with_simulator(SparseStab::with_seed(2, 42));

// Get original weight
let orig_weight = world.weights.get(original).unwrap().weight.weight();
Expand Down Expand Up @@ -673,7 +673,7 @@ mod tests {
let mut world: World<SparseStab> = World::new(42);

for _ in 0..10 {
world.spawn_with_simulator(SparseStab::new(2));
world.spawn_with_simulator(SparseStab::with_seed(2, 42));
}

let entities: Vec<EntityId> = world.entities().collect();
Expand All @@ -685,8 +685,8 @@ mod tests {
fn test_world_prune_by_weight() {
let mut world: World<SparseStab> = World::new(42);

let e1 = world.spawn_with_simulator(SparseStab::new(2));
let e2 = world.spawn_with_simulator(SparseStab::new(2));
let e1 = world.spawn_with_simulator(SparseStab::with_seed(2, 42));
let e2 = world.spawn_with_simulator(SparseStab::with_seed(2, 42));

// Set e2 to very low weight
world.weights.get_mut(e2).unwrap().weight = SampleWeight::from_linear(0.001);
Expand All @@ -702,8 +702,8 @@ mod tests {
fn test_world_spawn_with_full_seeding() {
let mut world: World<SparseStab> = World::new(42);

let e1 = world.spawn_with_full_seeding(SparseStab::new(2));
let e2 = world.spawn_with_full_seeding(SparseStab::new(2));
let e1 = world.spawn_with_full_seeding(SparseStab::with_seed(2, 42));
let e2 = world.spawn_with_full_seeding(SparseStab::with_seed(2, 42));

assert!(world.is_alive(e1));
assert!(world.is_alive(e2));
Expand All @@ -719,8 +719,8 @@ mod tests {
let mut world1: World<SparseStab> = World::new(42);
let mut world2: World<SparseStab> = World::new(42);

let e1a = world1.spawn_with_full_seeding(SparseStab::new(2));
let e1b = world2.spawn_with_full_seeding(SparseStab::new(2));
let e1a = world1.spawn_with_full_seeding(SparseStab::with_seed(2, 42));
let e1b = world2.spawn_with_full_seeding(SparseStab::with_seed(2, 42));

// Entity IDs should match
assert_eq!(e1a, e1b);
Expand Down
4 changes: 2 additions & 2 deletions exp/pecos-neo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ mod tests {
.add_channel(SingleQubitChannel::depolarizing(0.0))
.add_channel(TwoQubitChannel::depolarizing(0.0));

let mut state = SparseStab::new(2);
let mut state = SparseStab::with_seed(2, 42);
let mut runner = CircuitRunner::<SparseStab>::new()
.with_noise(noise)
.with_seed(42);
Expand Down Expand Up @@ -388,7 +388,7 @@ mod tests {
.add_plugin(&DepolarizingPlugin::new(0.0, 0.0))
.add_plugin(&MeasurementNoisePlugin::symmetric(0.0));

let mut state = SparseStab::new(2);
let mut state = SparseStab::with_seed(2, 42);
let mut runner = CircuitRunner::<SparseStab>::new()
.with_noise(noise)
.with_seed(42);
Expand Down
2 changes: 1 addition & 1 deletion exp/pecos-neo/src/noise/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ mod tests {
.build();

// Simple configuration
let mut state = SparseStab::new(1);
let mut state = SparseStab::with_seed(1, 42);
let mut simple_errors = 0;
for seed in 0..shots {
let model = NoiseModelBuilder::new().with_p1(p1).build();
Expand Down
18 changes: 9 additions & 9 deletions exp/pecos-neo/src/noise/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ mod tests {
let noise = ComposableNoiseModel::new().add_channel(channel);

// Run with noise
let mut state = SparseStab::new(1);
let mut state = SparseStab::with_seed(1, 42);
let mut runner = CircuitRunner::<SparseStab>::new()
.with_noise(noise)
.with_seed(42);
Expand Down Expand Up @@ -371,7 +371,7 @@ mod tests {
.add_channel(flow_channel)
.add_channel(meas_channel);

let mut state = SparseStab::new(1);
let mut state = SparseStab::with_seed(1, 42);
let mut runner = CircuitRunner::<SparseStab>::new()
.with_noise(noise)
.with_seed(42);
Expand Down Expand Up @@ -563,7 +563,7 @@ mod tests {

let noise = ComposableNoiseModel::new().add_channel(crosstalk);

let mut state = SparseStab::new(3);
let mut state = SparseStab::with_seed(3, 42);
let mut runner = CircuitRunner::<SparseStab>::new()
.with_noise(noise)
.with_seed(42);
Expand Down Expand Up @@ -669,7 +669,7 @@ mod tests {
);
let traditional_noise = ComposableNoiseModel::new().add_channel(traditional_channel);

let mut state_trad = SparseStab::new(1);
let mut state_trad = SparseStab::with_seed(1, seed);
let mut runner_trad = CircuitRunner::<SparseStab>::new()
.with_noise(traditional_noise)
.with_seed(seed);
Expand All @@ -685,7 +685,7 @@ mod tests {
let flow_channel = CompositeChannelBuilder::single_qubit("flow_sq", flow_noise);
let flow_noise_model = ComposableNoiseModel::new().add_channel(flow_channel);

let mut state_flow = SparseStab::new(1);
let mut state_flow = SparseStab::with_seed(1, seed);
let mut runner_flow = CircuitRunner::<SparseStab>::new()
.with_noise(flow_noise_model)
.with_seed(seed);
Expand Down Expand Up @@ -731,7 +731,7 @@ mod tests {
let traditional_channel = MeasurementChannel::symmetric(p_meas);
let traditional_noise = ComposableNoiseModel::new().add_channel(traditional_channel);

let mut state_trad = SparseStab::new(1);
let mut state_trad = SparseStab::with_seed(1, seed);
let mut runner_trad = CircuitRunner::<SparseStab>::new()
.with_noise(traditional_noise)
.with_seed(seed);
Expand All @@ -749,7 +749,7 @@ mod tests {
.with_filter(CompositeEventFilter::AfterMeasurement);
let flow_noise_model = ComposableNoiseModel::new().add_channel(flow_channel);

let mut state_flow = SparseStab::new(1);
let mut state_flow = SparseStab::with_seed(1, seed);
let mut runner_flow = CircuitRunner::<SparseStab>::new()
.with_noise(flow_noise_model)
.with_seed(seed);
Expand Down Expand Up @@ -810,7 +810,7 @@ mod tests {
.with_p_meas_symmetric(p_meas)
.build();

let mut state_trad = SparseStab::new(1);
let mut state_trad = SparseStab::with_seed(1, seed);
let mut runner_trad = CircuitRunner::<SparseStab>::new()
.with_noise(traditional_model)
.with_seed(seed);
Expand All @@ -835,7 +835,7 @@ mod tests {
.add_channel(sq_channel)
.add_channel(meas_channel);

let mut state_flow = SparseStab::new(1);
let mut state_flow = SparseStab::with_seed(1, seed);
let mut runner_flow = CircuitRunner::<SparseStab>::new()
.with_noise(flow_model)
.with_seed(seed);
Expand Down
Loading
Loading