local

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package local provides a backend.Backend backed by the in-process statevector simulator.

New creates a backend with optional WithMaxQubits (default 28) and WithLogger. Execution is synchronous: Backend.Submit runs the circuit immediately and returns a completed job. Results are cached in memory.

Package local provides a Backend backed by the statevector simulator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend runs circuits on the local statevector simulator.

func New

func New(opts ...Option) *Backend

New creates a local simulator backend.

func (*Backend) Cancel

func (b *Backend) Cancel(_ context.Context, _ string) error

Cancel is a no-op for the local backend since jobs complete synchronously.

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) Result

func (b *Backend) Result(_ context.Context, jobID string) (*backend.Result, error)

Result retrieves the result of a completed job.

func (*Backend) Status

func (b *Backend) Status(_ context.Context, jobID string) (*backend.JobStatus, error)

Status returns the status of a job. All local jobs are immediately completed.

func (*Backend) Submit

func (b *Backend) Submit(ctx context.Context, req *backend.SubmitRequest) (*backend.Job, error)

Submit executes the circuit synchronously and returns a completed job.

func (*Backend) Target

func (b *Backend) Target() target.Target

type Option

type Option func(*Backend)

Option configures a local Backend.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets the structured logger for the local backend.

func WithMaxQubits

func WithMaxQubits(n int) Option

WithMaxQubits sets the maximum number of qubits the simulator supports.

func WithSimulator added in v1.2.0

func WithSimulator(f SimFactory) Option

WithSimulator sets a custom simulator factory. This allows plugging in alternative simulators (e.g., GPU-accelerated) while keeping the same backend API.

type SimFactory added in v1.2.0

type SimFactory func(numQubits int) (sim.Simulator, error)

SimFactory creates a Simulator for the given number of qubits. The default factory creates a CPU statevector simulator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL