arcade.hardware
Stage 3 — Hardware: HLS4ML export, synthesis report parsing, resource estimation, scalability.
- class arcade.hardware.BaseHardwareEstimator[source]
Bases:
ABCInterface for hardware resource estimation.
Subclass and decorate with
@register_estimator("name").Example:
@register_estimator("my_estimator") class MyEstimator(BaseHardwareEstimator): def estimate(self, model, **kwargs): ... return ResourceReport(classifier_name="my_clf", lut=100)
- class arcade.hardware.AnalyticalEstimator[source]
Bases:
BaseHardwareEstimatorData-driven analytical hardware estimator.
- class arcade.hardware.ResourceReport(classifier_name, lut=None, ff=None, bram=None, dsp=None, latency_cycles=None, latency_ns=None, macs_per_inference=None, clock_period_ns=None, estimated=True, note='')[source]
Bases:
objectFPGA resource estimate for a single classifier.
- Parameters:
- arcade.hardware.register_estimator(name)[source]
Decorator to register a hardware estimator class by name.
- Parameters:
name (str)
- arcade.hardware.get_estimator(name)[source]
Look up a hardware estimator by registry name or dotted import path.
- Return type:
- Parameters:
name (str)
- arcade.hardware.estimate_resources(model, config=None, *, classifier_name='unknown')[source]
Estimate FPGA resources for a trained classifier.
Dispatches to type-specific parameter sets based on the model type.
- Parameters:
- Return type:
- Returns:
A
ResourceReportwith resource estimates.
- arcade.hardware.export_hls4ml(model, output_dir, *, backend='Vivado', clock_period=5.0, io_type='io_parallel', reuse_factor=1, precision='ap_fixed<16,6>')[source]
Convert a trained PyTorch model to an HLS4ML project.
- Parameters:
model (
Any) – Trained PyTorchnn.Module.output_dir (
Union[str,Path]) – Directory for the generated HLS project.backend (
str) – HLS backend ("Vivado"or"Quartus").clock_period (
float) – Target clock period in nanoseconds.io_type (
str) –"io_parallel"or"io_stream".reuse_factor (
int) – Resource reuse factor (higher = smaller area, longer latency).precision (
str) – Default fixed-point precision for all layers.
- Return type:
- Returns:
Path to the generated HLS project directory.
- Raises:
ImportError – If hls4ml is not installed.
ValueError – If no Linear layers are found in the model.
- arcade.hardware.parse_synth_report(project_dir, *, report_file=None)[source]
Parse a Vivado synthesis report and return key metrics.
- Parameters:
- Return type:
- Returns:
Dict with
"lut","ff","bram","dsp","latency_cycles","clock_period_ns","latency_ns", and"report_path".- Raises:
FileNotFoundError – If no report file is found.
- arcade.hardware.project_scalability(base_report, qubit_counts, *, base_num_qubits=5, num_levels=2, n_filter_types=1)[source]
Project resource usage to different qubit counts.
Extrapolates from a base measurement or estimate using known scaling relationships:
Filter count scales as
C(num_levels, 2) * num_qubits * n_filter_types.NN input dim scales linearly with filter count.
NN compute (MACs) scales quadratically with input dim for the first hidden layer, linearly for subsequent layers.
Threshold/comparator resources scale linearly.
- Parameters:
base_report (
ResourceReport) – Measured or estimated resources at base_num_qubits.qubit_counts (
Sequence[int]) – Target qubit counts to project to.base_num_qubits (
int) – Qubit count the base_report was measured at.num_levels (
int) – Energy levels per qubit.n_filter_types (
int) – Number of filter families (1=MF, 2=MF+RMF, 3=MF+RMF+EMF).
- Return type:
- Returns:
List of dicts with
"num_qubits","lut","ff","bram","dsp","latency_cycles","latency_ns", and"scale_factor".
- arcade.hardware.project_qubit_scaling(base_report, qubit_counts, *, base_num_qubits=5, num_levels=2, n_filter_types=1)
Project resource usage to different qubit counts.
Extrapolates from a base measurement or estimate using known scaling relationships:
Filter count scales as
C(num_levels, 2) * num_qubits * n_filter_types.NN input dim scales linearly with filter count.
NN compute (MACs) scales quadratically with input dim for the first hidden layer, linearly for subsequent layers.
Threshold/comparator resources scale linearly.
- Parameters:
base_report (
ResourceReport) – Measured or estimated resources at base_num_qubits.qubit_counts (
Sequence[int]) – Target qubit counts to project to.base_num_qubits (
int) – Qubit count the base_report was measured at.num_levels (
int) – Energy levels per qubit.n_filter_types (
int) – Number of filter families (1=MF, 2=MF+RMF, 3=MF+RMF+EMF).
- Return type:
- Returns:
List of dicts with
"num_qubits","lut","ff","bram","dsp","latency_cycles","latency_ns", and"scale_factor".
- class arcade.hardware.DSEPoint(reuse_factor, precision, io_type, lut=None, ff=None, dsp=None, bram=None, latency_ns=None, accuracy=None)[source]
Bases:
objectOne point in the design space.
- Parameters:
- class arcade.hardware.DSEResult(points=<factory>, pareto_optimal=<factory>, best_accuracy=None, best_resources=None, best_balanced=None)[source]
Bases:
objectResult of design-space exploration.
- Parameters:
- arcade.hardware.explore_design_space(model, train_features, train_labels, test_features, test_labels, *, reuse_factors=None, precisions=None, io_types=None, target_fpga='xc7z020', clock_period_ns=5.0)[source]
Sweep reuse_factor x precision x io_type and estimate resources.
For each combination, estimates FPGA resources analytically. When HLS4ML is available, uses actual synthesis estimates.