Skip to content

qubic.toolchain

run_assemble_stage(compiled_program, channel_configs, target_platform='rfsoc')

Wrapper around distributed processor assembler stage.

Parameters:

Name Type Description Default
compiled_program CompiledProgram | List[CompiledProgram]
required
channel_configs Dict[str, ChannelConfig]
required
target_platform str

target hardware platform; currently only 'rfsoc' is supported

'rfsoc'

Returns:

Type Description
dict or list of dict

dict(s) containing the assembled binaries

Source code in qubic/toolchain.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def run_assemble_stage(compiled_program: cm.CompiledProgram | List[cm.CompiledProgram], 
                       channel_configs: Dict[str, hw.ChannelConfig], target_platform: str = 'rfsoc') -> Dict | List[Dict]:
    """
    Wrapper around distributed processor assembler stage. 

    Parameters
    ----------
    compiled_program: CompiledProgram | List[CompiledProgram]
    channel_configs: hw.ChannelConfig
    target_platform: str
        target hardware platform; currently only 'rfsoc' is supported

    Returns
    -------
    dict or list of dict
        dict(s) containing the assembled binaries 
    """
    if target_platform != 'rfsoc':
        raise Exception('rfsoc is currently the only supported platform!')

    if isinstance(compiled_program, list):
        raw_asm_progs = []
        for prog in compiled_program:
            asm = am.GlobalAssembler(prog, channel_configs, hw.RFSoCElementCfg)
            raw_asm_progs.append(asm.get_assembled_program())
        return raw_asm_progs

    else:
        asm = am.GlobalAssembler(compiled_program, channel_configs, hw.RFSoCElementCfg)
        return asm.get_assembled_program()

run_compile_stage(program, fpga_config, qchip, compiler_flags=None)

Wrapper around distributed processor compiler stage.

Parameters:

Name Type Description Default
program List

single QubiC program or list of programs. Each program can be:

- list of dicts formatted according to the QubiC Higher-level 
  Representation
- list of QubiC intermediate representation instructions 
  (distproc.ir_instruction classes)
required
fpga_config FPGAConfig
required
qchip QChip
required
compiler_flags Dict[str, bool] | CompilerFlags

Options for configuring the compiler; see distproc.compiler.get_passes for more details. Default is None, which sets all flags to True (fine for most use cases)

None

Returns:

Type Description
CompiledProgram or List[CompiledProgram]

object containing compiled program

Source code in qubic/toolchain.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def run_compile_stage(program: List, fpga_config: hw.FPGAConfig, qchip: qc.QChip, 
                      compiler_flags: Dict[str, bool] | cm.CompilerFlags = None) -> cm.CompiledProgram | List[cm.CompiledProgram]:
    """
    Wrapper around distributed processor compiler stage. 

    Parameters
    ----------
    program: list
        single QubiC program or list of programs. Each program can be:

            - list of dicts formatted according to the QubiC Higher-level 
              Representation
            - list of QubiC intermediate representation instructions 
              (distproc.ir_instruction classes)
    fpga_config: hw.FPGAConfig
    qchip: qc.QChip
    compiler_flags: dict | cm.CompilerFlags
        Options for configuring the compiler; see distproc.compiler.get_passes for 
        more details. Default is None, which sets all flags to True (fine for 
        most use cases)

    Returns
    -------
    CompiledProgram or List[CompiledProgram]
        object containing compiled program
    """
    passes = cm.get_passes(fpga_config, qchip, compiler_flags=compiler_flags)
    if isinstance(program[0], dict):
        compiler = cm.Compiler(program)
        compiler.run_ir_passes(passes)
        return compiler.compile()
    elif isinstance(program[0], list):
        compiled_progs = []
        for circuit in program:
            compiler = cm.Compiler(circuit)
            compiler.run_ir_passes(passes)
            compiled_progs.append(compiler.compile())
        return compiled_progs
    else:
        raise TypeError