Skip to content

Commit 6294d3b

Browse files
committed
chore: update for mojo 25.4
Signed-off-by: Seth Stadick <sstadick@gmail.com>
1 parent 5177cee commit 6294d3b

19 files changed

+8432
-1349
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
name: Install Mojo and deps
3232
command: |
3333
export PATH="$PATH:/home/circleci/.pixi/bin"
34+
pixi global install rattler-build
3435
pixi install --locked
3536
- run:
3637
name: Run tests

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
# Next
33

4+
# v1.2.0 (06-19-2025)
5+
6+
- Upgrade to Mojo 25.4
7+
48
# v1.1.1 (06-07-2025)
59

610
- Added a compile time `ISH_SIMD_TARGET` flag that can be set to `baseline` to

ishlib/do_search.mojo

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from time.time import perf_counter
22

3-
from ExtraMojo.io import MovableWriter
43
from ExtraMojo.io.buffered import BufferedWriter
54

65
from ishlib.gpu import has_gpu
@@ -23,7 +22,7 @@ from ishlib.vendor.log import Logger
2322

2423

2524
fn do_search[
26-
W: MovableWriter
25+
W: Movable & Writer
2726
](settings: SearcherSettings, owned writer: BufferedWriter[W]) raises:
2827
Logger.info(
2928
# fmt: off

ishlib/fastx_search_runner.mojo

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from ExtraMojo.io import MovableWriter
21
from ExtraMojo.io.buffered import BufferedWriter
32

43
from ishlib import RED, PURPLE, GREEN, ByteSpanWriter, RecordType
@@ -19,22 +18,22 @@ struct FastxSearchRunner[M: Matcher]:
1918
var matcher: M
2019

2120
fn run_search[
22-
W: MovableWriter
21+
W: Movable & Writer
2322
](mut self, mut writer: BufferedWriter[W]) raises:
2423
# Peek only the first file to determine fastq or not, assume not-binary
2524
var peek = peek_file[record_type = RecordType.FASTX](
2625
self.settings.files[0]
2726
)
2827
for file in self.settings.files:
29-
var f = file[] # force copy
28+
var f = file # force copy
3029
Logger.debug("Processing", f)
3130
if peek.is_fastq:
3231
self.run_search_on_file[is_fastq=True](f, writer)
3332
else:
3433
self.run_search_on_file[is_fastq=False](f, writer)
3534

3635
fn run_search_on_file[
37-
W: MovableWriter, *, is_fastq: Bool = False
36+
W: Movable & Writer, *, is_fastq: Bool = False
3837
](mut self, file: Path, mut writer: BufferedWriter[W]) raises:
3938
var reader = FastxReader[read_comment=False](
4039
BufferedReader(GZFile(String(file), "r"))

ishlib/gpu/process_batch.mojo

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ fn parallel_starts_ends[
6363

6464
# Create the buffers
6565
var host_buffer_create_start = perf_counter()
66-
for ctx in ctxs:
67-
ctx[].set_block_info(
66+
for ref ctx in ctxs:
67+
ctx.set_block_info(
6868
targets_per_device,
6969
len(matcher.encoded_pattern()),
7070
matcher.matrix_len(),
@@ -74,10 +74,10 @@ fn parallel_starts_ends[
7474
settings.sg_ends_free,
7575
max_target_length=max_target_length,
7676
)
77-
ctx[].host_create_input_buffers()
77+
ctx.host_create_input_buffers()
7878

7979
for ctx in ctxs:
80-
ctx[].synchronize()
80+
ctx.synchronize()
8181
var host_buffers_created = perf_counter()
8282
Logger.timing(
8383
"Host buffer creation time:",
@@ -108,16 +108,16 @@ fn parallel_starts_ends[
108108
Logger.timing("Buffer fill time:", buffers_filled - buffer_fill_start)
109109

110110
# Launch Kernel
111-
for ctx in ctxs:
112-
ctx[].device_create_input_buffers()
113-
ctx[].copy_inputs_to_device()
114-
ctx[].device_create_output_buffers()
111+
for ref ctx in ctxs:
112+
ctx.device_create_input_buffers()
113+
ctx.copy_inputs_to_device()
114+
ctx.device_create_output_buffers()
115115
Logger.debug("Created device output buffers")
116-
ctx[].launch_kernel()
116+
ctx.launch_kernel()
117117
Logger.debug("Launched kernel")
118-
ctx[].host_create_output_buffers()
118+
ctx.host_create_output_buffers()
119119
Logger.debug("Created host output buffers")
120-
ctx[].copy_outputs_to_host()
120+
ctx.copy_outputs_to_host()
121121

122122
# Process the long seqs
123123
var cpu_start = perf_counter()
@@ -127,7 +127,7 @@ fn parallel_starts_ends[
127127

128128
# Get outputs
129129
for ctx in ctxs:
130-
ctx[].synchronize()
130+
ctx.synchronize()
131131
# ctx[].copy_outputs_to_host()
132132
var gpu_done = perf_counter()
133133
Logger.timing("GPU processing time (with cpu):", gpu_done - buffers_filled)
@@ -141,14 +141,14 @@ fn parallel_starts_ends[
141141
total_items = 0
142142
for ctx in ctxs:
143143
var end = min(
144-
total_items + ctx[].block_info.value().num_targets, len(seqs)
144+
total_items + ctx.block_info.value().num_targets, len(seqs)
145145
)
146146
var starts_start = perf_counter()
147147
cpu_parallel_starts[where_computed = WhereComputed.Gpu](
148148
matcher,
149149
settings,
150-
ctx[].host_scores.value().as_span().get_immutable(),
151-
ctx[].host_target_ends.value().as_span().get_immutable(),
150+
ctx.host_scores.value().as_span().get_immutable(),
151+
ctx.host_target_ends.value().as_span().get_immutable(),
152152
seqs[total_items:end],
153153
outputs,
154154
total_items,

ishlib/line_search_runner.mojo

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from ExtraMojo.io import MovableWriter
21
from ExtraMojo.io.buffered import BufferedWriter
32

43
from ishlib import RED, PURPLE, GREEN, ByteSpanWriter, RecordType
@@ -19,21 +18,21 @@ struct LineSearchRunner[M: Matcher]:
1918
var matcher: M
2019

2120
fn run_search[
22-
W: MovableWriter
21+
W: Movable & Writer
2322
](mut self, mut writer: BufferedWriter[W]) raises:
2423
# Simple thing first?
2524
for file in self.settings.files:
26-
var f = file[] # force copy
25+
var f = file # force copy
2726
var peek = peek_file[record_type = RecordType.LINE](f)
2827
if peek.is_binary:
2928
if self.settings.verbose:
30-
Logger.warn("Skipping binary file:", file[])
29+
Logger.warn("Skipping binary file:", file)
3130
continue
3231
Logger.debug("Processing", f)
3332
self.run_search_on_file(f, writer)
3433

3534
fn run_search_on_file[
36-
W: MovableWriter
35+
W: Movable & Writer
3736
](mut self, path: Path, mut writer: BufferedWriter[W]) raises:
3837
var file = String(path)
3938
var reader = BufferedReader(GZFile(file, "r"))

ishlib/matcher/__init__.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ trait GpuMatcher(Matcher):
115115
...
116116

117117

118-
trait Searchable(Copyable, Movable, CollectionElement):
118+
trait Searchable(Copyable, Copyable, Movable, Movable):
119119
fn buffer_to_search(ref self) -> Span[UInt8, __origin_of(self)]:
120120
...
121121

ishlib/matcher/alignment/__init__.mojo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ fn create_reversed(input: Span[UInt8]) -> List[UInt8]:
4343
return ret
4444

4545

46-
struct AlignedMemory[dtype: DType, width: Int, alignment: Int]:
46+
struct AlignedMemory[dtype: DType, width: Int, alignment: Int](
47+
Copyable, Movable, Sized
48+
):
4749
var ptr: UnsafePointer[SIMD[dtype, width], alignment=alignment]
4850
var length: Int
4951

ishlib/matcher/alignment/scoring_matrix.mojo

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ alias ACTGN0 = InlineArray[Int8, 25](
175175

176176
@value
177177
@register_passable
178-
struct MatrixKind:
178+
struct MatrixKind(Sized, Stringable, Writable):
179179
var value: UInt8
180180
alias ASCII = Self(0)
181181
alias ACTGN = Self(1)
182-
alias ACTGN0= Self(2)
182+
alias ACTGN0 = Self(2)
183183
alias BLOSUM62 = Self(3)
184184

185185
@staticmethod
@@ -411,7 +411,7 @@ struct ScoringMatrix:
411411
var score = 0
412412
var out = List[UInt8](capacity=len(seq))
413413
for value in seq:
414-
var encoded = self.ascii_to_encoding[Int(value[])]
414+
var encoded = self.ascii_to_encoding[Int(value)]
415415
score += Int(self.get(encoded, encoded))
416416
out.append(encoded)
417417
return (out, score)
@@ -427,7 +427,7 @@ struct ScoringMatrix:
427427
fn convert_ascii_to_encoding(read self, seq: Span[UInt8]) -> List[UInt8]:
428428
var out = List[UInt8](capacity=len(seq))
429429
for value in seq:
430-
out.append(self.ascii_to_encoding[Int(value[])])
430+
out.append(self.ascii_to_encoding[Int(value)])
431431
return out
432432

433433
@always_inline
@@ -436,7 +436,7 @@ struct ScoringMatrix:
436436
) -> List[UInt8]:
437437
var out = List[UInt8](capacity=len(seq))
438438
for value in seq:
439-
out.append(self.ascii_to_encoding[Int(value[])])
439+
out.append(self.ascii_to_encoding[Int(value)])
440440
return out
441441

442442
@always_inline
@@ -447,22 +447,22 @@ struct ScoringMatrix:
447447
fn convert_ascii_to_encoding(
448448
read self, owned seq: List[UInt8]
449449
) -> List[UInt8]:
450-
for value in seq:
451-
value[] = self.ascii_to_encoding[Int(value[])]
450+
for ref value in seq:
451+
value = self.ascii_to_encoding[Int(value)]
452452
return seq
453453

454454
@always_inline
455455
fn convert_encoding_to_ascii(read self, mut seq: List[UInt8]):
456-
for value in seq:
457-
value[] = self.encoding_to_ascii[Int(value[])]
456+
for ref value in seq:
457+
value = self.encoding_to_ascii[Int(value)]
458458

459459
@always_inline
460460
fn convert_encoding_to_ascii(
461461
read self, read seq: Span[UInt8]
462462
) -> List[UInt8]:
463463
var out = List[UInt8](capacity=len(seq))
464-
for value in seq:
465-
out.append(self.encoding_to_ascii[Int(value[])])
464+
for ref value in seq:
465+
out.append(self.encoding_to_ascii[Int(value)])
466466
return out
467467

468468
@always_inline

ishlib/parallel_fastx_search_runner.mojo

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from ExtraMojo.io import MovableWriter
21
from ExtraMojo.io.buffered import BufferedWriter
32

43
from time.time import perf_counter
@@ -62,22 +61,22 @@ struct ParallelFastxSearchRunner[M: Matcher]:
6261
var matcher: M
6362

6463
fn run_search[
65-
W: MovableWriter
64+
W: Movable & Writer
6665
](mut self, mut writer: BufferedWriter[W]) raises:
6766
# Peek only the first file to determine fastq or not, assume not-binary
6867
var peek = peek_file[record_type = RecordType.FASTX](
6968
self.settings.files[0]
7069
)
7170
for file in self.settings.files:
72-
var f = file[] # force copy
71+
var f = file # force copy
7372
Logger.debug("Processing", f)
7473
if peek.is_fastq:
7574
self.run_search_on_file[is_fastq=True](f, writer)
7675
else:
7776
self.run_search_on_file[is_fastq=False](f, writer)
7877

7978
fn run_search_on_file[
80-
W: MovableWriter, *, is_fastq: Bool = False
79+
W: Movable & Writer, *, is_fastq: Bool = False
8180
](mut self, file: Path, mut writer: BufferedWriter[W]) raises:
8281
# TODO: pass an enocoder to the FastaReader
8382
var reader = FastxReader[read_comment=False](
@@ -198,7 +197,7 @@ struct GpuParallelFastxSearchRunner[
198197
self.matcher = matcher
199198

200199
fn run_search[
201-
W: MovableWriter
200+
W: Movable & Writer
202201
](mut self, mut writer: BufferedWriter[W]) raises:
203202
# Peek the first file to get the suggested size, then use that for all of them.
204203
# Assume non-binary
@@ -254,7 +253,7 @@ struct GpuParallelFastxSearchRunner[
254253
return ctxs
255254

256255
fn search_files[
257-
W: MovableWriter,
256+
W: Movable & Writer,
258257
max_query_length: UInt = 200,
259258
max_target_length: UInt = 1024,
260259
](
@@ -283,7 +282,7 @@ struct GpuParallelFastxSearchRunner[
283282
](f, ctxs, writer)
284283

285284
fn run_search_on_file[
286-
W: MovableWriter,
285+
W: Movable & Writer,
287286
max_query_length: UInt = 200,
288287
max_target_length: UInt = 1024,
289288
*,

0 commit comments

Comments
 (0)