Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement Parser #2149

Open
wants to merge 98 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
e78f23a
Implement OpenQASM 3 lexer (#2129)
orpuente-MS Feb 2, 2025
38cdab7
Add initial AST and parser infrastructure (#2148)
idavis Feb 4, 2025
ae3a64b
Add ability to parse quantum decls and lit exprs (#2160)
idavis Feb 5, 2025
05c3c2a
Adding classical & io decls to the parser, stubbing out array decls (…
idavis Feb 7, 2025
adbe623
Fix panic in qasm3 lexer found by the fuzzer (#2170)
orpuente-MS Feb 11, 2025
2424252
Add fuzzing for qasm3 (#2167)
idavis Feb 11, 2025
f12ecab
Implement Pratt Parsing for Qasm3 parser (#2166)
orpuente-MS Feb 11, 2025
abc0613
Parse qasm3 switch statements (#2178)
orpuente-MS Feb 12, 2025
7d4e1a7
Add subroutine, return, and gate defs, externs, and old style decls (…
idavis Feb 12, 2025
279ea73
Add array and measurement declaration statements (#2180)
orpuente-MS Feb 13, 2025
aa6826a
parse if, for, and while statements
orpuente-MS Feb 19, 2025
7cb2d57
fix range expression
orpuente-MS Feb 20, 2025
e22b82e
update for loop unit tests
orpuente-MS Feb 20, 2025
03eb295
add continue statements
orpuente-MS Feb 20, 2025
42a207f
update completions unit tests
orpuente-MS Feb 20, 2025
5fe2b62
add break statements
orpuente-MS Feb 20, 2025
e6921f0
fix assignment expressions and add expression statements
orpuente-MS Feb 20, 2025
9f07a37
add end stmt
orpuente-MS Feb 20, 2025
fe2417a
add alias declarations
orpuente-MS Feb 20, 2025
f523cb8
format alias.rs file
orpuente-MS Feb 20, 2025
70e05b9
fixes during PR review with swernli
orpuente-MS Feb 20, 2025
39d4b2f
gate calls
orpuente-MS Feb 24, 2025
77ff1f3
update expect tests
orpuente-MS Feb 25, 2025
335c155
gate-call qubit args should be comma separated
orpuente-MS Feb 25, 2025
cc2ccc0
add barrier, box, calgrammar, cal, defcal, delay, measure arrow, and …
orpuente-MS Feb 25, 2025
1eecd2b
update completions tests
orpuente-MS Feb 25, 2025
1761044
add unit tests
orpuente-MS Feb 25, 2025
9875be4
fix formatting
orpuente-MS Feb 25, 2025
e19249c
update completions tests
orpuente-MS Feb 25, 2025
5c74762
update unit tests
orpuente-MS Feb 25, 2025
f722ac7
add support for timing literals
orpuente-MS Feb 26, 2025
7aa03d4
improve TODO messages
orpuente-MS Feb 26, 2025
fbc3f1b
address comments in PR review
orpuente-MS Feb 26, 2025
99962db
add gphase
orpuente-MS Feb 27, 2025
3d75808
add unit test for box with designator
orpuente-MS Feb 27, 2025
034db21
require exactly one angle argument in `gphase`
orpuente-MS Feb 27, 2025
7663c44
fix parse_include and parse_cal_grammar
orpuente-MS Feb 27, 2025
1303b66
PR review fixes
orpuente-MS Feb 27, 2025
5c3c6e3
fixes during PR review
orpuente-MS Feb 28, 2025
3715871
fixes during PR review
orpuente-MS Feb 28, 2025
ff7dbab
add unit tests for gate_call
orpuente-MS Feb 28, 2025
ac18610
change unit tests names
orpuente-MS Feb 28, 2025
13517c8
format file
orpuente-MS Feb 28, 2025
874fbb4
disambiguate between cast expr_stmts and classical decls
orpuente-MS Feb 28, 2025
bbd07a7
update cast unit tests
orpuente-MS Feb 28, 2025
3bfa4a1
make expr unit tests also run for expr_stmts by adding a semicolon at…
orpuente-MS Feb 28, 2025
f86780b
fix formatting
orpuente-MS Feb 28, 2025
ae69395
fix lexer bug
orpuente-MS Mar 1, 2025
ac46f83
format code
orpuente-MS Mar 1, 2025
d93b183
fix lexer bug and remove `second` from cooked lexer
orpuente-MS Mar 1, 2025
297f352
update test
orpuente-MS Mar 1, 2025
4d5cca4
remove extra scope
orpuente-MS Mar 3, 2025
8b7a2b9
Tidy up Display functions in QASM3 parser (#2209)
orpuente-MS Mar 5, 2025
4a1ae9c
Add initial semantic analysis/transform (#2214)
idavis Mar 7, 2025
81b07d7
Make Assign and AssignOp valid only in expression statements (#2215)
orpuente-MS Mar 8, 2025
5fda609
Make assignment a StmtKind (#2216)
orpuente-MS Mar 11, 2025
abc2454
Add grammar docstrings to QASM3 parser (#2222)
orpuente-MS Mar 12, 2025
a1d6530
Implement base declarations and binary expression lowering (#2221)
idavis Mar 12, 2025
044bf0b
Make control flow stmts use Stmt instead of List<Stmt> for their bodi…
orpuente-MS Mar 13, 2025
39a1bbb
Update cross file spans, separate parse/semantic result blurring (#2227)
idavis Mar 13, 2025
c338833
Lower control flow stmts in QASM3 parser (#2232)
orpuente-MS Mar 17, 2025
b13e82c
Adding new compiler, lowerer is now infallible (#2239)
idavis Mar 18, 2025
99b5caa
Unify compilation and error propagation. (#2247)
idavis Mar 21, 2025
045774f
Add gate calls and the AST items it depends on to the new QASM3 compi…
orpuente-MS Mar 24, 2025
07ed8ec
Removing old test
idavis Mar 24, 2025
93bbf57
Parsing now bundles IO source loading errors into parse errors. (#2252)
idavis Mar 25, 2025
4717a1a
Compile gphase, gatedef, and control flow statements (#2254)
orpuente-MS Mar 27, 2025
a23f9a3
QASM3 - Add implicit casts to function and gate arguments (#2257)
orpuente-MS Mar 27, 2025
fd5061e
QASM3 - simple index expr (#2258)
orpuente-MS Mar 27, 2025
c35ad73
Add angle support to the new compiler (#2267)
orpuente-MS Mar 31, 2025
34af2f8
Lower and compile complex binary ops (#2268)
orpuente-MS Apr 1, 2025
b4a905e
Fixing angle input/output (#2269)
idavis Apr 1, 2025
f89b707
Fix scoping resolution for defs
idavis Apr 1, 2025
1817194
functions and operations with const eval (#2270)
orpuente-MS Apr 1, 2025
7e45485
Compile annotations into attributes (#2271)
orpuente-MS Apr 1, 2025
b65e7da
unignore tests
orpuente-MS Apr 1, 2025
cf2cdff
add simulatable intrinsic QIR unit tests
orpuente-MS Apr 1, 2025
d5531e2
clippy lints
orpuente-MS Apr 2, 2025
b7e6183
apply cargo fmt
orpuente-MS Apr 2, 2025
cb2355d
make const measurement a parser error
orpuente-MS Apr 2, 2025
803047a
do not generate functors when `@SimulatableIntrinsic` is present
orpuente-MS Apr 2, 2025
7e1d102
cargo fmt
orpuente-MS Apr 2, 2025
ea224ef
break and continue stmts
orpuente-MS Apr 2, 2025
3092293
lower duration literals
orpuente-MS Apr 3, 2025
54f17fa
use `Type::Void` instead of `Option::None` to represent no return
orpuente-MS Apr 3, 2025
a0bfb92
return stmt casts to the return type of the function
orpuente-MS Apr 3, 2025
b243417
fix clippy warning
orpuente-MS Apr 3, 2025
a0e76ef
add assign_op complex tests
orpuente-MS Apr 3, 2025
fc55f12
mark assigning_uint_to_negative_lit_results_in_semantic_error as ignore
orpuente-MS Apr 3, 2025
8f2098f
lower extern
orpuente-MS Apr 3, 2025
be8f1ae
extern unit tests
orpuente-MS Apr 3, 2025
8c98210
Better error messages for const evaluator (#2277)
orpuente-MS Apr 4, 2025
1b775b1
Cyclic and multiple include errors (#2278)
orpuente-MS Apr 7, 2025
c48bcc2
Remove external parser. Fix Qiskit's failure to emit gates. (#2284)
idavis Apr 9, 2025
55367d7
Cleanup TODO items (#2285)
orpuente-MS Apr 9, 2025
b587f22
Review errors in lexer, parser, lowerer, and compiler (#2286)
orpuente-MS Apr 10, 2025
51d5245
Qiskit stdgates workaround (#2289)
idavis Apr 10, 2025
034e0f8
Add benchmark to new parser (#2288)
orpuente-MS Apr 11, 2025
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
38 changes: 21 additions & 17 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ env:
TMIN_LOG_FNAME: fuzz.tmin.log # File name to redirect the fuzzing input minimization log to.
GH_ISSUE_TEMPLATE_RFPATH: .github/ISSUE_TEMPLATE/fuzz_bug_report.md
# GitHub issue template rel file path.
TARGET_NAME: compile # Fuzzing target name. Fuzzes the `compile` func of the Q# compiler.
ARTIFACTS_RDPATH: fuzz/artifacts # Fuzzing artifacts rel dir path.
SEEDS_RDPATH: fuzz/seed_inputs # Fuzzing seed inputs rel dir path.
SEEDS_FNAME: list.txt # Fuzzing seed inputs list file name.
Expand All @@ -31,11 +30,15 @@ jobs:
fuzz:
name: Fuzzing
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # Fuzzing is not supported on Win. The macos is temporarily removed
# because of low availability.
runs-on: ${{ matrix.os }}
target_name: [qsharp, qasm3]

runs-on: ${{ matrix.os }}
permissions:
issues: write
steps:
- name: Install and Configure Tools
run: |
Expand All @@ -49,29 +52,30 @@ jobs:
submodules: "true"

- name: Gather the Seed Inputs
if: matrix.target_name == 'qsharp'
run: |
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.

# Clone the submodules of QDK:
REPOS="Quantum Quantum-NC QuantumKatas QuantumLibraries iqsharp qdk-python qsharp-compiler qsharp-runtime"
for REPO in $REPOS ; do
git clone --depth 1 --single-branch --no-tags --recurse-submodules --shallow-submodules --jobs 4 \
https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/$TARGET_NAME/$REPO
https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/${{ matrix.target_name }}/$REPO
done

# Build a comma-separated list of all the .qs files in $SEEDS_FNAME file:
find $SEEDS_RDPATH/$TARGET_NAME -name "*.qs" | tr "\n" "," > \
$SEEDS_RDPATH/$TARGET_NAME/$SEEDS_FNAME
find $SEEDS_RDPATH/${{ matrix.target_name }} -name "*.qs" | tr "\n" "," > \
$SEEDS_RDPATH/${{ matrix.target_name }}/$SEEDS_FNAME

- name: Build and Run the Fuzz Target
run: |
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.
cargo fuzz build --release --sanitizer=none --features do_fuzz $TARGET_NAME # Build the fuzz target.
cargo fuzz build --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} # Build the fuzz target.

# Run fuzzing for specified number of seconds and redirect the `stderr` to a file
# whose name is specified by the STDERR_LOG_FNAME env var:
RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz $TARGET_NAME -- \
-seed_inputs=@$SEEDS_RDPATH/$TARGET_NAME/$SEEDS_FNAME \
RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} -- \
-seed_inputs=@$SEEDS_RDPATH/${{ matrix.target_name }}/$SEEDS_FNAME \
-max_total_time=$DURATION_SEC \
-rss_limit_mb=4096 \
-max_len=20000 \
Expand Down Expand Up @@ -116,33 +120,33 @@ jobs:
# the subsequent `run:` and `uses:` steps.

# Determine the name of a file containing the input of interest (that triggers the panic/crash):
if [ -e $ARTIFACTS_RDPATH/$TARGET_NAME/crash-* ]; then # Panic and Stack Overflow Cases.
if [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }}/crash-* ]; then # Panic and Stack Overflow Cases.
TO_MINIMIZE_FNAME=crash-*;
elif [ -e $ARTIFACTS_RDPATH/$TARGET_NAME/oom-* ]; then # Out-of-Memory Case.
elif [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }}/oom-* ]; then # Out-of-Memory Case.
TO_MINIMIZE_FNAME=oom-*;
else
echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/$TARGET_NAME/\":"
ls $ARTIFACTS_RDPATH/$TARGET_NAME/
echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/${{ matrix.target_name }}/\":"
ls $ARTIFACTS_RDPATH/${{ matrix.target_name }}/
fi

if [ "$TO_MINIMIZE_FNAME" != "" ]; then
echo "TO_MINIMIZE_FNAME: $TO_MINIMIZE_FNAME"

# Minimize the input:
( cargo fuzz tmin --release --sanitizer=none --features do_fuzz -r 10000 $TARGET_NAME $ARTIFACTS_RDPATH/$TARGET_NAME/$TO_MINIMIZE_FNAME 2>&1 ) > \
( cargo fuzz tmin --release --sanitizer=none --features do_fuzz -r 10000 ${{ matrix.target_name }} $ARTIFACTS_RDPATH/${{ matrix.target_name }}/$TO_MINIMIZE_FNAME 2>&1 ) > \
$TMIN_LOG_FNAME || MINIMIZATION_FAILED=1

# Get the minimized input relative faile path:
if [ "$MINIMIZATION_FAILED" == "1" ]; then
# Minimization failed, get the latest successful minimized input relative faile path:
MINIMIZED_INPUT_RFPATH=`
cat $TMIN_LOG_FNAME | grep "CRASH_MIN: minimizing crash input: " | tail -n 1 |
sed "s|^.*\($ARTIFACTS_RDPATH/$TARGET_NAME/[^\']*\).*|\1|"`
sed "s|^.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }}/[^\']*\).*|\1|"`
else
# Minimization Succeeded, get the reported minimized input relative faile path::
MINIMIZED_INPUT_RFPATH=`
cat $TMIN_LOG_FNAME | grep "failed to minimize beyond" |
sed "s|.*\($ARTIFACTS_RDPATH/$TARGET_NAME/[^ ]*\).*|\1|" `
sed "s|.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }}/[^ ]*\).*|\1|" `
fi
echo "MINIMIZED_INPUT_RFPATH: $MINIMIZED_INPUT_RFPATH"
echo "MINIMIZED_INPUT_RFPATH=$MINIMIZED_INPUT_RFPATH" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -187,8 +191,8 @@ jobs:
path: |
${{ env.OWNER_RDPATH }}/${{ env.STDERR_LOG_FNAME }}
${{ env.OWNER_RDPATH }}/${{ env.TMIN_LOG_FNAME }}
${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ env.TARGET_NAME }}/*
${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ env.TARGET_NAME }}/${{ env.SEEDS_FNAME }}
${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ matrix.target_name }}/*
${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ matrix.target_name }}/${{ env.SEEDS_FNAME }}
if-no-files-found: error

- name: "If Fuzzing Failed: Report GutHub Issue"
Expand Down
Loading
Loading